Updating mushroom light cards to show light status when zigbee device is powered off

Hello,

Here is my setup :

I have various zigbee light bulbs (that do not act as repeaters/routers). There light bulbs are connected to ‘dumb’ wall swtiches that have a sonoff ZBMiniL2 behind them (so no that dumb really). The setup is like that because for me i control everything with the home assistant, but others in my household use the wall switches.

I understand all of the ramifications of cutting power to zigbee devices with regards to the mesh network, however i have smart plugs near every light bulb throughout my home, so the network is stable with the lights on or off.

This set up works perfectly. On my dashboard i have various custom mushroom light cards here is an example :

- type: custom:mushroom-light-card
        entity: light.outside_sh_light
        show_color_temp_control: true
        use_light_color: true
        show_color_control: true
        show_brightness_control: true
        collapsible_controls: false
        tap_action:
          action: call-service
          service: switch.toggle
          service_data:
            entity_id: switch.sh_sonoff_outside_light_switch
        card_mod:
          style: |
            ha-card {
              border: none;

As you will notice i have it set up so that when i click the light bulb it actually triggers the sonoff switch to turn off. The problem i have at this point is that the button does not update the light status. The bulb has obviously lost power, so no zigbee reporting is happening. For all HA knows the light is still on.

Is there are workaround to this so that when i toggle the sonoff switch the dashboard is updated to show the current light status? I thought of using an automation to check every minute, but this doesnt seem to work:

alias: Update Light Status
description: Check the status of multiple lights every minute and update the dashboard
trigger:
  - platform: time_pattern
    minutes: /1
action:
  - service: homeassistant.update_entity
    target:
      entity_id:
        - light.outside_mh_light
        - light.outside_sh_light
        - light.outside_gate_light
        - light.outside_bbq_light
        - light.living_room_light
        - light.kids_bedroom
        - light.sh_left_bedroom_light
        - light.sh_middle_bedroom_light
        - light.master_bedroom_light
    data: {}

Could anyone help?

Why not do a service call to turn off the light and then turn off the switch, and the reverse when its turned on ? (or your bulbs might already support a power on state which you could set to on).

I thought of that, which would solve half of the problem, because it would only work if the light is switched off using HA. my problem lies only with the light being turned off on the wall switch (i.e by someone who doesn’t use HA)

This turns the light off, because the sonoff zbminil2 cuts the power to the bulb. But the bulb doesn’t report as off because it has no power…

You could do something with templating to show the light as off, if the sonoff switch is off, or… or you could make HA immediately turn the switch back on if the physical switch turns if off, and use a service call to then turn off the light.

The issue with the latter approach is that the power will have been cut to the light momentarily, but I’ve found that if I do that with some of my zigbee bulbs, they seem to connect back to the network almost instantly, but your mileage may vary and you might have to build in some kind of delays to ensure the bulb is back on the network before sending the light.off command, which could be annoying

I have the same setup, but what I did was give up on having the lights themselves visible in HA. Instead, I just have the wall switches. (I have a separate page in HA where I list all the bulbs.)

The other two things you can do is adjust how quickly ZHA detects lost devices in its settings, but even setting that to 60 seconds won’t really help. You could also try to issue a network ping (does Zigbee support that?) to the bulb right after the wall switch change. For me I have 6 to 15 bulbs controlled by most wall switches so it doesn’t make sense to list them anyway.

Also, I found that the network did not withstand losing the bulbs from the wall switches. (I have 16 on track lights and 2 lamps with 6 each, so most of the network disappeared and remotes didn’t work.) To solve this, I put all the bulbs that are controlled from wall switches on ZHA via one USB adapter and all the other devices on Deconz via a second adapter. Since the networks are separate, all the remotes use paths through Deconz and aren’t affected by lights on the ZHA network being switched off at the wall.

-David