nstrelow / ha_philips_android_tv

Home Assistant custom component for the newer (2016+) Philips Android TVs
109 stars 28 forks source link

PUS7304 -The one- doesn't properly report state #32

Closed phaeton82 closed 4 years ago

phaeton82 commented 4 years ago

Stealing the error mentioned in the feature request topic since I have the same issue.

I use the Philips Andoid TV component with a Philips PUS7304. Nearly everything works smoothly except detection of the ON and OFF state of the TV. While the TV is actually OFF, this is detected properly in Home Assistant.

However, when the TV is ON, there is some fluctuation between ON and OFF - see screenshot

160878dfc6df82088f09f68e295196a04287e5d4

even though the TV is ON continuously.

Moreover, it seems that whenever the TV state erroneously is detected as OFF there is also an error in the log file - see below.

2020-01-30 21:35:54 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 327, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/media_player/__init__.py", line 811, in state_attributes
    for attr in ATTR_TO_PROPERTY
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/media_player/__init__.py", line 812, in <dictcomp>
    if getattr(self, attr) is not None
  File "/home/homeassistant/.homeassistant/custom_components/philips_android_tv/media_player.py", line 125, in volume_level
    return self._volume / self._max_volume
TypeError: unsupported operand type(s) for /: 'NoneType' and 'NoneType'

One of the things I want to do by including the TV into Home Assistant is an automation that automatically dims the room when the TV is playing, i.e. ON, and returns the room to regular brightness when the TV is switched OFF. With the intermittent ON and OFF states my Lights continuously change their brightness level.

Any advice is much appreciated.

I don't see the logs above. But I see these errors:

[TV Living room:8009] Failed to connect to service TPM191E-4786f0000cca2e260ea85bad5a5ebe88._googlecast._tcp.local., retrying in 5.0s
7:34 PM /usr/local/lib/python3.7/site-packages/pychromecast/socket_client.py (ERROR)
[TV Living room:8009] Error communicating with socket, resetting connection
7:34 PM /usr/local/lib/python3.7/site-packages/pychromecast/socket_client.py (WARNING)
[TV Living room:8009] Error reading from socket.
7:34 PM /usr/local/lib/python3.7/site-packages/pychromecast/socket_client.py (ERROR)

This is what I see in Lovelace when watching Netflix image

image

PostSven commented 4 years ago

Same issue here with same model TV, sometimes it's working and sometimes it's not (Same for WOL)

mikicof commented 4 years ago

I also have the same problem with the exact same tv, but I’ve found out that it only starts failing when connected to an external device, in my case with the xbox, when on a channel or on any app like netflix is working fine...

Hope that is helpful

mikicof commented 4 years ago

I’ve fixed the line giving the error and I’m still having disconnections, so it seems those are separate problems...

Xilt commented 4 years ago

Same issue here. Trying to make automation relying on tv state but thank to this error automatons become unreliable.

mikicof commented 4 years ago

I found out a workaround #38 that sets the status to unknown instead of off so you can set automations that triggers when goes from off to on specifically so it discards connection drops.

I have an automation that turns on the speakers when the tv goes on and with it works fine, previously i had some times when the speakers turned off itself.

nstrelow commented 4 years ago

Please check if said fix from @mikicof works and improves the reliability.