How to store states for IR/RF devices?

I have a Broadlink universal remote, and I have the integration for it installed and working. I want to use the thing to control my AV system so I can put away some of the many remotes it uses. IR and RF commands are one-way, so I need some way to keep track of what states the devices are in (i.e. on/off, source, etc.).

What is the best way to store persistent variables that keep track of that stuff, such that when I send the command to turn the monitor on, I can store that fact that it is (presumably) on, and when it’s off it is off etc.? I can think of ways I might do this but I’m sure you all have best practices.

You can’t ever be sure the monitor is on, but you can store its assumed state in Broadlink switches. Instructions for creating them are towards the end of the Broadlink docs.

The trouble with assumed states is that HA and the device may get out of sync, if somebody turns on the monitor manually, for example. To deal with this you may have to run some sort of housekeeping automation periodically - one that turns the switch off and sends an “off” command to the monitor without using the switch.

Switches won’t work with source etc, of course.

If you use power monitoring smart plugs you can use the power consumption to determine if the device is on or off. Then it is a simple matter to build template switches that call the IR commands and monitor the power for the state.

Personally I got sick of all the work arounds and slowly upgraded my equipment to eliminate IR and RF stateless devices.

3 Likes

For tracking non-binary states, there is a custom integration called Virtual Components:

hass-virtual/README.md at master · twrecked/hass-virtual · GitHub

The state is still assumed, though. Not sure how you’d handle it from a housekeeping point of view.

Thanks. Yes I understand about assumed states. It was the same with my Logitech Harmony.

So when you set up the switches as recommended do they then have a state that you can access in automations?

Also, both the remotes I want to emulate have toggles for on/off, i.e. same button/code does both. In that case, do I use the same value for command_on and command_off?

Yes, they’re “real” switch entities so you can use the switch. commands in automations and they appear correctly on dashboards.

I’ve only ever used them for lights, so I’m not sure about the toggle thing. You could probably do it as there’s no actual device involved, then use switch.toggle in automations. They’d still appear as on/off switches in dashboards, though.

If your remote is still working, check the harmony database for discrete (separate on/off commands).

It’s been a while, but I remember seeing them on most devices even when the original remote came with only a toggle button. At most, you’d have to check older/newer models by the same manufacturer, but they should be there.