esphome/garten_bus_controller.yaml

452 lines
11 KiB
YAML

esphome:
name: garten-bus-controller
esp32:
board: esp32-poe
framework:
type: arduino
# Enable logging
#logger:
# Enable Home Assistant API
api:
encryption:
key: !secret api_encryption_key
ota:
password: !secret ota_password
external_components:
- source:
type: git
url: "https://github.com/andyboeh/esphome-dmx512"
ref: master
#external_components:
# - source:
# type: local
# path: my_components
#wifi:
# ssid: "WLAN"
# password: !secret wifi_password
#
# # Enable fallback hotspot (captive portal) in case wifi connection fails
# ap:
# ssid: "Garten Bus Controller Hotspot"
# password: !secret ota_password
#captive_portal:
ethernet:
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO17_OUT
phy_addr: 0
power_pin: GPIO12
uart:
#- id: "uart_dmx"
#rx_pin: 0
#tx_pin:
#number: 1 # the pin where the transmission happens connected to tx (not reversed)
#allow_other_uses: true
#stop_bits: 2
#baud_rate: 250000
- id: uart_relays
rx_pin: 2
tx_pin: 3
baud_rate: 9600
- id: "uart_oxilife"
rx_pin: 4
tx_pin: 5
baud_rate: 19200
stop_bits: 1
parity: NONE
modbus:
- uart_id: "uart_relays"
id: "modbus_relays"
- uart_id: "uart_oxilife"
id: "modbus_oxilife"
modbus_controller:
- modbus_id: "modbus_relays"
id: "relayboard32"
address: 0x1
update_interval: "60s"
- modbus_id: "modbus_relays"
id: "relayboard8_with_inputs"
address: 0x2
update_interval: "1s"
- modbus_id: "modbus_oxilife"
id: "oxilife"
address: 0x1
update_interval: "1s"
packages:
# ------------ Relays of 32-Relay board ----
relay01: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "ventil-beete-nordwest"
dev_addr: 0x1
register_addr: 0x01
relay02: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "ventil-beet-west"
dev_addr: 0x1
register_addr: 0x02
relay03: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "ventil-sprinkler-westen"
dev_addr: 0x1
register_addr: 0x03
relay04: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "ventil-giessanlage-vorne"
dev_addr: 0x1
register_addr: 0x04
relay05: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "ventil-sprinkler-sud"
dev_addr: 0x1
register_addr: 0x05
relay06: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "ventil-beet-sued"
dev_addr: 0x1
register_addr: 0x06
relay07: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "ventil-brunnen-in-zisterne"
dev_addr: 0x1
register_addr: 0x07
#--- obere reihe
relay29: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "poolpumpe-speed3"
dev_addr: 0x1
register_addr: 29
relay30: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "poolpumpe-speed2"
dev_addr: 0x1
register_addr: 30
relay31: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "poolpumpe-speed1"
dev_addr: 0x1
register_addr: 31
relay32: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "poolpumpe-speed-off"
dev_addr: 0x1
register_addr: 32
# ------------ Relays of 8-Relay board ----
b2relay1: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard8_with_inputs
name: "garten_relayboard8_switch1"
dev_addr: 0x2
register_addr: 0x1
b2relay2: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard8_with_inputs
name: "garten_relayboard8_switch2"
dev_addr: 0x2
register_addr: 0x2
# Controls input output relationship
# 0 no relationship
# 1 self-locking
# 2 interlocking
# 3 momentary
# commented out for now, because it sends all the time
#number:
# - platform: modbus_controller
# modbus_controller_id: relayboard8_with_inputs
# name: "relayboard8-input-output-relationship"
# value_type: U_WORD
# address: 0x00fd
# min_value: 0
# max_value: 3
# skip_updates: true
#dmx512:
# id: dmx1
# uart_id: uart_dmx
# tx_pin:
# number: 1
# allow_other_uses: true
# uart_num: 0
# periodic_update: true
# ----------------------- Oxilife ------------------------------
sensor:
#- platform: modbus_controller
# modbus_controller_id: oxilife
# id: oxilife_ionization_current
# name: Ionization Strom
# value_type: U_WORD
- platform: modbus_controller
modbus_controller_id: oxilife
id: oxilife_hidro_current
name: Oxilife Hydrolyse
state_class: measurement
device_class: POWER_FACTOR
icon: mdi:percent
address: 0x0101
register_type: read
value_type: U_WORD
unit_of_measurement: "%"
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: oxilife
id: oxilife_ph
name: Oxilife pH
state_class: measurement
icon: mdi:ph
address: 0x0102
register_type: read
value_type: U_WORD
accuracy_decimals: 2
filters:
- multiply: 0.01
- platform: modbus_controller
modbus_controller_id: oxilife
id: oxilife_redox_level
name: Oxilife Redox Level
state_class: measurement
icon: mdi:atom
address: 0x0103
register_type: read
value_type: U_WORD
unit_of_measurement: "mV"
- platform: modbus_controller
modbus_controller_id: oxilife
id: oxilife_clorine_ppm
address: 0x0104
register_type: read
value_type: U_WORD
internal: true
- platform: modbus_controller
modbus_controller_id: oxilife
id: oxilife_conductivity
address: 0x0105
register_type: read
value_type: U_WORD
internal: true
- platform: modbus_controller
modbus_controller_id: oxilife
id: oxilife_temperature
name: Pool Temperatur
device_class: TEMPERATURE
state_class: measurement
address: 0x0106
register_type: read
value_type: U_WORD
unit_of_measurement: "°C"
accuracy_decimals: 1
filters:
- multiply: 0.1
# pH status
- platform: modbus_controller
modbus_controller_id: oxilife
name: Oxilife pH Status Alarm
id: oxilife_ph_status_alarm
address: 0x0107
register_type: read
value_type: U_WORD
bitmask: 0x000F
- platform: modbus_controller
modbus_controller_id: oxilife
name: Oxilife Polarization A Time
address: 0x0214
register_type: read
value_type: U_DWORD
device_class: DURATION
state_class: total_increasing
unit_of_measurement: "s"
- platform: modbus_controller
modbus_controller_id: oxilife
name: Oxilife Polarization B Time
address: 0x0216
register_type: read
value_type: U_DWORD
device_class: DURATION
state_class: total_increasing
unit_of_measurement: "s"
- platform: modbus_controller
modbus_controller_id: oxilife
name: Oxilife Runtime Polarity Changes
address: 0x0216
register_type: read
value_type: U_DWORD
state_class: total_increasing
- platform: modbus_controller
modbus_controller_id: oxilife
name: Oxilife Relay State
id: oxilife_raw_relays
address: 0x010E
register_type: read
value_type: U_WORD
binary_sensor:
# Oxilife
- platform: modbus_controller
modbus_controller_id: oxilife
id: oxilife_acid_pump
name: Oxilife Säure Pumpe
device_class: RUNNING
address: 0x0107
bitmask: 0x1000
register_type: read
- platform: modbus_controller
modbus_controller_id: oxilife
id: oxilife_ph_module_flow_control
name: Oxilife pH Flow Control
device_class: RUNNING
address: 0x0107
bitmask: 0x0400
register_type: read
- platform: modbus_controller
modbus_controller_id: oxilife
id: oxilife_hydrolysis_flow
name: Oxilife Hydrolysis Flow
device_class: RUNNING
address: 0x010D
bitmask: 0x0008
register_type: read
#Oxilife relays
- platform: modbus_controller
modbus_controller_id: oxilife
name: Oxilife Relay 1 pH
address: 0x010E
bitmask: 0x0001
device_class: POWER
register_type: read
- platform: modbus_controller
modbus_controller_id: oxilife
name: Oxilife Relay 2 Filtering
address: 0x010E
bitmask: 0x0010
device_class: POWER
register_type: read
- platform: modbus_controller
modbus_controller_id: oxilife
name: Oxilife Relay 3 Light
address: 0x010E
bitmask: 0x0004
device_class: POWER
register_type: read
- platform: modbus_controller
modbus_controller_id: oxilife
name: Oxilife Relay 4
address: 0x010E
bitmask: 0x0008
device_class: POWER
register_type: read
- platform: modbus_controller
modbus_controller_id: oxilife
name: Oxilife Relay Slow Speed
address: 0x010E
bitmask: 0x0100
device_class: POWER
register_type: read
- platform: modbus_controller
modbus_controller_id: oxilife
name: Oxilife Relay Medium Speed
address: 0x010E
bitmask: 0x0200
device_class: POWER
register_type: read
- platform: modbus_controller
modbus_controller_id: oxilife
name: Oxilife Relay High Speed
address: 0x010E
bitmask: 0x0400
device_class: POWER
register_type: read
# Relay board
- platform: modbus_controller
modbus_controller_id: relayboard8_with_inputs
name: "garten_relayboard8_input1"
register_type: holding
address: 0x81
- platform: modbus_controller
modbus_controller_id: relayboard8_with_inputs
name: "garten_relayboard8_input2"
register_type: holding
address: 0x82
switch:
- platform: modbus_controller
modbus_controller_id: oxilife
name: Oxilife Aux Relay
register_type: holding
address: 0x010E
bitmask: 0x0008
write_lambda: |-
uint16_t previous = id(oxilife_raw_relays).state;
ESP_LOGE("main","Previous state to overwrite: = %d", previous);
if(x)
previous |= 0x0008;
else
previous &= ~(0x0008);
ESP_LOGE("main","Previous state overwritten: = %d", previous);
payload.push_back(0x01); // device address
payload.push_back(0x10); // write function
payload.push_back((uint8_t)(0x010E >> 8)); // register address high
payload.push_back((uint8_t)(0x010E)); // register address low
payload.push_back(0x00); // register count high
payload.push_back(0x01); // register count low
payload.push_back(0x02); // byte count
payload.push_back((uint8_t)(previous >> 8)); // data high
payload.push_back((uint8_t)(previous)); // data low
return true;
# filtration state: 0x0421 0 off, 1 is on
# filtration mode: register 0x0411
# 0 manual
# 1 auto
# 2 heating
# 3 smart
# 4 intelligent
# 13 backwash