I dont see a whole lot of difference between setting the value of an attribute or calling a method such as device.on();. Both make changes to that particular device. In my case the attribute is really a placeholder for the name of the last action/activity that changed the state of the switch. What ever its value is set at does not change in any way the behavior of the device.
The above example was used to keep it simple. What my ultimate goal is to know how/what changed the switch.
The app has 2 main purposes
- Using the ST app, a virtual switch turns on/off a wemo switch via httpGet
- Receives on/off commands from Wemo to update the ST switch so that it reflect the true state of the Wemo.
Problems.
- When a Wemo is changed via outside app or manual switched on/off, my app receives the device id that changed and updates the ST virtual switch which causes the onEvent to trigger which causes my app to fire of httpGet. Wemo does not change anything if the state it received is the same as the current state of the switch however, it does trigger an event which is once again sent back to my ST app.
- When my app changes the virtual switch it does the httpGet to turn on/of the Wemo which responds with sendHTTP which my app picks up and most of the time it is discarded. If not, it returns the same event back to the wemo…
Both these problems would never be noticed if one simply does not press a switch two or more times in rapid succession . Even then thing may behave perfectly well but when they dont…
To make it go whacky…
With my ST SmartApp, press a Switch on then off in quick succession.
App turns on the ST virtual switch and send on command to Wemo App.
Wemo receives/process on command
App turns off the ST virtual switch and send off command to Wemo App.
Wemo app triggers sendHTTP event in response to the on commandwhich is sent back to ST smart app.
Wemo receives/process off command
Considering the virtual switch was off, the ST app responds and turns on the ST virtual switch which triggers an on event which sends the command back to Wemo app.
Wemo app triggers sendHTTP event in response to the off command which is sent back to ST smart app.
repeat and rinse