diff options
author | jwansek <eddie.atten.ea29@gmail.com> | 2025-06-08 14:47:07 +0100 |
---|---|---|
committer | jwansek <eddie.atten.ea29@gmail.com> | 2025-06-08 14:47:07 +0100 |
commit | 0e383fd8f3ae8e3d4ef7abb8c548f93201f3feac (patch) | |
tree | 2b83a943d2eaedf1745eb56b5fec1fba1bf58412 | |
parent | 4e81664442106c52771424f4b0b844264a6b457b (diff) | |
download | power.eda.gay-0e383fd8f3ae8e3d4ef7abb8c548f93201f3feac.tar.gz power.eda.gay-0e383fd8f3ae8e3d4ef7abb8c548f93201f3feac.zip |
Toggling geoffery with HTTP instead of MQTT
-rw-r--r-- | mqtt-client/mqtt-client.py | 10 | ||||
-rw-r--r-- | switch-snmp/Dockerfile | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/mqtt-client/mqtt-client.py b/mqtt-client/mqtt-client.py index 602774b..00a808f 100644 --- a/mqtt-client/mqtt-client.py +++ b/mqtt-client/mqtt-client.py @@ -3,6 +3,7 @@ from influxdb_client import InfluxDBClient, Point, WritePrecision from influxdb_client.client.write_api import SYNCHRONOUS import prometheus_client import threading +import asyncio import time import json import sys @@ -10,6 +11,7 @@ import os sys.path.insert(1, os.path.join(os.path.dirname(__file__), "TasmotaCLI")) import tasmotaMQTTClient +import tasmotaHTTPClient class MQTTClient: def __init__(self, mqtt_client_name = "reg.reaweb.uk/mqtt-client", loop_forever = True): @@ -92,6 +94,7 @@ class MQTTClient: print("Waiting...") time.sleep(8) tasmotaMQTTClient.MQTTClient(MQTT_HOST, "TasmotaGeoffery", os.environ["MQTT_USER"], os.environ["MQTT_PASSWD"], "ON") + print("Toggled again.") zigbee_id = list(msg_j["ZbReceived"].keys())[0] fields = msg_j["ZbReceived"][zigbee_id] @@ -103,7 +106,12 @@ class MQTTClient: if fields["Power"] == 2: print("TV Zigbee button pressed, toggling TasmotaTV Tasmota Plug") self.toggle_plug("TasmotaTV") - threading.Thread(target = toggle_geoffery, args = ()).start() + # threading.Thread(target = toggle_geoffery, args = ()).start() + loop = asyncio.get_event_loop() + loop.run_until_complete(tasmotaHTTPClient.main(host = "geoffery.plug", username = "admin", password = os.environ["MQTT_PASSWD"], toggle = True)) + time.sleep(8) + loop.run_until_complete(tasmotaHTTPClient.main(host = "geoffery.plug", username = "admin", password = os.environ["MQTT_PASSWD"], toggle = True)) + if zigbee_id == "0x74B3" and friendlyname == "HarveyButton" and "Power" in fields.keys(): if fields["Power"] == 2: diff --git a/switch-snmp/Dockerfile b/switch-snmp/Dockerfile index d09e341..9e12d5e 100644 --- a/switch-snmp/Dockerfile +++ b/switch-snmp/Dockerfile @@ -12,6 +12,6 @@ RUN pip3 install -r requirements.txt RUN rm "privateMibs(20220831).zip" RUN echo "*/1 * * * * root python3 /app/switches.py > /proc/1/fd/1 2>/proc/1/fd/2" > /etc/crontab -RUN echo "*/1 * * * * root sh -c 'sleep 30 && python3 /app/switches.py' > /proc/1/fd/1 2>/proc/1/fd/2" >> /etc/crontab +# RUN echo "*/1 * * * * root sh -c 'sleep 30 && python3 /app/switches.py' > /proc/1/fd/1 2>/proc/1/fd/2" >> /etc/crontab ENTRYPOINT ["bash"] CMD ["entrypoint.sh"] |