Jeg bruker en sonoff th16 og der firmware er esphome. Tanken er avslått mesteparten av døgnet, men det beregnes tidspunkt strømmen må slås på for at vannet skal være 75 grader klokken 04:45. Tanken bruker ca 400 sekund på å varme vannet 1 grad.
esphome:
name: varmtvannstank
platform: ESP8266
board: esp01_1m
wifi:
ssid: "HEIME5.ORG"
password: !secret heime_wifi
domain: .lan
# Enable fallback hotspot (captive portal) in case wifi connection fails
#ap:
# ssid: "Varmtvannstank Fallback Hotspot"
# password: "okz8anWfZKFP"
#captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
globals:
- id: heating
type: int
restore_value: no
initial_value: '0'
switch:
- platform: gpio
pin: 12
id: varmtvannstank_varme
#name: "varmtvannstank_varme"
restore_mode: ALWAYS_ON
dallas:
- pin: GPIO14
sensor:
- platform: dallas
index: 0
id: varmtvannstank_temperatur
#name: "varmtvannstank_temperatur"
filters:
- sliding_window_moving_average:
window_size: 5
send_every: 5
interval:
- interval: 1min
then:
- if:
condition:
- lambda: !lambda |-
auto time_now = id(homeassistant_time).utcnow();
auto time_heat_end = time_now;
if(id(varmtvannstank).mode != CLIMATE_MODE_AUTO)
id(heating) = 0;
int seconds = (75.0 - id(varmtvannstank_temperatur).state) * 404.30769;
if(seconds < 0)
seconds = 0;
time_heat_end.hour = 4;
if(time_heat_end.is_dst)
{
ESP_LOGD("main", "dst is on");
time_heat_end.hour = 3;
}
time_heat_end.minute = 45;
time_heat_end.second = 0;
time_heat_end.recalc_timestamp_utc();
if(time_heat_end < time_now)
time_heat_end = esphome::time::ESPTime::from_epoch_utc(time_heat_end.timestamp + 86400);
auto time_heat_start = esphome::time::ESPTime::from_epoch_utc(time_heat_end.timestamp - seconds - 3600);
ESP_LOGD("main", "seconds=%d", seconds);
ESP_LOGD("main", "%d-%d-%d %d:%d:%d", time_heat_start.year, time_heat_start.month, time_heat_start.day_of_month, time_heat_start.hour, time_heat_start.minute, time_heat_start.second);
if(time_now > time_heat_start && time_now < time_heat_end)
return true;
else
return false;
then:
- if:
condition:
- lambda: !lambda |-
if(id(varmtvannstank).mode == CLIMATE_MODE_AUTO && id(heating) != 2)
{
id(heating) = 2;
return true;
}
else
return false;
then:
- climate.control:
id: varmtvannstank
mode: AUTO
target_temperature_low: 79.0
target_temperature_high: 81.0
else:
- if:
condition:
- lambda: !lambda |-
if(id(varmtvannstank).mode == CLIMATE_MODE_AUTO && id(heating) != 1)
{
id(heating) = 1;
return true;
}
else
return false;
then:
- climate.control:
id: varmtvannstank
mode: AUTO
target_temperature_low: 54.0
target_temperature_high: 56.0
time:
- platform: homeassistant
id: homeassistant_time
climate:
- platform: bang_bang
id: varmtvannstank
name: "varmtvannstank"
sensor: varmtvannstank_temperatur
default_target_temperature_low: 79.0
default_target_temperature_high: 81.0
visual:
min_temperature: 54.0
max_temperature: 85.0
temperature_step: 0.1
heat_action:
- switch.turn_on: varmtvannstank_varme
idle_action:
- switch.turn_off: varmtvannstank_varme