Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions bellows/types/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

class int_t(int): # noqa: N801
_signed = True
_enum = False

def serialize(self):
return self.to_bytes(self._size, 'little', signed=self._signed)
Expand Down Expand Up @@ -83,6 +84,14 @@ class uint64_t(uint_t): # noqa: N801
_size = 8


class enum8(uint8_t): # noqa: N801
_enum = True


class enum16(uint16_t): # noqa: N801
_enum = True
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need the _enum attribute? Seems unused here, or in your home-assistant PR.



class Single(float):
def serialize(self):
return struct.pack('<f', self)
Expand Down
2 changes: 2 additions & 0 deletions bellows/zigbee/profiles/zha.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,6 @@ class DeviceType(enum.IntEnum):
DeviceType.ON_OFF_LIGHT_SWITCH: ([0x0004, 0x0005, 0x0006], []),
DeviceType.DIMMER_SWITCH: ([0x0004, 0x0005, 0x0006, 0x0008], []),
DeviceType.COLOR_DIMMER_SWITCH: ([0x0004, 0x0005, 0x0006, 0x0008, 0x0300], []),
# HVAC
DeviceType.THERMOSTAT: ([0x0004, 0x0201], []),
}
2 changes: 1 addition & 1 deletion bellows/zigbee/zcl/clusters/hvac.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Thermostat(Cluster):
0x0019: ('min_setpoint_dead_band', t.int8s),
0x001a: ('remote_sensing', t.uint8_t), # bitmap8
0x001b: ('ctrl_seqe_of_oper', t.uint8_t), # enum8
0x001c: ('system_mode', t.uint8_t), # enum8
0x001c: ('system_mode', t.enum8), # enum8
0x001d: ('alarm_mask', t.uint8_t), # bitmap8
0x001e: ('running_mode', t.uint8_t), # enum8
# ...
Expand Down
6 changes: 3 additions & 3 deletions bellows/zigbee/zcl/foundation.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ class Discrete:
0x2d: ('Signed Integer', t.int48s, Analog),
0x2e: ('Signed Integer', t.int56s, Analog),
0x2f: ('Signed Integer', t.int64s, Analog),
0x30: ('Enumeration', t.uint8_t, Discrete),
0x31: ('Enumeration', t.uint16_t, Discrete),
0x30: ('Enumeration', t.enum8, Discrete),
0x31: ('Enumeration', t.enum16, Discrete),
# 0x38: ('Floating point', t.Half, Analog),
0x39: ('Floating point', t.Single, Analog),
0x3a: ('Floating point', t.Double, Analog),
Expand All @@ -111,7 +111,7 @@ class Discrete:
DATA_TYPE_IDX = {
t: tidx
for tidx, (tname, t, ad) in DATA_TYPES.items()
if ad is Analog
if ad is Analog or tname == 'Enumeration'
}
DATA_TYPE_IDX[t.uint32_t] = 0x23
DATA_TYPE_IDX[t.EmberEUI64] = 0xf0
Expand Down