ZHA-Tradfri-ON/OFF- for lights and switches

Hi all,

I use an IKEA TRÅDFRI on/off remote (2-button) over ZHA, and wanted it to control a smart socket switch, not just a light. The existing blueprint from @poolcactus, "ZHA - IKEA Tradfri on/off switch (incl dimmer)", is great, but it's hard-wired to the light domain (light.turn_on/light.turn_off and brightness_step_pct dimming) — I couldn't find an existing blueprint that let the remote target a plain switch entity, so I built one.

Credit: All the ZHA event/cluster logic (command, cluster_id, endpoint_id matching for click vs. hold) comes straight from poolcactus's original blueprint. Full credit to them for figuring that out — I only generalized the target side.

What it does differently

  • Works with any light or switch entity — including sockets/smart plugs — not just lights.
  • Single press: top button turns the target(s) on, bottom turns them off (via homeassistant.turn_on/turn_off, so it dispatches correctly regardless of domain).
  • Hold-to-dim (10% steps, same as the original) still works exactly as before when every selected target is a light.
  • If you point it at a switch (or a mix of lights and switches), holding the button just does nothing extra beyond the initial on/off — makes sense, since a socket doesn't have brightness.

Install

One-click import:

Import to HA

Or grab the YAML / read more here: GitHub - LubosBury/zha-tradfri-onof-universal · GitHub

Requirements

  • Home Assistant with ZHA
  • IKEA TRÅDFRI on/off switch (2-button remote) paired via ZHA

MIT licensed. Feedback and PRs welcome — this is a fairly small/focused blueprint so it should be easy to tweak if you hit an edge case with your setup.