command / attributes files in spec for decode

barrier exists and is doing a watch for status change on pins 0 and 1
main is starting to add in the new cluster at endpoint 8 on interview
com is where fancy_transmit is now
master
Nathan 3 years ago
parent 886f3c8d9f
commit 67410efd8b

@ -2,18 +2,46 @@ import com
import xbee import xbee
from machine import Pin from machine import Pin
class barrier:
class Barrier:
moving = 0 moving = 0
position = 0 barrier_position = 0
ad0 = Pin("D0", Pin.IN, Pin.PULL_UP) ad0 = Pin("D0", Pin.IN, Pin.PULL_UP) #door
ad1 = Pin("D1", Pin.IN, Pin.PULL_UP) ad1 = Pin("D1", Pin.IN, Pin.PULL_UP) #motor
ad2 = Pin("D2", Pin.IN, Pin.PULL_UP)
ad4 = Pin("D4", Pin.OUT) ad4 = Pin("D4", Pin.OUT)
door = ad0.value()
motor = ad1.value()
update = False
def status(seq,payload): def status(self, seq, payload):
pass pass
def command(seq, payload):
def command(self, seq, payload):
pass pass
def watch(self): def watch(self):
pass current_door = self.door
current_motor = self.motor
self.door = self.ad0.value()
self.motor = self.ad1.value()
if (current_door != self.door) or (current_motor != self.motor):
self.update = True
else:
self.update = False
if self.door == 0:
if self.motor == 1:
self.moving = 0
self.barrier_position = 100
if self.motor == 0:
if self.door == 1:
self.moving = 0
self.barrier_position = 0
if self.motor == 0:
if self.door == 0:
if self.barrier_position == 100:
self.barrier_position = 50
self.moving = 1
if self.barrier_position == 0:
self.barrier_position = 50
self.moving = 2
return self.update

@ -5,7 +5,7 @@ def receive():
def fancy_transmit(payload, source_ep, dest_ep, cluster,profile): def fancy_transmit(payload, source_ep, dest_ep, cluster,profile):
send = 0 send = 0
while send==0: while send == 0:
try: try:
if xbee.transmit(xbee.ADDR_COORDINATOR, payload, source_ep=source_ep, dest_ep=dest_ep, cluster=cluster, profile=profile, if xbee.transmit(xbee.ADDR_COORDINATOR, payload, source_ep=source_ep, dest_ep=dest_ep, cluster=cluster, profile=profile,
tx_options=0) is None: tx_options=0) is None:

@ -40,6 +40,8 @@ print("receiving")
diff = 3600000 diff = 3600000
first_report = False first_report = False
timestamp = time.ticks_ms() timestamp = time.ticks_ms()
garage = barrier.Barrier()
while 1 != 0: while 1 != 0:
packet = com.receive() packet = com.receive()
if packet is not None: if packet is not None:
@ -86,7 +88,7 @@ while 1 != 0:
print(bytes(packet['payload'])) print(bytes(packet['payload']))
b = bytearray(packet['payload']) b = bytearray(packet['payload'])
print(b[0]) print(b[0])
payload = bytes([b[0], 00, b[1], b[2], 14, 8, 4, 1, 2, 0, 6, 3, 0, 0, 3, 0, 6, 0, 0]) payload = bytes([b[0], 00, b[1], b[2], 14, 8, 4, 1, 2, 0, 6, 4, 0, 0, 3, 0, 6, 3, 1,0, 0])
com.fancy_transmit(payload=payload, source_ep=0, dest_ep=0, cluster=32772, profile=0) com.fancy_transmit(payload=payload, source_ep=0, dest_ep=0, cluster=32772, profile=0)
print("simple descriptor response") print("simple descriptor response")
@ -130,7 +132,7 @@ while 1 != 0:
zcl_head = bytes([12, 30, 16, 171, 10]) zcl_head = bytes([12, 30, 16, 171, 10])
payload = zcl_head + bytes([0,0,10,0]) #for now only return off for state report payload = zcl_head + bytes([0,0,10,0]) #for now only return off for state report
com.fancy_transmit(payload=payload, source_ep=8, dest_ep=1, cluster=6, profile=260) com.fancy_transmit(payload=payload, source_ep=8, dest_ep=1, cluster=6, profile=260)
barrier.watch() garage.watch()
#print(xbee.receive()) #print(xbee.receive())
#print("temperature") #print("temperature")

@ -527,20 +527,36 @@ CLUSTERS_BY_NAME = {
}, { }, {
},), },),
'onoff': (0x0006, { 'onoff': (0x0006, {
'off': (0x00, (),), 'off': (0x00, (),),#command
'on': (0x01, (),), 'on': (0x01, (),),
'toggle': (0x02, (),), 'toggle': (0x02, (),),
'off_with_effect': (0x40, ('effect_id:uint8', 'effect_variant:uint8',),), 'off_with_effect': (0x40, ('effect_id:uint8', 'effect_variant:uint8',),),
'on_with_recall_global_scene': (0x41, (),), 'on_with_recall_global_scene': (0x41, (),),
'on_with_timed_off': (0x42, ('control:uint8', 'on_time:uint16', 'off_wait_time:uint16',),), 'on_with_timed_off': (0x42, ('control:uint8', 'on_time:uint16', 'off_wait_time:uint16',),),
}, { #middle hash is blank, unknown what this is
}, { }, {
}, { 'onoff': (0x0000, 'bool',),#attribute
'onoff': (0x0000, 'bool',),
'global_scene_control': (0x4000, 'bool',), 'global_scene_control': (0x4000, 'bool',),
'on_time': (0x4001, 'uint16',), 'on_time': (0x4001, 'uint16',),
'off_wait_time': (0x4002, 'uint16',), 'off_wait_time': (0x4002, 'uint16',),
},), },),
'barrierControl' 'barrier_control': (0x0103, {
#commands
'go_to_percent': (0x0000, ('percentOpen:uint8'),),
'stop': (0x0001,(),),
}, {#blank middle hash like onoff
}, {#attribute
'moving_state': (0x0001, 'enum8',),
'safety_status': (0x0002,'map16',),
'capabilities': (0x0003, 'map8',),
'open_events': (0x0004, 'uint16',),
'close_events': (0x0005, 'uint16',),
'command_open_events': (0x0006, 'uint16',),
'command_close_events': (0x0007, 'uint16',),
'open_perioad': (0x0008, 'uint16',),
'close_period': (0x0009, 'uint16',),
'barrier_position': (0x000A, 'uint8',),
},),
'onoff_configuration': (0x0007, { 'onoff_configuration': (0x0007, {
}, { }, {
}, { }, {

Loading…
Cancel
Save