I have an analog patio heater which I control via IR/Broadlink.
The original remote has buttons for on/off and heat mode 1, 2, 3, 4 and 5.
I want to use a button where I cycle through these heat modes. If it starts on three, one press takes it to 4. If it starts on 5, one press takes in to 1. (It starts at the last setting).
I have created switches for 1-5. (switch.heat_mode_1, switch.heat_mode_2 etc)
But I don’t know how to create an automation or a scenario (or script?) that cycles through those on the press of a button. Any tips?
(Always starting at 1 is also and option (automation that powers on and executes heat_mode_1)
at its most basic
create a helper to store the current mode
have an automation - on button press, check helper - Set mode appropriately and on successful set - set helper to current mode. (or assume successful and just store the next mode.)
I’d probably use an input_select for the helper - it lets you guarantee what the modes are and provides a selection box if oyu want to include it in the UI.
As this is IR I’m guessing you don’t have state feedback from the heater?
If the heater can be operated manually (outside home assistant) it is not going to be possible to synchronise the state of the heater with the state stored in home assistant.
Thats correct, unless I only use HA to control it, and not the remote. I have visual feedback on the appliance, thats why it would be ok always starting from 1. I have read up on Helpers and have most thing figured out except how to ”add 1”, ie going from text_1 to text_2. A lot of If-Thens I guess
Hey Stefan, I am doing this to control four ceiling fans each with four speed settings using a Tradfri 5-button remote. I use the left/right to switch control between fans and the up/down to control the speed of the ‘current’ fan. It could be easily done using just a single Lovelace button if you’re controlling one heater.
I use counter helpers to keep track of the current fan and the current speed for each fan (0=off, 1=low, 2=medium, etc.).
The value of each counter is available as a state and can be changed via the counter increment/decrement/reset services. Based on your description you would probably only use the increment and reset i.e. press button, check counter value, if < 5 counter.increment else counter.reset.
I use a template to get the counter value and replace it with the name of the command for that particular fan speed that I have set up in the Broadlink IR remote. Then I call the Broadlink remote.send_command service to set the speed.
I am just about to start work for the day but can post some yaml later if you think it might help.
Here is a simpler version of my automation, cut down to control one fan.
It has just dawned on me that if I had named my Broadlink remote commands as “1”, “2” etc. I wouldn’t need the template to convert from a number to a command name. Oh well, if it ain’t broke…