added try catch clause
This commit is contained in:
parent
4d401ecadd
commit
1d98bbe227
@ -40,10 +40,13 @@ def subscribe(client: mqtt_client):
|
||||
def on_message(client, userdata, msg):
|
||||
topic = msg.topic
|
||||
if "tele" in topic:
|
||||
if "STATE" in topic:
|
||||
data = json.loads(msg.payload.decode())
|
||||
device = topic.split('/')[1]
|
||||
powerState[device] = data['POWER']
|
||||
try:
|
||||
if "STATE" in topic:
|
||||
data = json.loads(msg.payload.decode())
|
||||
device = topic.split('/')[1]
|
||||
powerState[device] = data['POWER']
|
||||
except:
|
||||
pass
|
||||
if "stat" in topic:
|
||||
device = topic.split('/')[1]
|
||||
powerState[device] = msg.payload.decode()
|
||||
@ -84,4 +87,4 @@ if __name__ == "__main__":
|
||||
|
||||
while True:
|
||||
checkPC()
|
||||
sleep(1)
|
||||
sleep(1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user