Add Set Channel method.
This commit is contained in:
parent
e7a5a15a75
commit
1c75067de9
31
neohub.py
31
neohub.py
|
@ -5,6 +5,8 @@ import asyncio
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from system import System
|
||||||
|
|
||||||
class NeoHub:
|
class NeoHub:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._logger = logging.getLogger('neohub')
|
self._logger = logging.getLogger('neohub')
|
||||||
|
@ -45,6 +47,20 @@ class NeoHub:
|
||||||
return firmware_version
|
return firmware_version
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
async def get_system(self):
|
||||||
|
"""
|
||||||
|
Get system wide variables
|
||||||
|
|
||||||
|
Returns System object
|
||||||
|
"""
|
||||||
|
message = {"GET_SYSTEM": 0}
|
||||||
|
|
||||||
|
data = await self._send(message)
|
||||||
|
system_data = System(data)
|
||||||
|
return system_data
|
||||||
|
|
||||||
|
|
||||||
async def reset(self):
|
async def reset(self):
|
||||||
"""
|
"""
|
||||||
Reboot neohub
|
Reboot neohub
|
||||||
|
@ -61,12 +77,13 @@ class NeoHub:
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
async def set_channel(self, channel: int):
|
||||||
async def get_system(self):
|
|
||||||
"""
|
"""
|
||||||
Get system wide variables
|
Set ZigBee channel.
|
||||||
"""
|
|
||||||
message = {"GET_SYSTEM": 0}
|
|
||||||
|
|
||||||
data = await self._send(message)
|
Only channels 11, 14, 15, 19, 20, 24, 25 are allowed.
|
||||||
return data
|
"""
|
||||||
|
|
||||||
|
message = {"SET_CHANNEL": channel}
|
||||||
|
|
||||||
|
result = await self._send(message)
|
||||||
|
|
2
test.py
2
test.py
|
@ -14,7 +14,7 @@ async def run():
|
||||||
await hub.connect()
|
await hub.connect()
|
||||||
firmware_version = await hub.firmware()
|
firmware_version = await hub.firmware()
|
||||||
print(firmware_version)
|
print(firmware_version)
|
||||||
result = await hub.get_system()
|
result = await hub.set_channel(14)
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue