PaulAnnekov / tuyaha

Implements the special Tuya Home Assistant API.
Other
142 stars 106 forks source link

Minor change in order to fix the switch status #4

Closed niladam closed 5 years ago

niladam commented 5 years ago

This could and probably should be a single function to get the status of the device based on it's specified id.

I quickfixed this in order for the switches to function, and i think 2 weeks is a pretty long time. Also, please keep in mind that my python language skills are from none to low :)

I think if this gets merged it'll be a really great and really quick fix :)

This should fix #3

niladam commented 5 years ago

Personally, i think there could an easier way of doing this, without actually requesting the devices again from the API. However, i'm not really sure if this could actually work, since the SESSION basically holds the state -- which upon triggering changes -- therefore the SESSION data could become stale.

@PaulAnnekov - thoughts about this buddy?

PaulAnnekov commented 5 years ago

This code looks a bit dirty, but as I have no time to handle it better I will merge this PR. Anyway, thanks :wink: .

niladam commented 5 years ago

@PaulAnnekov

This code looks a bit dirty, but as I have no time to handle it better I will merge this PR. Anyway, thanks 😉 .

I know! I'm not a python developer and i think this is the 2nd time i'm doing something with it :P - and obviously, i already stated that about my skills.

I'm curious though, how you would've done the foreach ?