I have a fan component for a ceiling fan via broadlink. Works well and have set up an automation based on a temperature above 26c, triggered by temperature, presence and time. I was hoping to add more smarts to it, so above 26c, it starts on Low, above 28c set to Medium. Etc.
Would I need different automations for this or is there a way to do it in one automation?
You could use a data_template (i think that’s the right one) to have all of these in one automation…I think. I’m not good at templates and all of mine have been created with the help of others on here. I’ll try and dig something up, otherwise I’m keen to see what you hear back with from others.
EDIT: actually I think maybe service_template. I may be able to create an example for you
this WILL be rough, like I said, templates aren’t my thing… thinking about it again…maybe a data_template like this… but I am guessing at the syntax right now
I think the syntax is out a bit. Keep getting errors with this as the action. Invalid config for [automation]: expected a dictionary for dictionary value @ data['action'][0]['data_template']. Got None.
Thanks for the help, with have a play around.
I want to try and add a slow the fan automation if temp drops. But, as you say, I need to get this working first.
I think the trigger I gave you also needs work. There are some killer templating guru’s on here that I’m sure will tell you that my examples are rubbish and will give you something far better. We just need them online!
Could you post your existing automation? That would be helpful, especially since the documentation for fan components is somewhat lacking.
But basically, when using a service where you want a data item to be calculated on the fly, you use data_template instead of data, then use a template for whichever data options need to be calculated, along the lines that @sparkydave has suggested.
By posting your existing automation it will be more clear what entities are involved, how you’re triggering, etc., so useful suggestions can be made.
- id: lounge_fan_on
alias: Lounge Fan On
trigger:
- platform: state
entity_id: sensor.wirelesstag_lounge_temperature
- platform: state
entity_id: group.family_presence
to: 'on'
- platform: time
at: '06:30:00'
condition:
condition: and
conditions:
- condition: time
after: '06:00:00'
before: '20:00:00'
- condition: numeric_state
entity_id: sensor.wirelesstag_lounge_temperature
above: 26
- condition: state
entity_id: group.family_presence
state: 'on'
action:
service: fan.set_speed
entity_id: fan.lounge_fan
data_template:
speed: >
{% set temp = states('sensor.wirelesstag_lounge_temperature')|float %}
{% if temp < 28 %} low
{% elif temp < 30 %} medium
{% else %} high
{% endif %}
The idea is whenever someone comes home after everyone being away, or at 6:30 am, or whenever the temperature changes, as long as it is between 6:00 am and 8:00 pm, and someone is home, and the temperature is above 26, then the fan will be turned on, and the speed will depend on the current temperature. Obviously change the thresholds and the speed values if I didn’t get that part right.
you already have the code there to set low speed once the temp drops below 28
as I said @rowdybeans , there are others on here, a.k.a. @pnbruckner that are GURU’s with templates! If only I could be half as good at them… Glad you got it going.