Help with building basic automation logic

I’m relatively new to HA.
I’m trying to replicate home heating controls to replace a thermostats and a wall timer with boost function.
I have a number of Zigbee temprature sensors along with a Zigbee relay (SWZn1).
The plan is to use the relay to control the Mason valve which will call heat from the boiler.
I have set up a schedule based helper (SchdZn1)
I have setup 4 threshold based helpers to mimic thermostats with setpoints (TZ1-TZ4) using the temprature sensors as sources.

What I’m struggeling with is building the logic using automations in the GUI.
As far as I understand an automation will only be triggered if an event in the trigger section changes state.
This is the “logic” for what I assume would be 2 automations:

“On automation”
IF (TZ1==ON OR TZ2==ON OR TZ3==ON OR TZ4==ON) AND (SchdZn1==ON OR TimerBoost==ON): SET SWZn1=ON
“Off automation”
IF (TZ1==OFF AND TZ2==OFF AND TZ3==OFF AND TZ4==OFF) OR (SchdZn1==OFF AND TimerBoost==OFF): SET SWZn1=OFF

Does that mean I would need to add all the entities to the “trigger” section and then build out their logic in the “and if” section?
If so how would I group enities as above in my (cruel attempt at a logic equation)?
Or would I only be able to build something like that by writing it in some form of code?

Regards
Rabie

Make a template binary sensor with the output of your logic, and use the state of that in the automation.

It would greatly benefit you to learn YAML & Jinja coding for this level of complexity. It’s not hard.

If you post back with the actual names of your entities and the logic you want, I’m sure we could help more.

Ok, will look to upskill on those :wink:

I would be awesome if someone can give me something to start with, should be able to work it from there:

“On automation”
IF (TZ1==ON OR TZ2==ON OR TZ3==ON OR TZ4==ON) AND (SchdZn1==ON OR TimerBoost==ON): SET SWZn1=ON
“Off automation”
IF (TZ1==OFF AND TZ2==OFF AND TZ3==OFF AND TZ4==OFF) OR (SchdZn1==OFF AND TimerBoost==OFF): SET SWZn1=OFF

Temp1=sensor.study_temp1_temperature
Temp2=sensor.hall_temp1_temperature
Temp3=sensor.main_temp1_temperature
Temp4=sensor.living_temp1_temperature
TZ1=binary_sensor.thresh_study_temp1
TZ2=binary_sensor.thresh_hall_temp1
TZ3=binary_sensor.thresh_main_temp1
TZ4=binary_sensor.thresh_living_temp1
SchdZn1=schedule.sch_heating_zone1
TimerBoost=timer.timer_boost_zone1
SWZn1=light.ts0004_light

1 Like

I understood that more than anything else. . . yet. . .

It’s a process. :face_with_monocle:

Will have a look on Monday if no-one else gets there first. I had a look at the template binary sensor TZ-combining suggestion but that won’t work: if TZ1 and 2 are OFF, both sets of conditions can be true at once.

I think we’ll end up with an automation that

  • triggers off all of the TZ, schedule and boost entities;
  • has an or: pair of conditions to check one of the two logic sets is met;
  • runs a quick test in the action (probably on the OFF logic) to see if it should be turning on or off then take the appropriate action.

I think I’m sorted.
I ended up using a template with the logic in that and then using 2 automation.
1 to switch on the boiler and 1 to switch it off.

I added some extra logic to the template like an enable toggle for the schedule, the boost and them all the “thermostats” I made from the temperature sensors.

I just wish the scheduler could be configured down to a 5 or 15 minute mark, but 30 min increments will do for now.

Here is a sample of the template ( I did 3, one for the hotwater zone and 2 heating zones)

{{ (is_state('binary_sensor.thermostat_bedroommain', 'on') or is_state('binary_sensor.thermostat_study', 'on') or is_state('binary_sensor.thermostat_livingroom', 'on'))
and ((is_state('schedule.sch_heating_zone1', 'on') and is_state('input_boolean.enable_heating_schedule_zone1', 'on')) or is_state('timer.timer_boost_zone1','active')) }}
1 Like

Good stuff. With that edit you made to the requirements, the logic is a lot simpler.

It can if you configure it in YAML rather than with the UI — but then you can’t edit it from the UI either.