Compare commits
2 Commits
2609f72941
...
1d98bbe227
Author | SHA1 | Date | |
---|---|---|---|
1d98bbe227 | |||
4d401ecadd |
@ -40,10 +40,13 @@ def subscribe(client: mqtt_client):
|
|||||||
def on_message(client, userdata, msg):
|
def on_message(client, userdata, msg):
|
||||||
topic = msg.topic
|
topic = msg.topic
|
||||||
if "tele" in topic:
|
if "tele" in topic:
|
||||||
|
try:
|
||||||
if "STATE" in topic:
|
if "STATE" in topic:
|
||||||
data = json.loads(msg.payload.decode())
|
data = json.loads(msg.payload.decode())
|
||||||
device = topic.split('/')[1]
|
device = topic.split('/')[1]
|
||||||
powerState[device] = data['POWER']
|
powerState[device] = data['POWER']
|
||||||
|
except:
|
||||||
|
pass
|
||||||
if "stat" in topic:
|
if "stat" in topic:
|
||||||
device = topic.split('/')[1]
|
device = topic.split('/')[1]
|
||||||
powerState[device] = msg.payload.decode()
|
powerState[device] = msg.payload.decode()
|
||||||
|
11
Audio/smartplugs.service
Normal file
11
Audio/smartplugs.service
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Automatic smart plug manager for audio devices
|
||||||
|
After=multi-user.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=angoosh
|
||||||
|
ExecStart=python /home/angoosh/Scripts/audio_automation_pc.py
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
x
Reference in New Issue
Block a user