Commit a2d8fd7a authored by Peter-Bernd Otte's avatar Peter-Bernd Otte

Added dimmTopics - not yet fully implemented.

parent fbbee2c3
...@@ -20,7 +20,8 @@ class rLightDesire(Enum): ...@@ -20,7 +20,8 @@ class rLightDesire(Enum):
class relais: class relais:
def __init__(self, MQTTClient, MQTTName, MQTTRelaisTopic, defaultTopics=None, toggleTopics=None, switchOffTopics=None, def __init__(self, MQTTClient, MQTTName, MQTTRelaisTopic, defaultTopics=None, toggleTopics=None, dimmTopics=None,
switchOffTopics=None,
inverseSwitchOnTopics=None, prolongateStateTopics=None, defaultSwitchOffTime=None, debug=False): inverseSwitchOnTopics=None, prolongateStateTopics=None, defaultSwitchOffTime=None, debug=False):
self.MQTTname = MQTTName #string self.MQTTname = MQTTName #string
self.type = "relais" self.type = "relais"
...@@ -36,6 +37,7 @@ class relais: ...@@ -36,6 +37,7 @@ class relais:
self.defaultTopics = defaultTopics if defaultTopics is not None else set() # MQTT-Name (includes also type in JSON message) self.defaultTopics = defaultTopics if defaultTopics is not None else set() # MQTT-Name (includes also type in JSON message)
self.toggleTopics = toggleTopics if toggleTopics is not None else set() self.toggleTopics = toggleTopics if toggleTopics is not None else set()
self.dimmTopics = dimmTopics if dimmTopics is not None else set()
self.switchOffTopics = switchOffTopics if switchOffTopics is not None else set() self.switchOffTopics = switchOffTopics if switchOffTopics is not None else set()
self.inverseSwitchOnTopics = inverseSwitchOnTopics if inverseSwitchOnTopics is not None else set() self.inverseSwitchOnTopics = inverseSwitchOnTopics if inverseSwitchOnTopics is not None else set()
self.prolongateStateTopics = prolongateStateTopics if prolongateStateTopics is not None else set() self.prolongateStateTopics = prolongateStateTopics if prolongateStateTopics is not None else set()
...@@ -137,6 +139,17 @@ class relais: ...@@ -137,6 +139,17 @@ class relais:
self.setV(0, reason="PTM215 pressed down, toggle") self.setV(0, reason="PTM215 pressed down, toggle")
else: else:
print(self.MQTTname, "Error: Type not supported for toggle.") print(self.MQTTname, "Error: Type not supported for toggle.")
for x in self.dimmTopics: # topics do dimming, not yet implemented. currently like toggle
if topic == x:
if self.debug: print(self.MQTTname, "Dimm Topic:", topic, "msg:", msg)
if msg['type'] == "PTM215": # switches
if msg['v'] > 0: # on key pressed down
if self.v == 0:
self.setV(1, reason="PTM215 pressed down, dimm up") # Toggle
else:
self.setV(0, reason="PTM215 pressed down, dimm down")
else:
print(self.MQTTname, "Error: Type not supported for dimm.")
for x in self.switchOffTopics: # topics switch off the relais for x in self.switchOffTopics: # topics switch off the relais
if topic == x: if topic == x:
if self.debug: print(self.MQTTname, "Switch Off Topic:", topic, "msg:", msg) if self.debug: print(self.MQTTname, "Switch Off Topic:", topic, "msg:", msg)
...@@ -173,7 +186,3 @@ class relais: ...@@ -173,7 +186,3 @@ class relais:
self.state = rStates.noFeedback self.state = rStates.noFeedback
self.printCurrentState() self.printCurrentState()
self.publishCurrentStatus(reason="no or wrong feedback from relais") self.publishCurrentStatus(reason="no or wrong feedback from relais")
# test with:
# mosquitto_pub -t homie/fsr-ww/1 -m '{"setv": 0, "time": 1564251546.330417, "type": "FUD14", "v": 1}'
# mosquitto_sub -t 'homie/I2CActor/testraum/testrelais' -v
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment