Skip to content

Commit

Permalink
Fixes #159. Changed the handle group callback to use the group in the…
Browse files Browse the repository at this point in the history
… database link instead of the message group to figure out which local button is being changed.
  • Loading branch information
TD22057 committed Dec 28, 2019
1 parent 3fd1dd8 commit c5c2fae
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
9 changes: 9 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
- Fixed bug in motion sensor replies to a model info request
([Issue #163][I163]).

- Fixed bug in thermostat ambient temperature calculation ([Issue #142][I142])
(thanks @krkeegan).

- Fixed bug in KeypadLinc, FanLinc, and Outlet for non-group 1 links
([Issue #159][I159]) (thanks @chris153002).


## [0.6.8]

### Fixes
Expand Down Expand Up @@ -295,7 +302,9 @@
[I136]: https://github.com/TD22057/insteon-mqtt/issues/136
[I138]: https://github.com/TD22057/insteon-mqtt/issues/138
[I139]: https://github.com/TD22057/insteon-mqtt/issues/139
[I142]: https://github.com/TD22057/insteon-mqtt/issues/142
[I148]: https://github.com/TD22057/insteon-mqtt/issues/148
[I157]: https://github.com/TD22057/insteon-mqtt/issues/157
[I159]: https://github.com/TD22057/insteon-mqtt/issues/159
[I160]: https://github.com/TD22057/insteon-mqtt/issues/160
[I163]: https://github.com/TD22057/insteon-mqtt/issues/163
13 changes: 8 additions & 5 deletions insteon_mqtt/device/FanLinc.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,6 @@ def handle_group_cmd(self, addr, msg):
msg (InpStandard): Broadcast message from the device. Use
msg.group to find the group and msg.cmd1 for the command.
"""
# Group 1 is for the dimmer - pass that to the base class:
if msg.group == 1:
super().handle_group_cmd(addr, msg)
return

# Make sure we're really a responder to this message. This shouldn't
# ever occur.
entry = self.db.find(addr, msg.group, is_controller=False)
Expand All @@ -381,6 +376,14 @@ def handle_group_cmd(self, addr, msg):
msg.group, addr)
return

# The local button being modified is stored in the db entry.
localGroup = entry.data[2]

# Group 1 is for the dimmer - pass that to the base class:
if localGroup == 1:
super().handle_group_cmd(addr, msg)
return

# 0x11: on
if msg.cmd1 == 0x11:
self._set_fan_speed(entry.data[0], on_off.REASON_SCENE)
Expand Down
15 changes: 9 additions & 6 deletions insteon_mqtt/device/KeypadLinc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1453,34 +1453,37 @@ def handle_group_cmd(self, addr, msg):

reason = on_off.REASON_SCENE

# The local button being modified is stored in the db entry.
localGroup = entry.data[2]

# Handle on/off codes
if on_off.Mode.is_valid(msg.cmd1):
is_on, mode = on_off.Mode.decode(msg.cmd1)

# For switches, on/off determines the level. For dimmers, it's
# set by the responder entry in the database.
level = 0xff if is_on else 0x00
if self.is_dimmer and is_on and msg.group == self._load_group:
if self.is_dimmer and is_on and localGroup == self._load_group:
level = entry.data[0]

self._set_level(msg.group, level, mode, reason)
self._set_level(localGroup, level, mode, reason)

# Increment up 1 unit which is 8 levels.
elif msg.cmd1 == 0x15:
assert msg.group == self._load_group
self._set_level(msg.group, min(0xff, self._level + 8),
assert localGroup == self._load_group
self._set_level(localGroup, min(0xff, self._level + 8),
reason=reason)

# Increment down 1 unit which is 8 levels.
elif msg.cmd1 == 0x16:
assert msg.group == self._load_group
self._set_level(msg.group, max(0x00, self._level - 8),
self._set_level(localGroup, max(0x00, self._level - 8),
reason=reason)

# Starting/stopping manual increment (cmd2 0x00=up, 0x01=down)
elif on_off.Manual.is_valid(msg.cmd1):
manual = on_off.Manual.decode(msg.cmd1, msg.cmd2)
self.signal_manual.emit(self, msg.group, manual, reason)
self.signal_manual.emit(self, localGroup, manual, reason)

# If the button is released, refresh to get the final level in
# dimming mode since we don't know where the level stopped.
Expand Down
5 changes: 4 additions & 1 deletion insteon_mqtt/device/Outlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,13 @@ def handle_group_cmd(self, addr, msg):
msg.group, addr)
return

# The local button being modified is stored in the db entry.
localGroup = entry.data[2]

# Handle on/off commands codes.
if on_off.Mode.is_valid(msg.cmd1):
is_on, mode = on_off.Mode.decode(msg.cmd1)
self._set_is_on(msg.group, is_on, mode, on_off.REASON_SCENE)
self._set_is_on(localGroup, is_on, mode, on_off.REASON_SCENE)

# Note: I don't believe the on/off switch can participate in manual
# mode stopping commands since it changes state when the button is
Expand Down

0 comments on commit c5c2fae

Please sign in to comment.