Smart heating scheduler for Home Assistant (extra: multi-zones version)

@robi hello, could you elaborate a bit? I had Honeywell but i didnt like it.

All these Tado, honeywell presents themselves as super smart… fuzzy logic ie … assume the boiler is on … heating once you reach room temperature, but it teach itself for example for how long room gets cold so it somehow proactively starts heating before it fall below some level, so u don’t have to wait to get expected temperature etc…

thats why i am wondering how this system can manage such behavior etc.

appreciate.

No, that kind of logic is not (yet) supported.

@robi well, so does it work reliable etc… i am still not clear how to solve such an solution.

I am using it for 2 years now.

hi @robi
i went thru the whole thread but there are still not clear items…

  1. what radiator valves did u use?
  2. whats the final thermometer that was used?
  3. does Sonoff Mini Switch Module handle 16A on relay? (seems per spec only 10A, wondering if there is similar module that can handle 16A?)

thank you!

  1. At the moment I’m still using the old heating system with fixed valves, the main switch of this package just commands the thermostat input of the boiler.
  2. Purchased several models of wireless thermometers - all failed due to various reasons. They are simply not reliable enough to be used in such a system. I still use Dallas DS18B20 sensors connected to ESP8266 in each room (mounted in Geeklink IR blasters doubling as IR controllers for other devices in the same room. Just moved from Tasmota to testing ESPHome on these). Also evaluating SHTC3 sensors which according to the datasheet have a precision of ±0.2°C @ -40°C to +125°C and humidity.
  3. Don’t know, as I don’t switch that much current through any of my relays.

In my newly built system I will use valves equipped with this kind of thermal actuators (normal open version, 24V):
kép

The main relay board I will employ to control all the valve actuators in all the zones, will be a card like this one:

It communicates with ESPHome through MODBUS RTU protocol, has quality OMRON relays placed in sockets on the PCB.

I’m already testing ESPHome running on ESP32-POE-ISO:


Runs super-reliable with the above card (and a TTL-RS485 Serial Converter (MAX485) in between), I must say I’m impressed.

I strongly recommend everyone to check this PID controlled thermostat instead of HA’s built-in generic_thermostat. Can be replaced plug-and-play inside the configuration, and allows much finer control of heating. It’s available in HACS:

1 Like

Hi Robi,

This relay board is a good find with relays in sockets, thx for sharing!
Note that it can be noisy if you would place it near to living zone.
Im using this relay board below with Rpi3B+ 64, in a sealed box in a wc next to the bedroom (1wall)
and the switch noise is acceptable in that way. -bigger relays can be more noisy!-

Im using DS18b20 sensors as well, with shielded wires pulled in through the pipes in the wall paralell to electricity wires.
They are working well, even the longest wire is about 15m, im using 3sensors for 1GPIO on Rpi, with 2.2K pullup.

Viktor

Hi Phier,

you can drive your high current contactor drive coils from sonoff board relay outputs (not so sophisticated but working).
Or if you are more familiar with electronics, you can search for an appropriate optocoupler driver beetween your sonoff GPIO output and your contactor coil drive current needs.
It can be more reliable as not using 1more moving element.

Viktor

Hi Robi,

Just want to say that my system based on your work is running well, and thank you so much for your work and to share it with us, good job!

One thing that i reailzed on usage is, when i turn timer_switch or override_switch onoff when the system is in away mode, the automated temperature levels are not set back to away temp values., i have to manually trigger climate on frontend to away-none-away to set the correct values back.
I have tried to fix it somehow but failed…

Thx,
Viktor

I’ll have a look.

My relays will be in the basement so no problem with the relays ticking noise there.

is it possible to use a smart thermostat valve? do yo need to convert them to switches then? and how is that gonna work, is it just gonna full open and full close all the time?

At the moment it is tested to use HA’s built-in generic_thermostat or the smart_thermostat custom integration above.

But it could adapt to any other kind climate integration.

Hi Robert,

Thanks for sharing your setup, much appreciated!!

I’ve setup my heating in HA based on your automations. I have a total of 6 zones, each zone controls the corresponding TRVs and a main heating valve that controls the hot water flow for the heating in my apartment.

I’m having an issue with the temperature sliders as those automations don’t run because I get following error messages in the logs:

* Template variable error: 'str object' has no attribute 'timestamp' when rendering '{% set t = strptime((now().timestamp() | timestamp_local), "%Y-%m-%d %H:%M:%S").timestamp()-strptime(now().strftime("%Y-%m-%d 00:00:00"),"%Y-%m-%d %H:%M:%S").timestamp() %} {% set time_start = state_attr('input_datetime.heating_weekday_morning_start','timestamp') %} {% set time_end = state_attr('input_datetime.heating_weekday_day_start','timestamp') %} {{ time_start <= t < time_end and is_state('binary_sensor.workday_sensor', 'on')}}'
* Template variable error: 'str object' has no attribute 'timestamp' when rendering '{% set t = strptime((now().timestamp() | timestamp_local), "%Y-%m-%d %H:%M:%S").timestamp()-strptime(now().strftime("%Y-%m-%d 00:00:00"),"%Y-%m-%d %H:%M:%S").timestamp() %}'

The problem seems to be with the template condition in the adjusting temperature automations:

{% set t = strptime((now().timestamp() | timestamp_local), "%Y-%m-%d %H:%M:%S").timestamp()-strptime(now().strftime("%Y-%m-%d 00:00:00"),"%Y-%m-%d %H:%M:%S").timestamp() %}
{% set time_start = state_attr('input_datetime.heating_weekday_morning_start','timestamp') %}
{% set time_end = state_attr('input_datetime.heating_weekday_day_start','timestamp') %}
{{ time_start <= t < time_end and is_state('binary_sensor.workday_sensor', 'on')}}

Sorry but I am no expert these complex conditions so I am not sure how to fix it.
Maybe someone can put me in the right direction.

Thanks!!!

Update:

I found a solution that seems to work for now from an other post. Maybe it is useful for somebody else.

Instead of:

{% set t = strptime((now().timestamp() | timestamp_local), "%Y-%m-%d %H:%M:%S").timestamp()-strptime(now().strftime("%Y-%m-%d 00:00:00"),"%Y-%m-%d %H:%M:%S").timestamp() %}
{% set time_start = state_attr('input_datetime.heating_weekday_morning_start','timestamp') %}
{% set time_end = state_attr('input_datetime.heating_weekday_day_start','timestamp') %}
{{ time_start <= t < time_end and is_state('binary_sensor.workday_sensor', 'on')}}

I use now:

{{ now().fromtimestamp(state_attr('input_datetime.heating_weekday_morning_start', 'timestamp')).time() <= now().time() <= now().fromtimestamp(state_attr('input_datetime.heating_weekday_day_start', 'timestamp')).time() and is_state('binary_sensor.workday_sensor', 'on') }}

Changed all my automations accordingly and so far all working without errors.

1 Like

Hi Robi,

First of all I’m impressed by your work and the fact of sharing it! As a starter with HA, but have experience with other domotica systems (domoticz) I would like to use your work and migrate my current heating system to HA. Maybe you’re willing to help migrating.

A little explanation;

  • I’ve got one central heating system with integrated pump, and is turned on or off with an zwave switch.
  • The ground floor is heated with heattubes in the floor and the first floor with convectors.
  • The ground floor can be isolated from the system with the help of a valve (open or close). It works with an zwave switch and needs to be ON for 20 seconds for opening or OFF 20 seconds for closing the valve.
    With help of motion- and temperature sensors on the 1st floor the system decides to heat the whole house or only the first floor.
  • The groundfloor heating pump works with a zwave switch and is activated when central heating is activated and needs to be running as long as the system heats (ciculates the water in the ground floor)
  • I’ve got two motion sensor on the first floor; when the first is triggered the heating is turned on for half hour and when the second one is triggered the heating is turned on for one hour,
  • I’ve got an temperature sensor on the ground and first floor,
  • Off course all the above is depending on the master schedule ;-).

I’m seeking for some clarifications whitin you’re solution and hopefully your willing to help me out?

  • The best choice should probably be the 2-zone system, wright?
  • How can I best setup the climate.yaml file:
    • Heater1: switch.--------
    • target_sensor1: sensor.-------
    • Heater2: switch.--------
    • target_sensor2: sensor.-------
  • I’m confused how to configure zz_switch/switch_heater.yaml and switch_rpi.yaml due the fact I haven’t got an RPI and/or MQTT sensors.
  • Is there a way to put the presence on the 1st floor integrated?
  • How can I add activation time to the valve switch?
  • How can I disable presence of people?
  • What is the difference or why should I configure openweather and outside temp sensors?

Thanks in advance, John

Quite complex indeed, let me think about it, I’ll get back in a few days.

Hi Robi,

Already thanks!

Hi Robert,
I use your brilliant heating scheduler code in my Home Assistant installation. I’ve recently updated to 2021.12.4 and noticed errors in the log when starting up. I confess to not knowing enough about YAML to fix this myself. I was wondering if you may be able to help me please. Here is one of the errors:

> 2021-12-22 11:27:12 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'strptime' got invalid input '2021-12-22T11:27:12.027556+00:00' when rendering template '{% set t = strptime((now().timestamp() | timestamp_local), "%Y-%m-%d %H:%M:%S").timestamp()-strptime(now().strftime("%Y-%m-%d 00:00:00"),"%Y-%m-%d %H:%M:%S").timestamp() %} {% set time_start = state_attr('input_datetime.heating_weekday_morning_start','timestamp') %} {% set time_end = state_attr('input_datetime.heating_weekday_day_start','timestamp') %} {{ time_start <= t < time_end and is_state('binary_sensor.workday_sensor', 'on')}}' but no default was specified. Currently 'strptime' will return '2021-12-22T11:27:12.027556+00:00', however this template will fail to render in Home Assistant core 2022.1
> 2021-12-22 11:27:12 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'str object' has no attribute 'timestamp' when rendering '{% set t = strptime((now().timestamp() | timestamp_local), "%Y-%m-%d %H:%M:%S").timestamp()-strptime(now().strftime("%Y-%m-%d 00:00:00"),"%Y-%m-%d %H:%M:%S").timestamp() %} {% set time_start = state_attr('input_datetime.heating_weekday_morning_start','timestamp') %} {% set time_end = state_attr('input_datetime.heating_weekday_day_start','timestamp') %} {{ time_start <= t < time_end and is_state('binary_sensor.workday_sensor', 'on')}}'
> 2021-12-22 11:27:12 WARNING (MainThread) [homeassistant.helpers.script] Error in 'choose[0]' evaluation: In 'template' condition: UndefinedError: 'str object' has no attribute 'timestamp'

I have searched the HA forums and there are examples of how to fix “Template warning: ‘strptime’ got invalid input” but none apply directly and my knowledge is not there (yet).
There is a block for each template that has this error. Once I know how to fix one block I can fix the others but need some help please.
Kind regards
Richard

Hi Robert,
I fixed this issue using time conditions:

It’s similar solution than @armins2k. Instead of:

{% set t = strptime((now().timestamp() | timestamp_local), "%Y-%m-%d %H:%M:%S").timestamp()-strptime(now().strftime("%Y-%m-%d 00:00:00"),"%Y-%m-%d %H:%M:%S").timestamp() %}
{% set time_start = state_attr('input_datetime.heating_weekday_morning_start','timestamp') %}
{% set time_end = state_attr('input_datetime.heating_weekday_day_start','timestamp') %}
{{ time_start <= t < time_end and is_state('binary_sensor.workday_sensor', 'on')}}

I use:

    - conditions:
      - condition: state
        entity_id: binary_sensor.workday_sensor
        state: 'off'      
      - condition: time
        after: input_datetime.heating_weekend_day_start
        before: input_datetime.heating_weekend_evening_start

For the nightime condition, I need to change a little bit:

    - conditions:
      - condition: state
        entity_id: binary_sensor.workday_sensor
        state: 'off'      
      - condition: or
        conditions:          
        - condition: time
          after: input_datetime.heating_weekend_night_start
        - condition: time
          before: input_datetime.heating_weekend_morning_start

My personal opinion is that this way is cleaner for a guy not used to be programmer.

Best regards,
Arkharim