Device status - sync issue


#1

1) Give a description of the problem
I created a virtual switch (on / off) that works fine to control another ST device (a Harmony hub). But if the device is physically turned on, the virtual switch gets out of sync and still shows as off in ST.
I’m new to WebCore, but I gotta believe it’s possible. I don’t know how to use “$status” or “DeviceWatch-DeviceStatus”, or if those are even something that is related to my problem.

2) What is the expected behavior?
I would like to find a way to keep the on/off state current in the virtual switch - regardless of whether or not I turned it on / off with the power button.

3) What is happening/not happening?
Virtual switch is getting out of sync.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
(PASTE YOUR LOGS HERE BETWEEN THE MARKS THEN HIGHLIGHT ALL OF THE LOGS SND CLICK ON THE </> ICON TO FORMAT THEM)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

I think the second IF needs to be in it’s own statement, like this:

temp

This should synchronize Switch 2 to match Switch 1.


#3

I think I’ve got it working. One of the problems is that the Harmony “watch tv” activity (a switch in ST) wasn’t updating automatically. Even if I used the Harmony remote, the switch wouldn’t update. My solution is a bit of a hack, but it works. I created 3 different pistons:

  1. The one in my original post above (or the reformatted one from WCmore)

  2. Updates the status of the Harmony activity every minute:
    image

  3. Sets the virtual switch to the same status as the Harmony activity switch:
    image

I’m not crazy about running #2 every 60 seconds, and I’m sure there’s a more elegant way to do this, but my ham handed method is at least functional for now.

Open to suggestions to streamline it if anyone has a brilliant idea.


#4

I agree 100%


What baffles me most is your logic though.

IF Switch 14 turns on, then turn on Switch 17
IF Switch 14 turns off, then turn off Switch 17
IF Switch 17 turns on, then turn on Switch 14
IF Switch 17 turns off, then turn off Switch 14

Why have two switches?!? It looks like one switch will do what you need, without the hassle of synchronizing the two…


#5

Good question. I have 2 Harmony hubs, and use Amazon echos for voice control.

If I tell alexa to “turn the tv on” she assumes that I want the kitchen tv on. If I want the basement tv on I have to say “alexa tell Harmony to turn the tv on”. Kind of a PITA, and the boss gets confused.

My virtual switch can be named whatever I want, and now I can say “alexa turn on the basement tv”. Small but significant difference.

This method keeps the virtual switch synchronized with the harmony hub activity if someone goes old school and uses the remote control. If it’s out of synch then telling alexa to turn the basement tv off wouldn’t work.


#6

Amazon recently made changes to the Alexa commands.
You can now make any phrase turn on or off any device.

Alexa app > 3 bars top left > Routines

I still recommend keeping all your code and logical processing in webCoRE, but now you can make easy (natural) phrases turn on/off long named devices.

I would try this route, and focus on only using one Simulated Switch per activity.


#7

Thanks WCmore! I tried the Alexa routine method prior to using webCoRE and she didn’t like the order of words in certain phrases. If I remember correctly you couldn’t say “alexa turn off the basment tv”, but you could say “alexa turn the basement tv off”. And nobody in this house says things in the same order regardless of the number of times I lock them in the dungeon.

I do only have one virtual switch in this process - for Alexa, the other switch is a Harmony Activity (from the Harmony hub). After more fiddling I was able to turn off my 60 second piston. Turns out my Harmony Activity switch in ST doesn’t update very fast (2-3 min). I was impatient while testing it and figured it needed to be refreshed to work.


#8

I cheat sometimes and set it up using only one word.
For example, when I say, “Alexa, gasoline” she flips a switch that webCoRE is monitoring. At this point, webCoRE takes over, and queries my car to tell me how many gallons I have left in my tank.


I no longer have a Harmony hub, but I do remember delays such as this. Thankfully, most activities we trigger are used for at least that long, so your hub should be automatically updated by the time you are ready to switch to another.

I am glad you were able to disable your 60 second infinite loop.