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

Nice, thanks for posting!

I’m pretty happy with the performance of my one Sonoff SNZB-02. The only down side is for whatever reason (I haven’t bothered to research yet) it doesn’t report battery status. But it does a great job of reporting both temperature and humidity often enough and with sufficient precision for most needs, as your chart shows.

Mine reports 100% all the time, through a Sonoff Gateway with Tasmota. Which I’m going to replace soon as it looks like it likes to cause battery drain in the Zigbee units…

Great project Robi, I look into this every year trying to find a good solution.
At the moment I’m using the ‘ramp thermostat’ in node red which isn’t bad but I miss the manual control and I’m always looking for a better solution.

For sensing, I gave up on battery sensors because of the delay in sensing.
I use esphome in 1-wire mode to support two DS18B20:

sensor:
  - platform: dallas
    address: 0xD0000007AD86DE28
    name: "ESP upper lounge thermostat"
    filters:
      - exponential_moving_average:
          alpha: 0.1
          send_every: 4

  - platform: dallas
    address: 0x01000007ADA8A028
    name: "ESP lower lounge thermostat"
    filters:
      - calibrate_linear:
          # Map 0.0 (from sensor) to 0.0 (true value)
          - 0.0 -> 0.0
          - 23.1 -> 22.2
      - exponential_moving_average:
          alpha: 0.1
          send_every: 4

To try and get a more accurate and responsive reading, I have the two DS18B20’s in the same room, one placed higher than normal and one placed lower near the floor. This seems to overcome the problems of the room feeling cold before the heating comes on and prevents the room from over shooting the set target temperature to much.

HA then calculates the average of these before feeding node red.

I’m going to download your setup because I like the manual control and see how things go.

1 Like

Wow. Can you describe a bit more in detail this approach? What type of heating do you have how do you choose sensor placement, etc.

Its still a ‘work in progress’.

I only have the one zone central heating with panel radiators. The floors are laminate, so can feel cold.

I have a esp32 with 1 pair of CAT6 wires and the two DS18B20’s in parallel along the wire. The DS18B20’s are just held to the wall via the cable and a bit of blutack so I can adjust for the optimum position.

Each sensor feeds into Grafana so I can monitor the difference as the room heats up and cools down.

Once I get it how I like it, I’ll mount the sensors in a small sensor housing and wire in permanently.

This was the output from the sensors over the last 24 hours:

They run mostly in parrallel… What’s the benefit? If you have an average of the two, it’s likely like having one sensor located around the middle in between.

You are probable right and this may end up as one for the bin afterwards. As I said, it’s a ‘work in progress’ and Im trying to eliminate the overshot which comes from the residual heat in the radiators after the heating turns off and then having to wait a long time before the heating comes back on again.

Few comments on SNZB-02:

1/ SONOFF SNZB-02 control via MQTT | zigbee2mqtt.io

  • The reporting interval issue’s statement is a bit misleading. Let’s say probably just outdated, because actually it works. :slight_smile:

2/ Sonoff SNZB-02 Temp Sensor Reporting Interval - #30 by demig

To be continued…

3/ The parameters that can be configured with zigbee2mqtt

Min rep interval
5 (s)
Max rep interval
1800 (s)
Min rep change
50 (0,5C)

I think by having any smart setup , it can be used for room’s temperature control eg. with radiator valve like the good old MAX!

I have now a setup of reporting every 0,05C change. It’s quite good , but can be even better eg. report not only by 0,05 C change but every 30 secs instead of only 30 mins

4/ Battery vs. precision

Surely by increasing the reporting interval the battery drains faster.

Actually the CR2450 is about 550-650 mAh, however with a little hack (3d printed case expansion of the backside) 2xAA can be used to increase the lifetime without expecting frequent battery replacement (~ 2500mAh)

5/ Some weird behavior

Few sensors (5 out of 10) were fluctuated initially the measured temperature see picture:

That was observed for few days then I have remove from the zigbee network. few days later repaired them back to the zigbee and I was surprised the problem has disappeared. :slight_smile:

All are still fine after one week like the good ones since the beginning…

It’s hard to explain the reason of that situation, probably the sensor inside required a bit more time to be stable after the package is arrived. eg. a kind of humidity issue inside the case…

So finally I am happy so far with that cheap sensor especially because the reporting parameter can be adjusted according to the actual requirements.

The problem is that Zigbee2MQTT doesn’t properly support network-enabled gateways. I use ZHA because of that…

Well, I am just testing a kind of “network enabled gateways” like a pure CC2531 used as zigbee coordinator with zigbee2mqtt and a nanoCUL with homegear used for MAX gateway. Both are plugged in into a linux PC acting as network enabled gw. An other linux are accessing both over the network by using usbip feature:

USBIP Wikipage

Of course both software handle the devices like a local USB devices.

Sofar looks good. Actually any linux capable HW can be used for such a gw having USB ,LAN ports eg. ASUS router/rasberryPI etc.

How do you install this Blueprint the Standard Import doesnt work,

Thank you so much for sharing this awesome Automation!

Hi
thanks for providing the solution for controlling the heating, it works perfectly for me, however it hasnt quite got the Wife approval factor. She would still like a manual solution. I dont think she would need a seperate control unit to set timers and temperature, but this would be a solution, I was thinking more of just a physical button to toggle the override input boolean. I have tried to get Alexa to trigger the override, but it doesnt appear to work. Any ideas?
Thanks
Si

This is not a blueprint. It’s just a collection of automations, you need to manually edit the files.

I don’t have Alexa sorry, no clue what to do in this case. It’s just an input boolean switch…

Hi Robi!

Im Viktor from HU, thanks a lot for sharing this, i just started using your 2-zone config and HA for 2weeks, i defo loving it. I just have basic linux and programming undertanding level, but succesfully adapted your project to mine -still in prgress-. Here is a modified look i have done:

My questions:
I have a template warning comes with the new HA version at “as_timestamp” lines, and try to get rid of it by adding “,0” as default, but it not seems ok:
/config/zz_automations/overrider.yaml:
datetime: “{{ (as_timestamp(now(),0) + 7200 | float) | timestamp_custom(’%Y-%m-%d %H:%M:%S’) > 1800 }}”

Another topic is, i would like to have 8minute delay on pump_start at every state change of outputs. (i have wax actuators and they are slow to on -3minutes-, even slower to off -8minutes-) cos the pump flow can be blocked if 1wax is opening and 1 is still closing. I have tried, its working, but not stable…:

# - id: heating_pump_start
#   alias: 'Heating Pump Start'
#   trigger:
#     - platform: state
#       entity_id: switch.nappali_perem
#       from: 'off'
#       to: 'on'
#     - platform: state
#       entity_id: switch.nappali_belso
#       from: 'off'
#       to: 'on'
#     - platform: state
#       entity_id: switch.eloszoba_furdo
#       from: 'off'
#       to: 'on'
#     - platform: state
#       entity_id: switch.halo_belso
#       from: 'off'
#       to: 'on'
#     - platform: state
#       entity_id: switch.halo_perem
#       from: 'off'
#       to: 'on'
#   condition:
#     condition: or
#     conditions:
#       - condition: state
#         entity_id: switch.nappali_perem
#         state: 'on'
#       - condition: state
#         entity_id: switch.nappali_belso
#         state: 'on'
#       - condition: state
#         entity_id: switch.eloszoba_furdo
#         state: 'on'
#       - condition: state
#         entity_id: switch.halo_belso
#         state: 'on'
#       - condition: state
#         entity_id: switch.halo_perem
#         state: 'on'
#   action:
#     - service: timer.start
#       entity_id: timer.timer_pump
#     - service: switch.turn_off
#       entity_id: switch.main_pump
# - alias: delay pump start til actuator opens (timer parameter in main configuration file)
#   trigger:
#     - platform: event
#       event_type: timer.finished
#       event_data:
#         entity_id: timer.timer_pump
#   action:
#     service: switch.turn_on
#     entity_id: switch.main_pump

I started investigating the new as_timestamp limitations, I’m on it, will post an update soon.

As for the delay, you don’t need all that. There’s the min_cycle_duration parameter in generic_thermostat, exactly for this:

min_cycle_duration time | integer (Optional)

Set a minimum amount of time that the switch specified in the heater option must be in its current state prior to being switched either off or on.

Hi Robi,

Thanks for the answer!
The cycle time is ok for switching beetwen actuators -understand now,thx- if at least one is in open state.

But if all the actuators are closed and heating turns on, the pump switched immediately on, but the actuator still under opening progress.

EDIT: ok…just figured out that i need to invert rpi gpios and rewire to NO relay pin,
to make the actuators normally open by default, so if pump start all open and some
may closing. BUT, i would like to make the system working as well throgh manual thermostat if something fails, or no power on relays. It needs NO actuators that i have and a series thermostat on pump. But i cant handle this no. I need some coding to make all actuators open if pump stopped.

So to achieve the desired working i think:
I have to connect actuators to NO relay pins (and cos they are NO to be able to use them opened by default and without powered HA.
The pump switching circuit can be NC to be able to control overheating and underheating without powered HA and a series thermostat.

Now connected like:

##### Raspberry PI with relay hat

- platform: rpi_gpio
  ports:
     5: nappali_perem
     6: nappali_belso
     13: eloszoba_furdo
     16: halo_belso
     19: halo_perem
    #  20: heater_1
    #  21: heater_2
  invert_logic: False
*It needs to be True and rewire relay*
  
- platform: rpi_gpio
  ports:
    #  20: heater_1
    #  21: heater_2
     26: main_pump
  invert_logic: True
*It needs to be False and invert wire relay*

Thanks,
Viktor

I use actuators which Normal Open by hardware, ie. they need to be applied power to close…

What kind of pump do you use? Modern pumps (like Grundfos) have an adaptive load control mechanism built-in so a few minutes with closed valves should not cause a problem. The pump will self-control the pressure it generates so overpressure won’t happen. As the valves open gradually, pump speed will automatically increase, and vice-versa. That’s a feature built-in the pump, you don’t have to control that.

Corrected to comply with the latest HA:
datetime: "{{ (as_timestamp(now()) + 3600 | float(default=0)) | timestamp_custom('%Y-%m-%d %H:%M:%S') }}"

1 Like