Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xAAL
Code
Python
Commits
90f27028
Commit
90f27028
authored
1 month ago
by
KERDREUX Jerome
Browse files
Options
Downloads
Patches
Plain Diff
Fix refresh rate due to Meross request (email)
parent
d67be14f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
devices/protocols/Meross/xaal/meross/gw.py
+20
-19
20 additions, 19 deletions
devices/protocols/Meross/xaal/meross/gw.py
with
20 additions
and
19 deletions
devices/protocols/Meross/xaal/meross/gw.py
+
20
−
19
View file @
90f27028
import
aiohttp
from
xaal.lib
import
tools
from
meross_iot.http_api
import
MerossHttpClient
...
...
@@ -15,34 +14,35 @@ logger = logging.getLogger(PACKAGE_NAME)
# disable internal logging
logging
.
getLogger
(
"
meross_iot
"
).
setLevel
(
logging
.
WARNING
)
class
GW
(
object
):
def
__init__
(
self
,
engine
):
def
__init__
(
self
,
engine
):
self
.
engine
=
engine
self
.
devices
=
[]
self
.
config
()
engine
.
on_start
(
self
.
setup
)
engine
.
on_stop
(
self
.
_exit
)
# refresh devices state
engine
.
add_timer
(
self
.
refresh
,
6
0
)
# dis
engine
.
add_timer
(
self
.
discover
,
6
0
)
# refresh devices state
engine
.
add_timer
(
self
.
refresh
,
12
0
)
# dis
cover
engine
.
add_timer
(
self
.
discover
,
30
0
)
def
config
(
self
):
cfg
=
tools
.
load_cfg
(
PACKAGE_NAME
)
if
not
cfg
:
cfg
=
tools
.
new_cfg
(
PACKAGE_NAME
)
cfg
[
'
config
'
]
=
{
'
addr
'
:
tools
.
get_random_uuid
(),
'
login
'
:
''
,
'
password
'
:
''
}
cfg
=
tools
.
new_cfg
(
PACKAGE_NAME
)
cfg
[
'
config
'
]
=
{
'
addr
'
:
tools
.
get_random_uuid
(),
'
login
'
:
''
,
'
password
'
:
''
}
cfg
[
'
devices
'
]
=
{}
logger
.
warn
(
"
Created an empty config file
"
)
logger
.
warn
ing
(
"
Created an empty config file
"
)
cfg
.
write
()
self
.
cfg
=
cfg
async
def
setup
(
self
):
config
=
self
.
cfg
.
get
(
'
config
'
,
{})
login
=
config
.
get
(
'
login
'
,
None
)
passwd
=
config
.
get
(
'
password
'
,
None
)
region
=
config
.
get
(
'
region
'
,
'
eu
'
)
if
not
login
or
not
passwd
:
logger
.
warning
(
'
No email or password in configuration file
'
)
return
...
...
@@ -67,9 +67,9 @@ class GW(object):
logger
.
error
(
e
)
meross_devices
=
self
.
manager
.
find_devices
()
#import pdb;pdb.set_trace()
#
import pdb;pdb.set_trace()
# config
devices_config
=
self
.
cfg
.
get
(
'
devices
'
,{})
devices_config
=
self
.
cfg
.
get
(
'
devices
'
,
{})
# devices
uuids
=
[
d
.
meross
.
uuid
for
d
in
self
.
devices
]
for
m_dev
in
meross_devices
:
...
...
@@ -79,19 +79,19 @@ class GW(object):
# find a class to handle this device
klass
=
bindings
.
find_class
(
m_dev
)
if
not
klass
:
logger
.
warn
(
f
"
No binding for
{
m_dev
.
type
}
"
)
logger
.
warn
ing
(
f
"
No binding for
{
m_dev
.
type
}
"
)
continue
# search config
conf
=
devices_config
.
get
(
m_dev
.
uuid
,
None
)
conf
=
devices_config
.
get
(
m_dev
.
uuid
,
None
)
if
not
conf
:
logger
.
info
(
f
"
Found a new device
{
m_dev
.
type
}
{
m_dev
.
uuid
}
"
)
base_addr
=
tools
.
get_random_base_uuid
()
devices_config
.
update
({
m_dev
.
uuid
:{
'
base_addr
'
:
base_addr
}})
devices_config
.
update
({
m_dev
.
uuid
:
{
'
base_addr
'
:
base_addr
}})
devices_config
.
inline_comments
[
m_dev
.
uuid
]
=
m_dev
.
type
else
:
base_addr
=
tools
.
get_uuid
(
conf
.
get
(
'
base_addr
'
,
None
))
base_addr
=
tools
.
get_uuid
(
conf
.
get
(
'
base_addr
'
,
None
))
# create device
dev
=
klass
(
m_dev
,
base_addr
)
dev
=
klass
(
m_dev
,
base_addr
)
# poll the current state
await
dev
.
meross
.
async_update
()
await
dev
.
update
()
...
...
@@ -109,6 +109,7 @@ class GW(object):
logger
.
info
(
'
Saving configuration file
'
)
self
.
cfg
.
write
()
def
setup
(
eng
):
GW
(
eng
)
return
True
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment