Skip empty rooms in preset files
This commit is contained in:
parent
4b9d86b470
commit
dc7c7abdbb
1 changed files with 10 additions and 10 deletions
20
c4ctrl.py
20
c4ctrl.py
|
@ -17,13 +17,13 @@ class C4Interface():
|
||||||
# Set a default topic
|
# Set a default topic
|
||||||
if topic: self.topic = topic
|
if topic: self.topic = topic
|
||||||
|
|
||||||
def push(self, cmd, topic=None, retain=True):
|
def push(self, cmd, topic=None, retain=None):
|
||||||
"""Send cmd to topic via the MQTT broker."""
|
"""Send cmd to topic via the MQTT broker."""
|
||||||
from paho.mqtt import publish
|
from paho.mqtt import publish
|
||||||
|
|
||||||
# Overwrite defaults
|
# Overwrite defaults
|
||||||
if topic: self.topic = topic
|
if topic: self.topic = topic
|
||||||
if retain == False: self.retain = retain
|
if retain != None: self.retain = retain
|
||||||
|
|
||||||
if type(cmd) == list:
|
if type(cmd) == list:
|
||||||
# Add <qos> and <retain> to every message
|
# Add <qos> and <retain> to every message
|
||||||
|
@ -261,8 +261,12 @@ class C4Room:
|
||||||
"payload" : light.payload
|
"payload" : light.payload
|
||||||
})
|
})
|
||||||
|
|
||||||
# Do not retain "magic" messages
|
if cmd == []: return
|
||||||
return self.c4.push(cmd, retain=(not magic))
|
|
||||||
|
if magic: # Do not retain "magic" messages
|
||||||
|
return self.c4.push(cmd, retain=(not magic))
|
||||||
|
else:
|
||||||
|
return self.c4.push(cmd)
|
||||||
|
|
||||||
|
|
||||||
class Wohnzimmer(C4Room):
|
class Wohnzimmer(C4Room):
|
||||||
|
@ -663,14 +667,10 @@ class ColorScheme:
|
||||||
if topic in self.mapping.keys():
|
if topic in self.mapping.keys():
|
||||||
return self.mapping[topic]
|
return self.mapping[topic]
|
||||||
elif self.single_color:
|
elif self.single_color:
|
||||||
if self._topic_is_master(topic):
|
if not self._topic_is_master(topic):
|
||||||
return None
|
|
||||||
else:
|
|
||||||
return self._single_color()
|
return self._single_color()
|
||||||
elif self.return_random_color:
|
elif self.return_random_color:
|
||||||
if self._topic_is_master(topic):
|
if not self._topic_is_master(topic):
|
||||||
return None
|
|
||||||
else:
|
|
||||||
return self._random_color()
|
return self._random_color()
|
||||||
# Fallback
|
# Fallback
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in a new issue