Giter Site home page Giter Site logo

oh-plg-samsungtv's Introduction

Introduction

Plugin to controll Samsung TV via SmartView API. This plugin is based on the fantastic work of https://github.com/McKael/samtv

NOTE: The SmartView API is a bit strange. Not all models/tv work the same way.
E.g. my TV in the Bedroom works without a special handshake, just over a simple WebSocket connection.
The TV in the Livingroom needs a special crypto handshake.

This plugin does handle only the special crypto case and can not be used with the plain websocket API.

The plugin is very quick & dirty, and more a proof-of-concept!
It depends on the externel pairing functionality of:

Pairing is coming soon!
A "working-on" port to node.js can be found here: https://github.com/mStirner/samtv-remote

Special thanks to @sectroyer, @McKael & @tdudek for their incredible and awesome work!

Note

After configuring (pairing & setting secrets), the plugin needs to be restarted

Development

Create a new plugin over the HTTP API:
[PUT] http://{{HOST}}:{{PORT}}/api/plugins/:

{
    "name": "Samsung TV",
    "enabled": true,
    "version": 1,
    "intents": [
        "devices", 
        "endpoints", 
        "vault"
    ],
    "uuid": "ac19271c-82b2-11ed-9028-c3c23c2befc8"
}

Example output from the API:

{
    "_id": "63a58de22e87a47ef614ae56",
    "name": "Samsung TV",
    "enabled": true,
    "version": 1,
    "intents": [
        "devices",
        "endpoints",
        "vault"
    ],
    "uuid": "ac19271c-82b2-11ed-9028-c3c23c2befc8",
    "timestamps": {
        "created": 1671794146435,
        "updated": null
    },
    "autostart": true
}

Device description

[GET] http://192.168.2.100:8001/api/v2/

{
  "id": "uuid:bd816fe9-5a03-48f2-8cbd-c048378e5645",
  "name": "[TV] UE60J6289",
  "version": "2.0.25",
  "device": {
    "type": "Samsung SmartTV",
    "duid": "uuid:bd816fe9-5a03-48f2-8cbd-c048378e5645",
    "model": "15_HAWKM_2D",
    "modelName": "UE60J6240",
    "description": "Samsung DTV RCR",
    "networkType": "wired",
    "ssid": "",
    "ip": "192.168.2.100",
    "firmwareVersion": "Unknown",
    "name": "[TV] UE60J6289",
    "id": "uuid:bd816fe9-5a03-48f2-8cbd-c048378e5645",
    "udn": "uuid:bd816fe9-5a03-48f2-8cbd-c048378e5645",
    "resolution": "1920x1080",
    "countryCode": "DE",
    "msfVersion": "2.0.25",
    "smartHubAgreement": "true",
    "wifiMac": "5c:49:7d:21:14:27",
    "developerMode": "0",
    "developerIP": ""
  },
  "type": "Samsung SmartTV",
  "uri": "http://192.168.2.100:8001/api/v2/"
}

Mount the plugin source code into the backend plugins folder:

sudo mount --bind ~/projects/OpenHaus/plugins/oh-plg-samsungtv/ ~/projects/OpenHaus/backend/plugins/ac19271c-82b2-11ed-9028-c3c23c2befc8/

Use the UUID returned from the HTTP API after creating the plugin item

Then start the backend with:

npm run dev

The changes made in the plugin source code, should trigger a automatically backend reload.

Links & Informations

oh-plg-samsungtv's People

Contributors

mstirner avatar

Watchers

 avatar

oh-plg-samsungtv's Issues

Add dedicated interfaces for ws/https

Due to the architecture of OpenHaus/backend, a plain HTTP API cant have WebSocket endpoints.
When the HTTP API provides a websocket endpoint, a dedicated interfaces needs to be created.

OpenHausIO/backend#458

E.g.:

  • api.example.com:8123/api/ : HTTP Rest API
  • api.example.com:8123/api/foo/ws : WebSocket API

To work with both, ws & http api, 2 interfaces are needed. One for each.

Store: Add controll method vor api version

Different TVs/models need different command payloads, which are all very similar.

Use a store config item to determine which is used for which device/endpoint.
NOTE: Use device id as identifier.

Implement app starting e.g. Plex, YouTube, etc.

[POST] http://192.168.2.100:8001/api/v2/applications/111199000681 = plex

Response:

{
    "ok": true
}

[GET] http://192.168.2.100:8001/api/v2/applications/111199000681

{
    "name": "Plex",
    "running": true,
    "version": "2.012",
    "visible": true,
    "id": "111199000681"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.