Files
home-assistant/esphome_b4_controller.yaml
2026-05-17 16:27:15 +02:00

316 lines
6.9 KiB
YAML

esphome:
name: esphome-b4-hochbeete
friendly_name: Hochbeete Controller
esp32:
board: esp32-s3-devkitc-1
framework:
type: arduino
logger:
hardware_uart: USB_SERIAL_JTAG
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_relay
sda: 8
scl: 18
scan: true
frequency: 400kHz
- id: bus_ads
sda: 13
scl: 14
scan: true
frequency: 100kHz
pcf8574:
- id: pcf8574_hub_out_1
i2c_id: bus_relay
address: 0x24
ads1115:
- id: ads1115_hub
i2c_id: bus_ads
address: 0x48
globals:
- id: hb1_wet_voltage
type: float
restore_value: yes
initial_value: '1.20'
- id: hb1_dry_voltage
type: float
restore_value: yes
initial_value: '2.70'
- id: hb2_wet_voltage
type: float
restore_value: yes
initial_value: '1.20'
- id: hb2_dry_voltage
type: float
restore_value: yes
initial_value: '2.70'
- id: hb3_wet_voltage
type: float
restore_value: yes
initial_value: '1.20'
- id: hb3_dry_voltage
type: float
restore_value: yes
initial_value: '2.70'
- id: hb4_wet_voltage
type: float
restore_value: yes
initial_value: '1.20'
- id: hb4_dry_voltage
type: float
restore_value: yes
initial_value: '2.70'
switch:
- platform: gpio
name: "Bewässerung Hochbeet 1"
id: b4_relay1
pin:
pcf8574: pcf8574_hub_out_1
number: 4
mode: OUTPUT
inverted: true
restore_mode: ALWAYS_OFF
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
restore_mode: ALWAYS_OFF
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
restore_mode: ALWAYS_OFF
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
restore_mode: ALWAYS_OFF
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"
sensor:
- platform: ads1115
ads1115_id: ads1115_hub
multiplexer: A0_GND
gain: 4.096
resolution: 16_BITS
name: "Feuchtigkeitsmessung V Hochbeet 1"
id: b4_sensor1
update_interval: 2s
unit_of_measurement: "V"
accuracy_decimals: 3
state_class: measurement
icon: "mdi:flash"
- platform: ads1115
ads1115_id: ads1115_hub
multiplexer: A1_GND
gain: 4.096
resolution: 16_BITS
name: "Feuchtigkeitsmessung V Hochbeet 2"
id: b4_sensor2
update_interval: 2s
unit_of_measurement: "V"
accuracy_decimals: 3
state_class: measurement
icon: "mdi:flash"
- platform: ads1115
ads1115_id: ads1115_hub
multiplexer: A2_GND
gain: 4.096
resolution: 16_BITS
name: "Feuchtigkeitsmessung V Hochbeet 3"
id: b4_sensor3
update_interval: 2s
unit_of_measurement: "V"
accuracy_decimals: 3
state_class: measurement
icon: "mdi:flash"
- platform: ads1115
ads1115_id: ads1115_hub
multiplexer: A3_GND
gain: 4.096
resolution: 16_BITS
name: "Feuchtigkeitsmessung V Hochbeet 4"
id: b4_sensor4
update_interval: 2s
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: 2s
icon: "mdi:water-percent"
lambda: |-
float wet_voltage = id(hb1_wet_voltage);
float dry_voltage = id(hb1_dry_voltage);
float v = id(b4_sensor1).state;
if (isnan(v) || dry_voltage <= wet_voltage) return NAN;
float p = (dry_voltage - v) * 100.0f / (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: 2s
icon: "mdi:water-percent"
lambda: |-
float wet_voltage = id(hb2_wet_voltage);
float dry_voltage = id(hb2_dry_voltage);
float v = id(b4_sensor2).state;
if (isnan(v) || dry_voltage <= wet_voltage) return NAN;
float p = (dry_voltage - v) * 100.0f / (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: 2s
icon: "mdi:water-percent"
lambda: |-
float wet_voltage = id(hb3_wet_voltage);
float dry_voltage = id(hb3_dry_voltage);
float v = id(b4_sensor3).state;
if (isnan(v) || dry_voltage <= wet_voltage) return NAN;
float p = (dry_voltage - v) * 100.0f / (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: 2s
icon: "mdi:water-percent"
lambda: |-
float wet_voltage = id(hb4_wet_voltage);
float dry_voltage = id(hb4_dry_voltage);
float v = id(b4_sensor4).state;
if (isnan(v) || dry_voltage <= wet_voltage) return NAN;
float p = (dry_voltage - v) * 100.0f / (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