Giter VIP home page Giter VIP logo

homebridge-http-tv's Introduction

homebridge logo

Homebridge HTTP TV Plugin

A Homebridge plugin to let you control your TV (or a bridge server) using HTTP

license release node version downloads build status tweet

Features

  • Exposes a HomeKit TV accessory
  • Characteristics changes trigger HTTP requests to user-defined URLs
  • Every request customizable with HTTP method, headers and body
  • Kind of like homebridge-http-switch but for TVs

Installation

Homebridge should be installed. Then run the following to install homebridge-http-tv.

sudo npm install -g homebridge-http-tv

Add the platform to your Homebridge config.json file. You can find your file location here.

{
    "platforms": [
        {
            "platform": "http-tv",
            "devices": {
                "device config here, see below": ""
            }
        }
    ]
}

You're good to go now!

Configuration

You can use the visual config editor in Homebridge Config UI X. However for more detailed configuration you may have to edit the config.json file directly.

A note on HTTP requests

Generally you can globally define headers and http body in the main device config. However, every object marked <HTTPRequest> can include method, headers, and body properties, that only get used for that HTTP request. See example below.

Config Properties

  • name <string> required: Defines the name which is later displayed in HomeKit

  • power <HTTPRequest> required:

    • onUrl <URL> required: The URL to be requested when the TV is turned on.
    • offUrl <URL> required: The URL to be requested when the TV is turned off.
  • sources <Array<HTTPRequest>> required: The input sources available.

    • name <string> required: The name for the input source
    • url <URL> required: The URL to query when this input is selected.
    • type <number> optional (Default: 3 (HDMI)): The input type as defined here
  • method <string> optional (Default: "GET"): The HTTP method to be used for all requests.

  • headers <object> optional: Key-Value object for HTTP headers to be included in every request.

  • serialNumber <string> optional (Default: "TV01"): Defines a custom serial number shown in the home app.

  • model <string> optional (Default: "TV"): Defines a custom model name shown in the home app.

  • manufacturer <string> optional (Default: "Mateffy"): Defines a custom manufacturer name shown in the home app.

HTTPRequest: The HTTP request object
  • method <string> optional (Default: "TV01"): The HTTP method to be used for all requests.
  • headers <object> optional: Key-Value object for HTTP headers to be included in every request.
  • body <string> optional: The HTTP body

Config Example

{
    "platforms": [
        {
            "platform": "http-tv",
            "devices": [
              {
                "name": "My TV",
                "serialNumber": "my-http-tv-1",
                "method": "POST",
                "headers": {
                    "Authorization": "Bearer token-example"
                },
                "power": {
                    "onUrl": "http://bridge.local/tv/on",
                    "offUrl": "http://bridge.local/tv/off",
                    "headers": {
                        "X-Custom-Header": "Value"
                    }
                },
                "sources": [
                    {
                        "name": "HDMI1",
                        "url": "http://bridge.local/tv/source/1",
                        "type": 3,
                        "method": "PATCH",
                        "headers": {
                            "X-Custom-Header-2": "value"
                        }
                    },
                    {
                        "name": "HDMI2",
                        "url": "http://bridge.local/tv/source/2",
                        "type": 3,
                        "body": "custom request body"
                    }
                ],
                "model": "HTTP TV",
                "manufacturer": "Lukas Mateffy"
              }
            ]
        }
    ]
}

Changelog

1.0.1

  • Fixed documentation in README

homebridge-http-tv's People

Contributors

capevace avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

alessaba filip-fk

homebridge-http-tv's Issues

declaring all tvs as external accessory.

TV shows the icon of HOME, instead of TV. they fixed it by declaring all tvs as external accessory.
please fix for me. ๐Ÿ™‡๐Ÿปโ€โ™‚๏ธ
256FF39A-255A-4046-9A23-33619E12E497

Only absolute URLs are supported

Here is my config:

{
"devices": [
{
"name": "Sharp TV",
"serialNumber": "6C000357",
"method": "POST",
"power": {
"onUrl": {
"url": "http://192.168.150.2/Power.cgi/",
"method": "POST",
"body": "power=0&standby=0&ret=&rPOWR=1"
},
"offUrl": {
"url": "http://192.168.150.2/Power.cgi/",
"method": "POST",
"body": "power=1&standby=0&ret=&rPOWR=0"
}
},
"sources": [
{
"name": "HDMI 1",
"url": "http://192.168.150.2/Input.cgi",
"type": 3
}
],
"model": "PN-R703",
"manufacturer": "Sharp"
}
],
"platform": "http-tv"
}

The TV shows up on my Home App, but every time I try to use it, I get the following error. What exactly am I missing? The same POST request does work when I use it on HTTP-SWITCH

Cannot update TV power via HTTP TypeError: Only absolute URLs are supported
at getNodeRequestOptions (/usr/lib/node_modules/homebridge-http-tv/node_modules/node-fetch/lib/index.js:1305:9)
at /usr/lib/node_modules/homebridge-http-tv/node_modules/node-fetch/lib/index.js:1410:19
at new Promise ()
at Function.fetch [as default] (/usr/lib/node_modules/homebridge-http-tv/node_modules/node-fetch/lib/index.js:1407:9)
at HTTPTVAccessory.httpRequest (/usr/lib/node_modules/homebridge-http-tv/src/platformAccessory.ts:229:31)
at HTTPTVAccessory.setActive (/usr/lib/node_modules/homebridge-http-tv/src/platformAccessory.ts:140:15)
at Active.emit (events.js:376:20)
at /usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1632:16
at new Promise ()
at Active. (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1630:14)

Polling / Status Request

First of all: great plugin, I love it :D

Is your feature request related to a problem? Please describe:
Right now, whenever someone turns the TV off using its remote, the switch in Homebridge doesn't get refreshed.

Describe the solution you'd like:
It would be great if the plugin could poll to see if the tv is turned on. This would guarantee that Homebridge only shows the device as turned on when it actually is (and vice versa).

Describe alternatives you've considered:
You could add a third URL for polling. A request to this url could return True/False, 1/0, Status Code 200 / 400, etc to signify the status of the device

Volume and DPad control

HI,
I stumbled upon your plugin and it works pretty nicely and reliably.
I noticed there's a feature missing though: Volume and Dpad control.
If you look, for example, at this plugin, you can see there is the option to access a dpad interface, and as far as i know, volume control is also possible.
I am very interested in this feature but honestly i don't know how to implement accessories in homebridge, so i am gonna file this issue.

A Nice and simple implementation would be having URLs in the config like

  • volUpURL
  • volDownURL
  • keyUpURL
  • keyDownURL
  • keyLeftURL
  • keyRightURL
    and so on.

This is part of how the additional interface should look like in the Home App (screenshot taken from the plugin linked above)
preview

Thanks in advance, and hope to hear back from you soon

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.