From 98e78d94b3d6bb7caae8049e4a93866ceeb0f0f9 Mon Sep 17 00:00:00 2001
From: David Woodhouse <dwmw@amazon.co.uk>
Date: Tue, 5 Sep 2023 22:00:31 +0100
Subject: [PATCH] Domoticz notification for mains switches

---
 pool.yaml | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/pool.yaml b/pool.yaml
index 07c4677..1b649ae 100644
--- a/pool.yaml
+++ b/pool.yaml
@@ -592,6 +592,22 @@ switch:  #### To switch on and off the communication with the BLE device ####
     pin:
       number: GPIO15
       inverted: true
+    on_turn_on:
+      then:
+        - mqtt.publish_json:
+            topic: domoticz/in
+            payload: |-
+              root["command"] = "udevice";
+              root["idx"] = 516;
+              root["nvalue"] = 1;
+    on_turn_off:
+      then:
+        - mqtt.publish_json:
+            topic: domoticz/in
+            payload: |-
+              root["command"] = "udevice";
+              root["idx"] = 516;
+              root["nvalue"] = 0;
 
   - platform: gpio
     id: pool_pump
@@ -599,6 +615,22 @@ switch:  #### To switch on and off the communication with the BLE device ####
     pin:
       number: GPIO16
       inverted: true
+    on_turn_on:
+      then:
+        - mqtt.publish_json:
+            topic: domoticz/in
+            payload: |-
+              root["command"] = "udevice";
+              root["idx"] = 518;
+              root["nvalue"] = 1;
+    on_turn_off:
+      then:
+        - mqtt.publish_json:
+            topic: domoticz/in
+            payload: |-
+              root["command"] = "udevice";
+              root["idx"] = 518;
+              root["nvalue"] = 0;
 
   - platform: gpio
     id: pool_light
@@ -606,6 +638,22 @@ switch:  #### To switch on and off the communication with the BLE device ####
     pin:
       number: GPIO4
       inverted: true
+    on_turn_on:
+      then:
+        - mqtt.publish_json:
+            topic: domoticz/in
+            payload: |-
+              root["command"] = "udevice";
+              root["idx"] = 515;
+              root["nvalue"] = 1;
+    on_turn_off:
+      then:
+        - mqtt.publish_json:
+            topic: domoticz/in
+            payload: |-
+              root["command"] = "udevice";
+              root["idx"] = 515;
+              root["nvalue"] = 0;
 
   - platform: gpio
     id: shed_fan
@@ -613,3 +661,19 @@ switch:  #### To switch on and off the communication with the BLE device ####
     pin:
       number: GPIO32
       inverted: true
+    on_turn_on:
+      then:
+        - mqtt.publish_json:
+            topic: domoticz/in
+            payload: |-
+              root["command"] = "udevice";
+              root["idx"] = 517;
+              root["nvalue"] = 1;
+    on_turn_off:
+      then:
+        - mqtt.publish_json:
+            topic: domoticz/in
+            payload: |-
+              root["command"] = "udevice";
+              root["idx"] = 517;
+              root["nvalue"] = 0;
-- 
2.49.0