-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Help] - zigbee readout #25
Comments
There's no documentation for things like that. You would need to write your own application on top of zigpy-znp similar to bellows cli implementation |
Using import asyncio
import logging
import coloredlogs
import zigpy_znp.types as t
import zigpy_znp.commands as c
# There are many different radio libraries but they all have the same API
from zigpy_znp.zigbee.application import ControllerApplication
coloredlogs.install(level=logging.DEBUG)
logging.getLogger('zigpy_znp').setLevel(logging.DEBUG)
LOGGER = logging.getLogger(__name__)
class MainListener:
'''
Contains callbacks that zigpy will call whenever something happens.
Look for `listener_event` in the Zigpy source or just look at the logged warnings.
'''
def __init__(self, application):
self.application = application
def device_joined(self, device):
asyncio.create_task(self.async_device_joined(device))
async def async_device_joined(self, device):
LOGGER.info("Device joined: %s", device)
for endpoint_id, endpoint in device.endpoints.items():
# If it's a proper motion sensor, it probably has an IAS Zone cluster
# that you need to bind to before it does anything.
#
# If it's a Xiaomi motion sensor, it'll just send attribute updates.
if not hasattr(endpoint, 'ias_zone'):
continue
endpoint.ias_zone.add_context_listener(self)
await endpoint.ias_zone.bind()
await endpoint.ias_zone.write_attributes({'cie_addr': self.application.ieee})
await endpoint.ias_zone.enroll_response(0x00, 0x00)
def attribute_updated(self, device, cluster, attribute_id, value):
# This is where you'll receive attribute updates
LOGGER.info("Received an attribute update %s=%s on cluster %s from device %s",
attribute_id, value, cluster, device)
async def main():
app = ControllerApplication(ControllerApplication.SCHEMA({
'database_path': '/path/to/zigbee.db',
'device': {
'path': '/dev/serial/by-id/your-serial-port',
}
}))
listener = MainListener(app)
app.add_listener(listener)
await app.startup(auto_form=True)
# Permit joins for a minute
await app.permit(60)
await asyncio.sleep(60)
# Just run forever
while True:
asyncio.sleep(10000)
if __name__ == '__main__':
await asyncio.run(main()) |
some primer on zigbee https://github.com/MarkDing/IoT-Developer-Boot-Camp/wiki/Zigbee-Boot-Camp |
Ok thanks for the great info! So basically this module is still in an early phase of development and not quite suited for my needs right? |
|
I'm closing this issue for now since it doesn't directly relate to zigpy-znp, but feel free to comment if you need any help using zigpy on its own. |
@Mopele Please consider contributing to the discussions in zigpy/zigpy#471 and zigpy/zigpy#477 |
Hey I would like to read out a zigbee motion sensor with my raspberry Pi via Python. I dont want to use stuff like Home-Server and those big plattforms for home automation but rather build my own application for my specific needs. What hardware would be required and is there any documentation how to do that, because I couldnt manage to find any.
Thanks for the help!
The text was updated successfully, but these errors were encountered: