Compare commits

..

2 Commits

Author SHA1 Message Date
1d98bbe227
added try catch clause 2025-01-18 00:43:47 +01:00
4d401ecadd
added systemd unit file 2025-01-14 21:57:05 +01:00
2 changed files with 19 additions and 5 deletions

View File

@ -40,10 +40,13 @@ def subscribe(client: mqtt_client):
def on_message(client, userdata, msg):
topic = msg.topic
if "tele" in topic:
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()

11
Audio/smartplugs.service Normal file
View 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