ollo69 / ha-samsungtv-smart

📺 Home Assistant SamsungTV Smart Component with simplified SmartThings API Support configurable from User Interface.
Apache License 2.0
443 stars 58 forks source link

Problems turning off the TV #10

Closed fredericks1982 closed 4 years ago

fredericks1982 commented 4 years ago

The problem

When I try to switch off my TV from Home Assistant nothing happens on my TV. If I call directly the services media_player.turn_off or media_player.toggle the problem persists, if I send directly the KEY_POWER using the service media_player.play_media it always work perfectly.

Environment

http: base_url: http://192.168.1.XXX:8123 ip_ban_enabled: true login_attempts_threshold: 3

wake_on_lan:

samsungtv_smart:

fillilutten commented 4 years ago

Same here.

Home Assistant Core release: 0.107.4 Operating environment: docker SamsungTV Smart Integration release: v0.1.13 TV model: KS9000 (US) KS8000 (EU) SmartThings integration NOT configured

ollo69 commented 4 years ago

Looking log seems that KEY_POWER command is sent in any case, but I discover a possible issue in the power status check. Can you retry with the last version that I just released (v0.1.15)?

fredericks1982 commented 4 years ago

I've just updated to v0.1.15 and retried, but without success: media_player.toggle doesn't switch off TV (even if the TV entity status is 'on' - checked from dev tools states tab), while calling the media_player.play_media > send_key service shuts down the TV correctly.

ollo69 commented 4 years ago

Command sent to the TV with play_media or with the power off button is exactly the same, the only difference is that the power button check the tv status before sending the command. Also I see from your log that command is sent in any case. You don't have any error in the log?

Does all the other control work properly (volume, play pause etc.) How do you configure the component? Using configuration.yaml or config flow?

fillilutten commented 4 years ago

I just noticed. If the TV is on and I push the power button on my lovelace card the power button color turns as if the TV is off, but the TV is still on. If I then push one more time on the power button the TV turns itself off, but the power button is colored as if the TV is on. And then takes like a minute to detect that it's off and then goes to grey.

ollo69 commented 4 years ago

When you push the power off buttom, the status is forced to off and then start a delay of 20 sec. because normally the TV continue answer to ping for this time. During this period, if you send again a power command, a KEY_POWER is sent again to turn the TV back on. So it seems that you need to send the KEY_POWER 2 times to have the TV answer to the command. Are all the other commands working properly? Are you sure that when you use the MEDIA_PLAY service you don't have to send the command 2 times?

fredericks1982 commented 4 years ago

Just to recap:

ollo69 commented 4 years ago

The only difference between media_player.play_media and media_player.toggle is that the first is an async methon and the second not, but at the end in HA all sync method are async method wrapped, so I do not see any difference. In any case i last version (v0.1.17) I converted the method to async, so try again now.

The local check is the faster and more reliable way to check the TV status. Health check via SmartThings is also done, but status update at SmartThings side obviosly take longer than local.

fillilutten commented 4 years ago

Thanks so much! Its working just perfect for me now. I've always used an IR blaster but this will replace that for this use case.

ollo69 commented 4 years ago

Good to hear. I don't really understood what changed moving method to async, because the WS call is finally sync, but that's it!!

fredericks1982 commented 4 years ago

Thanks @ollo69, now all seems working fine!