TheAgentK / tuya-mqtt

Nodejs-Script to combine tuyaapi and openhab via mqtt
MIT License
173 stars 81 forks source link

Empty Data Returned After Publishing get-states #57

Closed arrmo closed 3 years ago

arrmo commented 3 years ago

Describe the bug\ First off - this may be me! Apologies if it is 😞.

I have tuya-mqtt up and running, it's working well overall. Thanks! My issue is when I send the command get-states, it doesn't seem to "trigger the device to send an immediate update of all known device DPS topics". Rather, I get an immediate reply, but it's empty.

To Reproduce\ Steps to reproduce the behavior:

  1. Start up the tuya-mqtt server
  2. Subscribe to the Tuya device
  3. Send the get-states command
  4. Check the data sent back -> always getting,
    Client mosq-RF6Yundi0OZUPWQAdg received PUBLISH (d0, q1, r0, m6, 'tuya/emfrontswitch/dps/state', ... (2 bytes))
    Client mosq-RF6Yundi0OZUPWQAdg sending PUBACK (m6, rc0)
    {}

    Expected behavior\ Expecting to trigger the device to send current dps states / date.

Desktop (please complete the following information):\

tsightler commented 3 years ago

The "get-states" functionality only works with friendly topics so you need to use a pre-defined device template or create a custom template for your device to use this. Then you would send the "get-states" message to the device's primary friendly command topic:

tuya/emfrontswitch/command

Unfortunately, many modern Tuya devices do not respond to any schema commands so I decided to always require a template vs having cases where it works and others where it does not.

arrmo commented 3 years ago

That makes sense, thanks for the explanation! And yes, even just adding a "generic" device template (i.e. switch, for a energy monitoring capable switch) addresses it - it returns the full set of DPS data then. My apologies if I missed this in the documentation - still figuring this out.

Thanks again.

arrmo commented 3 years ago

BTW, if you don't mind - is there a way to query the current subscriptions, and clear them? Just because as I have been messing with this (debugging), I likely have a bunch stacked up 😆.

Thanks!