i’ve got a standing fan with an IR remote i am trying to automate. it has 8 speeds that cycle up or down (pressing ‘down’ when on ‘1’ goes to ‘8’). i want the IR command to be fired and the input select to be updated (so i can monitor the state) when i press and ‘up’ or ‘down’ button on the ui
I was trying to create and automation to send the code to the IR remote, but my brain is stuck on how to template this to make it simple. i had tried
but that doesn’t account for the cycling “up” from ‘8’ to ‘1’ and down from ‘1’ to ‘8’. I could make a separate script just for this setting as its the only ‘cyclical one’ but i’m sure there’s a better way. any help is appreciated.
hey thanks for the quick response. i’m not sure i’m understanding though. won’t this give me the same problem if its comparing the ‘from’ state to the ‘to’ state since 8 > 1, but the remote actually ‘decreases’ from 1 to 8 in a cycle if i press it when its on 1?
{% set before = trigger.from_state.state | float %}
{% set after = trigger.to_state.state | float %}
{% if before == 8 and after == 1 %}
input_select.select_next
{% elif before == 1 and after == 8 %}
input_select.select_previous
{% elif before < after %}
input_select.select_next
{% else %}
input_select.select_previous
{% endif %}