Page 1 of 3

Controlling a SamyGO TV through Home Assistant

Posted: Mon Jul 10, 2017 2:36 pm
by mad_ady
Home Assistant (http://homeassistant.io/) is a Home automation platform that allows you to monitor and control all sorts of devices an platform in the privacy of your own house (no cloud). I've added my SamyGO TV (H6400) to Home Assistant by using the samygo-web-api (viewtopic.php?f=75&t=11881).

A general howto for understanding and configuring Home Assistant is over here: https://forum.odroid.com/viewtopic.php?t=27321

The changes needed to HomeAssistant to control your TV are stored in this github repository: https://github.com/mad-ady/home-assista ... omizations

Installation:
1. Make sure you've installed the web api and its dependencies on the TV
2. Install Home Assistant on your computer/RPI/Odroid/device and go through the standard configuration
3. Copy the jsonrest sensor to your custom components folder:

Code: Select all

mkdir -p ~homeassistant/.homeassistant/custom_components/sensor/
wget -O ~homeassistant/.homeassistant/custom_components/sensor/jsonrest.py https://raw.githubusercontent.com/mad-ady/home-assistant-customizations/master/custom_components/sensor/jsonrest.py
[/del] -- json rest no longer needed for modern Home Assistant versions (>0.65)
4. Configure your Home Assistant by adding several sensors and a web cam.
Example configuration: https://github.com/mad-ady/home-assista ... o-api.yaml
Example URLs: https://github.com/mad-ady/home-assista ... ecret.yaml
5. Restart homeassistant or reload the configuration
6. Profit:
Home Assistant Web UI:Image
Home Assistant History (view state changes): Image
Youtube demo: https://www.youtube.com/watch?v=jC7yUe_AJw4

Tested on a H6400. Older models might need some tweaking with regard to the screenshot functionality. Patches and ideas welcome! TV is surprisingly stable despite repeated injections - good job SamyGO team!

Re: Controlling a SamyGO TV through Home Assistant

Posted: Tue Jul 11, 2017 8:32 pm
by mad_ady
Updated first post and added a link to Home Assistant general configuration: https://forum.odroid.com/viewtopic.php?t=27321

Re: Controlling a SamyGO TV through Home Assistant

Posted: Fri Sep 08, 2017 6:30 am
by brendanheyu
@mad_ady - I just thought I'd let you know that I joined this forum to specifically say to you - AWESOME! I saw your video on youTube and traced you back to here.

I'm going to dash home and check to see if I can hook my samsung TV with samygo and link it into my homeassistant!

Nice work!

Re: Controlling a SamyGO TV through Home Assistant

Posted: Fri Sep 08, 2017 9:01 am
by mad_ady
:) I'm glad you find it helpful. The hard work is done by the SamyGO libraries, I just added a web API around them so that I could query them from Home Assistant.
If you have a newer generation TV (J or higher), the API won't work, and needs to be redone. I can do it, but I would need help from somebody with shell access on such a TV.

Re: Controlling a SamyGO TV through Home Assistant

Posted: Tue Oct 03, 2017 6:33 pm
by teprrr
Hey, that looks great! Do you have plans to push this towards the official homeassistant distribution at some point (would probably require converting it to a `mediaplayer` platform)? If so and you need help with it, I'll be there for it if I'll manage to root my H-series.

Re: Controlling a SamyGO TV through Home Assistant

Posted: Wed Oct 04, 2017 6:59 am
by mad_ady
I was planning on pushing the jsonrest custom component first (actually merge the functionality in the REST sensor).
Regarding making it a media player - I don't know. I will need to find out what a mediaplayer component does and if the API can satisfy all the needs. Otherwise, yes, it would be doable.

Re: Controlling a SamyGO TV through Home Assistant

Posted: Wed Oct 04, 2017 9:55 pm
by teprrr
Merging with the rest sensor sounds indeed ideal! I'm unsure how to use another "platform" inside a media_player, but in principle it will just allow an easy and stable API for common media player commands so it should be doable. I'll create issues / submit patches to your repository when i'm able to check it out, thanks again for your contribution, it drove me towards rooting the device once and for all. That and doing an Ambilight-like custom LED backlight sounds like a fun small project (with the help of libScreenShot!).

Re: Controlling a SamyGO TV through Home Assistant

Posted: Sun Oct 08, 2017 7:07 pm
by teprrr
I wrote a preliminary mediaplayer component just to see how it would work. The basic functionality is already there, what would be nice to have is a list of available sources (I was considering parsing the output from libHideSources, but it displays way too much information...) to make switching the inputs easier. https://github.com/rytilahti/home-assis ... 6a015f0851 is the commit, and adding

Code: Select all

mediaplayer:
  - platform: samygo
    name: TV
    host: 192.168.XX.XX
    token: !secret samygo_token
into the config file is enough to activate it :-)

I'm still undecided what other features should be implemented (channel changing, source changing at least) and whether to try to push this towards the official release, but it's a start and makes it a bit easier than using the rest api with jsonrest directly.

edit: also, the webcam/screenshot part is not there yet either..

Re: Controlling a SamyGO TV through Home Assistant

Posted: Mon Oct 09, 2017 7:16 am
by mad_ady
Hey, that looks really good!
When it's working well enough it should be pushed upstream.
I'll try it out, hopefully this week.
Regarding a list of sources, I will look at libHideSources and expose the available sources though an API call. I'll let you know when it's done.

Re: Controlling a SamyGO TV through Home Assistant

Posted: Mon Oct 09, 2017 11:20 pm
by teprrr
Ok, let me know what you think! I looked into libHideSources earlier and it would indeed be possible to parse its log file generated (however, it has to be injected during the boot up while LIST is being set). I did not do that as the listing was way too broad and it was showing a lot of entries which are not available at all on my telly. If you manage to get it work, we can add the obtained list, or otherwise provide a predefined list of sources :-)