From: David Woodhouse Date: Mon, 27 Nov 2023 11:06:38 +0000 (+0000) Subject: Add water softener measure X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f16bd3934f0c8d519b134c48f48436ce9096cb46;p=users%2Fdwmw2%2Fesp32-pool.git Add water softener measure --- diff --git a/softener.yaml b/softener.yaml new file mode 100644 index 0000000..ab474d1 --- /dev/null +++ b/softener.yaml @@ -0,0 +1,147 @@ +# +# https://www.aliexpress.com/item/1005004099215436.html +# +# GPIO23: Onboard blue LED (used to show MQTT connectivity) +# GPIO16: Onboard relay (bathroom fan) +# GPIO13: DHT22 + +esphome: + name: softener + +esp32: + board: esp32-gateway + framework: + type: arduino + +# Enable logging +logger: + level: DEBUG + +ota: + password: !secret ota_upgrade_pw + +external_components: + - source: + type: local + path: ../git/esphome_syslog/components + components: [syslog] + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_pw + +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; + }); + + # Publishto Domoticz as nvalue and svalues + - id: tell_domo_nsvalues + mode: queued + parameters: + udevice: int + nvalue: int + svalue: string + then: + lambda: |- + id(mqtt_client).publish_json("domoticz/in", [=](JsonObject root) { + root["command"] = "udevice"; + root["idx"] = udevice; + root["nvalue"] = nvalue; + root["svalue"] = svalue; + }); + +# # 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 + +time: + - platform: sntp + id: sntp_time + servers: !secret ntp_servers + +#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: + - light.turn_on: blue_led + + on_disconnect: + then: + - light.turn_off: blue_led + +light: + - platform: binary + name: "Blue LED" + id: blue_led + output: led_output + +output: + - id: led_output + platform: gpio + pin: GPIO23 + +switch: + - platform: gpio + name: "Fan" + id: fan_relay + pin: GPIO16 + +sensor: + - platform: hx711 + dout_pin: GPIO13 + clk_pin: GPIO14 + gain: 128 + update_interval: 30s + name: "HX711 value" + filters: + - calibrate_linear: + - 424400 -> 0 + - -1592100 -> 89.05 + unit_of_measurement: kg + on_value: + then: + lambda: |- + if (!isnan(x)) + id(tell_domo_svalue)->execute(524, std::to_string(x));