Decouple switch input from relay output v1.0.0

Some zigbee devices (Sonoff ZB Mini and possibly Tuya) read input from a switch and set the state of a relay automatically, i.e. the switch and relay are coupled on the device. They also allow the relay state to be read and controlled remotely.

When connected to a smart lightbulb these turn off power to the bulb when switched, meaning the bulb goes offline and its setting can’t be changed directly. This blueprint decouples the switch and relay. The relay output is controlled by a toggle/input_boolean helper, and the output can be directly routed to the smart lightbulb.

  • The bulb remains powered even when the physical switch is toggled
  • The bulb can be isolated using a software switch in HA
  • The switch can still control the output of the bulb
  • If the automation is disabled the switch reverts to directly controlling power to the bulb.

Due to the delay of going through an automation the lights flicker when the physical switch is toggled.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

blueprint:
  name: Decouple Sonoff ZBMini
  description: v1.0.0 Separate the switch input and the relay output of a Sonoff zbMini device.
  domain: automation
  author: Stephen Turner
  input:
    zbMini:
      name: ZBMini device
      description: The device to be decoupled
      selector:
        entity:
          filter:
            - domain: switch
    isolator:
      name: Virtual isolator
      description: An input_boolean helper device, the state of this will control the output relay
      selector:
        entity:
          filter:
            domain: input_boolean
    controlled_light:
      name: Switched target lights
      description: One or more light entities, The switch connected to the ZBMini will toggle these
      selector:
        target:
          entity:
            domain: light

trigger:
  - platform: state
    entity_id:
      - !input isolator
      - !input zbMini
condition:
  - condition: or
    conditions:
      - condition: and
        conditions:
          - condition: state
            entity_id: !input isolator
            state: "off"
          - condition: state
            entity_id: !input zbMini
            state: "on"
      - condition: and
        conditions:
          - condition: state
            entity_id: !input isolator
            state: "on"
          - condition: state
            entity_id: !input zbMini
            state: "off"
action:
  - service: switch.toggle
    data: {}
    target:
      entity_id: !input zbMini
  - service: light.toggle
    data: {}
    target:
      !input controlled_light
mode: single
3 Likes

Seems that I’m not able to get your blueprint to work. My switch keeps working just like it did before and automation never runs.

Does toggling the Isolator’s input_boolean cause it to run?

I have some Moes zigbee switches but I only have wifi lights - will this automation work with these devices?

I don’t know as I don’t have the same config, give it a try and let us know what you find. The blueprint itself is pretty simple so you should be able to alter it to suit your needs.

OK, got it working. Fault was, as usual, between the seat and the monitor.
Very useful blueprint. Thank you.
Not using the Sonoff switch but the Tuya (Moes) one instead. Would be wise update the description of blueprint accordingly.

I have update suggestion as well:
currently, it switches the bulb ON its last known brightness state. It would be nice if I could override brightness and set it to any value (precentage) when switching ON. I personally need 100% as I’m using wall switches as “reset” if needed and seems that users expect wall switches+bulb work in usual manner.

Hell yeah, it would be great if i can get to make this work. Does this work with a Sonoff ZBMINI-L? So without a neutral? Im a newbie with HA and switches so any help on these and how to connect would be much appreciated. I already disconnected my ZBMINI-L because the combination of a smart light swith with smart lights didn’t work because of the cut off power to the lights. This would stop this, right?

@jeroenva1981
Test it out if it works for you or not. Takes just a couple of minutes. I could not see any limitations as all it does is switch the relay back ON and sets the binary helper either ON or OFF. Also, please note: if you can not switch your bulb off any more then you have to switch binary helper manually once. This fixes it.

@macintoshee Yes, it came to me at an odd time. The switch should appear to keep working as it did before, however instead of the switch turning off power to the smartbulb, it keeps power on going and tells the smartbulb to turn off.

Thanks so much for this. I managed to get this working on the sonoff ZBMINI L2 (No neutral wire ZigBee version). When smart bulb is on and I hit the physical light switch the smart bulb turns off but is still powered and can be controlled via HA or Google Voice commends etc. However if the smart bulb is off and I hit the physical light switch this does not turn on the bulb.
Also after 4 or 5 tries it stops working all of a sudden until I toggle the isolator which kills power to the smart bulb.

could you possibly let me know how you wired this ?

I wired mine as per

so if I turn the physical switch off the sonoff gets no power and won’t do anything until someone flicks the switch again. I assume I need to re wire it in some way. and did you manage to ever get the smart bulb to turn on via the physical switch? I’ve currently got it wired to an extractor fan, but my initial plan was to put them in light switches so that can both use physical and ha based switches to turn it on/off and not get the issue where someone turns the switch off and have to turn it on again physically to use it again

anyone got any pointers to the wiring ?

Hi,

I’am also wondering if it works with the L2 version of the ZBMini ?