No more toggling of outlet state

Hello,

Brief presentation of the scene :

  • A Xiaomi button
  • A smart plug with the fan connected to it.
  • If I click the button, the plug’s state toggles to turn the fan on or off.

I had an issue with a smart plug, it seems dead (when I click it, it lights up for a moment then turns off).

So I changed the plug but it no longer works, even after deleting the scene.

If the plug is off, one click turns it on but it’s impossible to turn it off with another click or with a double click (for testing).
Yet visually the switch turns blue and it is also active on zigbee2mqtt.

I had to make a much more complicated if:

If you just connected your plug and it has never been used, it probably doesn’t yet have a state in Gladys and therefore the inversion may not work

I recommend turning the plug on from Gladys once and after that the inversion will work :wink:

It was already known to Gladys, and I manually enabled and disabled it x times from Gladys.

Ok, and does it work with the complicated if?

Because "

Yes, with the IF, it works.

Are you really sure that « invert the outlets » doesn’t work? Don’t you have a duplicate scene that might make you invert the outlet twice?

I just tested it on

I went through my scenes again and I didn’t see anything…

The sent messages still show the fan has a value of 1.

With another plug it works fine.
Could this be related to the hardware?

The code does exactly the same thing as your « if », so if it works with the « if », I don’t see why it wouldn’t do the same

Source: Gladys/server/lib/scene/scene.actions.js at master · GladysAssistant/Gladys · GitHub

Is there a way to set a breakpoint on that so I can see what’s happening?
Or, at worst, should I add a console.log?

I think we should try to figure out at which step it’s not working!

Which integration is the smart plug from?
Do you have a way to see if the plug is receiving anything?

So :

  • it turns on and off manually via Gladys
  • if I turn it off manually and press my button, it turns on
  • if I turn it on manually and press my button, it does not turn off

How can I see what it’s receiving ?
Zigbee2mqtt
When I press the button, zigbee2mqtt always receives:
```info \u003csmall\u003e2025-06-23 16:46:15\u003c/small\u003e`z2m:mqtt: MQTT publish: topic ‹ zigbee2mqtt/Prise Girier ventilateur ›,
payload
'{« child_lock »:"UN

Hi @Hizo
Is your Zigbee2MQTT (z2m) managed by Gladys or externally?
What is the version of your Zigbee2MQTT (z2m)?
When you control it from Zigbee2MQTT (on/off), does it respond properly?

Hi @mutmut

Is your z2m managed by Gladys or external?

By Gladys

What is the version of your z2m?

1.42.0

When you control it from z2m (on/off), does it respond properly?

Yes

You can try applying the latest Gladys update, which brings the next major version of Zigbee2MQTT (2.x), it could fix the problem (support for certain devices devices).

@Hizo I have a little idea, I wonder if it’s not a variable type issue, the « 1 » might be a string and thus last_value === 0 is always false which makes it send an OFF systematically!

But then we should understand why for this specific outlet it would send a string. Does the other outlet where it works also come from Zigbee2mqtt?

In my opinion that’s unrelated, I think it’s a scenes problem :slight_smile:

Indeed, that’s the triple-equals trap :slight_smile:

I clicked on the update but not much happened…

In my test with the other outlet, I added it to the same block as the one that’s not working.

I’ll make a note to test the behavior over the weekend to see if it’s really a type-related issue :slight_smile:

In the meantime, if it works with the « if », all the better :wink:

@Hizo I checked — actually everything is fine on the Gladys code side, but I think I figured it out!

On the Zigbee2mqtt link you shared, Zigbee2mqtt says the following:

The plug has been buggy since firmware version 1.0.5, notably:

TuYa has disabled the automatic reporting of power, voltage and current values

As a result, Gladys never receives the plug’s updated state…

Given all the negative feedback on that page, I’d recommend you change the plug — considering the price, it’ll save you some gray hairs ^^

At my place, I have several Nous Zigbee plugs. I’m happy with them and they’re relatively well rated on Domadoo (4.7/5 based on 77 reviews).