Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panasonic GX800 series with Panasonic Viera TV integration doesn't works #29088

Closed
maframan opened this issue Nov 25, 2019 · 43 comments · Fixed by #33829
Closed

Panasonic GX800 series with Panasonic Viera TV integration doesn't works #29088

maframan opened this issue Nov 25, 2019 · 43 comments · Fixed by #33829

Comments

@maframan
Copy link

maframan commented Nov 25, 2019

Home Assistant release with the issue:
channel: stable
hassos: "2.11"
homeassistant: 0.102.1
hostname: hassio
logging: info
machine: raspberrypi3
supervisor: "192"
supported_arch:

  • armv7
  • armhf
    timezone: Europe/Rome

Last working Home Assistant release (if known):
homeassistant: 0.102.1

Operating environment (Hass.io/Docker/Windows/etc.):
Hass.io

Integration:
https://www.home-assistant.io/integrations/panasonic_viera/

Description of problem:
Internal server error 500 when press all buttons except the mute button that works.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

  • platform: panasonic_viera
    host: 192.168.102.61
    mac: XX:XX:XX:XX:XX:XX
    app_power: true

Traceback (if applicable):


Additional information:

@springstan
Copy link
Member

Looks similar to #21185. I would advise you to create another issue in the panasonic_viera repo so this can be implemented in the python package that is used in this integration.

@ramondunker
Copy link

Looks similar to #21185. I would advise you to create another issue in the panasonic_viera repo so this can be implemented in the python package that is used in this integration.

It has already been implemented in the package.

@springstan
Copy link
Member

Thanks for the tip @ramondunker, in which version has this device been implemented?

@ramondunker
Copy link

Oh I'm sorry @springstan, I was looking at the wrong issue.

Issue I'm having is this one:
florianholzapfel/panasonic-viera#9

It has been addressed in the latest init.py (https://github.com/florianholzapfel/panasonic-viera/blob/master/panasonic_viera/__init__.py), but hasn't been implemented in Home Assistant.

@springstan
Copy link
Member

No worries.

@ramondunker could you test the newest version of panasonic_viera in Home Assistant and report back so that it can be implemented?

@ramondunker
Copy link

I would if you could explain how to implement it in my own Home Assistant setup :-). @springstan

@springstan
Copy link
Member

Well you could easily update your version of panasonic_viera by adjusting the following lines
https://github.com/home-assistant/home-assistant/blob/e793ed9ab0b8857ba0aa88a7e7bfb8accd7761b2/requirements_all.txt#L968-L969
https://github.com/home-assistant/home-assistant/blob/e793ed9ab0b8857ba0aa88a7e7bfb8accd7761b2/homeassistant/components/panasonic_viera/manifest.json#L5
to include panasonic_viera==0.3.4. By restarting your Home Assistant setup the mentioned version will be installed automatically and you can test it out ✌

@ramondunker
Copy link

Okay thanks but where can I find those files? Looked at /config/deps but nothing in there. @springstan

@ramondunker
Copy link

Okay thanks but where can I find those files? Looked at /config/deps but nothing in there. @springstan

I'm using a Raspberry Pi Zero W with Hassio.

@springstan
Copy link
Member

Oh I am sorry but I believe this does not work under Hassio. However, you could set up a new development environment and test it there.

@ramondunker
Copy link

Okay thankyou. I will look into that after my tests! If it works on my dev environment, can I implement it into Hassio? @springstan

@springstan
Copy link
Member

Sorry I am not too familiar with Hassio, therefore I cannot give you a concrete answer to that question. Still thank you very much for testing this out 👍

@ramondunker
Copy link

Okay I've installed a dev environment and installed 0.3.4. I edited configuration.yaml to include the mediaplayer. I'm getting the error: Failed to call service media_player/media_play_pause. Please refer to the docs for using encryption.

Could you help me find out how to get the encryption? @springstan

@springstan
Copy link
Member

I think that this error message comes from the used library, therefore it looks like encryption needs to be implemented into the Home Assistant Panasonic viera component. The docs referring to the documentation of the library, which probably includes an example of how to use encryption.

@ramondunker
Copy link

ramondunker commented Jan 12, 2020

Okay I worked it out! I placed this code inside media_player.py:

import panasonic_viera rc = panasonic_viera.RemoteControl("192.168.1.52") Make the TV display a pairing pin code rc.request_pin_code() Interactively ask the user for the pin code pin = raw_input("Enter the displayed pin code: ") Authorize the pin code with the TV rc.authorize_pin_code(pincode=pin) Display credentials (application ID and encryption key) print rc._app_id print rc._enc_key We can now start communicating with our TV Send EPG key rc.send_key(panasonic_viera.Keys.epg)

And I changed the volume_up function to:

def volume_up(self): """Volume up the media player.""" volume = self.rc.get_volume() self.rc.set_volume(volume + 1)

And it works. I guess every function has to be changed to use the key to make it all working.

@ramondunker
Copy link

Got it working. Now when I turn the tv off and I want to turn it back on it gives an Error 500: Internal server error. Any ideas? @springstan

@springstan
Copy link
Member

Not really sure what is causing this server error, unfortunately I do not own a panasonic viera device myself so I cannot test it myself.

@SeanHub
Copy link

SeanHub commented Jan 31, 2020

@ramondunker do you think you could put your code changes together in a pull-request? I'd also like to use this integration with my TV but can't because of the missing encryption. Hopefully your code can get merged into the master branch.

@ramondunker
Copy link

I'm not sure if that's going to work because there is no UI for entering the PIN inside Home Assistant. It has to be done with CLI. @SeanHub

@Depechie
Copy link

Depechie commented Feb 3, 2020

Hmm @springstan my hassbian install of home assistant is missing that manifest file in the Panasonic integration folder? Or am I looking at this in the wrong place?

@SeanHub
Copy link

SeanHub commented Feb 3, 2020

@ramondunker fair point, maybe a one time script could run the pin code functionality and the app_id and encryption_key that is returned could then be placed in the configuration values for the integration, for example:

media_player:
- platform: panasonic_viera
host: 192.168.0.10
app_id: BSkeeKuuwakd9Q==
encryption_key: EarvNQodKYlj5zTEIhZoXQ==

@springstan
Copy link
Member

springstan commented Feb 3, 2020

Hmm @springstan my hassbian install of home assistant is missing that manifest file in the Panasonic integration folder? Or am I looking at this in the wrong place?

@Depechie No, you are looking in the right place. Not sure why it is missing but I would recommend to create it (manifest.json) manually just to be safe.

@ramondunker
Copy link

Well you could easily update your version of panasonic_viera by adjusting the following lines
https://github.com/home-assistant/home-assistant/blob/e793ed9ab0b8857ba0aa88a7e7bfb8accd7761b2/requirements_all.txt#L968-L969
https://github.com/home-assistant/home-assistant/blob/e793ed9ab0b8857ba0aa88a7e7bfb8accd7761b2/homeassistant/components/panasonic_viera/manifest.json#L5
to include panasonic_viera==0.3.4. By restarting your Home Assistant setup the mentioned version will be installed automatically and you can test it out ✌

Does it have to be a development environment? Or would a manual install of Home Assistant suffice?

@joogps
Copy link
Contributor

joogps commented Mar 30, 2020

I made a pull request that updates the component to support encryption (with persistent data and all). I just need to figure out how to make the tests pass (it's the first time I ever contribute to HA).

@ramondunker
Copy link

I made a pull request that updates the component to support encryption (with persistent data and all). I just need to figure out how to make the tests pass (it's the first time I ever contribute to HA).

Wow good job! I noticed my integration with my tv isn’t working anymore. I’m getting CancelledError error.

@joogps
Copy link
Contributor

joogps commented Mar 30, 2020

The panasonic_viera integration still needs a lot of improvements. For example, it fails to generate the media_player entity if a connection can't be established (differently from webostv). But I'll try to work on it! Just need to finish some school stuff...

@Depechie
Copy link

Woow awesome work @joogps !! Can’t wait to get this up and running.

@joogps
Copy link
Contributor

joogps commented Apr 18, 2020

You’re welcome! Once you update your installation, you will be able to configure the integration either via YAML or the UI 😊

@ramondunker
Copy link

You’re welcome! Once you update your installation, you will be able to configure the integration either via YAML or the UI 😊

It seems that my TV isn't syncing. It shows that it's off in HA, but it is turned on.

@joogps
Copy link
Contributor

joogps commented Apr 20, 2020

Well, it takes some seconds... Did you check if the entity is set as 'unavailable'? Also check the logs to see if there are any connection errors happening!

@ramondunker
Copy link

I noticed that this occurs when I use the TV remote. Home Assistant doesn't sync the changed state when turned on or off with the TV remote. Have you had this issue aswel?

@joogps
Copy link
Contributor

joogps commented Apr 20, 2020

Nope, mine just syncs perfectly. Maybe it's not updating itself, I need to investigate on that.

@Depechie
Copy link

hey @joogps I have a GZ950 and the new integration asked the pin connect and the new entity does show on / off status fine of the TV.
Turning it off works too, but turning it on will result in Unavailable in Home Assistant and this error log:

Logger: custom_components.panasonic_viera.media_player
Source: custom_components/panasonic_viera/media_player.py:224
First occurred: April 26, 2020, 11:48:46 PM (2 occurrences)
Last logged: April 26, 2020, 11:56:50 PM

Could not establish remote connection:

@joogps
Copy link
Contributor

joogps commented Apr 26, 2020

That's probably because your TV disconnects when it turns off. You could try to define a turn_on_action (which will override the default turn on method) to something that would be able to turn the TV on. In this case, wake-on-lan would be a good option.

wake_on_lan:

panasonic_viera:
  host: 192.168.0.1 # This is the IP address of your TV
  turn_on_action:
      - service: wake_on_lan.send_magic_packet
        data:
          mac: "AA:BB:CC:DD:99:1A" # This is the MAC address of your TV

However, not all TVs and connection methods support it. Mine doesn't while connected via Wi-Fi, but maybe it would if I had connected it through the Ethernet port. Good luck!

@Depechie
Copy link

Any idea @joogps why the official Panasonic app ( on my iPhone ) can start the TV than? Is it using another method you think?
( I will try the WOL packet later )

@joogps
Copy link
Contributor

joogps commented Apr 26, 2020

It's probably using wake-on-lan too. :)

@joogps
Copy link
Contributor

joogps commented Apr 26, 2020

Also, @Depechie quick question: are you using Wi-Fi or ethernet? I'm curious because my TV doesn't support wake-on-lan while on Wi-Fi and I can't use Ethernet.

@joogps
Copy link
Contributor

joogps commented Apr 26, 2020

By the way, the documentation page will be updated when Home Assistant gets updated. There you can find more info about customization. :)

@Depechie
Copy link

Well it is indeed connected through WiFi and the turn action has no effect with WOL. Still weird the Panasonic app has no issues.

@Depechie
Copy link

For reference it now gives another error:

An unknown error occurred: local variable 'res' referenced before assignment
Traceback (most recent call last):
File "/home/homeassistant/.homeassistant/custom_components/panasonic_viera/media_player.py", line 217, in async_create_remote_control
partial(RemoteControl, self._host, self._port, **params)
File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/homeassistant/lib/python3.7/site-packages/panasonic_viera/init.py", line 164, in init
self._request_session_id()
File "/srv/homeassistant/lib/python3.7/site-packages/panasonic_viera/init.py", line 412, in _request_session_id
root = ET.fromstring(res)
UnboundLocalError: local variable 'res' referenced before assignment

@joogps
Copy link
Contributor

joogps commented Apr 26, 2020

For reference it now gives another error:

An unknown error occurred: local variable 'res' referenced before assignment

That's a problem with the panasonic_viera library when the connection is not successful. My latest pull request fixes it.

Well it is indeed connected through WiFi and the turn action has no effect with WOL. Still weird the Panasonic app has no issues.

That's strange... I will download the app and see if I can figure out how it works.

@Depechie
Copy link

Still, already thx for all the work!! I think with this new version I can already do all the automations I was thinking about. Turning ON the TV is not a high prio for me at the moment ;)

@joogps
Copy link
Contributor

joogps commented Apr 26, 2020

That makes me very happy! :D

If you need to send remote key commands for your automations, I'm working on it too: #34444

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants