Skip to content

Query Samsung TV status via REST end point #11179

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

Closed
wants to merge 2 commits into from
Closed

Query Samsung TV status via REST end point #11179

wants to merge 2 commits into from

Conversation

RiRomain
Copy link
Contributor

@RiRomain RiRomain commented Dec 17, 2017

Description:

Optionally get the status of a Samsung TV using Samsung's REST end point.
This avoid sending a dummy command that wake up some of the newest model.

Detail: When checking for update, the TV wakes up and connect to wifi. If during this time, the status was queried (by sending a dummy command), the TV would be turned ON.
This commit fixed that by checking if the REST endpoint is available instead of sending a key command.

The status of the TV will still appear as ON for a few second several time per day which could be problematic for automation, but at least the TV won't be turned ON and the status will be set back to OFF after a few seconds.

Related issue (if applicable): fixes #10905

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#4226

Example entry for configuration.yaml (if applicable):

media_player:
  - platform: samsungtv
    host: 192.168.0.123
    port: 8001
    mac: AA:BB:CC:DD:EE:FF
    get_status_via_rest: True

Checklist:

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • [-] New dependencies have been added to the REQUIREMENTS variable (example).
  • [-] New dependencies are only imported inside functions that use them (example).
  • [-] New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • [-] New files were added to .coveragerc.

Optionally get the status of a Samsung TV using Samsung's REST end point.
This avoid sending a dummy command that wake up some of the newest model.
self.send_key('KEY')

def _update_status_via_rest(self):
url = "http://{}:{}/api/v2/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic needs to be added to the upstream samsungctl library.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid that would be out of scope for this library, since the library just focus on control via websocket, and does not interact with the REST endpoint for now.

If it's required I'll try, but not sure my code make it to samsungctl library.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request opened in SamsungCTL library
Ape/samsungctl#71

@jfuerwentsches
Copy link

@RiRomain I have the same issue with my UE40 MU6179 UXZG and tried the code from the PR. I updated the samsungtv.py and added the get_status_via_rest Flag to my configuration.yml, but it did not work. After updating I can switch off the TV using Home Assistant.

Is it okay to just swap the code in samsungtv.py and restart Home Assistant, or do I need to do anything else?

@RiRomain
Copy link
Contributor Author

RiRomain commented Jan 7, 2018

If you can switch it off, what is the issue?
This change only avoid the tv to be turned on by accident, it does not modify on/off behaviour.

Not sure how to do it on a live hass, I used a dev instance (using pycharm on windows).

RiRomain pushed a commit to RiRomain/samsungctl that referenced this pull request Jan 15, 2018
This new method "is_tv_on()" report the status of the TV.
This aim at avoiding sending a dummy key for TV using websocket,
doing so can wake TV up if send during an update, or during an update
status check.

home-assistant/core#11179
@kennedyshead
Copy link
Contributor

fixes #12302 (I think)

@balloob
Copy link
Member

balloob commented Apr 9, 2018

This PR seems to have gone stale. Rest logic needs to go into the lib being used.

Closing it. You can reopen it when you're ready to finish it.

@balloob balloob closed this Apr 9, 2018
@RiRomain
Copy link
Contributor Author

RiRomain commented Apr 9, 2018

I did open a request in the lib, but seems it won't be merge any time soon. Ape/samsungctl#71

@home-assistant home-assistant locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Samsung TV MU6170UXZG restart instead of turning off
7 participants