Closed awakenrz closed 6 years ago
Thanks for your work.
However, I'm a little confused on what this changes. If only one device ID is passed as an argument to the Tuya constructor, consecutive calls to get()
and set()
will by default use that ID. To successfully implement multiple Tuya devices with one instance, we would have to use Homebridge's Platform API rather than the Accessory API.
My understanding is that each accessory will instantiate its own TuyaOutlet
object.
Looking at TuyaAPI
's implementation of get
and set
, it looks like it'll try to find the right accessory to talk to given the devId
of the accessory.
I've successfully tested my change with two TuyaOutlet accessories in my homebridge config and there hasn't been any issues yet.
It should already be possible to use multiple devices by declaring multiple instances in the config file (although you must pass in the IP for each instance).
Did you try using two devices at once before making changes?
Ah, thank you! I think I mis-read the issue. I was reading https://github.com/codetheweb/homebridge-tuya-outlet/issues/5. But it looks like in https://github.com/codetheweb/homebridge-tuya-outlet/issues/4, specifying IP seems to be a temporary fix. Yes you're right, it also works without my change.
Ok 😄
This PR adds the ability for the homebridge plugin to handle more than one Tuya smart plug devices.
@codetheweb
This will address https://github.com/codetheweb/homebridge-tuya-outlet/issues/4