]> www.infradead.org Git - users/dwmw2/esp32-pool.git/commitdiff
Convert pool to esp-idf and base.yaml
authorDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 7 Aug 2024 15:53:51 +0000 (16:53 +0100)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 7 Aug 2024 15:53:51 +0000 (16:53 +0100)
No IPv6 yet as pool currently has static IP

pool.yaml

index 234973342daa9f8970e41e962ed209d3b12a08a7..9961d98efc859df210b8c49fddb3dc4a6472c760 100644 (file)
--- a/pool.yaml
+++ b/pool.yaml
@@ -74,38 +74,34 @@ esphome:
 esp32:
   board: esp32-gateway
   framework:
-    type: arduino
+    type: esp-idf
 
-# Enable logging
-logger:
-  level: DEBUG
-
-ota:
-  password: !secret ota_upgrade_pw
+packages:
+  base: !include base.yaml
 
 external_components:
  - source: github://nrandell/dallasng
- - source:
-     type: local
-     path: ../git/esphome_syslog/components
-   components: [syslog]
-
-#wifi:
-#  ssid: !secret wifi_ssid
-#  password: !secret wifi_pw
-#
-#  # Enable fallback hotspot (captive portal) in case wifi connection fails
-#  ap:
-#    ssid: "Pool Fallback Hotspot"
-#    password: "JWWHJb38UzxY"
-#
-#  manual_ip: !include poolup.yaml
-#
-#captive_portal:
 
 syslog:
     ip_address: !secret syslog_ip
 
+network:
+  enable_ipv6: false
+
+wifi: !remove
+
+ethernet:
+  type: LAN8720
+  mdc_pin: GPIO23
+  mdio_pin: GPIO18
+  clk_mode: GPIO17_OUT
+  phy_addr: 0
+  manual_ip: !include poolip.yaml
+
+#network:
+#  enable_ipv6: true
+
+
 script:
   - id: bounce_1w_power
     then:
@@ -154,8 +150,8 @@ script:
         // on at +0.3°C' logic we now have below.
 
         time_t now = ::time(NULL);
-        boolean cur_state = id(valve_output).state;
-        boolean want_state = cur_state;
+        bool cur_state = id(valve_output).state;
+        bool want_state = cur_state;
         if (cur_state) {
             // Only turn off if the output has got all the way down below the input temp
             want_state = outtemp >= intemp;
@@ -191,7 +187,7 @@ script:
         }
 
         if (now < id(control_valve_last_change) + 300) {
-            ESP_LOGD("control_valve", "Too soon to turn %s (%d seconds)", want_state ? "ON" : "OFF",
+            ESP_LOGD("control_valve", "Too soon to turn %s (%ld seconds)", want_state ? "ON" : "OFF",
                      now - id(control_valve_last_change));
             return;
         }
@@ -222,34 +218,6 @@ script:
            }
         }
 
-    # Publish a value to Domoticz as an nvalue
-  - id: tell_domo_nvalue
-    mode: queued
-    parameters:
-      udevice: int
-      nvalue: int
-    then:
-      lambda: |-
-        id(mqtt_client).publish_json("domoticz/in", [=](JsonObject root) {
-                                                    root["command"] = "udevice";
-                                                    root["idx"] = udevice;
-                                                    root["nvalue"] = nvalue;
-                                                    });
-
-    # Publish a value to Domoticz as an svalue
-  - id: tell_domo_svalue
-    mode: queued
-    parameters:
-      udevice: int
-      svalue: string
-    then:
-      lambda: |-
-        id(mqtt_client).publish_json("domoticz/in", [=](JsonObject root) {
-                                                    root["command"] = "udevice";
-                                                    root["idx"] = udevice;
-                                                    root["svalue"] = svalue;
-                                                    });
-
 globals:
   - id: solar_in_fails # Number of minutes without a reading.
     type: int
@@ -273,8 +241,6 @@ globals:
 
 time:
   - platform: sntp
-    id: sntp_time
-    servers: !secret ntp_servers
     on_time:
         # Turn on BLE client every 30 minutes for 2 minutes
         # (or until it turns itself off after a successful reading)
@@ -348,25 +314,7 @@ time:
           id: pump_default
           force: false
 
-ethernet:
-  type: LAN8720
-  mdc_pin: GPIO23
-  mdio_pin: GPIO18
-  clk_mode: GPIO17_OUT
-  phy_addr: 0
-  manual_ip: !include poolip.yaml
-
-#network:
-#  enable_ipv6: true
-
 mqtt:
-  broker: !secret mqtt_server
-  port: 1884
-  discovery_prefix: ${mqtt_prefix}/homeassistant
-  log_topic: ${mqtt_prefix}/logs
-  username: "pool"
-  password: !secret pool_mqtt_pw
-  id: mqtt_client
   on_connect:
     then:
         - delay: 2s # Too soon and the first messages don't get through!
@@ -427,7 +375,7 @@ mqtt:
       then:
         - lambda: |-
             auto cumulative = x["electricitymeter"]["energy"]["import"]["cumulative"];
-            int kwh, watts;
+            int kwh = 0, watts = 0;
             if (cumulative) {
                kwh = (cumulative.as<double>() * 1000.0f) + 0.1f;
                id(tell_domo_svalue)->execute(29, std::to_string(kwh));