TiBo
1
i want if relay is on/off and (dallas) temperatur between to values to do diffrent actions
someting like this
binary_sensor:
- platform: gpio
# ...
on_state:
then:
- if:
- condition:
id(temperature) > 100
then:
- switch.turn_off: relay_1
else:
- switch.turn_on: button.wohnzimmer_fenster_ota_update
i cant get it working
tom_l
2
Your condition isn’t quite right, neither is your indentation, try this:
binary_sensor:
- platform: gpio
# ...
on_state:
then:
- if:
condition:
lambda: 'return id(temperature).state > 100;'
then:
- switch.turn_off: relay_1
else:
- button.press: my_button
Also you cant use the switch turn on service for a button, use - button.press: my_button
instead and you should be using the id of the button.
TiBo
3
Thanks you are right the example is buggy.
The problem is the Trigger.
- The example above Example triggers ony if the binary_sensor change but not when the Teperature is rising
if i turn the Logig to react on the Temperature like this
sensor:
- platform: dallas
address: 0xB301145DE7EA6F28
name: "$human_devicename Temperatur"
id: Temperatur
on_value:
then:
- if: # check temperature
condition:
lambda: |-
if ( (x > $Temperatur_off) or (x < $Temperatur_on) ){
ESP_LOGD("between", "true");
return true;
} else {
ESP_LOGD("between", "false");
return false;
}
then:
- logger.log: "Range 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: "Range above $Temperatur_off and relay off"
- switch.turn_on: laser_cool
- text_sensor.template.publish:
id: id_state
state: "cool"
else:
- logger.log: "Range above $Temperatur_off and relay on"
# turn off all other
- switch.turn_on: laser_heat
- text_sensor.template.publish:
id: id_state
state: "heat"
- This Example Triggers if the Temperature change but not when then relay is toggled.
Thast what i mean at my Tpoci Question
Is it possible to have more decision levels in esphome?
Full Code here: