Get current state (on/off) of panasonic tv

Hi everyone,

I really like the panasonic tv binding, but i’m missing a way to get the current state of the tv (on/off). I tried network binding and fritzbox tr064, but it’s not very accurate because my tv seems to get active in the middle of the night (getting updates, ???).

Is there a way to get the state (on/off) of my tv reliably?

I finally found out how to turn on my tv (55AS750-Series) using panasonic tv binding. I had to enable the following setting (in german):
“Netzwerk > TV Remote Einstellungen: Einschalten per App”
(In english maybe: network > TV remote settings: switch on by app)

The binding command {panasonictv=“tv:POWER”} is just a toggle button, so I don’t know if I switched the tv on or off.

Any ideas?

Sebastian

Hello,

I have a 6 years old Panasonic TV and the binding doesn’t work.

For the state ON or OFF i look the online State over the IP address

And then I linked a item with the online state

In the Control Panel you see the state

Now you can look for the item state or make a rule for the On and OFF…
I hope this helps

1 Like

Hi Andy,

thanks for sharing your solution! I’m doing it your way now.

I just liked the idea of powering on my tv using an openhab rule. But to do this I have to enable “Power On by App” in my tv settings. Unfortunately this means that my tv is always “pingable” and therefor is Online in openhab even if it is not running.

I measured power usage of the tv: when “Power On by App” is enabled and the tv is off, it draws 13.3W! (in running mode it is ~48W) So I don’t need/want to power on my tv by rule any more :slight_smile: When I disable “Power On by App” it uses 0.0W (Model TX-55ASW754)

If someone is interested, I found a nice python script to control a panasonic tv: https://github.com/florianholzapfel/panasonic-viera
With this script it was possible to power on and off the tv (“Power On by App” was enabled) and it returned an error if you sent a command and the tv was switched off. The openhab binding always returns “200 OK” even if the tv is not running. Maybe someone wants to dig deeper.

Have a nice day!

Hi Andy,
Some panasonic TV’s send data to a multicast group. I assume it is part of the Discovery function for the Android and iOS apps. When the TV is turned on, it immediately sends out a multicast to port 1900 as below.

Ethernet II, Src: WistronN_f1:65:5a (60:02:b4:f1:65:5a), Dst: IPv4mcast_7f:ff:fa (01:00:5e:7f:ff:fa)
Internet Protocol Version 4, Src: 192.168.Y.XX, Dst: 239.255.255.250
0100 … = Version: 4
… 0101 = Header Length: 20 bytes
Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
Total Length: 368
Identification: 0x9c00 (39936)
Flags: 0x00
Fragment offset: 0
Time to live: 4
Protocol: UDP (17)
Header checksum: 0x66c1 [validation disabled]
Source: 192.168.Y.XX
Destination: 239.255.255.250
[Source GeoIP: Unknown]
[Destination GeoIP: Unknown]
User Datagram Protocol, Src Port: 13719 (13719), Dst Port: 1900 (1900)
Source Port: 13719
Destination Port: 1900
Length: 348
Checksum: 0x9f73 [validation disabled]
[Stream index: 529]
Hypertext Transfer Protocol
NOTIFY * HTTP/1.1\r\n
HOST: 239.255.255.250:1900\r\n
CACHE-CONTROL: max-age=1800\r\n
LOCATION: http://192.168.Y.XX:55000/dmr/ddd.xml\r\n
NT: urn:schemas-upnp-org:service:AVTransport:1\r\n
NTS: ssdp:alive\r\n
SERVER: FreeBSD/8.0 UPnP/1.0 Panasonic-MIL-DLNA-SV/1.0\r\n
USN: uuid:4D454930-0100-1000-8001-20C6EBEC2E6A::urn:schemas-upnp-org:service:AVTransport:1\r\n
\r\n
[Full request URI: http://239.255.255.250:1900*]

If the binding matched the source address and multicast to port 1900 then it could provide status. Not sure how to do this, may be there is a feature request for the binding.

dkw

Possible Solution to get current state (on/off) of Panasonic TV

Expected Behavior
Some kind of Switch to see the actual state

Current Behavior
You can‘t see if the TV is running or not

Possible Solution (works with my TX-55ASW654 )
If the TV is running, there is an XML Structure at Port 55000 of your TV IP Adress. If it‘s not running the structure is missing. And so you can check if a part of the xml File, for example 1 is available.

http://192.xxx.xxx.xx:55000/dmr/ddd.xml (IP of your TV)

XML File:

<?xml version="1.0" encoding="UTF-8"?> 1 0 and so on...

What to do:

  1. Install the HTTP Binding

  2. At Configuration/Services create a file http.cfg which contains:
    timeout=1000
    granularity=1000
    format=true

panazustand.url=http://192.xxx.xxx.xx:55000/dmr/ddd.xml
panazustand.updateInterval=1000

  1. In your Item File add:

  2. Add to your Sitemap:
    Text item=tvistanaus label=“TV [%s]” icon=“cinema”

  3. Create a rule file. I named it Panasonicrefresh.rules with:

rule “Panasonicrefresh”
when
Item tvzustand changed
then
if (tvzustand.state.toString === null) {
logInfo(“FILE”,“TV is off R:Panasonicrefresh” )

postUpdate(tvistanaus, OFF)
}
else if (tvzustand.state.toString == "1") { 	
logInfo("FILE","TV is  on  R:Panasonicrefresh" )

postUpdate(tvistanaus, ON)

}
end

  1. What you have to know: It takes a few seconds (about 30) for the condition to change

And now?

It‘s working for me and my TV. Maybe someone can test it on his/her TV and I hope someone can complete the binding with this or a compatible solution.

My Environment
OH 2.2. on Raspberry Pi 3

1 Like

I don’t have a Panasonic TV, but here’s a more generic solution.

We recently purchased a TCL Roku TV. It has a fairly robust API, but I wasn’t happy with any of the available methods for getting timely status updates. On the Roku TV, the board seems to stay awake (and therefore pingable) for about 15 minutes after turning it off. That means that the network binding by itself isn’t a reliable way to get status.

The API has a method for returning information about the TV, including the power state, but that means two things. First, I would have to rely on at least two different items and some rules to get the status; information from the API as well as the network binding since the API obviously won’t be accessible once it goes into deep sleep. Second, I would have to be hitting the API quite a bit to get timely updates.

What I ended up doing is attaching a an ESP8266 with a photoresistor to the LED on the bottom of the TV that is on when it is powered off. With ESPEasy, this was pretty trivial and I get instant updates with no polling. I hate polling.

Also, as far as having to keep the TV in a higher power mode to turn it on remotely, you might see if sending a WOL packet before the power on command. On the TCL, after the 15 minutes when the board goes to sleep I have to send a WOL to get it to a state where the API is accessible again. This means you will probably have to hard wire the TV.

1 Like

Thanks for your input, an interesting solution. You also can control the state of your TV by measuring the power consumption with a Z Wave wall plug.
I was looking for a „built in“ software solution. :slightly_smiling_face:

Hi,

I followed your instructions, but somehow it wont work as expected.

My situation:

  1. Pansonic TV works (xml is available when on; and not when of)
<?xml version="1.0"?>
  <root xmlns="urn:schemas-upnp-org:device-1-0" xmlns:vli="urn:schemas-panasonic-com:vli" xmlns:viera="urn:schemas-panasonic-com:viera">
  <specVersion><major>1</major><minor>0</minor></specVersion>
  <device>
    <deviceType>urn:schemas-upnp-org:device:MediaRenderer:1</deviceType>
    <friendlyName>55AS650_Series</friendlyName>
    <manufacturer>Panasonic</manufacturer>
    <modelName>Panasonic VIErA</modelName>
    <modelNumber>TX-55AS650W</modelNumber>
    <UDN>uuid:4D454930-0100-1000-8001-20C6EBE0FE49</UDN>
    <viera:X_DMSUDN>uuid:4D454930-0000-1000-8001-20C6EBE0FE49</viera:X_DMSUDN>
    <viera:X_DMRUDN>uuid:4D454930-0100-1000-8001-20C6EBE0FE49</viera:X_DMRUDN>
    <viera:X_NRCUDN>uuid:4D454930-0200-1000-8001-20C6EBE0FE49</viera:X_NRCUDN>
    <vli:X_MHC_DEVICE_ID>5900199219426476</vli:X_MHC_DEVICE_ID>
    <iconList>
      <icon>
        <mimetype>image/png</mimetype>
        <width>48</width>
        <height>48</height>
        <depth>24</depth>
        <url>/dmr/dlna_icon_48.png</url>
      </icon>
      <icon>
        <mimetype>image/png</mimetype>
        <width>120</width>
        <height>120</height>
        <depth>24</depth>
        <url>/dmr/dlna_icon_120.png</url>
      </icon>
      <icon>
        <mimetype>image/jpeg</mimetype>
        <width>48</width>
        <height>48</height>
        <depth>24</depth>
        <url>/dmr/dlna_icon_48.jpg</url>
      </icon>
      <icon>
        <mimetype>image/jpeg</mimetype>
        <width>120</width>
        <height>120</height>
        <depth>24</depth>
        <url>/dmr/dlna_icon_120.jpg</url>
      </icon>
    </iconList>
    <dlna:X_DLNADOC xmlns:dlna="urn:schemas-dlna-org:device-1-0">DMR-1.50</dlna:X_DLNADOC>
    <serviceList>
      <service>
        <serviceType>urn:schemas-upnp-org:service:RenderingControl:1</serviceType>
        <serviceId>urn:upnp-org:serviceId:RenderingControl</serviceId>
        <SCPDURL>/dmr/sdd_0.xml</SCPDURL>
        <controlURL>/dmr/control_0</controlURL>
        <eventSubURL>/dmr/event_0</eventSubURL>
      </service>
      <service>
        <serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType>
        <serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId>
        <SCPDURL>/dmr/sdd_1.xml</SCPDURL>
        <controlURL>/dmr/control_1</controlURL>
        <eventSubURL>/dmr/event_1</eventSubURL>
      </service>
      <service>
        <serviceType>urn:schemas-upnp-org:service:AVTransport:1</serviceType>
        <serviceId>urn:upnp-org:serviceId:AVTransport</serviceId>
        <SCPDURL>/dmr/sdd_2.xml</SCPDURL>
        <controlURL>/dmr/control_2</controlURL>
        <eventSubURL>/dmr/event_2</eventSubURL>
      </service>
    </serviceList>
  </device>
</root>
  1. I get this, doesnt matter if TV is of or on

Here is my log, what I dont understand is the question mark “?”

2019-01-27 11:23:09.041 [vent.ItemStateChangedEvent] - tvzustand changed from ? to
2019-01-27 12:00:41.636 [vent.ItemStateChangedEvent] - tvzustand changed from to ?

  1. My config:
    http.cfg
# timeout in milliseconds for the http requests (optional, defaults to 5000)

timeout=1000

# the interval in milliseconds when to find new refresh candidates

# (optional, defaults to 1000)

granularity=1000

# whether to substitute the current time or state value into the URL

# (optional, defaults to true)

format=true

# configuration of the first cache item

panazustand.url=http://192.168.10.136:55000/dmr/ddd.xml

panazustand.updateInterval=1000

# configuration of the second cache item

#&lt;id2&gt;.url=

#&lt;id2&gt;.updateInterval=

xxx.items

//Panasonic TV Alex Zimmer

String tvzustand {http="&lt;[panazustand:30000:REGEX(.?(.?).*)]"}

Switch tvistanaus

Panasonicrefresh.rules

rule "Panasonicrefresh"

when

Item tvzustand changed

then

if (tvzustand.state.toString === null) {

logInfo("FILE","TV is off R:Panasonicrefresh" )

postUpdate(tvistanaus, OFF)

}

else if (tvzustand.state.toString == "1") {

logInfo("FILE","TV is on R:Panasonicrefresh" )

postUpdate(tvistanaus, ON)

}

end

Any ideas?

I think it is doing what you tell it to. Try improving the Item definition -
Switch tvistanaus "My TV [%s]"

Me neither. Something that doesn’t display properly, like an XML fragment.

I’m no good with REGEX, but I suspect it is not giving the string you expect.
You can find out by adding a logInfo to your rule
logInfo ("testing", "mystery response " + tvzustand.state.toString)

Is the intention just to see if you get a response or not?
You could change your if-elseif to if-else

Ok, thanks for response.

  1. improvement of the item did not work, what should it be doing in your opinion?
  2. Added the loginfo and got the folling log:
[lipse.smarthome.model.script.testing] - mystery response ?

So I assume I get at least a response right? And the response is “?” ?

The intention in fact is to get a response or not, bcause the dedicated “ddd.xml” is only available in my browser when the TV is on, when TV is of i get HTTP ERROR 400.
So I changed the .rules file to:

rule "Panasonicrefresh"

when

Item tvzustand changed

then

logInfo ("testing", "mystery response " + tvzustand.state.toString)

if (tvzustand.state.toString === null) {

logInfo("FILE","TV is off R:Panasonicrefresh" )

postUpdate(tvistanaus, OFF)

}

else (tvzustand.state.toString == "1") {

logInfo("FILE","TV is on R:Panasonicrefresh" )

postUpdate(tvistanaus, ON)

}

end

But now I get always TV is on, doesnt matter if TV is ON or not.

2019-01-27 14:38:39.431 [INFO ] [lipse.smarthome.model.script.testing] - mystery response 
2019-01-27 14:38:39.448 [INFO ] [.eclipse.smarthome.model.script.FILE] - TV is  on  R:Panasonicrefresh

That part is a nonsense; else is just else, with no condition.

OK, so this part is never satisfied. I think that’s because an empty string is not null. Try == "" instead, or change your if-else around to look for “?” for ON.

The [%s] part should give you string version of the Item’s value in your UI, for a switch that would be ON or OFF (or - for NULL)
But that behaviour could be overridden by your sitemap that we can’t see.

You mean?

if (tvzustand.state.toString == "")

Hi Alex,

you followed my instructions and it should work. Your http.cfg and your rule looks fine. Have a look at your transformations in the Paper UI, maybe somethings missing?

Hope it works and you will enjoy.
Greetz Günter

I have only the Regex Transformation installed, this should be enough or do I need to install other transformation as well?

The MAP Transformation is not necessary. Try to install Xpath and XSLT to solve the problem.
Its about a year ago and I dont remember everything exactly :roll_eyes: There was a lot of OpenHAB things to do in the meantime…

Have both installed, no change… still getting log:

tvzustand changed from ? to

and vise versa when switching on or off…

Your http.cfg is fine. Change your Item File to:

Now I get

2019-02-03 02:34:30.257 [vent.ItemStateChangedEvent] - tvzustand changed from 1 to 
2019-02-03 07:13:19.405 [vent.ItemStateChangedEvent] - tvzustand changed from  to 1

But still

Maybe something with the rule is wrong?

rule "Panasonicrefresh"
when
Item tvzustand changed
then
if (tvzustand.state.toString === null ) {
logInfo ("FILE","TV is off R:Panasonicrefresh")
logInfo ("testing", "mystery response " + tvzustand.state.toString)
postUpdate(tvistanaus, OFF)
}
else if (tvzustand.state.toString == "?") {
logInfo("FILE","TV is on R:Panasonicrefresh" )
logInfo ("testing", "mystery response " + tvzustand.state.toString)
postUpdate(tvistanaus, ON)
}
end

I added some log infos, can this be an issue?

Well, yes, you’ve changed what states the Item takes, but not what the rule is looking for.
Discussed earlier that tvzustand.state.toString === null is not the same as empty string “”

rule "Panasonicrefresh"
when
   Item tvzustand changed
then
   if (tvzustand.state.toString == "1") {
      logInfo("FILE","TV is on R:Panasonicrefresh" )
      tvistanaus.postUpdate(ON)
   } else {
      logInfo ("FILE","TV is off or stolen")
      tvistanaus.postUpdate(OFF)
   }
end

It works!! Thx a lot! Couldnt do without your help!