aboutsummaryrefslogtreecommitdiffstats
path: root/mqtt-client
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2025-01-17 17:54:30 +0000
committerjwansek <eddie.atten.ea29@gmail.com>2025-01-17 17:54:30 +0000
commit069e1484918fefdf409da09e88550251e919db4f (patch)
tree9ff3f6b91bf6ab32a652a9ba446fb0cddeec7d7b /mqtt-client
parent209bcbbdf4ea50f7145674dd1c855eb6410a065e (diff)
downloadpower.eda.gay-master.tar.gz
power.eda.gay-master.zip
Added Zigbee button behavioursHEADmaster
Diffstat (limited to 'mqtt-client')
-rw-r--r--mqtt-client/mqtt-client.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/mqtt-client/mqtt-client.py b/mqtt-client/mqtt-client.py
index a441e6d..c846578 100644
--- a/mqtt-client/mqtt-client.py
+++ b/mqtt-client/mqtt-client.py
@@ -54,6 +54,22 @@ class MQTTClient:
print("Zigbee device '%s' reported: %s" % (friendlyname, str(fields)))
self.append_influxdb(fields, "zigbee", {"friendlyname": friendlyname, "id": zigbee_id})
+ if zigbee_id == "0x7327" and friendlyname == "TVButton" and "Power" in fields.keys():
+ if fields["Power"] == 2:
+ print("TV Zigbee button pressed, toggling TasmotaTV Tasmota Plug")
+ self.toggle_plug("TasmotaTV")
+
+ if zigbee_id == "0x74B3" and friendlyname == "HarveyButton" and "Power" in fields.keys():
+ if fields["Power"] == 2:
+ print("Harvey's button pressed, toggling TasmotaHarveyPC Plug")
+ self.toggle_plug("TasmotaHarveyPC")
+
+ def toggle_plug(self, friendlyname):
+ t = "cmnd/TasmotaPlug/%s/Power" % friendlyname
+ payload = "TOGGLE"
+ self.mqttc.publish(t, payload = payload)
+ print("Send payload '%s' to %s" % (payload, t))
+
def append_influxdb(self, fields, measurement_name, tags):
points = [{"measurement": measurement_name, "tags": tags, "fields": fields}]
write_api = self.influxc.write_api(write_options = SYNCHRONOUS)