Hello.
I’m trying to make a homemade thermostat to control from ha. The tactic is as follows: less than 20 nothing works, turns on from 20 to 30 hysteresis 0.5
How can I get hysteresis from the assistant? And apply this in a lambda?
Controlling tp_global u ha via input_number
Check out my code) can it be optimized?
This is not how it works, only manual numbers …
Not WORK if (id(tp_obratka).state < (id(tp_global) - id(tp_gist)))
work if (id(tp_obratka).state < id(tp_global) - 0.5 )
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
globals:
- id: tp_start
type: int
restore_value: no
initial_value: '28'
- id: tp_global
type: int
restore_value: no
initial_value: '30'
- id: tp_gist
type: int
restore_value: no
initial_value: '0.5'
status_led:
pin:
number: GPIO13
inverted: false
binary_sensor:
- platform: status
name: "Teplyi pol"
dallas:
- pin: GPIO14
update_interval: 2s
sensor:
- platform: wifi_signal
name: "tp_WiFi"
update_interval: 60s
- platform: dallas
address: 0xF33C01B556F0A928
name: "tp_podacha"
id: tp_podacha
on_value:
then:
- script.execute: tp_control
- platform: dallas
address: 0xFE0119212D102B28
name: "tp_obratka"
id: tp_obratka
on_value:
then:
- script.execute: tp_control
- platform: homeassistant
name: "tp_ustavka"
entity_id: input_number.tp_ustavka
id: tp_ustavka
on_value:
then:
- script.execute: tp_globalset
switch:
- platform: gpio
pin: GPIO12
name: "tp_nasos"
id: tp_nasos
script:
- id: tp_control
then:
- lambda: |-
if (id(tp_podacha).state > 20 ) {
if (id(tp_obratka).state < (id(tp_global) - id(tp_gist))) {
id(tp_nasos).turn_on();
} else if (id(tp_obratka).state > id(tp_global) ) {
id(tp_nasos).turn_off();
}
} else {
id(tp_nasos).turn_off();
}
- id: tp_globalset
then:
- globals.set:
id: tp_global
value: !lambda |-
return id(tp_ustavka).state;