aboutsummaryrefslogtreecommitdiffstats
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
parent209bcbbdf4ea50f7145674dd1c855eb6410a065e (diff)
downloadpower.eda.gay-069e1484918fefdf409da09e88550251e919db4f.tar.gz
power.eda.gay-069e1484918fefdf409da09e88550251e919db4f.zip
Added Zigbee button behavioursHEADmaster
-rw-r--r--.gitignore1
-rw-r--r--mqtt-client/mqtt-client.py16
2 files changed, 17 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 7de9703..ad2c630 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@ db.env
config.env
influxdb-config/
influxdb-data/
+node-red-data/
# Byte-compiled / optimized / DLL files
__pycache__/
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)