Hi,
I’m struggling with a complex setup , I don’t know how to mange it easily :
I have a kind of HVAC in my house (we call it VMC in french, which is a way to force air renewal in the house, with a central fan… Some kind of climate control, but only meant to renew air without aiming at a certain temperature…).
This “big fan” is sucking the air of the house 24h/24, and I want to control it so it only renew the air when it is revelant to do so : a few hours per day, and after each shower (it also sucks air just above the shower rooms…)
So, till now, I have those rules :
Set ON at 7h00
Set OFF at 9h30
Set ON at 17h30
Set OFF at 22h00
BUT, I’d like to set ON after the bathroom light has been turned on for 5 minutes (I know how to do this), and set it ON for 1 hours…
BUT, I don’t want it to be off if we should keep it ON…
i.e: if I take a shower at 17h30, it will not be set OFF at 18h30, cause I want it to be on till 22h…
If I take a shower at 21h55, I want it to be ON till 22h55…
If I take a shower at 15h, It will be ON till 16h…
I think about timers and resetting them, but have no clue on how to do this !??
In facts, the programmatic way should be :
-- at 7h00, set VMCTimer = 150 minutes (and turn on VMC !)
-- at 17h30, set VMCTimer = 270 minutes (and turn on VMC !)
-- if VMCTimer < 60 minutes then
VMCTimer = 60 minutes
-- Every minute, decrement VMCTimer....
-- when VMCTimer = 0 switch off VMC...
I’ve read a bit about timers, but I haven’t found if there is a way to set different values to the same timer…
The hard point for me is that I have different timer values, and I don’t want a timer to be cancelled by another one :
if the “17h30 to 22h” timer is about to expire and a 60 minutes timer has been set at 21h30 , the switch must remain ON until the second timer expires…
So, to sum up, I just want one timer, which the value could be set by different actions, don’t know if it is easy to do with standard configuration and automations, or perhaps it will be easier to code in python (I can code)
I think a slightly different approach might be easier. It involves a timer and four automations.
The first automation simply turns the VMC on at the normal preset times. The second also turns it on but when the light has been on for five minutes. It also starts a one hour timer. Here are the timer and those two automations:
timer:
vmc_on:
duration: '01:00:00'
automation:
- alias: Turn VMC on at preset times
trigger:
- platform: time
at: '07:00:00'
- platform: time
at: '17:30:00'
action:
service: homeassistant.turn_on
entity_id: VMC_ENTITY_ID
- alias: Turn on VMC and start timer when light turned on
trigger:
platform: state
entity_id: BATHROOM_LIGHT_ENTITY_ID
to: 'on'
for:
minutes: 5
action:
- service: timer.start
entity_id: timer.vmc_on
- service: homeassistant.turn_on
entity_id: VMC_ENTITY_ID
The third automation turns the VMC off at the normal preset times, but only if the timer is idle. And the last automation turns the VMC off when the timer expires, but only if the time is during a normal off period. Here are those two automations:
- alias: Turn VMC off at preset times
trigger:
- platform: time
at: '09:30:00'
- platform: time
at: '22:00:00'
condition:
condition: state
entity_id: timer.vmc_on
state: 'idle'
action:
service: homeassistant.turn_off
entity_id: VMC_ENTITY_ID
and
- alias: Turn off VMD when timer expires
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.vmc_on
condition:
condition: or
conditions:
- condition: time
after: '09:30:00'
before: '17:30:00'
- condition: time
after: '22:00:00'
before: '07:30:00'
action:
service: homeassistant.turn_off
entity_id: VMC_ENTITY_ID
Ok, I thought about using conditions to avoid turning off when not needed.
Your example is perfect.
I’ll also give a try to some python coding, just for fun