Samsung TV acting as a Switch


#1

Hello. I posted this onto the end of another thread by a user asking how to add their TV into webcore. I have done that by adding it in as a ‘Pollable Device’. All sorted on that front! But…

1) Give a description of the problem
While the switch changes while I look on IDE, it’s not activating my light to change.

2) What is the expected behavior?
The light should turn on/off with the TV.

3) What is happening/not happening?
It sometimes turns off with it, but will not turn back on. I wonder if there is a time lag and as such the ‘changes to’ bit is no longer changing by the time webcore knows about it???

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)

12/04/2018, 08:52:37 +679ms
+2ms ╔Received event [TV].switch = Off with a delay of 72ms
+100ms ║RunTime Analysis CS > 15ms > PS > 37ms > PE > 48ms > CE
+103ms ║Runtime (38728 bytes) successfully initialized in 37ms (v0.3.104.20180323) (100ms)
+103ms ║╔Execution stage started
+111ms ║║Comparison (enum) Off changes_to (string) off = false (1ms)
+112ms ║║Condition #8 evaluated false (4ms)
+113ms ║║Condition group #1 evaluated false (state did not change) (5ms)
+117ms ║║Comparison (enum) Off changes_to (string) on = false (0ms)
+118ms ║║Condition #5 evaluated false (3ms)
+119ms ║║Condition group #2 evaluated false (state did not change) (5ms)
+121ms ║╚Execution stage complete. (18ms)
+122ms ╚Event processed successfully (122ms)

12/04/2018, 08:50:52 +74ms
+1ms ╔Received event [TV].switch = On with a delay of 49ms
+89ms ║RunTime Analysis CS > 12ms > PS > 27ms > PE > 49ms > CE
+91ms ║Runtime (38727 bytes) successfully initialized in 27ms (v0.3.104.20180323) (89ms)
+92ms ║╔Execution stage started
+100ms ║║Comparison (enum) On changes_to (string) off = false (0ms)
+101ms ║║Condition #8 evaluated false (4ms)
+102ms ║║Condition group #1 evaluated false (state did not change) (5ms)
+106ms ║║Comparison (enum) On changes_to (string) on = false (1ms)
+107ms ║║Condition #5 evaluated false (4ms)
+108ms ║║Condition group #2 evaluated false (state did not change) (5ms)
+110ms ║╚Execution stage complete. (19ms)
+112ms ╚Event processed successfully (111ms)


#2

In the else statement, remove the IF block and just put

With
White bulb 6
Do
Set level to 50%
End with


#3

OK. Could I also separate it to two IF blocks? would that work?
i.e.


#4

Test it :slight_smile:


#5

Just got in. The piston as we discussed above didn’t work. The logs keep saying that the switch didn’t change, when in fact it definitely did. I’m wondering if the switch is delayed from when the actual TV turns off, and then by the time ST/WC knows about it, it’s no longer classified as a recent change. Does that make sense?

I’ve now got something like this (UPDATE- if the lamp is already on, it does turn off, just it won’t turn on with this piston).

12/04/2018, 17:54:45 +273ms
+0ms ╔Received event [TV].switch = On with a delay of 66ms
+114ms ║RunTime Analysis CS > 15ms > PS > 32ms > PE > 68ms > CE
+117ms ║Runtime (38772 bytes) successfully initialized in 32ms (v0.3.104.20180323) (116ms)
+118ms ║╔Execution stage started
+148ms ║║Comparison (enum) On changed = false (24ms)
+149ms ║║Condition #8 evaluated false (27ms)
+150ms ║║Condition group #1 evaluated false (state did not change) (29ms)
+152ms ║║Condition group #9 evaluated true (state did not change) (0ms)
+154ms ║║Cancelling statement #10’s schedules…
+159ms ║║Skipped execution of physical command [Front room lamp].off([]) because it would make no change to the device. (3ms)
+160ms ║║Executed [Front room lamp].off (4ms)
+162ms ║╚Execution stage complete. (45ms)
+163ms ╚Event processed successfully (164ms)

12/04/2018, 17:54:24 +846ms
+1ms ╔Received event [TV].switch = Off with a delay of 64ms
+142ms ║RunTime Analysis CS > 13ms > PS > 56ms > PE > 73ms > CE
+145ms ║Runtime (38772 bytes) successfully initialized in 56ms (v0.3.104.20180323) (143ms)
+146ms ║╔Execution stage started
+173ms ║║Comparison (enum) Off changed = false (21ms)
+174ms ║║Condition #8 evaluated false (24ms)
+175ms ║║Condition group #1 evaluated false (state did not change) (25ms)
+178ms ║║Condition group #9 evaluated true (state did not change) (0ms)
+179ms ║║Cancelling statement #10’s schedules…
+185ms ║║Skipped execution of physical command [Front room lamp].off([]) because it would make no change to the device. (3ms)
+185ms ║║Executed [Front room lamp].off (4ms)
+188ms ║╚Execution stage complete. (43ms)
+189ms ╚Event processed successfully (189ms)

Open to suggestions!!!


#6

This is the only way I could make it work, weird isn’t it…! And even then there is a lag between the tv turning on/off and the light doing its thing


#7

FYI, I noticed that the first If statement (in the OP) is returning false due to the following line in your log:

+111ms ║║Comparison (enum) Off changes_to (string) off = false (1ms)

The TV is sending the (enum) Off whereas the comparison is looking for the value (string) off.

It looks like the Samsung TVs are not sending correct values that WebCore can interpret (Off vs. off)

To fix this, you should define two variables for “On” and “Off” and compare Switch 5 to one of the newly created variables.

I ran into this same issue and this worked for me (Mine is basically the same as yours but I have an extra switch that I am monitoring)


#8

@SalisburyJake is correct, I’ve had to do that in my pistons using the TV as a trigger, too. You can get around it without using variables by just writing in the value with a capitalized first letter:

You can do this by changing your “compare to” section to Expression and typing in your value:


#9

Yeah that’s probably a better way to handle this issue


#10

Ah I hadn’t even noticed the lack of capital letter. This will hopefully work!!

Thanks very much. I’ve been making do with any change of TV switch triggering the lights/mode etc but obviously this is annoying sometimes!

I’ll post back if I have any problems.