项目作者: jamesleesaunders

项目描述 :
Python Hive Hub
高级语言: Python
项目地址: git://github.com/jamesleesaunders/PyAlertMe.git
创建时间: 2016-09-21T19:14:02Z
项目社区:https://github.com/jamesleesaunders/PyAlertMe

开源协议:MIT License

下载


PyAlertMe

Build Status
codecov

PyAlertMe is a set of classes which, when used in conjunction with a Digi XBee (ZigBee) module, can be used to simulate an AlertMe (Lowes Iris, Hive, British Gas Safe and Secure) Hub, SmartPlug or Sensor.

Use

Hub

  1. # Setup Serial
  2. XBEE_PORT = '/dev/tty.usbserial-DN018OI6'
  3. XBEE_BAUD = 9600
  4. ser = serial.Serial(XBEE_PORT, XBEE_BAUD)
  5. # Define Callback (Optional)
  6. def callback(type, node_id, field, value):
  7. if type == 'Attribute':
  8. print("Attribute Update\n\tNode ID: " + node_id + " Field: " + field + " Value: " + str(value))
  9. elif type == 'Node':
  10. print("Node Update\n\tNode ID: " + node_id + " Field: " + field + " Value: " + str(value))
  11. # Create Hub Object
  12. hub_obj = Hub(callback)
  13. hub_obj.start(ser)

Example output:

  1. 2017-08-30 21:51:21,138 INFO zbhub 134 New Device 00:0d:6f:00:00:1b:6a:6a Fully Associated
  2. Attribute Update [Node ID: 00:0d:6f:00:00:1b:6a:6a Field: manu Value: AlertMe.com]
  3. Attribute Update [Node ID: 00:0d:6f:00:00:1b:6a:6a Field: type Value: Door/Window sensor]
  4. Attribute Update [Node ID: 00:0d:6f:00:00:1b:6a:6a Field: version Value: 55979]
  5. Attribute Update [Node ID: 00:0d:6f:00:00:1b:6a:6a Field: manu_date Value: 2008-04-17]
  6. { '00:0d:6f:00:00:1b:6a:6a': { 'manu': 'AlertMe.com',
  7. 'type': 'Door/Window sensor',
  8. 'version': 55979},
  9. '00:0d:6f:00:00:1b:76:ea': { 'manu': 'AlertMe.com',
  10. 'type': 'Lamp',
  11. 'version': 1905},
  12. '00:0d:6f:00:00:78:61:c0': { 'manu': 'AlertMe.com',
  13. 'type': 'Button Device',
  14. 'version': 34667},
  15. '00:0d:6f:00:03:bb:b9:f8': { 'manu': 'AlertMe.com',
  16. 'type': 'SmartPlug',
  17. 'version': 9586}}
  18. Select Device:Attribute Update [Node ID: 00:0d:6f:00:03:bb:b9:f8 Field: power_demand Value: 0]
  19. Attribute Update [Node ID: 00:0d:6f:00:03:bb:b9:f8 Field: trigger_state Value: 0]
  20. Attribute Update [Node ID: 00:0d:6f:00:03:bb:b9:f8 Field: temperature Value: 99.05]
  21. Attribute Update [Node ID: 00:0d:6f:00:03:bb:b9:f8 Field: tamper_state Value: 1]
  22. Attribute Update [Node ID: 00:0d:6f:00:00:1b:6a:6a Field: manu Value: AlertMe.com]
  23. Attribute Update [Node ID: 00:0d:6f:00:00:1b:6a:6a Field: type Value: Door/Window sensor]
  24. Attribute Update [Node ID: 00:0d:6f:00:00:1b:6a:6a Field: version Value: 55979]
  25. Attribute Update [Node ID: 00:0d:6f:00:00:1b:6a:6a Field: manu_date Value: 2008-04-17]
  26. Attribute Update [Node ID: 00:0d:6f:00:03:bb:b9:f8 Field: power_demand Value: 0]

The hub supports the following devices:

  • SmartPlug
  • Power Clamp
  • Button Device
  • PIR Device
  • Door/Window sensor
  • Alarm Detector
  • Keyfob Device
  • Beacon
  • Lamp

SmartPlug

  1. # Setup Serial
  2. XBEE_PORT = '/dev/tty.usbserial-DN018OI6'
  3. XBEE_BAUD = 9600
  4. ser = serial.Serial(XBEE_PORT, XBEE_BAUD)
  5. # Create SmartPlug Object
  6. device_obj = SmartPlug()
  7. device_obj.start(ser)

XBee Setup

Configure XBee as follows:
XBee Modem XB24-ZB, ZIGBEE Coordinator API, Version 21A7 (or better).
Alternatively use you can use scripts/setup-xbee.py to configure the Xbee.

Coordinator (Hub)

  • ZigBee Stack Profile (ZS): 2
  • Encryption Enable (EE): 1
  • Encryption Options (EO): 1
  • Encryption Key (KY): 5a6967426565416c6c69616e63653039
  • API Enable (AP): 2
  • API Output Mode (AO): 3

Router (Device)

  • ZigBee Stack Profile (ZS): 2
  • Encryption Enable (EE): 1
  • Encryption Options (EO): 0
  • Encryption Key (KY): None
  • API Enable (AP): 2
  • API Output Mode (AO): 3

Example Use

See examples/hub-example.py for example Hub.
See examples/smartplug-example.py for example SmartPlug.

Credits

Huge thanks to Desert Home http://www.desert-home.com/2014/02/raspberry-pi-and-lowes-iris-smart-switch.html from which this project originates from.