Weird behaviour with Follow profile

I’m experiencing something weird in my configuration, using the follow profile. When toggling the main light, the secondary light toggles on-off one extra time. Let me explain my situation:

  • Main light, Sonoff Zigbee device connected through Zigbee2MQTT. I have a Switch-Item that controls this light.
  • Secondary light, Sonoff WiFi device (Tasmota) connected through Zigbee2MQTT. I have a switch item that controls this light (default profile), but connected the Main Light switch item to this thing channel, using a Follow profile.

When I turn on the main light with the openHAB item, the secondary light goes On → Off → On. When I turn off the main light the secondary light goes Off → On → Off. If I turn off the main light when the secondary light is off, the secondary light goes On → Off.

If I turn off the main light from within zigbee2mqtt or with the physical switch, the secondary light doesn’t show the additional On/Off toggle.

I tried removing the ‘secondary switch item’ from the secondary device, but this doesn’t change the behavior.

I did not change anything in my config (not to my knowledge at least), and previously this was functioning like it should. Did anything changed in latest releases of openHAB (i’m on the most recent stable release) or any clues how to debug this?

Not sure if you need the follow profile at all. The follow profile takes every state update (not commands) and sends this as a command to the follow-linked channel.

From your explanation it sounds like you are about just to switch two lights simultaniously.

My usual approach would be to

  • create two items, one for each device/light, linked with standard profile
  • put both into a group

This gives you three items in total, one group item plus the two individual light items.

Now you can send commands to the group (→ switching both lights) or send command to just one of them to control them separately.

The additional toggles may come from some state updates (Zigbee reporting enabled?) which cause addtional commands going to the Tasmota light.

1 Like

Follow the events.

When using the follow profile you have two channels, channel A and channel B.

What the profile does is translate updates from channel A into commands sent to channel B. So what updates do you see coming from channel A?

In OH 5.1 the source for the Item events are now captured and printed to events.log. But state updates are not logged to events.log by default. You may need to change the logging level for openhab.event.ItemStateUpdatedEvent to see those in the log too.

Also pay attention to autoupdate and if this is a Generic MQTT Thing the postCommand property. Both of these can generate more events that might be getting in the way.

Thanks Rich, this helped to find the issue. Checking the eventlog I found that:

  1. The switch item is turned off by the auto-update
  2. Zigbee2MQTT sends the old state to openHAB (ie. ON)
  3. Zigbee2MQTT sends the new state to openHAB (ie. OFF).

This leads to the toggle of the secondary (non Zigbee) device, while the main device doesn’t experience the toggle.

Google helped me out and pointed me to the zigbee2mqtt github. Turning off cache_state fixes the issue.

Now to find out how this setting has been toggled…I can’t remember that I adjusted it myself :wink: