diff --git a/docker-compose.yml b/docker-compose.yml index 2001359..176f566 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,10 +4,23 @@ services: image: ghcr.io/home-assistant/home-assistant:stable restart: unless-stopped privileged: true - network_mode: host + environment: + - TZ=Europe/Vienna volumes: - /srv/home-assistent/config:/config - /etc/localtime:/etc/localtime:ro - /run/dbus:/run/dbus:ro - environment: - - TZ=Europe/Vienna \ No newline at end of file + networks: + - traefik_nw_public + labels: + - traefik.enable=true + - traefik.http.routers.homeassistant.entrypoints=web,websecure + - traefik.http.routers.homeassistant.rule=Host(`ha.haider.app`) + - traefik.http.routers.homeassistant.tls=true + - traefik.http.routers.homeassistant.tls.certresolver=production + - traefik.docker.network=traefik_nw_public + - traefik.http.services.homeassistant.loadbalancer.server.port=8123 + +networks: + traefik_nw_public: + external: true \ No newline at end of file diff --git a/esphome_b4_controller.yaml b/esphome_b4_controller.yaml new file mode 100644 index 0000000..95782b6 --- /dev/null +++ b/esphome_b4_controller.yaml @@ -0,0 +1,262 @@ +esphome: + name: esphome-b4-hochbeete + friendly_name: Hochbeete Controller + +esp32: + board: esp32-s3-devkitc-1 + framework: + type: arduino + +logger: + +api: + encryption: + key: WwhN4hpN66W9gSvTfkMA6f/Gen98Y8eEmUW08C3z2Xs= + +ota: + - platform: esphome + +wifi: + ssid: "HZ" + password: "pCI&QA?PNAn'R1Y3h7PQ7Uh4" + ap: + ssid: "Kincony-B4-Fallback" + password: "12345678" + +captive_portal: + +i2c: + - id: bus_a + sda: 8 + scl: 18 + scan: true + frequency: 400kHz + +pcf8574: + - id: pcf8574_hub_out_1 + i2c_id: bus_a + address: 0x24 + +switch: + - platform: gpio + name: "Bewässerung Hochbeet 1" + id: b4_relay1 + pin: + pcf8574: pcf8574_hub_out_1 + number: 4 + mode: OUTPUT + inverted: true + icon: "mdi:sprinkler-variant" + + - platform: gpio + name: "Bewässerung Hochbeet 2" + id: b4_relay2 + pin: + pcf8574: pcf8574_hub_out_1 + number: 5 + mode: OUTPUT + inverted: true + icon: "mdi:sprinkler-variant" + + - platform: gpio + name: "Bewässerung Hochbeet 3" + id: b4_relay3 + pin: + pcf8574: pcf8574_hub_out_1 + number: 6 + mode: OUTPUT + inverted: true + icon: "mdi:sprinkler-variant" + + - platform: gpio + name: "Bewässerung Hochbeet 4" + id: b4_relay4 + pin: + pcf8574: pcf8574_hub_out_1 + number: 7 + mode: OUTPUT + inverted: true + icon: "mdi:sprinkler-variant" + +binary_sensor: + - platform: gpio + name: "Feucht Hochbeet 1" + id: b4_input1 + pin: + pcf8574: pcf8574_hub_out_1 + number: 0 + mode: INPUT + inverted: true + filters: + - delayed_on: 10ms + icon: "mdi:water-opacity" + + - platform: gpio + name: "Feucht Hochbeet 2" + id: b4_input2 + pin: + pcf8574: pcf8574_hub_out_1 + number: 1 + mode: INPUT + inverted: true + filters: + - delayed_on: 10ms + icon: "mdi:water-opacity" + + - platform: gpio + name: "Feucht Hochbeet 3" + id: b4_input3 + pin: + pcf8574: pcf8574_hub_out_1 + number: 2 + mode: INPUT + inverted: true + filters: + - delayed_on: 10ms + icon: "mdi:water-opacity" + + - platform: gpio + name: "Feucht Hochbeet 4" + id: b4_input4 + pin: + pcf8574: pcf8574_hub_out_1 + number: 3 + mode: INPUT + inverted: true + filters: + - delayed_on: 10ms + icon: "mdi:water-opacity" + +ads1115: + - address: 0x48 + +sensor: + - platform: ads1115 + multiplexer: A0_GND + gain: 6.144 + resolution: 16_BITS + name: "Feuchtigkeitsmessung V Hochbeet 1" + id: b4_sensor1 + update_interval: 5s + unit_of_measurement: "V" + accuracy_decimals: 3 + state_class: measurement + icon: "mdi:flash" + + - platform: ads1115 + multiplexer: A1_GND + gain: 6.144 + resolution: 16_BITS + name: "Feuchtigkeitsmessung V Hochbeet 2" + id: b4_sensor2 + update_interval: 5s + unit_of_measurement: "V" + accuracy_decimals: 3 + state_class: measurement + icon: "mdi:flash" + + - platform: ads1115 + multiplexer: A2_GND + gain: 6.144 + resolution: 16_BITS + name: "Feuchtigkeitsmessung V Hochbeet 3" + id: b4_sensor3 + update_interval: 5s + unit_of_measurement: "V" + accuracy_decimals: 3 + state_class: measurement + icon: "mdi:flash" + + - platform: ads1115 + multiplexer: A3_GND + gain: 6.144 + resolution: 16_BITS + name: "Feuchtigkeitsmessung V Hochbeet 4" + id: b4_sensor4 + update_interval: 5s + unit_of_measurement: "V" + accuracy_decimals: 3 + state_class: measurement + icon: "mdi:flash" + + - platform: template + name: "Feuchtigkeit Hochbeet 1" + id: b4_moisture_1 + unit_of_measurement: "%" + accuracy_decimals: 0 + device_class: humidity + state_class: measurement + update_interval: 5s + icon: "mdi:water-percent" + lambda: |- + const float wet_voltage = 1.20; + const float dry_voltage = 2.70; + float v = id(b4_sensor1).state; + if (isnan(v)) return NAN; + float p = (dry_voltage - v) * 100.0 / (dry_voltage - wet_voltage); + if (p < 0) p = 0; + if (p > 100) p = 100; + return p; + + - platform: template + name: "Feuchtigkeit Hochbeet 2" + id: b4_moisture_2 + unit_of_measurement: "%" + accuracy_decimals: 0 + device_class: humidity + state_class: measurement + update_interval: 5s + icon: "mdi:water-percent" + lambda: |- + const float wet_voltage = 1.20; + const float dry_voltage = 2.70; + float v = id(b4_sensor2).state; + if (isnan(v)) return NAN; + float p = (dry_voltage - v) * 100.0 / (dry_voltage - wet_voltage); + if (p < 0) p = 0; + if (p > 100) p = 100; + return p; + + - platform: template + name: "Feuchtigkeit Hochbeet 3" + id: b4_moisture_3 + unit_of_measurement: "%" + accuracy_decimals: 0 + device_class: humidity + state_class: measurement + update_interval: 5s + icon: "mdi:water-percent" + lambda: |- + const float wet_voltage = 1.20; + const float dry_voltage = 2.70; + float v = id(b4_sensor3).state; + if (isnan(v)) return NAN; + float p = (dry_voltage - v) * 100.0 / (dry_voltage - wet_voltage); + if (p < 0) p = 0; + if (p > 100) p = 100; + return p; + + - platform: template + name: "Feuchtigkeit Hochbeet 4" + id: b4_moisture_4 + unit_of_measurement: "%" + accuracy_decimals: 0 + device_class: humidity + state_class: measurement + update_interval: 5s + icon: "mdi:water-percent" + lambda: |- + const float wet_voltage = 1.20; + const float dry_voltage = 2.70; + float v = id(b4_sensor4).state; + if (isnan(v)) return NAN; + float p = (dry_voltage - v) * 100.0 / (dry_voltage - wet_voltage); + if (p < 0) p = 0; + if (p > 100) p = 100; + return p; + +uart: + - id: uart_rs485 + tx_pin: GPIO38 + rx_pin: GPIO39 + baud_rate: 9600 \ No newline at end of file