unparagoned / njsTuya

Openhab interface for Tuya home automation devices sold under various names
27 stars 11 forks source link

Status #20

Closed edwolfe3 closed 4 years ago

edwolfe3 commented 5 years ago

Is there a way to have the status updated if the Smart Life switched is turned on via another source (e.g. Alex)?

unparagoned commented 5 years ago

When using the app or cloud the devices switches to broadcasting it's state in an encrypted mode and there is nill support for local mode if you have the app open or I suspect Alexa running over the cloud. But getting the state via cloud mode should work fine.

edwolfe3 commented 5 years ago

I mean, if I turn the outlet on via Alexa or manually by pushing the power button on the device, how can I detect that in a rule?

unparagoned commented 5 years ago

You need to run a rule to check or get the status every x seconds or get the status before running an action. There is no "push" functionality for local or cloud. So if I have a function that gets the status every 5 seconds. So if if I push the power button on the switch it should update via openhab within 5 seconds.

TRSx80 commented 4 years ago

This problem can be avoided if only local control is used?

unparagoned commented 4 years ago

@TRSx80 Local control won't help, you have to get/check the status to see if it has changed or been updated by another source. The only way I can think of to see if a device state may have changed is to have a wifi card in promiscuous mode and get the state if any packets are sent to the tuya device. But like I said previously it would be more reliable and much simplier to just run the script to get the state every second or so.

TRSx80 commented 4 years ago

Thanks for clarification!

In my case, for actuators anyway, the commands would always be coming from the HA controller, so I guess that means I would be OK (at least for time being). Something to keep in mind though, in case that changes later. :thinking:

Also, I made a post over on your thread at OpenHAB as I been researching current state of Tuya stuff on OpenHAB. You seem quite knowledgeable on the topic since you seem to be using it for a while already, so I sought your feedback. Not sure if you check in much over there any more these days...