-
-
Notifications
You must be signed in to change notification settings - Fork 26
Command line scripts
The homebridge-blinds plugin can execute besides HTTP requests also scripts via homebridge. They are executed on the homebridge local Unix shell command-line interpreter.
Any of the URL config parameters (up_url,
down_url,
stop_url,
etc.) can be used to trigger command-line scripts instead. To use this feature, simply add the file://
prefix to the command. The command should be specified in full without URL encoding. This could be used to trigger external blinds commands via serial connection or MQTT.
For example:
"up_url": "file://python /home/pi/run_script.py"
If file://
is found as the prefix, it is removed, and the remaining string is executed directly. Use caution when defining scripts as they are submitted to the system as received.
An example use case could be executing scripts for opening, closing, pausing blinds. There is no limit to creativity. One way to make use of the command-line scripts is by having a different script for each desired action. If using this plugin, when the blinds communicate over MQTT, the following sample script may be utilized:
Depending on the setup and use case, below is an example script (each action, such as stop, up, down, has its own message/ script in MQTT):
import paho.mqtt.client as mqtt
client = mqtt.Client()
client.connect(“MQTT broker address", port, 60)
client.publish(“topic/for/blinds", "desired message to trigger action");
client.disconnect();
hauni97 has a repository describing the functionality from hardware to MQTT setup in further detail.
See the Wiki for examples of user-written scripts. Setting verbose
to true
in the config may also be useful for troubleshooting.