[SOLVED] LG Webos Binding issue & Wake on LAN WOL

  • Hardware: Raspberry Pi 3
  • OS: raspbian
  • Java Runtime Environment: last update
  • openHAB version: 2.3.0-1
  • Issue of the topic: LG Webos Binding not working properly only Channels change.

Hi there,
My system is working perfectly. Now I am trying to setup the LG Webos Binding:
https://docs.openhab.org/addons/bindings/lgwebos/readme.html

The 2 only things that are not working properly are:

Power ON, but in the doc is said that is not working so far.

DESCRIPTION. Current power setting. TV can only be powered off, not on.	

and channels, I cannot get change them the setup.

ITEMS:

Dimmer LG_TV0_Volume "Volume [%S]"           { channel="lgwebos:WebOSTV:8c6bbc16-8ef5-4e80-aed4-d0f88417353d:volume" }
Number LG_TV0_VolDummy "VolumeUpDown"
Number LG_TV0_ChannelNo "Channel [%d]"       { channel="lgwebos:WebOSTV:8c6bbc16-8ef5-4e80-aed4-d0f88417353d:channel" }
Number LG_TV0_ChannelDummy "ChannelUpDown"
String LG_TV0_Channel "Channel [%S]"         { channel="lgwebos:WebOSTV:8c6bbc16-8ef5-4e80-aed4-d0f88417353d:channelNam$

RULES:

// for relative volume changes
rule "VolumeUpDown"
when Item LG_TV0_VolDummy received command
then
    switch receivedCommand{
        case 0: LG_TV0_Volume.sendCommand(DECREASE)
        case 1: LG_TV0_Volume.sendCommand(INCREASE)
    }
end

// for relative channel changes
rule "ChannelUpDown"
when Item LG_TV0_ChannelDummy received command
then
    switch receivedCommand{
        case 0: LG_TV0_ChannelNo.sendCommand(DECREASE)
        case 1: LG_TV0_ChannelNo.sendCommand(INCREASE)

    }
end

Maybe the rule, we are missing something?

The rest of items works fine, I can open netflix, TV Guide and so on, power is working only to OFF, but not to ON, volumen works fine…

Thank you in advance.

Your LG_TV0_ChannelNo item is a Number item. It doesn’t accept the command INCREASE or DECREASE.
The Volume works because it is a Dimmer item.

Change your code to:

// for relative channel changes
rule "ChannelUpDown"
when Item LG_TV0_ChannelDummy received command
then
    val Number Channel = LG_TV0_ChannelNo.state as Number
    switch receivedCommand {
        case 0: LG_TV0_ChannelNo.sendCommand(Channel - 1)
        case 1: LG_TV0_ChannelNo.sendCommand(Channel + 1)
    }
end

There may be a problem with that code when the channel number is 1 and you decrease the number
I don’t know if the LG TV accept the channel number 0
You may need to check in the number is 0 and chage it to the max channel number to cycle through the channels
The same goes when you get to the max channel number
Your code would the be: (Assuming that you have 199 channels)

// for relative channel changes
rule "ChannelUpDown"
when Item LG_TV0_ChannelDummy received command
then
    if (receivedCommand == NULL) return; do nothing if NULL command received
    var Number Channel = LG_TV0_ChannelNo.state as Number
    switch receivedCommand {
        case 0: Channel = Channel - 1
        case 1: Channel = Channel + 1
    }
    if (Channel == 0) Channel = 199
    if (Channel == 200) Channel = 1
    LG_TV0_ChannelNo.sendCommand(Channel)
end

Thank you for the answer.
I get this error:

2018-08-29 10:34:31.881 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'home.rules' has errors, therefore ignoring it: [431,12]: mismatched input 'Channel' expecting 'end'

What it line 412?

val Number Channel = LG_TV0_ChannelNo.state as Number

The rule:

rule "ChannelUpDown"
when Item LG_TV0_ChannelDummy received command
then

val Number Channel = LG_TV0_ChannelNo.state as Number

    switch receivedCommand{
        case 0: Channel = Channel - 1
        case 1: Channel = Channel + 1
    }

    LG_TV0_ChannelNo.sendCommand(Channel)

end

Whe it is working, I will add the limit channel, but My TV has more than 199 channel :confused:

You need to change to var instead of val

var Number Channel = LG_TV0_ChannelNo.state as Number

Still error:

2018-08-29 10:51:54.034 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'home.rules' has errors, therefore ignoring it: [431,12]: mismatched input 'Channel' expecting 'end'

What is line 431?

with var…

        var Number Channel = LG_TV0_ChannelNo.state as Number

Try this:

var Channel = LG_TV0_ChannelNo.state as Number

ufff now I get this:

2018-08-29 11:14:07.795 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'home.rules' has errors, therefore ignoring it: [431,6]: no viable alternative at input 'Channel'
[434,17]: no viable alternative at input 'Channel'
[434,35]: missing '}' at '-'
[435,9]: mismatched input 'case' expecting 'end'
```

```
rule "ChannelUpDown"
when Item LG_TV0_ChannelDummy received command
then
//Line 431
var Channel = LG_TV0_ChannelNo.state as Number

    switch receivedCommand{
        case 0: Channel = Channel - 1
        case 1: Channel = Channel + 1
    }

    LG_TV0_ChannelNo.sendCommand(Channel)

end

```

Allright maybe Channel is reserved try changing the name of the variable:

rule "ChannelUpDown"
when Item LG_TV0_ChannelDummy received command
then
var channelNo = LG_TV0_ChannelNo.state as Number
    switch receivedCommand {
        case 0: channelNo = channelNo - 1
        case 1: channelNo = channelNo + 1
    }
    LG_TV0_ChannelNo.sendCommand(channelNo)
end

:smiley:
yes, that was the issue. I was trying in parallel while waiting your answer, and that was the issue.

Now, is working, cool. Only for changing channel, there is a delay of 3-4 seconds, for volume and other thing, no delay. I guess this is normal, I do not know…

About the issue with Power up, this will be solved in the future?
And, what about for more than 199 channels limitation? My TV has more than 199.

thanks.

For power the binding can’t turn the TV on because the TV’s API isn’t running while the TV is off. If you look at the binding docs for the WebOS binding I believe they explain how you can power the TV on using the wake on lan binding. I do this with my webos 3.5 TV and it works great.

Thanks for the answer.

Actually I have setup the WOL, but something I am missing because is not working the arping. I have this info in the log, and the macaddress is not right, I miss " : "…

2018-08-29 16:16:04.005 [INFO ] [nhab.binding.wol.internal.WolBinding] - Wake-on-LAN packet sent [broadcastIp=192.168.2.255, macaddress=31a8de07b52e]
  • I have the binding installed
  • And the item is:
Switch LG_TV0_WOL                            { wol="192.168.2.255#31:A8:DE:07:B5:2E" }
1 Like

It could be nice to update the doc, I do not know if I could, or should be done by OH developers?
:smiley:

Everyone is free to submit a PR. There is a review process so no one can run amok and mess up the docs willy nilly. :slight_smile:

1 Like

Could you please have a look on my items? WOL for me is not working. I am missing something?
Thank you.

OK, I found the answer here, I had to activate the option from the TV on settings. It seems that now is working.

ok, everything is working perfectly now.

I only have this warning, I do not know about what, but everything works fine:

2018-08-29 23:30:25.933 [WARN ] [mmon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception
java.lang.NullPointerException: null
	at org.openhab.binding.lgwebos.internal.BaseChannelHandler.refreshSubscription(BaseChannelHandler.java:59) ~[?:?]
	at org.openhab.binding.lgwebos.handler.LGWebOSHandler.lambda$4(LGWebOSHandler.java:210) ~[?:?]
	at java.util.HashMap.forEach(HashMap.java:1289) [?:?]
	at java.util.Collections$UnmodifiableMap.forEach(Collections.java:1505) [?:?]
	at org.openhab.binding.lgwebos.handler.LGWebOSHandler.refreshAllChannelSubscriptions(LGWebOSHandler.java:210) [239:org.openhab.binding.lgwebos:2.3.0]
	at org.openhab.binding.lgwebos.handler.LGWebOSHandler.onCapabilityUpdated(LGWebOSHandler.java:156) [239:org.openhab.binding.lgwebos:2.3.0]
	at com.connectsdk.device.ConnectableDevice$2.run(ConnectableDevice.java:217) [239:org.openhab.binding.lgwebos:2.3.0]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]
```

Awesome, glad you got it working!

I seem to get this same exception every time my TV is turned off. I’m sure it’s due to the TV dropping the connection with the binding as it’s powered off.