From: David Woodhouse Date: Wed, 7 Aug 2024 15:53:51 +0000 (+0100) Subject: Convert pool to esp-idf and base.yaml X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=57037e0ccd28b45d0f0cb30fe0e89936d95776b2;p=users%2Fdwmw2%2Fesp32-pool.git Convert pool to esp-idf and base.yaml No IPv6 yet as pool currently has static IP --- diff --git a/pool.yaml b/pool.yaml index 2349733..9961d98 100644 --- 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() * 1000.0f) + 0.1f; id(tell_domo_svalue)->execute(29, std::to_string(kwh));