112 lines
2.0 KiB
YAML
112 lines
2.0 KiB
YAML
esphome:
|
|
name: irrigation-system
|
|
friendly_name: Bewässerung
|
|
|
|
esp32:
|
|
board: esp32-c6-devkitm-1
|
|
framework:
|
|
type: esp-idf
|
|
|
|
wifi:
|
|
ssid: !secret wifi_ssid
|
|
password: !secret wifi_password
|
|
fast_connect: true
|
|
|
|
api:
|
|
encryption:
|
|
key: !secret api_key
|
|
|
|
ota:
|
|
platform: esphome
|
|
password: !secret ota_password
|
|
|
|
logger:
|
|
|
|
web_server:
|
|
|
|
# UART-Bus für Modbus
|
|
uart:
|
|
id: uart_bus
|
|
tx_pin: GPIO1
|
|
rx_pin: GPIO2
|
|
baud_rate: 9600
|
|
stop_bits: 1
|
|
parity: NONE
|
|
|
|
# Modbus-Komponente (der Hub)
|
|
modbus:
|
|
- id: modbus1
|
|
uart_id: uart_bus
|
|
|
|
modbus_controller:
|
|
- id: valve_device
|
|
address: 0x01
|
|
modbus_id: modbus1
|
|
|
|
number:
|
|
- platform: modbus_controller
|
|
modbus_controller_id: valve_device
|
|
id: valve_controller_command
|
|
name: "Valve Control"
|
|
address: 0x01
|
|
value_type: U_WORD
|
|
# min_value: 0
|
|
# max_value: 2
|
|
# step: 1
|
|
|
|
globals:
|
|
- id: my_valve_is_open
|
|
type: bool
|
|
restore_value: false
|
|
initial_value: 'true'
|
|
|
|
valve:
|
|
- platform: template
|
|
name: "Modbus Ventil"
|
|
id: my_modbus_valve
|
|
|
|
# Lambda, um den aktuellen Zustand zu bestimmen
|
|
# Liest den Zustand aus der globalen Variable
|
|
lambda: |-
|
|
return id(my_valve_is_open);
|
|
|
|
# Aktion beim Drücken auf "Öffnen"
|
|
open_action:
|
|
- number.set:
|
|
id: valve_controller_command
|
|
value: 1
|
|
- globals.set:
|
|
id: my_valve_is_open
|
|
value: 'true'
|
|
|
|
# Aktion beim Drücken auf "Schliessen"
|
|
close_action:
|
|
- number.set:
|
|
id: valve_controller_command
|
|
value: 2
|
|
- globals.set:
|
|
id: my_valve_is_open
|
|
value: 'false'
|
|
|
|
# (Optional) Aktion beim Drücken auf "Stopp"
|
|
stop_action:
|
|
- number.set:
|
|
id: valve_controller_command
|
|
value: 0
|
|
|
|
sensor:
|
|
- platform: modbus_controller
|
|
modbus_controller_id: valve_device
|
|
name: "Supply Voltage"
|
|
register_type: read
|
|
device_class: voltage
|
|
entity_category: diagnostic
|
|
accuracy_decimals: 2
|
|
filters:
|
|
- lambda: |-
|
|
return x / 1000.0;
|
|
address: 0x00F5
|
|
unit_of_measurement: "V"
|
|
value_type: U_WORD
|
|
|