core: Cannot connect to Bravia TV after restart when TV is in standby mode

The problem

If home assistant is restarting and the TV is turned off (standby), Home Assistant is not able to control the TV. To get back the ability to control the TV via Home Assistant, I have to turn on the TV by other means. The issue does not occur when the TV is running during a Home Assistant restart.

Environment

  • Home Assistant Core release with the issue: 0.110.5
  • Last working Home Assistant Core release (if known): 0.109.x
  • Operating environment (Home Assistant/Supervised/Docker/venv): Docker
  • Integration causing this issue: Sony Bravia TV
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/braviatv

Problem-relevant configuration.yaml

not applicable - frontend configuration

Traceback/Error logs

none apart the following messages, in the frontend view. Notice: these logs only appear when the initial connection between hass and the tv (controllability exists)

Update of media_player.sony_bravia_tv is taking over 10 seconds
Updating braviatv media_player took longer than the scheduled update interval 0:00:10

Additional information

  • I do not use docker host networking, so WOL is not working
  • When running a custom python script on my notebook and disabling the WOL-code in bravia-tv, I do not have issues
  • issue persists in the release candidate
  • enabling debug logging for homeassistant.components.braviatv and bravia_tv does not provide any info.

Here’s a short gif of what is (not) happening. After a few seconds I manually turned on the tv and controllability is restored Screen_Recording_2020-06-06_at_07 04 55

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 39 (31 by maintainers)

Most upvoted comments

@HorizonKane fair enough. PSK has definitely been more reliable because the cookies don’t ever change (otherwise PSK wouldn’t work). Unfortunately it’s not an option for everyone, which is likely the reason why it never became the official component, even after the original author of the bravia lib went inactive.

@bieniu I see you have a pull request in, but I believe this could be the once and for all fix here. I’ve only tested the bravia lib change and not the Home Assistant change (why I haven’t made a pull request yet). The idea is that is_connected() now actually returns True only when the TV has a working authentication cookie instead of returning True when it has any cookie. This makes the Home Assistant logic simpler and hopefully less prone to these weird edge cases.

Sorry for being absent for awhile; I’ve been a bit burnt out with working from home. That makes total sense now. I’ve got an idea I’ll try in a bit after work.