Hello,
i want an automation in ESPhome, but cant get it running.
I have:
an Hot water Boiler (Quoka / Grohe Red), with an Dallas Temperature Sensor inside
an Sonnoff TH16 ( 1 Relay, 1 Dallas sensor , 1 (Laser)LED on GPIO4 )
the LaserLED is directed to the floor, so i have a nice red dot on the floor.
I want:
the LaserLED should show the state of my hot water Boiler.
- if relay is off and temperature is low (lower than normal warm water <60 °) LaserLED off.
- if relay is on and the temperature is low (below 80 °C) the LaserLED should flash from off to on with transition (the blinking is no problem)
- if relay is on and the temperature is high (above 80.1 °C) the LaserLED should stay on (no flashing)
- if relay is off and the temperature is still high ( if no water is taken out, the temperature drops very slowly ) the LaserLED should flash from on to off with transition
Info: The boiler has its own temperature sensor, and security mechanism so that no overheating is possible.
here is my code:
# Device Description
#Pin Function
#GPIO1 TX pin (C1 Pin 2)
#GPIO3 RX pin (C1 Pin 3)
# Folgende Werte Steuern die Schwellwerte für die LaserLED/Signal LED
substitutions:
devicename: esphotwater
human_devicename: Heisswasser # Name in HA
gpio_taster: '0' # GPIO0 Button (inverted)
gpio_relay: '12' # GPIO12 Relay & RED LED
gpio_blueled: '13' # GPIO13 Blue LED (inverted)
gpio_dallas: '4' # GPIO4 Optional Sensor (C1 Pin 5)
gpio_laserled: '2' # GPIO2 B59D10_laserled Optional Pin EXP-LOG (TH16 Ver 2.1 2019)
Temperatur_on: '91' # Temperatur wenn LaserLED dauerhaft an sein soll - Temperatur voll erreicht
Temperatur_off: '67' # Unterhalb dieser Temperatur ist das Gerät aus (Nachts)
packages:
wifi: !include common/wifi.yaml # Wifi SSID/Passwort
misc: !include common/misc.yaml # Web Interface
time: !include common/time.yaml # ZeitServer
api: !include common/api.yaml # API Daten
logger:
level: INFO
esphome:
name: $devicename
platform: ESP8266
board: esp01_1m
text_sensor:
- platform: wifi_info
ip_address:
name: $human_devicename Wifi IP
id: text_ip
mac_address:
name: $human_devicename Wifi MAC
id: text_mac
ssid:
name: $human_devicename Wifi SSID
id: text_ssid
- platform: version
id: text_version
name: $human_devicename ESP Version
hide_timestamp: true
icon: mdi:wrench
- platform: template
name: $human_devicename Uptime
id: uptime_human
icon: mdi:clock-start
- platform: template
name: "$human_devicename Status"
id: id_state
dallas:
- pin: $gpio_dallas
update_interval: 10s
id: dallas_hotwater
sensor:
- <<: !include common/sensor_wifisignal.yaml # <- WiFi Status
- <<: !include common/sensor_uptime.yaml # <- Human Uptime in D H M s
# Individual sensors - Dallas oder Anaolog NTC
- platform: dallas
address: 0xB301145DE7EA6F28
name: "$human_devicename Temperatur"
filters:
- filter_out: nan
- offset: +17
# works with dallas
id: Temperatur
on_value:
then:
- if: # state off
condition:
lambda: |-
if (x < $Temperatur_off){
return true;
} else {
return false;
}
then:
- logger.log: "State 1 below $Temperatur_off"
- switch.turn_off: laser_on
- switch.turn_off: laser_heat
- switch.turn_off: laser_cool
- light.turn_off: laserled_light
- text_sensor.template.publish:
id: id_state
state: "Off"
else: # state warm
- logger.log: "State 2 above $Temperatur_off"
- if: # check temperature
condition:
lambda: |-
if ( (x > $Temperatur_off) or (x < $Temperatur_on) ){
return true;
} else {
return false;
}
then:
- logger.log: "State 3 above $Temperatur_off or under $Temperatur_on State"
- if: # check if relay is on
condition:
lambda: 'return id(relay).state;' # is inverted
then:
- logger.log: "State 4 Range above $Temperatur_off and relay on"
# turn off all other
- switch.turn_off: laser_on
- switch.turn_off: laser_cool
- switch.turn_on: laser_heat
- text_sensor.template.publish:
id: id_state
state: "Heat"
- if: # check if tempreture is high
condition:
lambda: |-
if (x > $Temperatur_on){
return true;
} else {
return false;
}
then:
- logger.log: "State 5 Range above $Temperatur_on relay on"
- switch.turn_off: laser_heat
- switch.turn_off: laser_cool
- switch.turn_on: laser_on
- text_sensor.template.publish:
id: id_state
state: "Ready"
else:
- logger.log: "State 6 Range above $Temperatur_on error 1"
- switch.turn_off: laser_heat
- switch.turn_off: laser_cool
- switch.turn_on: laser_on
- text_sensor.template.publish:
id: id_state
state: "Error 1"
else:
- logger.log: "State 5 Range above $Temperatur_off and relay off"
- switch.turn_off: laser_on
- switch.turn_off: laser_heat
- switch.turn_on: laser_cool
- text_sensor.template.publish:
id: id_state
state: "Cool"
- if: # check if tempreture is high
condition:
lambda: |-
if (x > $Temperatur_on){
return true;
} else {
return false;
}
then:
- logger.log: "State 7 Range above $Temperatur_on relay off"
- switch.turn_off: laser_heat
- switch.turn_off: laser_cool
- switch.turn_on: laser_on
- text_sensor.template.publish:
id: id_state
state: "Ready but off"
else:
- logger.log: "State 8 Range above $Temperatur_on error 2"
- switch.turn_off: laser_heat
- switch.turn_off: laser_cool
- switch.turn_on: laser_on
- text_sensor.template.publish:
id: id_state
state: "Error 2"
binary_sensor:
- <<: !include common/binary_sensor.yaml # <- HA connection status
# Sonnoff Taster
- platform: gpio
pin:
number: $gpio_taster
mode:
input: true
pullup: true
inverted: true
name: "$human_devicename Taster"
on_press:
- switch.toggle: relay
- switch.toggle: blue_led
switch:
- <<: !include common/switch.yaml # Reset Button on webui
# Relay boiler on/off
- platform: gpio
name: "$human_devicename Relais"
pin: $gpio_relay
inverted: false
id: relay
- platform: gpio
name: "$human_devicename BlueLed"
pin: $gpio_blueled
inverted: false
id: blue_led
internal: true
# LaserLED Dauerpermanent on
- platform: template
name: "$human_devicename An"
optimistic: true
id: laser_on
# internal: true
turn_on_action:
then:
- light.turn_on:
id: laserled_light
turn_off_action:
then:
- light.turn_off:
id: laserled_light
transition_length: 100ms
# LaserLED flash dunkel -> hell
- platform: template
name: "$human_devicename aufheizen"
optimistic: true
id: laser_heat
# internal: true
turn_on_action:
- light.turn_off: laserled_light
- while:
condition:
lambda: 'return true;'
then:
- light.turn_on:
id: laserled_light
transition_length: 3s
- delay: 3500ms
- light.turn_off:
id: laserled_light
transition_length: 1ms
- delay: 700ms
turn_off_action:
then:
- light.turn_off:
id: laserled_light
transition_length: 100ms
# LaserLED flash hell -> dunkel
- platform: template
name: "$human_devicename abkühlen"
optimistic: true
id: laser_cool
# internal: true
turn_on_action:
- light.turn_off: laserled_light
- while:
condition:
lambda: 'return true;'
then:
- light.turn_on:
id: laserled_light
transition_length: 1ms
- delay: 700ms
- light.turn_off:
id: laserled_light
transition_length: 3s
- delay: 3500ms
turn_off_action:
then:
- light.turn_off:
id: laserled_light
transition_length: 100ms
output:
# Register the LED as a dimmable output ....
- platform: esp8266_pwm
id: laserled
pin: $gpio_laserled
inverted: false
light:
# ... and then make a light out of it.
# LaserLED dot on the flor
- platform: monochromatic
name: "$human_devicename LaserLED Light"
output: laserled
internal: true
id: laserled_light
I have updated the code. and its nearly working now. ( i forgot to implement an Version counter, but ist must be version 123 if not more )
But there are two Problems:
- The status is “flickering” if process go’s down the lines status get set off,heat,ready
- If the temperature is below off and i turn on the relay, the LaserLED stay off, (id false the device is in but it needs more time of course)