I’m looking for some ideas to include an override in my ceiling fan automation(s) so that when I manually adjust my ceiling fan through lovelace or voice commands, the automatic function stops for a few hours using a timer helper. I have this kind of thing working on a bunch of other automations, but those are all triggered either by buttons or scripted voice commands. So I control the input on those and know when they fire. Something like this though, where I might just use a fan card to adjust speed and on/off or through impromptu voice commands is throwing me for a loop.
I’ve thought about an input_boolean to use as a condition, but I’m struggling on where to actually flip it since my automation sets the fan on/off and sets fan speed as well. So, I don’t think I could use those as triggers or conditions unless I can determine the source of the incoming command and maybe condition off that in another automation.
Any ideas?
alias: Living Room Ceiling Fan Manager
description: "Controls the living room ceiling fan so that it comes on in the morning at low speed, but adjusts to high speed when the temperature outside rises above 73 degrees."
trigger:
- platform: state
entity_id:
- binary_sensor.mode_manager_morning
from: "off"
to: "on"
id: morning_mode_on
- platform: state
entity_id:
- sensor.weather_station_pro_sensor_temperature
id: temp_change
alias: When the outside temperature changes
- platform: state
entity_id:
- input_boolean.good_night
from: "off"
to: "on"
id: good_night
condition: []
action:
- choose:
- conditions:
- condition: trigger
id:
- morning_mode_on
sequence:
- alias: Set the fan to low speed
service: fan.turn_on
metadata: {}
data:
percentage: 10
target:
entity_id:
- fan.living_room_ceiling_fan
alias: Morning mode turns on
- conditions:
- condition: trigger
id:
- temp_change
sequence:
- alias: If not in good night mode
if:
- condition: state
entity_id: input_boolean.good_night
state: "off"
then:
- alias: If the outside temp is at or above 73
if:
- condition: state
entity_id: binary_sensor.outside_temperature_at_or_above_73
state: "on"
then:
- alias: Set the fan to high speed
service: fan.turn_on
metadata: {}
data:
percentage: 80
target:
entity_id:
- fan.living_room_ceiling_fan
else:
- alias: Set the fan to low speed
service: fan.turn_on
metadata: {}
data:
percentage: 10
target:
entity_id:
- fan.living_room_ceiling_fan
alias: Outside temp changes
- conditions:
- condition: trigger
id:
- good_night
sequence:
- alias: Turn off the fan
service: fan.turn_off
metadata: {}
data: {}
target:
entity_id:
- fan.living_room_ceiling_fan
alias: Good night switch turns on
mode: restart
one approach is to use a number helper. pick a value like -1 to means use automatic mode. Then in Lovelace or voice set this number. this number is the override. when it changes set the fan to this helper number value if it != -1.
In this automation you have, set the value as you have it unless the helper != -1.
reset the helper to -1 after your chosen timeout.
I think you are having challenges because you are trying to allow the direct manipulation of the fan speed in the ui
Yeah, I think this might be the way to go. I’m going to try the input_number helper method now and see what I can get away with.
If that doesn’t work, then I’ll probably just resort to having an override button on the dashboard and in Alexa that I have to remember to trigger first to override the automation and start a timer.
I do wonder if there is a way I could trigger off the event of the fan service and see what actually triggered it. That would easily solve this.
LOL yeah. Never expect me to do things the easy way. There are times when it may be warm/hot outside and I don’t want the fan blowing at 80%, so I just bark at the Alexa to turn the fan down or off. But then, the automation kicks in and says “nope, you take what I give you”. This is what I get for wanting a smart home that is reactionary.
One instance where it was almost impossible to untangle I reversed the approach: the automated behavior sets a short timer. When the state change takes place, there is an if to see if the timer is running. If not, it must be manual.
I’m confident the input_number will work. I have something similar.
another approach is to have a time/schedule of what you want it to be. and whenever it isn’t what you expect, presume it’s an override.
If you prefer that approach, we can make that happen… but would be easier for me to code it than explain it… so id do it when I’m not on mobile. let me know… happy to do that.
TBH, I kinda like the timer/schedule override approach better. I’d love to see what you can come up with (and thanks also to @Edwin_D for the idea as well).
ok… caveat, i’m on the road, and i didn’t test this, but you’re good enough at this that i hope the framework is enough. here’s the trigger automation. i’m putting the setting of state into a script. for this purpose i’m using the setting of one of my lights that you should switch to your fan.
while writing that code, i think i concluded that the input_number override approach has higher code beauty… but i didn’t want to abandon what i was doing… but beauty’s in the eye of the beholder…
You are a rock star! I’ll get something whipped up here shortly. It just occurred to me that I can use my TOD sensors instead of schedules perhaps (I have 5 different TOD sensors that emulate modes (old carry over logic from SmartThings ) and can probably leverage them in a couple of templates.
I’ll let you know how I get on with it and HUGE thanks for the code.