I have two physical switches (z-wave ZDB5100). I want to control a dimmable light. When pressing button1 it should turn on the light to 10%, when pressing button2 it should be set to 100%. I would the switches to reflect the mode, so if pressing button1 and then button2 the light should be at 100%, button1 off and button2 on.
I have created a rule to support this, but I have to react on changed events to have it triggered when pressing the buttons. Is it expected behavior that physically pushing buttons does not cause commands to be send? I was hoping I could use received command, so that I could post updates to the other button without triggering the rule.
I am using habapp, but the issue should be the same for rules:
def __init__(self):
super().__init__()
# Setup items
self.BedroomSwitch1 = SwitchItem.get_item('BedroomSwitch1')
self.BedroomSwitch2 = SwitchItem.get_item('BedroomSwitch2')
self.ColorLedSwitch_1 = SwitchItem.get_item('ColorLedSwitch_1')
self.ColorLedBrightness_1 = DimmerItem.get_item('ColorLedBrightness_1')
self.ColorLedTemperature_1 = DimmerItem.get_item('ColorLedTemperature_1')
# Trigger on item updates
self.listen_event(self.BedroomSwitch1.name, self.BedroomSwitch1_changed, ItemStateChangedEvent)
self.listen_event(self.BedroomSwitch2.name, self.BedroomSwitch2_changed, ItemStateChangedEvent)
def BedroomSwitch1_changed(self, event):
if self.BedroomSwitch1.is_on():
if self.ColorLedTemperature_1.value != 50:
self.openhab.send_command(self.ColorLedTemperature_1, "50")
if self.ColorLedBrightness_1.value != 1:
self.openhab.send_command(self.ColorLedBrightness_1, "1")
if self.ColorLedSwitch_1.is_off():
self.openhab.send_command(self.ColorLedSwitch_1, "ON")
elif self.BedroomSwitch1.is_off():
self.openhab.send_command(self.ColorLedSwitch_1, "OFF")
if self.BedroomSwitchColor2.is_on():
self.openhab.post_update(self.BedroomSwitchColor2, "OFF")
def BedroomSwitch2_changed(self, event):
if self.BedroomSwitch2.is_on():
if self.ColorLedTemperature_1.value != 50:
self.openhab.send_command(self.ColorLedTemperature_1, "50")
if self.ColorLedBrightness_1.value != 100:
self.openhab.send_command(self.ColorLedBrightness_1, "100")
if self.ColorLedSwitch_1.is_off():
self.openhab.send_command(self.ColorLedSwitch_1, "ON")
elif self.BedroomSwitch2.is_off():
self.openhab.send_command(self.ColorLedSwitch_1, "OFF")
if self.BedroomSwitchColor1.is_on():
self.openhab.post_update(self.BedroomSwitchColor1, "OFF")