Zigbee2MQTT - HA doesn't know state of light manually turned on

I was doing to things in HA, as I am rebuilding my HA instance — which has been great to do after 7 years of running a totally polluted and hacked about HA… It was how I learned a lot :slight_smile:

Any way, one of the changes was moving to Zigbee2MQTT – which is amazing BTW!

I manually turned on a Sengled white bulb on using a simple knob switch on a bulb outlet plug. The light is paired and works just fine with Zigbee2MQTT, HA, NodeRed, triggered with automation by Hue switches and Hue motions, etc. All good. I can see the bulb in Z2M just fine.

I walked away to do something and left the light on. I came back and jumped into HA to do something and noticed that the light was showing in “off” state in HA.

I checked the Z2M logs and I can see it publishing to the logs the state, brightness, etc. Checked the HA logs and I don’t see anything.

So I’m thinking there is some message publishing or configuration options I’m missing - where Z2M should tell what it knows about a device in such scenario?

I can easily sync them back up – turning on/off a switch or triggering the motions, but that sounds like the wrong way.

Any help is appreciated!

After some fun, hallucination, misled and obsession to resolve the correct way, I found the fix was simple had I just slowed down and taken a little time to read documentation.

Updated the availability: section of the Z2M configuration.yaml as follows:

availability:
  enabled: true
  active:
    timeout: 5
  passive:
    timeout: 1500

Are you sure ChatGPT didn’t hallucinate some of those options? The entire advanced section seems to be MQTT-specific settings and I suspect Z2M is ignoring them. None of those advanced options seem to be listed in Z2M docs

Haha… Yes, thanks for pointing this out.

Because I have experience with LLMs, I for sure was skeptical and realized I may receive the exact feedback you shared.

This is a case of me not knowing any better and I wasn’t doing any damaging configuration to my HA environment. So I backed everything up and made the changes to the Z2M config. I couldn’t find an instance where something I configured popped an error somewhere - including in the Z2M addon and Z2M console logs (at debug level). It would be nice if it would inform what it’s ignoring to help. But the fact remains that after making these changes, the initial problem I was having was resolved. In all honestly, I was hesitant to post my resolution, knowing that it could have hallucinated, but the problem is resolved.

Now I’ll make take the time to work this all backwards now and see exactly what works and what doesn’t. Good way to learn since I have a working situation.

Thanks for being honest!

And you my friend have helped me track down the proper fixes! After your comments, I was bothered and felt compelled to research more, learn, and figure this out the right way. And you are right. And because it’s Friday in the US, I happen to have more time today to work on this :slight_smile:

So I removed everything I added from the advanced: section Z2M configuration.yaml which basically set it to default config.

I then modified to update the availability: section of the Z2M configuration.yaml as follows:

availability:
  enabled: true
  active:
    timeout: 5
  passive:
    timeout: 1500

Performed all testing - with that config and with it disabled and guess what? Everything works, meaning this was all that was needed. Removing the config, and I end up back with original problem. So it’s clear that’s all that was needed to begin with. :man_facepalming:t2: How embarrassing! But just like the earlier hallucination learning expedition, I did learn! :sweat_smile: I’m humble and it’s all good! This is one of the rare moments I didn’t try things on my own. I let the new-ness of Z2M scare me a bit. Glad it’s resolved the right way now and I have a good understanding based on the documentation!

Thank you again @ShadowFist for pointing this out.

2 Likes

Hi, Hoping you can help me with this problem. I switched from ZHA to Z2M because I needed support for a new device that wasn’t supported properly by ZHA.

Everything went smoothly, except I noticed I’m having the same problem as the62694. None of my Sengled bulbs will show they are turned on when manually turned when the power is applied. I didn’t have this problem with ZHA.

I tried adding the same fix mentioned above and didn’t see any difference. Any suggestion on what setting needs to be applied so I can see when the bulb is on when power is applied?

First things first - I’m assuming you restarted Z2M for your yaml setting to take effect, right?
Secondly, you don’t need to do it in yaml. You can do everything in the Z2M Frontend (the one in the left sidebar, not the addon itself).
Go to Z2M > Settings > Availability tab > Select Availability (Advanced).
Set your preferred settings for active & passive devices in minutes (remember that most Sengled bulbs are considered passive end-devices) > Hit Submit

Thanks for the reply. I did try the above mentioned fix and it doesn’t appear to be working with the Sengled bulbs I have. After making the changes in the Z2M frontend, clicking submit, and restarting Z2M, I checked the configuration file for Z2M and availability is showing.

I don’t have another brand of Zigbee bulbs to be able to determine if it is the Sengled bulbs that aren’t sending out their state when power is turned on or something with my setup.

What is your passive timeout set to?

Like I said earlier,

It should be easy to double check this by going to the Device page in Z2M for your Sengled bulb. It will probably be marked as an end device (passive) and not a router (active)

I did try the default 10 min for active and 1500 min for passive. With no difference.

When I changed the passive timeout to 1 min to test. The bulb will show unavailable after 1 min when power is removed. When power is applied, the bulb will turn it on, show availabe again and show the correct state as on for the bulb. The problem is after 1 minute, with no change to the power, the bulb will show unavailable. When this happen, the bulb(and other passived zigbee devices) will be grayed out and not controllable from the HA dashboard.

1 min is too low for passive devices I think. You’re gonna flood the network, have false alerts of devices being offline (battery devices only check in once in a while) and drain the batteries.

Try something more reasonable, like 15-20 mins

If I set it to 15-20min, wouldn’t the bulb then go offline and I wouldn’t be able to control them? That seems to be what is happening when I test the 1min timeout setting.

I feel like I’m missing something since I’m not getting any identication that the bulb is sending anything to Z2M that the bulb is on when it is powered on. Is there somewhere I can see if anythng was sent by the bulb?

OK…still messing around. When I look at the Z2M log in add-on, I can see when I manually turned the lamp on in the log. The problem is it publishing it at “state”:“OFF” when the bulb is on.

[2025-02-16 11:44:10] info: z2m:mqtt: MQTT publish: topic ‘zigbee2mqtt/Florida Room Lamp’, payload ‘{“brightness”:254,“energy”:0.43,“linkquality”:200,“power”:8.3,“state”:“OFF”,“update”:{“installed_version”:9,“latest_version”:9,“state”:“idle”}}’

No, it probably won’t go offline if it reports back to Z2M within those 15 min, same as it didn’t go offline when the timeout was set to 25 hours (default).

What you could do is go to the Reporting Tab for each of your bulbs and configure reporting for the OnOff cluster, like this (use the values in my screenshot to get immediate reports):

Yes, you can either turn on debug logging for Z2M, or else install MQTT Explorer on your PC and monitor the mqtt messages being sent by the bulb.

YOU DID IT! Configuring the OnOff cluster worked!

Thanks for all your help!

1 Like