Hi.I use rpi5 and dakboard in my office. I want hubitat to trigger linux command so rpi could turn on and off HDMI connected TV. How to make hubitat to execute linux commands via for eg. ssh?
Could you not turn the TV off through some other avenue, like a Harmony hub or similar? Perhaps a smart plug controlled by HE.
With the rpi.... Do you know if you can turn the TV on or off from the rpi? I.e. have you tested that already? If yes, if you are already using or are happy to setup node red I would expect it would open up some possibilities, like accepting a http request that could be the trigger to do some action using node red, like running a script.
This was the first thing that came to mind for me.
Of course you’d need to have something running on the RPi that can accept the request. But that’s not too hard to add, if there isn’t already a web server running.
That would probably be the simplest way from the hub’s perspective, using built-in tools.
With custom written groovy code for Hubitat, lots of things are possible, but that takes more knowledge and effort.
@thebearmay do you know if a hub could remotely connect to a Linux command line running on another device?
I think I've seen telnet used before, potentially for the Aus weather (BoM) driver....
Another possible option would be to run Home Assistant on the RPi, and have it control the TV (either via a direct integration, if available, OR by having it run a script on the RPi.) You could then use something like the Home Assistant Device Bridge (HADB) integration to allow HA devices to appear in Hubitat.
While not the most trivial solution, you may find it very handy to have both Hubitat and Home Assistant working together - best of both worlds!
Best option is probably Telnet for CLI interaction. Could also look at using SSH via NodeRed, and connecting it to a set of virtual devices on the hub via MakerAPI.
I do something like this with Node Red running under Docker on my Raspberry Pi.
Here is a flow where the hub calls a HTTP endpoint on Node Red which executes a SSH command on my router to reboot it:
The "PWD" node at the top is just there to test that it works. When I trigger that, the debug node outputs "/root". The two nodes at the bottom send me a notification when the reboot is called.
I have a similar Node Red flow where, when the hub gets notified that my systems are running on UPS, it makes a HTTP to Node Red that runs a script on the Raspberry Pi to shut down the Pi. In that one I used an Exec node to run the shell script instead of as SSH command.
So you can directly run SSH from Node Red, or you can use Node Red to run shell scripts. They can be triggered by HTTP calls, or you can use Node Red Nodes for Hubitat (node-red-contrib-hubitat (node) - Node-RED) to trigger off of device state changes on the hub.
Running an instance (or two in my case) of Node Red can be very useful. Some people choose to use it for all of their automation, but I prefer to use Rule Machine for (nearly) all of my rule logic. But I find Node Red really useful for extending the capabilities of the hub in cases like this.
@bornholm, I use MagicMirror on my RPIs and it has an API for that. Dackboard has an API too but I'm not sure it support what you want.
Anyway, I am in the process of doing away with MagicMirror and thinking of going with a Hubitat dashboard to display on them instead. To turn the screen on and off, as @thebearmay suggested, I will telnet the command with a tailored driver dedicated to only do that.
It works on my Rpi 3. Hopefully it could work on Rpi 5 too. If you are interested:
https://raw.githubusercontent.com/ymerj/Hubitat-miscellaneous/refs/heads/main/TelnetRPIscreen.groovy
You will need to install telnet server on your rpi.
Years ago, I wrote a small telnetd for Linux that ran in a sandbox and would exec the name of a program with arguments provided by the telnet client.
Maybe webhooks would work for you.
This is how I control a Mac Mini from Hubitat. Rule Machine sends HTTP GET to an application called Keyboard Maestro on the Mac Mini and that executes Apple Scripts. There are harder ways to do it if one is into that.