Hello
So I am setting a fan based on a CO2 reading- to do this I convert the CO2 reading to a percentage using a template sensor:
template:
- sensor:
- name: "Cave Vent Setpoint"
state: >
{{ min(max((states('sensor.cave_co2')|float - 600 )/4, 0), 100) }}
The idea here is that the fan goes on at a sensor reading of 600 and maxes out at a reading of 1000.
Then to set the fan speed I have an automation which triggers on every setpoint change:
alias: Auto Cave Speed
description: ""
trigger:
- platform: state
entity_id:
- sensor.cave_vent_setpoint
condition: []
action:
- service: fan.set_percentage
data:
percentage: |
{{ states('sensor.cave_vent_setpoint') }}
target:
entity_id: fan.cave_vent
mode: single
My question is this: Is this the most efficient way of doing this? I was expecting to not have to have the automation trigger all the time by having the template call the set_fan_percentage
service, but I couldn’t find a way of calling a service from within a template. Now obviously I could slow it down a bit by not having it trigger all the time, but was hoping for a more elegant solution.