Updated gartenhaus light

This commit is contained in:
Martin Bauer 2023-08-22 14:15:17 +02:00
commit 50779acee3
7 changed files with 969 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
# Gitignore settings for ESPHome
# This is an example and may include too much for your use-case.
# You can modify this file to suit your needs.
/.esphome/
/secrets.yaml

444
garten_bus_controller.yaml Normal file
View File

@ -0,0 +1,444 @@
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: 1 # the pin where the transmission happens connected to tx (not reversed)
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
- 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: "modbus-switch01"
dev_addr: 0x1
register_addr: 0x01
relay02: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "modbus-switch02"
dev_addr: 0x1
register_addr: 0x02
relay03: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "modbus-switch03"
dev_addr: 0x1
register_addr: 0x03
relay16: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "modbus-switch16"
dev_addr: 0x1
register_addr: 0x0f
relay17: !include
file: "modbus_relay.yaml"
vars:
cid: relayboard32
name: "modbus-switch17"
dev_addr: 0x1
register_addr: 0x10
# ------------ 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: 1
uart_num: 0
periodic_update: true
output:
- platform: dmx512
channel: 1
universe: dmx1
id: pool_licht_r
- platform: dmx512
channel: 2
universe: dmx1
id: pool_licht_g
- platform: dmx512
channel: 3
universe: dmx1
id: pool_licht_b
- platform: dmx512
channel: 4
universe: dmx1
id: magnolie_links_r
- platform: dmx512
channel: 5
universe: dmx1
id: magnolie_links_g
- platform: dmx512
channel: 6
universe: dmx1
id: magnolie_links_b
light:
- platform: rgb
name: pool_licht
red: pool_licht_r
green: pool_licht_g
blue: pool_licht_b
default_transition_length: 0s
restore_mode: RESTORE_DEFAULT_OFF
- platform: rgb
name: magnolie_links
red: magnolie_links_r
green: magnolie_links_g
blue: magnolie_links_b
default_transition_length: 0s
restore_mode: RESTORE_DEFAULT_OFF
# ----------------------- 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

View File

@ -0,0 +1,184 @@
esphome:
name: gartenhaus-taster-input
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
ethernet:
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO17_OUT
phy_addr: 0
power_pin: GPIO12
globals:
- id: taster_oben_state
type: int
restore_value: yes
initial_value: '0'
binary_sensor:
- platform: gpio
name: "gartenhaus_lichtschalter_gross"
filters:
- invert:
- delayed_on: 10ms
pin:
number: 4
mode:
input: true
pullup: true
device_class: LIGHT
on_press:
then:
- if:
condition:
lambda: 'return (id(taster_oben_state) == 0);'
then:
- globals.set:
id: taster_oben_state
value: '1'
- homeassistant.service:
service: scene.turn_on
data:
entity_id: scene.garten_farbig
else:
- globals.set:
id: taster_oben_state
value: '0'
- homeassistant.service:
service: scene.turn_on
data:
entity_id: scene.garten_aus
- platform: gpio
name: "gartenhaus_lichtschalter_klein_links"
filters:
- invert:
- delayed_on: 10ms
pin:
number: 15
mode:
input: true
pullup: true
device_class: LIGHT
on_press:
homeassistant.service:
service: script.esphome_light_toggle
data:
light_name: "light.gartenhaus_deckenlicht_mitte, light.gartenhaus_deckenlicht_hinten"
transition: "0"
red: "0"
blue: "0"
green: "0"
white: "255"
- platform: gpio
name: "gartenhaus_lichtschalter_klein_rechts"
filters:
- invert:
- delayed_on: 10ms
pin:
number: 16
mode:
input: true
pullup: true
device_class: LIGHT
on_press:
homeassistant.service:
service: script.esphome_light_toggle
data:
light_name: "light.gartenhaus_deckenlicht_vorne"
transition: "0"
red: "0"
blue: "0"
green: "0"
white: "255"
- platform: gpio
name: "gartenhaus_taster1"
filters:
- invert:
- delayed_on: 10ms
pin:
number: 14
mode:
input: true
pullup: true
device_class: LIGHT
- platform: gpio
name: "gartenhaus_taster2"
filters:
- invert:
- delayed_on: 10ms
pin:
number: 13
mode:
input: true
pullup: true
device_class: LIGHT
- platform: gpio
name: "gartenhaus_taster3"
filters:
- invert:
- delayed_on: 10ms
pin:
number: 2
mode:
input: true
pullup: true
device_class: LIGHT
- platform: gpio
name: "gartenhaus_taster4"
filters:
- invert:
- delayed_on: 10ms
pin:
number: 5
mode:
input: true
pullup: true
device_class: LIGHT
#on_multi_click:
# - timing:
# - ON for at most 1s
# - OFF for at most 0.3s
# - ON for at most 1s
# - OFF for at least 0.2s
# then:
# - homeassistant.event:
# event: esphome.gartenhaus_lichtschalter_gross_doubleclick
# - homeassistant.service:
# service: light.toggle
# data:
# entity_id: light.gartenhaus_deckenlicht_mitte
# - timing:
# - ON for at most 1s
# - OFF for at least 0.5s
# then:
# - homeassistant.event:
# event: esphome.gartenhaus_lichtschalter_gross_click
# - homeassistant.service:
# service: light.toggle
# data:
# entity_id: light.gartenhaus_deckenlicht_hinten

View File

@ -0,0 +1,142 @@
# ----------------------------------------- Generic -----------------------------------------------
esphome:
name: gartenhaus-led-controller
esp32:
board: esp32-poe
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
#password: !secret ota_password
encryption:
key: !secret api_encryption_key
ota:
password: !secret ota_password
ethernet:
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO17_OUT
phy_addr: 0
power_pin: GPIO12
# ----------------------------------------- Buttons -----------------------------------------------
# 13 led r
# 14 led l
# 16 button r
# 15 button l
binary_sensor:
- platform: gpio
name: gartenhaus-led-controller-button-links
pin:
number: 15
inverted: true
mode:
input: true
pullup: true
- platform: gpio
name: gartenhaus-led-controller-button-rechts
pin:
number: 16
inverted: true
mode:
input: true
pullup: true
# Motion sensor
- platform: gpio
pin: 32
name: gartenhaus-led-controller-motion-sensor
device_class: motion
# ----------------------------------------- Button lights -----------------------------------------------
switch:
- platform: gpio
name: gartenhaus-led-controller-button-led-links
restore_mode: RESTORE_DEFAULT_OFF
pin:
number: 14
mode:
output: true
- platform: gpio
name: gartenhaus-led-controller-button-led-rechts
restore_mode: RESTORE_DEFAULT_OFF
pin:
number: 13
mode:
output: true
# ----------------------------------------- Led Channel 1 -----------------------------------------------
# Kanal1: GPIO3
# Kanal2: GPIO2
# Kanal3: GPIO4
# Kanal4: GPIO5
light:
- platform: esp32_rmt_led_strip
rgb_order: grb
chipset: SK6812
icon: mdi:led-strip-variant
id: gartenhaus_wandlicht
name: Gartenhaus Wandlicht
pin: 3
num_leds: 300
is_rgbw: true
rmt_channel: 0
effects:
- addressable_rainbow:
name: Regenbogen
width: 300
- addressable_color_wipe:
name: Wipe
colors:
random: true
num_leds: 150
- random:
name: "Zufall langsam"
transition_length: 30s
update_interval: 30s
- addressable_twinkle:
name: Twinkle
- addressable_fireworks:
name: Feuerwerk
- platform: esp32_rmt_led_strip
rgb_order: grb
chipset: SK6812
name: Gartenhaus Deckenlicht
id: gartenhaus_deckenlicht
pin: 2
num_leds: 352
is_rgbw: true
rmt_channel: 1
internal: true
- platform: partition
name: Gartenhaus Deckenlicht Hinten
segments:
- id: gartenhaus_deckenlicht
from: 0
to: 116
- platform: partition
name: Gartenhaus Deckenlicht Mitte
segments:
- id: gartenhaus_deckenlicht
from: 117
to: 233
reversed: true
- platform: partition
name: Gartenhaus Deckenlicht Vorne
segments:
- id: gartenhaus_deckenlicht
from: 234
to: 351

16
modbus_relay.yaml Normal file
View File

@ -0,0 +1,16 @@
switch:
- platform: modbus_controller
modbus_controller_id: ${cid}
name: ${name}
register_type: holding
address: ${dev_addr}
write_lambda: |-
bool open = (x == 1);
payload.push_back(${dev_addr}); // device address
payload.push_back(0x6); // write function
payload.push_back(0); // relay select
payload.push_back(${register_addr}); //
payload.push_back(open ? 0x01 : 0x02); // Command
payload.push_back(0x00);
return true;

83
modbustester.yaml Normal file
View File

@ -0,0 +1,83 @@
esphome:
name: modbustester
esp32:
board: esp32-poe
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
#password: !secret ota_password
encryption:
key: !secret api_encryption_key
ota:
password: !secret ota_password
ethernet:
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO17_OUT
phy_addr: 0
power_pin: GPIO12
uart:
- id: uart_for_modbus
rx_pin: 1
tx_pin: 0
baud_rate: 19200
stop_bits: 1
parity: NONE
modbus:
uart_id: "uart_for_modbus"
id: modbus_comp
modbus_controller:
- modbus_id: "modbus_comp"
id: oxilife
address: 0x1
update_interval: "1s"
sensor:
#- platform: modbus_controller
# modbus_controller_id: oxilife
# id: oxilife_ionization_current
# name: Ionization Strom
# address: 0x0100
# value_type: U_WORD
- platform: modbus_controller
modbus_controller_id: oxilife
id: tester_oxilife_hidro_current
name: Test Oxilife Hydro Strom
address: 0x0101
register_type: read
value_type: U_WORD
- platform: modbus_controller
modbus_controller_id: oxilife
id: tester_oxilife_ph
name: Test Oxilife 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: tester_oxilife_redox_level
name: Test Oxilife Redox Level
address: 0x0103
register_type: read
value_type: U_WORD
unit_of_measurement: "mV"

95
poolcoversensor.yaml Normal file
View File

@ -0,0 +1,95 @@
esphome:
name: poolcoversensor
esp32:
board: esp32-poe
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
password: !secret ota_password
ota:
password: !secret ota_password
#wifi:
# ssid: "WLAN"
# password: !secret wifi_password
#
# # Enable fallback hotspot (captive portal) in case wifi connection fails
# ap:
# ssid: "Poolcoversensor Fallback 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
sensor:
- platform: ultrasonic
trigger_pin: 4
echo_pin: 36
name: "Poolcover Einstieg Abstand"
icon: "mdi:door-sliding-open"
update_interval: 1s
timeout: 3m
binary_sensor:
- platform: gpio
device_class: opening
name: "Poolcover Vorne Einstieg"
icon: "mdi:waves-arrow-right"
filters:
- delayed_on: 100ms
pin:
number: 16
mode:
input: true
pullup: true
- platform: gpio
device_class: opening
name: "Poolcover Mitte"
icon: "mdi:waves-arrow-up"
filters:
- delayed_on: 100ms
pin:
number: 15
mode:
input: true
pullup: true
- platform: gpio
device_class: opening
name: "Poolcover Ende"
icon: "mdi:waves-arrow-left"
filters:
- delayed_on: 100ms
pin:
number: 14
mode:
input: true
pullup: true
# Those pins act as GND to be connected with the binary inputs
switch:
- platform: gpio
id: gndpin1
pin: 13
internal: true
- platform: gpio
id: gndpin2
pin: 2
internal: true
- platform: gpio
id: gndpin3
pin: 5
internal: true