--- /dev/null
+#
+# 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));