Code Monkey home page Code Monkey logo

cec-rest's Introduction

CEC REST

A simple REST api to control CEC devices via a pi (or another device connected to your tv with HDMI)!

Home Assistant

Easy integrate your CEC device in Home Assistant by using this Restful Switch configuration

switch:
  - platform: rest
    name: TV CEC
    resource: http://192.168.69.10:3000/dev0
    state_resource: http://192.168.69.10:3000/dev0/powerStatus
    is_on_template: '{{ value == "on" }}'
    body_on: '{"action":"turnOn"}'
    body_off: '{"action":"turnOff"}'
    headers:
      Content-Type: application/json
    scan_interval: 5

API

GET /

Returns info about connected CEC devices and which functions you can run

Example response:

{
   "dev0":{
      "name":"TV",
      "logicalAddress":"0",
      "address":"0.0.0.0",
      "activeSource":"no",
      "vendor":"Unknown",
      "osdString":"TV",
      "cecVersion":"1.4",
      "powerStatus":"on",
      "language":"eng",
      "turnOn":"[function]",
      "turnOff":"[function]",
      "togglePower":"[function]",
      "changeSource":"[function]",
      "sendKey":"[function]"
   },
   "dev4":{
      "name":"Playback 1",
      "logicalAddress":"4",
      "address":"2.0.0.0",
      "activeSource":"no",
      "vendor":"Pulse Eight",
      "osdString":"CEC-Control",
      "cecVersion":"1.4",
      "powerStatus":"on",
      "language":"eng",
      "turnOn":"[function]",
      "turnOff":"[function]",
      "togglePower":"[function]"
   },
   "setActive":"[function]",
   "setInactive":"[function]",
   "volumeUp":"[function]",
   "volumeDown":"[function]",
   "mute":"[function]",
   "getKeyNames":"[function]",
   "command":"[function]"
}

GET /<device>

Example path: /dev0 Example response:

{
   "name":"TV",
   "logicalAddress":"0",
   "address":"0.0.0.0",
   "activeSource":"no",
   "vendor":"Unknown",
   "osdString":"TV",
   "cecVersion":"1.4",
   "powerStatus":"on",
   "language":"eng",
   "turnOn":"[function]",
   "turnOff":"[function]",
   "togglePower":"[function]",
   "changeSource":"[function]",
   "sendKey":"[function]"
}

GET /<device>/<property>

Example path: /dev0/powerStatus Example response:

on

POST /<device>

Example path /dev0 Example body:

{
    "action": "powerOff"
}

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.