ZigBeeBulb behind Shelly Wifi Relay - How to switch on relay to switch on light

Hey folks,

has anyone an idea, how to solve that problem:
I have several lights controlled with zigbee2mqtt - everything works fine.
The lights itself can be powered on/off with shelly1 (wifi relay).

Toggling the physical light-switch triggers the shelly, which powers the bulb. Shelly does this independantly and i don’t want to change this (fallback in case HASS is offline).

The HASS-state of the zigbee light changes to “unavaiable” if shelly powers off the zigbee bulb. Sure, because zigbee2mqtt pings the devices, gets no answer and then sends unavailable. Thats fine.

Question: How to automate, that triggering the light with status “unavailable” to “on” triggers the shelly on instead (which switches the light on).

In Lovelace, especially lovelace-floorplan, i want to have one single icon with the status of the light; short press for on/off and long-press for changing RGB and brightness.

Trying with https://www.home-assistant.io/integrations/light.switch/ , but there is only support for on/off.
Others ideas?

Thanks for your support !

Folke

Update: I have found an easy solution:

I have defined a light.group, containing the shelly and the 4 zigbee bulbs connected to that shelly.

light:
  - platform: group
    name: WZD
    entities:
       - light.wohnzimmerdeckeshelly
       - light.wzd1
       - light.wzd2
       - light.wzd3
       - light.wzd4

Turning the group “on” set shelly to on and HASS will not send anything to zigbee2mqtt, because the devices are unavailable, but the 4 zigbee bulbs immediately start to light because they get now main power - and a couple of seconds later the zigbee bulbs also showing up as “on” in HASS.

Long pressing the icon in lovelace you can set color and brightness, which is ignored by shelly, because it supports only on and off. But the zigbee bulbs are doing the expected.

Not so good:
Switching the group to “off” the shelly immediately disables power and the bulbs are getting dark, but it takes up to 15-30 seconds until HASS shows the whole group as “off”, because the zigbee bulbs are not reporting the “off” state (no power, no zigbee). You have to wait until zigbee detects the unavailibility, if enabled - you have to set advanced.availibility_timeout in zigbee2mqtt configuration for this to work.

Workaround:
Here is my trigger which fakes zigbee2mqtt “off” messages using mqtt service. So HASS shows immediately off.

AUTOMATION

automation:
- id: '1590961473448'
  alias: WZDaus
  trigger:
  - entity_id: light.wohnzimmerdeckeshelly
    from: 'on'
    platform: state
    to: 'off'
  condition: []
  action:
  - data:
      payload: '{"state": "OFF"}'
      topic: zigbee2mqtt/wzd1
    service: mqtt.publish
  - data:
      payload: '{"state": "OFF"}'
      topic: zigbee2mqtt/wzd2
    service: mqtt.publish
  - data:
      payload: '{"state": "OFF"}'
      topic: zigbee2mqtt/wzd3
    service: mqtt.publish
  - data:
      payload: '{"state": "OFF"}'
      topic: zigbee2mqtt/wzd4
    service: mqtt.publish
1 Like