New Contrib Node to monitor and control HDMI devices using CEC (node-red-contrib-cec)

1,007 views
Skip to first unread message

damo....@gmail.com

unread,
Aug 28, 2017, 1:05:33 AM8/28/17
to Node-RED
Hi Everyone,

Just sharing a new node I have created - node-red-contrib-cec

The idea of these new nodes is too allow node red to send and receive CEC commands from CEC-enabled HDMI devices. 

It includes 4 nodes as follows:

  1. cec-input - input node that receives CEC messages from a HDMI bus.
  2. cec-output - output node that sends CEC commands to the HDMI bus.
  3. cec-state - tracks and stores the status of all the devices connected to the HDMI CEC bus by listening to the cec messages.
  4. cec-config - provides connection details for connecting to the cec serial port.
I am using it with a Rasberry Pi attached to my Sony Television via HDMI to remotely switch inputs based on events received via MQTT, such as someone coming to my front door.

A comprehensive guide is included along with screenshots of a sample flow to experiment with (see attached).

Sharing in case it may be of use to others.  Happy to receive feedback and suggestions for improvement, or a shout out if you found it useful.

Cheers,
Damien.

node-red-contrib-cec-example-flow.png

David Dempster

unread,
Sep 5, 2017, 3:48:08 AM9/5/17
to Node-RED
Hi Damien,
Would your exciting node be useful in my home setup?

I have three TVs in my house running LibreElec on two Raspberry Pi-2s and a RPi-3.
I also run Node-Red and MQTT (Mosquitto) on a RPi-3 with various ESP8266 nodes and Amazon Echo Dot.

Would your node allow me to control a TV via Node-Red dashboard and/or from Alexa (Echo Dot commands) ??

I'll have to get up the learning curve about CEC.

Kind regards from David (Dempster)

Damien Clark

unread,
Sep 5, 2017, 8:50:32 PM9/5/17
to node...@googlegroups.com
Hey David,

I’m not familiar with Echo Dot, but if you can run node-red on a Rpi that is connected to your TV using HDMI, then yes, you should be able to use it to control your equipment.  

There are some great resources on cec around.  One I found particularly helpful was http://www.cec-o-matic.com/  It, along with the underlying library I used helped with the ‘command’ syntax for interacting on the cec bus.  

To experiment, without using node-red (i.e. on the command line), you want to use cec-client.  This can be installed from the debian package cec-utils.

How well things work for you may be largely dependent on the quality of your entertainment equipment and how well they have implemented the specifications.  Some experimentation is likely necessary.  

My goal for the node was to have my TV’s turn on, and/or switch input to my Raspberry Pi whenever motion was detected at my front door.  The Raspberry Pi is displaying a video feed from a camera located there.  

Good luck with it. :)

Damo.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/e5-oQC3MTYI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/1e64a624-ac1c-4d13-95fb-87cbe7491cd7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Julian Knight

unread,
Sep 6, 2017, 8:01:47 AM9/6/17
to Node-RED
That sounds like fun. I hope you can share the setup with us all. Maybe a post to flows?

damo....@gmail.com

unread,
Oct 2, 2017, 12:52:00 AM10/2/17
to Node-RED
Hey Julian,

Back at work, so less personal time than before. 

I've updated the supporting library for these nodes, and implemented a flow to do what I wanted.

I've included a screenshot of the flow, and attached the flow json for anyone interested.

Essentially the flow
  1. listens to mqtt broker for motion events at my front door;
  2. filters out any motion stop events;
  3. queries node-red-contrib-cec to see if the TV is already turned on; and if so
  4. sends command to the HDMI CEC bus to switch input to the Raspberry Pi which displays a feed from the cameras using omxplayer

The television is near the front door in my home, so you can see who is there before opening the door.


Damo.

cec.json

damo....@gmail.com

unread,
Oct 2, 2017, 5:58:42 AM10/2/17
to Node-RED

Re-posting the flow screenshot.  Selected nodes show the message path.

D.

Auto Generated Inline Image 1
Reply all
Reply to author
Forward
0 new messages