From 59adf119c23789b7765b9894caa8b5bd5cd38979 Mon Sep 17 00:00:00 2001 From: Sebastian Haas Date: Sun, 28 Mar 2021 23:30:15 +0200 Subject: [PATCH] restructure for HACS add license, readme and hacs metadata --- .gitignore | 1 + LICENSE | 21 ++++ README.md | 98 +++++++++++++++++++ .../hisense_tv/__init__.py | 0 .../hisense_tv/config_flow.py | 0 .../hisense_tv/const.py | 0 .../hisense_tv/helper.py | 0 .../hisense_tv/manifest.json | 0 .../hisense_tv/media_player.py | 0 .../hisense_tv/strings.json | 0 .../hisense_tv/translations}/en.json | 0 hacs.json | 4 + info.md | 7 ++ readme.md | 0 14 files changed, 131 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md rename __init__.py => custom_components/hisense_tv/__init__.py (100%) rename config_flow.py => custom_components/hisense_tv/config_flow.py (100%) rename const.py => custom_components/hisense_tv/const.py (100%) rename helper.py => custom_components/hisense_tv/helper.py (100%) rename manifest.json => custom_components/hisense_tv/manifest.json (100%) rename media_player.py => custom_components/hisense_tv/media_player.py (100%) rename strings.json => custom_components/hisense_tv/strings.json (100%) rename {translations => custom_components/hisense_tv/translations}/en.json (100%) create mode 100644 hacs.json create mode 100644 info.md delete mode 100644 readme.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed8ebf5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__ \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..dab168f --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Sebastian Haas + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e5d135b --- /dev/null +++ b/README.md @@ -0,0 +1,98 @@ +# Hisense TV Integration for Home Assistant + +Integration an Hisense TV as media player into Home Assistant. The communication is handled via the integrated MQTT broker and wake-on-LAN. + +## Current features: +* Turn on / off +* Display current status + * Source (TV, HDMI, Apps) + * Channel name / number + * EPG data of current show +* Volume control +* Media browser + * LNB selector + * Channel selector + * Apps + +TBD: +* Expose ON/OFF as switch +* Expose all keys as buttons +* Enhance EPG/guide handling + +## Configuration + +The TV provides a MQTT broker on port `36669`. Home Assistant can only communicate with one MQTT broker, so you have to create a bridge between the two broker. + +## MQTT + +The MQTT broker is secured by credentials. Some TVs (like mine) even require client certificates for incomming connections. I won't include them in this repo, but you can find them online or extract them yourself. See [Acknowledgment](https://github.com/sehaas/ha_hisense_tv#acknowledgment). + +Connection shema: +``` ++-----------+ +-----------+ +| Home | client | Mosquitto | +| Assistant |--------->| | ++-----------+ +-----------+ + /\ + bridge || + \/ + +-------------+ + | Hisense TV | + | MQTT Broker | + +-------------+ +``` + +The `mosquitto` bridge configuration using client certificates. + +``` +connection hisense +address :36669 +username +password +clientid HomeAssistant +bridge_tls_version tlsv1.2 +bridge_cafile hisense_ca.pem +bridge_certfile hisense_client.pem +bridge_keyfile hisense_client.key +bridge_insecure true +start_type automatic +try_private true +topic /remoteapp/# both 0 "" +``` +Replace ``, credentials and `` according to your setup. The `` is needed if you have multiple TVs, otherwise you should just use the default `hisense`: +``` +topic /remoteapp/# both 0 hisense "" +``` + +(Optional) If you have multiple TVs you have to replicate the whole configuration for each TV. +The `` must be unique for every TV. For example: +``` +topic /remoteapp/# both 0 livingroom_tv "" +``` +``` +topic /remoteapp/# both 0 kids_tv "" +``` + +(Optional) This setup uses the same prefix for incoming and outgoing messages. The integration supports separated values. You have to adapt the topic setup accordingly. + +## Wake-on-LAN + +The TV can be turned on by a Wake-on-LAN packet. The MAC address must be configured during integration setup. + +## Setup in Home Assistant + +The integration can be added via the Home Assistant UI. Add the integration and setup your TV. During the first setup your TV should be turned on. The integration requires a PIN code from you TV. The PIN will be triggered automatically during setup. This is a onetime step where the client `HomeAssistant` is requesting access to remote controll the TV. + +# YMMV + +Tested on an [Hisense A71 Series](https://hisenseme.com/product/75-65-58-55-50-43-a71-series/) with mandatory client certificates. `gettvstate` does not return a `state` but can be used to authenticate the client. +The + +# Acknowledgment +Everything I needed to write this integration could be gathered from these sources. Information about the MQTT topics, credentials or certificates can be found there. + +* [@Krazy998's mqtt-hisensetv](https://github.com/Krazy998/mqtt-hisensetv) +* [@newAM's hisensetv_hass](https://github.com/newAM/hisensetv_hass) +* [HA Community](https://community.home-assistant.io/t/hisense-tv-control/97638/1) +* [RemoteNOW App](https://play.google.com/store/apps/details?id=com.universal.remote.ms) +* [@d3nd3](https://github.com/d3nd3/Hisense-mqtt-keyfiles) \ No newline at end of file diff --git a/__init__.py b/custom_components/hisense_tv/__init__.py similarity index 100% rename from __init__.py rename to custom_components/hisense_tv/__init__.py diff --git a/config_flow.py b/custom_components/hisense_tv/config_flow.py similarity index 100% rename from config_flow.py rename to custom_components/hisense_tv/config_flow.py diff --git a/const.py b/custom_components/hisense_tv/const.py similarity index 100% rename from const.py rename to custom_components/hisense_tv/const.py diff --git a/helper.py b/custom_components/hisense_tv/helper.py similarity index 100% rename from helper.py rename to custom_components/hisense_tv/helper.py diff --git a/manifest.json b/custom_components/hisense_tv/manifest.json similarity index 100% rename from manifest.json rename to custom_components/hisense_tv/manifest.json diff --git a/media_player.py b/custom_components/hisense_tv/media_player.py similarity index 100% rename from media_player.py rename to custom_components/hisense_tv/media_player.py diff --git a/strings.json b/custom_components/hisense_tv/strings.json similarity index 100% rename from strings.json rename to custom_components/hisense_tv/strings.json diff --git a/translations/en.json b/custom_components/hisense_tv/translations/en.json similarity index 100% rename from translations/en.json rename to custom_components/hisense_tv/translations/en.json diff --git a/hacs.json b/hacs.json new file mode 100644 index 0000000..fc3db5c --- /dev/null +++ b/hacs.json @@ -0,0 +1,4 @@ +{ + "name":"Hisense TV", + "domains": ["media_player"] +} \ No newline at end of file diff --git a/info.md b/info.md new file mode 100644 index 0000000..99eba83 --- /dev/null +++ b/info.md @@ -0,0 +1,7 @@ +# Hisense TV + +A Hisense TV media player integration for Home Assistant using the embedded MQTT broker. + +* [Current Features](https://github.com/sehaas/ha_hisense_tv#current-features) +* [Configuration](https://github.com/sehaas/ha_hisense_tv#configuration) +* [Setup in Home Assistant](https://github.com/sehaas/ha_hisense_tv#setup-in-home-assistant) \ No newline at end of file diff --git a/readme.md b/readme.md deleted file mode 100644 index e69de29..0000000