Simplify if statements
This commit is contained in:
parent
d020621429
commit
be32affbb6
1 changed files with 10 additions and 12 deletions
|
@ -48,19 +48,17 @@ def on_connect(client, userdata, flags, rc):
|
|||
|
||||
|
||||
def on_message(client, userdata, message):
|
||||
if message.payload == b"power_on":
|
||||
if not power_state.is_set():
|
||||
power_state.set()
|
||||
send(pi, ["power", "aux"])
|
||||
client.publish("speakers/pi-soulra/state", "on")
|
||||
logging.info("Sent power_on signal")
|
||||
if message.payload == b"power_on" and not power_state.is_set():
|
||||
power_state.set()
|
||||
send(pi, ["power", "aux"])
|
||||
client.publish("speakers/pi-soulra/state", "on")
|
||||
logging.info("Sent power_on signal")
|
||||
|
||||
elif message.payload == b"power_off":
|
||||
if power_state.is_set():
|
||||
power_state.clear()
|
||||
send(pi, ["power"])
|
||||
client.publish("speakers/pi-soulra/state", "off")
|
||||
logging.info("Sent power_off signal")
|
||||
elif message.payload == b"power_off" and power_state.is_set():
|
||||
power_state.clear()
|
||||
send(pi, ["power"])
|
||||
client.publish("speakers/pi-soulra/state", "off")
|
||||
logging.info("Sent power_off signal")
|
||||
|
||||
elif message.payload == b"volume_up":
|
||||
send(pi, ["volume-up"])
|
||||
|
|
Loading…
Add table
Reference in a new issue