Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dp-refresh fire for all devices of the gateway instead of the only one concerned #640

Open
Buom01 opened this issue Nov 21, 2023 · 1 comment

Comments

@Buom01
Copy link

Buom01 commented Nov 21, 2023

Hello,

Describe the bug
Tuyapi's devices sharing a gateway emits dp-refresh events of all other devices of the gateway, like if the event come from the tuyapi's device itself.

To Reproduce
[Ask if you need more details, I didn't make a separate repo]

  1. Connect to 2+ devices through a gateway with tuyapi (preferably same device type).
  2. Fire a dp-refresh on one of them, like clicking a button or anything
  3. dp-refresh is emitted from all devices by tuyapi

Solution
dp-refresh provide anything like

{
  dps: { '2': 'single_click' },
  cid: '[...]',
  t: 1700543876
}

.

The cid is the uuid we got on the Query Device Details API page from Tuya. Should use it to only emits from the right device instead of the whole gateway.

Screenshots
Capture d’écran du 2023-11-21

Desktop (please complete the following information):

  • OS: Linux Fedora
  • OS Version: Workstation 38
  • Node Version: v18.18.2

Additional context
I'm currently making a small abstraction layer for my smart house, making an object for each kind of devices. According to my research, device's events from the same gateway seem to not being filtered, according to the source code ( https://github.com/codetheweb/tuyapi/blob/master/index.js#L827 ). I don't think it's intended.

@msillano
Copy link

As an abstraction layer see TuyaDAEMON. It uses a different approach: a big json object handles all devices, DP properties, and quirks. Adding a new device only requires an update of this object ('global.alldevices', a global singleton with set and get methods).
Evens are filtered by ID AND CID, so no problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants