[SOLVED] LG TV binding Netcast 3.0 issue connecting with TV

Evening everyone,

I am trying to integrate my LG smart tv with openhab (version 2.3.0). From the LG website I got information that TV model has Netcast 3.0 platform (not WebOS) so I installed the correct LG TV binding.

lgtv.cfg was amended as per manual:

# The ip address of the lgtv (required)
#<lgtvId1>.host=
lgtv:lg.host=192.168.1.200

# The TCP port to use (optional, defaults to 8080)
#<lgtvId1>.port=
lgtv:lg.port=8080

# The the pairkey / if it's wrong the device shows the right pairkey
# at every connection attempt
#<lgtvId1>.pairkey=
lgtv:lg.pairkey=

# The TCP port address of the openhab system to receive lgtv status messages
# (only first occurrence is used for all TVs)
#<lgtvId1>.serverport=
lgtv:lg.serverport=8080

# The location to put XML files with the information of availiable
# channels and apps (optional)
#<lgtvId1>.xmldatafiles=./
lgtv:lg.xmldatafiles=./

# The check alive interval (optional, defaults to 60secs)
#<lgtvId1>.checkalive=
lgtv:lg.checkalive=60

Then I used the sitemap and items from manual:

sitemap

}
		Frame label="Tv" {
        Switch item=LgTvConnStatus
        Switch item=LgTvPower mappings=[ON="Power Off"]
        Setpoint item=LgTvChannel minValue=0 maxValue=300 step=1.0
        Setpoint item=LgTvVolume minValue=0 maxValue=100 step=1.0
        Switch item=LgTvMute mappings=[ON="Mute", OFF="Mute"]
        Text item=LgTvChannelName
        Selection item=LgTvChannel mappings=[1="ORF1",2="ORF2"]
        Switch item=LgTvAppExecute label="AppExecute" mappings=[Skype=Skype, Spotify=Spotify]
        Switch item=LgTvAppTerminate label="AppTerminate" mappings=[Skype=Skype, Spotify=Spotify]
    }
    }

items

/* LGTV
Switch LgTvPower                        "Power Command"                 (GF_Living)     {lgtv="ON:lg:POWER"}
Switch LgTvMute                         "Mute"                          (GF_Living)     {lgtv="ON:lg:KEY_MUTE, OFF:lg:KEY_MUTE"}
Number LgTvVolume                       "lgVolume [%.1f]"               (GF_Living)     {lgtv="INIT:lg:VOLUME_CURRENT, INCREASE:lg:VOLUME_UP, DECREASE:lg:VOLUME_DOWN, *:lg:VOLUME_SET"}
Number LgTvChannel                      "Channel [%.1f]"                (GF_Living)     {lgtv="INIT:lg:CHANNEL_CURRENTNUMBER, INCREASE:lg:CHANNEL_UP, DECREASE:lg:CHANNEL_DOWN, *:lg:CHANNEL_SET" }
String LgTvChannelName                  "Channelname [%s]"              (GF_Living)     {lgtv="INIT:lg:CHANNEL_CURRENTNAME"}
String LgTvGetChannels                  "getchannels [%s]"              (GF_Living)     {lgtv="INIT:lg:GET_CHANNELS, ON:lg:GET_CHANNELS"}
String LgTvGetApps                      "getapps [%s]"                  (GF_Living)     {lgtv="INIT:lg:GET_APPS, ON:lg:GET_APPS"}
String LgTvAppExecute                   "excuteapp"                     (GF_Living)     {lgtv="*:lg:APP_EXECUTE"}
String LgTvAppTerminate                 "terminateapp"                  (GF_Living)     {lgtv="*:lg:APP_TERMINATE"}
Switch LgTvConnStatus                   "connstatus "                   (GF_Living)     {lgtv="*:lg:CONNECTION_STATUS"} 

I haven`t restarted my RPI at this point yet - not sure if this should be performed right now or this step is not required.

On openhab app I can`t see any items listed under TV, there is only empty “TV” frame. Not sure exactly where this problem is lying, checking syntax everything appears to be correct.

TV

Checking openhab log I can see the following errors. How do I get per key ?

Searching for an answer on community, I can`t find anyone who would have success with this binding so if we could find solution this would be great tutorial for anyone who is trying to use it. I hope I can find someone who already experienced similar issues before.

Many thanks

try to use this one:

pid:org.openhab.lgtv
lgtv.host=192.168.1.200
lgtv.port=8080
lgtv.pairkey=
lgtv.serverport=8080
lgtv.xmldatafiles=./
lgtv.checkalive=60

you will need the pairkey according to my understanding

Configurations in *.cfg files for legacy (1x) bindings on openHAB2 do not require the binding name prefix (since each legacy binding is using its own *.cfg file)

Also: your alias was lg (not lgtv as in your Items file)

lgtv:lg:...
^^^^:xx
bind:alias

The first line (pid) is used temporarily in order to “clean up” any previous configurations (e.g. the lg alias).
After all is ok, you can remove it from lgtv.cfg

edit: found a typo (mgtv) in: LG TV - Bindings | openHAB :slight_smile:

correction: .port should default to 60128 (not 8080) according to the docs.
change it in lgtv.port=

close the comment :slight_smile: (otherwise your Items are not loaded)

/* LGTV */

According to the docs: “if it’s wrong the device shows the right pairkey at every connection attempt”

Thank you Angelos,

I changed my lgtv.cfg content as follow:

pid:org.openhab.lgtv

# The ip address of the lgtv (required)
#<lgtvId1>.host=
lgtv.host=192.168.1.200

# The TCP port to use (optional, defaults to 8080)
#<lgtvId1>.port=
lgtv.port=60128

# The the pairkey / if it's wrong the device shows the right pairkey
# at every connection attempt
#<lgtvId1>.pairkey=
lgtv.pairkey=548567

# The TCP port address of the openhab system to receive lgtv status messages
# (only first occurrence is used for all TVs)
#<lgtvId1>.serverport=
lgtv.serverport=8080

# The location to put XML files with the information of availiable
# channels and apps (optional)
#<lgtvId1>.xmldatafiles=./
lgtv.xmldatafiles=./

# The check alive interval (optional, defaults to 60secs)
#<lgtvId1>.checkalive=
lgtv.checkalive=60

Since changing tv port number to 60128 I now get pop up message on my TV with pairing key. The number displayed on TV is shown with spaces every two digits , assuming I have to enter it without any spaces between them. So I done that but I still seen the same pop up few times every few minutes.

You mentioned about possible error in items , what exactly I need to change there, sorry I didn`t get that.

Just updated picture from the openhab log

Your Items file needs a small correction:
You started a comment line /* LGTV but never closed the comment (with */)
this means that the entire file is considered as a big comment :slight_smile:

close the comment at the first line to allow OH2 to read the Items

/* LGTV */
^^      ^^
open    close

Or use two forward slashes.:wink:

// LGTV

1 Like

Sorry, I got that , just closed the comment, still no items shown.

does the log file still complain about “cannot retrieve item…” ?

Currently log is displaying error with pair key so still cant connect to tv.

It`s throwing this error every 10 seconds.

Just to mention , I restarted RPI few minutes ago but made no difference.

did you get the pairkey from your TV?
can you post the updated lgtv.cfg file?

lgtv.cfg file looks as follow

pid:org.openhab.lgtv

# The ip address of the lgtv (required)
#<lgtvId1>.host=
lgtv.host=192.168.1.200

# The TCP port to use (optional, defaults to 8080)
#<lgtvId1>.port=
lgtv.port=60128

# The the pairkey / if it's wrong the device shows the right pairkey
# at every connection attempt
#<lgtvId1>.pairkey=
lgtv.pairkey=548567

# The TCP port address of the openhab system to receive lgtv status messages
# (only first occurrence is used for all TVs)
#<lgtvId1>.serverport=
lgtv.serverport=8080

# The location to put XML files with the information of availiable
# channels and apps (optional)
#<lgtvId1>.xmldatafiles=./
lgtv.xmldatafiles=./

# The check alive interval (optional, defaults to 60secs)
#<lgtvId1>.checkalive=
lgtv.checkalive=60

Tv was displaying this key 548567 which I entered in the lgtv.cgf file but still not connecting.

Edit:
Key was shown in three blocks 54 85 67 but assuming no spaces are needed.

why does your log scream about another IP (.19) than the one configured in your lgtv.cfg (.200)?

check the contents of:
/var/lib/openhab2/config/org/openhab/lgtv.config and post them here

Sorry my bad , copied from notepad device ip is correct as per log .19
Corrected content of lgtv.cfg and looks like follow.

pid:org.openhab.lgtv

# The ip address of the lgtv (required)
#<lgtvId1>.host=
lgtv.host=192.168.1.19

# The TCP port to use (optional, defaults to 8080)
#<lgtvId1>.port=
lgtv.port=60128

# The the pairkey / if it's wrong the device shows the right pairkey
# at every connection attempt
#<lgtvId1>.pairkey=
lgtv.pairkey=548567

# The TCP port address of the openhab system to receive lgtv status messages
# (only first occurrence is used for all TVs)
#<lgtvId1>.serverport=
lgtv.serverport=8080

# The location to put XML files with the information of availiable
# channels and apps (optional)
#<lgtvId1>.xmldatafiles=./
lgtv.xmldatafiles=./

# The check alive interval (optional, defaults to 60secs)
#<lgtvId1>.checkalive=
lgtv.checkalive=60

try to access the following 4 URLs from a web browser and report back :slight_smile:

http://192.168.1.19:60128/
http://192.168.1.19:60128/udap/api/pairing
http://192.168.1.19:8080/
http://192.168.1.19:8080/udap/api/pairing

I tried all 4 URL`s but none of them I can access - I tried on two different browsers Internet Explorer and Mozilla Firefox

web1

web2

Pull request created

1 Like

we may need to do some more changes… it is not clear to me what is the correct TCP lgtv.port=
to be used wrt to connecting to the TV

Is it 8080 as described in the comments of the distributed lgtv.cfg (and defaults to 8080 also in the ConfigAdmin with pid:org.openhab.org if not set) or is it 60128 as described in the docs ?

I have no clue :slight_smile:

It looks like it is 60128 (since the TV reacted to this and generated/displayed the 6 digit pairkey) (also missing from docs the fact that the Pair Key (or pairkey ???) is a 6 digit number that should be introduced in the lgtv.cfg without spaces :stuck_out_tongue:

I understand. Do I need to restart openhab after changing port number from 60128 to 8080 ?