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

Problems turning off the TV #10

Closed
fredericks1982 opened this issue Apr 15, 2020 · 11 comments
Closed

Problems turning off the TV #10

fredericks1982 opened this issue Apr 15, 2020 · 11 comments

Comments

@fredericks1982
Copy link

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

  • Home Assistant Core release: 0.107.7
  • Operating environment: docker
  • SamsungTV Smart Integration release: v0.1.13
  • TV model: KU6500
  • SmartThings integration configured
  • Problem-relevant configuration.yaml:
default_config:

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

wake_on_lan:

samsungtv_smart:
  - host: 192.168.1.YYY
    app_list: '{"Plex": "3201512006963/KIciSQlYEM.Plex", "RaiPlay": "5im3FztIhW.RaiTVtizen", "YouTube": "111299001912/9Ur5IzDKqV.TizenYouTube", "Prime Video": "3201512006785/org.tizen.ignition", "TuneIn": "tisT7SVUug.tunein"}'
    show_channel_number: true

Traceback/Error logs

Calling media_player.turn_off service >> NOT WORKING

2020-04-15 15:57:00 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.140xxxx6068xxxx] Received {'type': 'call_service', 'domain': 'media_player', 'service': 'turn_off', 'service_data': {'entity_id': 'media_player.tv'}, 'id': 28}
2020-04-15 15:57:00 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=media_player, service=turn_off, service_data=entity_id=media_player.tv>
2020-04-15 15:57:00 DEBUG (SyncWorker_0) [custom_components.samsungtv_smart.api.samsungws] Connection closed.
2020-04-15 15:57:00 DEBUG (SyncWorker_0) [custom_components.samsungtv_smart.api.samsungws] Sending key KEY_POWER
2020-04-15 15:57:00 DEBUG (SyncWorker_0) [custom_components.samsungtv_smart.api.samsungws] WS url ws://192.168.1.ZZZ:8001/api/v2/channels/samsung.remote.control?name=W0hvbWUgQXNxxxxxxxxxxxxxxx==
2020-04-15 15:57:00 DEBUG (SyncWorker_0) [custom_components.samsungtv_smart.api.samsungws] Connection closed.
2020-04-15 15:57:00 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=media_player.tv, old_state=<state media_player.tv=on; source_list=['digitalTv', 'Plex', 'RaiPlay', 'YouTube', 'Prime Video', 'TuneIn'], volume_level=0.0, is_volume_muted=False, media_content_type=channel, media_title=Italia1 HD (506), media_channel=506, app_id=TV/HDMI, source=digitalTv, friendly_name=TV, icon=mdi:television, supported_features=24509, device_class=tv @ 2020-04-15T15:54:44.677218+02:00>, new_state=<state media_player.tv=off; friendly_name=TV, icon=mdi:television, supported_features=24509, device_class=tv @ 2020-04-15T15:57:00.756846+02:00>>
2020-04-15 15:57:00 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.140xxxx6068xxxx] Sending {'id': 2, 'type': 'event', 'event': <Event state_changed[L]: entity_id=media_player.tv, old_state=<state media_player.tv=on; source_list=['digitalTv', 'Plex', 'RaiPlay', 'YouTube', 'Prime Video', 'TuneIn'], volume_level=0.0, is_volume_muted=False, media_content_type=channel, media_title=Italia1 HD (506), media_channel=506, app_id=TV/HDMI, source=digitalTv, friendly_name=TV, icon=mdi:television, supported_features=24509, device_class=tv @ 2020-04-15T15:54:44.677218+02:00>, new_state=<state media_player.tv=off; friendly_name=TV, icon=mdi:television, supported_features=24509, device_class=tv @ 2020-04-15T15:57:00.756846+02:00>>}
2020-04-15 15:57:00 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.140xxxx6068xxxx] Sending {'id': 28, 'type': 'result', 'success': True, 'result': {'context': Context(user_id='0df1c041a2e4xxxxxxxxxxxxxxxxxxxx', parent_id=None, id='dbfe1937299dxxxxxxxxxxxxxxxxxxxx')}}

Calling media_player.toggle service >> NOT WORKING

2020-04-15 16:00:06 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.140xxxx6068xxxx] Received {'type': 'call_service', 'domain': 'media_player', 'service': 'toggle', 'service_data': {'entity_id': 'media_player.tv'}, 'id': 29}
2020-04-15 16:00:06 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=media_player, service=toggle, service_data=entity_id=media_player.tv>
2020-04-15 16:00:06 DEBUG (SyncWorker_13) [custom_components.samsungtv_smart.api.samsungws] Connection closed.
2020-04-15 16:00:06 DEBUG (SyncWorker_13) [custom_components.samsungtv_smart.api.samsungws] Sending key KEY_POWER
2020-04-15 16:00:06 DEBUG (SyncWorker_13) [custom_components.samsungtv_smart.api.samsungws] WS url ws://192.168.1.ZZZ:8001/api/v2/channels/samsung.remote.control?name=W0hvbWUgQXNxxxxxxxxxxxxxxx==
2020-04-15 16:00:06 DEBUG (SyncWorker_13) [custom_components.samsungtv_smart.api.samsungws] Connection closed.
2020-04-15 16:00:06 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=media_player.tv, old_state=<state media_player.tv=on; source_list=['digitalTv', 'Plex', 'RaiPlay', 'YouTube', 'Prime Video', 'TuneIn'], volume_level=0.0, is_volume_muted=False, media_content_type=channel, media_title=Italia1 HD (506), media_channel=506, app_id=TV/HDMI, source=digitalTv, friendly_name=TV, icon=mdi:television, supported_features=24509, device_class=tv @ 2020-04-15T15:57:24.816900+02:00>, new_state=<state media_player.tv=off; friendly_name=TV, icon=mdi:television, supported_features=24509, device_class=tv @ 2020-04-15T16:00:06.918805+02:00>>
2020-04-15 16:00:06 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.140xxxx6068xxxx] Sending {'id': 2, 'type': 'event', 'event': <Event state_changed[L]: entity_id=media_player.tv, old_state=<state media_player.tv=on; source_list=['digitalTv', 'Plex', 'RaiPlay', 'YouTube', 'Prime Video', 'TuneIn'], volume_level=0.0, is_volume_muted=False, media_content_type=channel, media_title=Italia1 HD (506), media_channel=506, app_id=TV/HDMI, source=digitalTv, friendly_name=TV, icon=mdi:television, supported_features=24509, device_class=tv @ 2020-04-15T15:57:24.816900+02:00>, new_state=<state media_player.tv=off; friendly_name=TV, icon=mdi:television, supported_features=24509, device_class=tv @ 2020-04-15T16:00:06.918805+02:00>>}
2020-04-15 16:00:06 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.140xxxx6068xxxx] Sending {'id': 29, 'type': 'result', 'success': True, 'result': {'context': Context(user_id='0df1c041a2e4xxxxxxxxxxxxxxxxxxxx', parent_id=None, id='c68629ea24654223b5bfc3f793bc4c6d')}}

Sending KEY_POWER directly >> WORKING

2020-04-15 16:04:20 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.140xxxx6068xxxx] Received {'type': 'call_service', 'domain': 'media_player', 'service': 'play_media', 'service_data': {'entity_id': 'media_player.tv', 'media_content_type': 'send_key', 'media_content_id': 'KEY_POWER'}, 'id': 34}
2020-04-15 16:04:20 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=media_player, service=play_media, service_data=entity_id=media_player.tv, media_content_type=send_key, media_content_id=KEY_POWER>
2020-04-15 16:04:20 DEBUG (SyncWorker_7) [custom_components.samsungtv_smart.api.samsungws] Connection closed.
2020-04-15 16:04:20 DEBUG (SyncWorker_7) [custom_components.samsungtv_smart.api.samsungws] Sending key KEY_POWER
2020-04-15 16:04:20 DEBUG (SyncWorker_7) [custom_components.samsungtv_smart.api.samsungws] WS url ws://192.168.1.ZZZ:8001/api/v2/channels/samsung.remote.control?name=W0hvbWUgQXNxxxxxxxxxxxxxxx==
2020-04-15 16:04:20 DEBUG (MainThread) [custom_components.samsungtv_smart.media_player] Start getting running app...
2020-04-15 16:04:20 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.140xxxx6068xxxx] Sending {'id': 34, 'type': 'result', 'success': True, 'result': {'context': Context(user_id='0df1c041a2e4xxxxxxxxxxxxxxxxxxxx', parent_id=None, id='dd4e1cce531049f396c57fd258c70b90')}}
2020-04-15 16:04:20 DEBUG (MainThread) [custom_components.samsungtv_smart.media_player] ... end getting app list - no app found.
2020-04-15 16:04:27 DEBUG (MainThread) [homeassistant.helpers.restore_state] Dumping states
2020-04-15 16:04:27 DEBUG (SyncWorker_18) [homeassistant.helpers.storage] Writing data for core.restore_state
@fillilutten
Copy link

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
Copy link
Owner

ollo69 commented Apr 15, 2020

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
Copy link
Author

fredericks1982 commented Apr 16, 2020

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
Copy link
Owner

ollo69 commented Apr 16, 2020

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
Copy link

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
Copy link
Owner

ollo69 commented Apr 16, 2020

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
Copy link
Author

Just to recap:

  • all other commands seem to work well
  • media_player.play_media > send_key: KEY_POWER always works normally (I can toggle TV status with just one service call);
  • media_player.toggle switches off TV only calling the service twice (I've kept TV on for more than 20s before trying);
  • when I switch off TV with HASS, the TV status on SmartThings app immediately changes: I wonder whether is possible to use some SmartThing event/status info to quickly update TV status on HASS instead of the 20s delay trick.

@ollo69
Copy link
Owner

ollo69 commented Apr 17, 2020

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
Copy link

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
Copy link
Owner

ollo69 commented Apr 18, 2020

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
Copy link
Author

Thanks @ollo69, now all seems working fine!

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

No branches or pull requests

3 participants