Subscribe to Device Command?

Is it possible to subscribe to a Device Command? Not subscribe to the device state change, but subscribe to a command being issued from some other source.

Not that I am aware of... :thinking:

Would you mind explaining the use-case for this? I am genuinely curious.

1 Like

I have a button, or rather my wife has a button, that turns on/off her lamp. If the lamp is on the button turns it off, if the lamp is off the button turns it on.

It is controlled by a matter plug. Sometimes the plug doesn't report the current state. So obviously the button doesn't work. I found that if I issue an initialize it will get back in sync.

However, if I'm not home.... Wifey can no longer control lamp. And that ain't good for me.

My thought was to see if a command was issued and check status and automatically issue an initialize. I can do it another way, just thought that might be simpler.

1 Like

Thank you for explaining the issue. I have seen other reports of Matter devices requiring re-Initialization as well in the forum. I wonder if @bcopeland is aware of this or not? If not, he probably is now.

Seems like something either the driver or the Matter subsystem of Hubitat should try to correct automatically. If a device command is issued to a Matter device, and that device does not respond within a timeout period, the system should try to automagically correct the issue and reissue the command. Obviously, we don't want an endless loop if someone has simply unplugged the device... So, it probably takes some thought. :thinking:

In webCoRE you can disable command optimization which means that even if the state is showing as off, the off command will still be issued to the light no matter what. I HAD to use this when I had LightwaveRF devices which were stateless and could get out of sync.
I don't use RM so I don't know if that is a feature in RM.
Would this be something that would help with your issue?

The problem comes in as I have to know the current state of the light to determine whether to issue an on or off command.

I think what I can do is see if the current state changed when I issue any command and if it didn’t then send the initialize. Just have to convince her to wait a few seconds before trying it again.

Ah, I see what your getting at now. You are basically using the button to toggle the light.

1 Like

You could use a virtual switch in the middle.

  • The button turns the virtual switch on (if the virtual switch is currently off) or off (if the virtual switch is currently on).
  • When the virtual switch turns on, turn on the Matter plug.
  • When the virtual switch turns off, turn off the Matter plug.
  • After a timeout period (~5s) triggered by a change in the virtual switch state, compare the switch states of the virtual switch and Matter plug.
  • If the switch states differ, take correction action: initialize the Matter plug, retry to match the virtual switch state, etc.
1 Like

That’s basically what I will do. Since it’s in a custom app I will probably use a state variable rather than create another device.

:eyes:… I had a problem like this on some new devices I was writing drivers for yesterday… I thought it was just bad firmware, but a hub reboot fixed it for me… In fairness it was likely do to some library updates (unreleased) that had happened recently too

1 Like

I have 2 Govee table lamps using the Generic Matter RGBW Light driver that are not always updating.

I have it happen every once in a while. Initialize always seems to work. Never tried a reboot.