Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hjdhjd/homebridge-blinds-cmd

:sunrise: Homebridge plugin to enable window blinds to be controlled by executing a command line.
https://github.com/hjdhjd/homebridge-blinds-cmd

homebridge homebridge-blinds-cmd homebridge-plugin homekit homekit-support smart-motorized-blinds somfy window-blinds

Last synced: about 2 months ago
JSON representation

:sunrise: Homebridge plugin to enable window blinds to be controlled by executing a command line.

Awesome Lists containing this project

README

        

[![homebridge-blinds-cmd: Native HomeKit support for non-smart motorized blinds through command-line scripts](https://raw.githubusercontent.com/hjdhjd/homebridge-blinds-cmd/master/homebridge-blinds-cmd.svg)](https://github.com/hjdhjd/homebridge-blinds-cmd)

# Homebridge Blinds Command

[![Downloads](https://img.shields.io/npm/dt/homebridge-blinds-cmd?color=%23333333&logo=icloud&logoColor=%23FFFFFF&style=for-the-badge)](https://www.npmjs.com/package/homebridge-blinds-cmd)
[![Version](https://img.shields.io/npm/v/homebridge-blinds-cmd?label=Homebridge%20Blinds%20Cmd&color=%23333333&style=for-the-badge&logoColor=%23FFFFFF&logo=data:image/svg%2bxml;base64,PHN2ZyB3aWR0aD0iMTAyNHB4IiBoZWlnaHQ9IjEwMjRweCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CjxnIHN0eWxlPSIiPiAgPHBhdGggZD0iTTg2LjI5MTAwMCwyMjIuNTIyOTk1IEwzNy41MDA5OTksMjk3LjE1OTk5NiBMOTg2LjUwMDAyMywyOTcuMTU5OTk2IEw5MzcuNzEwMDIyLDIyMi41Mjg5OTkgTDg2LjI4NzA0OCwyMjIuNTI4OTk5IEw4Ni4yOTEwMDAsMjIyLjUyMjk5NSBaICIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHlsZT0iZml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9rZT0iIyhudWxsKSIgc3Ryb2tlLXdpZHRoPSI0MS4xMDc0OTgiIC8+CiAgPHBhdGggZD0iTTg2LjI5MTAwMCw3MjYuODQwMDI3IEwzNy41MDA5OTksODAxLjQ3NzAyOCBMOTg2LjUwMDAyMyw4MDEuNDc3MDI4IEw5MzcuNzEwMDIyLDcyNi44NDYwMzEgTDg2LjI4NzA0OCw3MjYuODQ2MDMxIEw4Ni4yOTEwMDAsNzI2Ljg0MDAyNyBaICIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHlsZT0iZmlsbDogcmdiYSgyNTUsIDI1NSwgMjU1LCAxLjAwMDAwMCk7IHN0cm9rZS13aWR0aDogNDEuMTA3NDk4cHg7IHN0cm9rZTogKG51bGwpOyAiIGZpbGw9IiNmZWZmZmYiIHN0cm9rZT0iIyhudWxsKSIgc3Ryb2tlLXdpZHRoPSI0MS4xMDc0OTgiIC8+CjwvZz48L3N2Zz4=)](https://www.npmjs.com/package/homebridge-blinds-cmd)
[![UniFi Protect@Homebridge Discord](https://img.shields.io/discord/432663330281226270?color=%23333333&label=Discord&logo=discord&logoColor=%23FFFFFF&style=for-the-badge)](https://discord.gg/QXqfHEW)
[![verified-by-homebridge](https://img.shields.io/badge/homebridge-verified-blueviolet?color=%2357277C&style=for-the-badge&logoColor=%23FFFFFF&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI5OTIuMDkiIGhlaWdodD0iMTAwMCIgdmlld0JveD0iMCAwIDk5Mi4wOSAxMDAwIj48ZGVmcz48c3R5bGU+LmF7ZmlsbDojZmZmO308L3N0eWxlPjwvZGVmcz48cGF0aCBjbGFzcz0iYSIgZD0iTTk1MC4xOSw1MDguMDZhNDEuOTEsNDEuOTEsMCwwLDEtNDItNDEuOWMwLS40OC4zLS45MS4zLTEuNDJMODI1Ljg2LDM4Mi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wxMDMuMzctLjlMNzU4LjEsNjM5Ljc1YTE2LjEzLDE2LjEzLDAsMCwwLDIyLjY2LDBsMzguNDMtMzguNDNhMTYuMTMsMTYuMTMsMCwwLDAsMC0yMi42Nkw1MDYuNSwyNjUuOTNhMTYuMTEsMTYuMTEsMCwwLDAtMjIuNjYsMEwxNjQuNjksNTgwLjQ0QTczLjY5LDczLjY5LDAsMCwxLDYxLjEsNTgwTDIxLjU3LDU0MC42OWwtLjExLS4xMmE3My40Niw3My40NiwwLDAsMSwuMTEtMTAzLjg4TDQzNi44NSwyMS40MUE3My44OSw3My44OSwwLDAsMSw1NDAsMjAuNTZMNjYyLjYzLDEzOS4zMnYtMS4xYTczLjYxLDczLjYxLDAsMCwxLDczLjU0LTczLjVINzg4YTczLjYxLDczLjYxLDAsMCwxLDczLjUsNzMuNVYzMjkuODFhMTYsMTYsMCwwLDAsNC43MSwxMS4zMmw4My4wNyw4My4wNWguNzlhNDEuOTQsNDEuOTQsMCwwLDEsLjA4LDgzLjg4WiIvPjwvc3ZnPg==)](https://github.com/homebridge/homebridge/wiki/Verified-Plugins)

## HomeKit support for non-smart motorized blinds through command-line scripts.

`homebridge-blinds-cmd` is a [Homebridge](https://homebridge.io) plugin that allows you to raise, lower, and get the current position of your window blinds by executing a given command-line or script. It makes a HomeKit window covering accessory available to you that can report status and be controlled entirely through command-line scripts.

## Why use this plugin for window blinds support in HomeKit?
These days, there is a decent selection of window blinds available on the market with native HomeKit support. However, there are also blinds systems, such as Somfy, which don't have any meaningful HomeKit support. Add to that the proprietary remote protocols and you're in for a challenge in trying to make window blinds part of your [HomeKit](https://www.apple.com/ios/home) smart home.

There are other blinds plugins for Homebridge that are either tailored to specific blinds solutions, or more broadly focused on blinds that can be controlled through HTTP -- and they do a great job if that's what you're seeking. You can certainly do those things with this plugin, though you'll be writing your own scripts to do so. So why use this plugin in particular in this scenario? Well, in some cases you've got complex state conditions you want to reflect in HomeKit.

For instance, let's take the example of a living room with two motorized Somfy shades (I'm picking Somfy for this example because it's what I'm most familiar with, but other brands have similar concepts). In our example, we have a remote control that has three presets configured - one to control the first shade, one to control the second shade, and one to control both simultaneously. Controlling each of the individual shades is an easy enough task for most of the blinds-related Homebridge plugins.

That last scenario though can be tricky. What if you want to expose, for the sake of argument, the three presets described above as three shades in HomeKit. What you'd like is that when you raise or lower that third preset, the one that controls two shades simultaneously, that HomeKit also reflects the updates across those shades. This type of relational mapping between shades and presets can be challenging to make work. That's what this plugin is for. Allowing you to do easy things like controlling an individual shade and providing you the flexibility to implement more complex things, should you choose to do so, in the form of command-line scripts.

### Changelog
Changelog starting with v2.0 is available [here](https://github.com/hjdhjd/homebridge-blinds-cmd/blob/master/Changelog.md).

## Installation
If you are new to Homebridge, please first read the [Homebridge](https://homebridge.io) [documentation](https://github.com/homebridge/homebridge/wiki) and installation instructions before proceeding.

If you have installed the [Homebridge Config UI](https://github.com/oznu/homebridge-config-ui-x), you can intall this plugin by going to the `Plugins` tab and searching for `homebridge-blinds-cmd` and installing it.

If you prefer to install `homebridge-blinds-cmd` from the command line, you can do so by executing:

```sh
sudo npm install -g homebridge-blinds-cmd
```

## Configuration
I strongly recommend using the [Homebridge Config UI](https://github.com/oznu/homebridge-config-ui-x) rather than editing your config.json directly. It does a good job of showing you all the options and always generating a valid configuration so you don't get stuck on typos or looking for stray commas in your `config.json`.

For those that prefer configuring things directly, add the accessory in `config.json` in your home directory inside `.homebridge`.

```js
"platforms": [
{
"platform": "Blinds Command",

"blinds": [
{
"name": "Downstairs Window Blinds",
"manufacturer": "Somfy",
"model": "Sonesse",
"serial": "1234",
"up": "/path/to/your/raise_blinds_script",
"down": "/path/to/your/lower_blinds_script",
"status": "/path/to/your/blinds_state_script",
"stop": "/path/to/your/stop_blinds_script",
"transitionInterval": 10,
"refreshRate": 5
}
]
}
]
```

### Options
* `up`, `down`, `stop`, and `status` should point to scripts or command lines to run to execute those actions. `up` and `down` are required, and all others are optional.
* Setting a `stop` command in conjunction with a `transitionInterval` will allow you to simulate partially opening or closing your blinds, enabling scenarios such as asking HomeKit to open the blind to a certain percentage (e.g. Hey Siri, set the blinds to 30%).
* `manufacturer`, `model`, and `serial` are optional settings to allow you to further identify your blinds in HomeKit.
* `transitionInterval` is an optional setting that allows you to simulate a blind transition movement between open and closed. If it takes 15 seconds for the blinds to open, enter `15` here and `homebridge-blinds-cmd` will simulate the time it takes to complete that transition in HomeKit. The default is 10 seconds.
* `refreshRate` will execute the `status` command at whatever refresh rate you set, in seconds. This is useful when the state of your blinds changes outside of HomeKit, and you want to regularly check it's status.

### Script inputs and outputs
`homebridge-blinds-cmd` expected the following:

* **`status` script:** Should output a number from 0 to 100 to inform HomeKit of what the current position of the blind is.
* **`up`, `down`, or `stop` script:** Must be able to accept an additional argument containing the position that's been requested by the user.
For example:

```js
{
...
"up": "/path/to/raise_blinds_script"
...
}
```

All configured scripts (`up`, `down`, `stop`, and `status`) will be called as /path/to/raise_blinds_script 100, where 100 is whatever position was requested by the end user and passed on to HomeKit. This should enable those who wish to take advantage of situations where you may want to only open a shade half way, to do so. The script should output a number from 0 to 100 to inform HomeKit of what the new position of the blind is.

In the case of the `status` script, the value specified by `homebridge-blinds-cmd` represents the position that the plugin believes the blind is at. For example, if `homebridge-blinds-cmd` believes the blind is 30% open, it will check for status by executing `/path/to/status_script 30`. If you believe the number specified by the plugin is correct, you should return the same value: 30 in this case. Whatever value is returned by the status script is what HomeKit will ultimately report.

There are two example scripts to get you started in the scripts folder. They should help you get started whether you're using a Somfy URTSI or a Bond Bridge to control your shades.

## Notes
This plugin doesn't query nor have direct knowledge of the actual position of your blinds. Instead, it emulates the position based on your most recent request to raise / lower the blinds (i.e. it remembers what you last asked it to do and reports that back to HomeKit). Some blinds, such as Somfy, don't support querying their specific state. That said, if you do wish to use a specific position, you can do so. It's passed as the last argument to the up and down script configuration options. How you choose to handle it, is up to you. What your plugin should output is the position it wants to HomeKit (e.g. 100 if the blind is fully open).

Additionally, if you specify `transitionInterval` and `stop` you'll magically get the ability to move the blind a precise amount. For instance, if you try to open the blind to 20%, `homebridge-blinds-cmd` will run the `up` script and then use `transitionInterval` to figure out how many seconds to allow the blinds to move before running the `stop` script. The result, if you have `transitionInterval` correctly calculated for your blinds, should be relatively precise placement of your blinds at home - something that many popular blinds (e.g. Somfy), can't do natively! The [sample control script](https://github.com/hjdhjd/homebridge-blinds-cmd/blob/master/scripts/somfy-bond.pl) for Bond provides a good example of how to do this.

A sample control script for Somfy is included. This script is provided as an example of what is possible. Your mileage may vary - this script was tested on a Mac and should work on other platforms, best of luck. It assumes the use of a [Somfy URTSI](https://www.somfysystems.com/products/1810872/universal-rts-interface) attached to an [iTach Flex](https://www.globalcache.com/products/flex/)) via serial. The script is fairly robust and allows for multiple URTSI scenarios including multiple URTSIs and shade groups.

I've also used, and currently use, a [Bond Bridge](https://www.bondhome.io). It's a terrific device with builtin support for Somfy RF signals as well as a wide variety of IR and RF formats for shades, ceiling fans, and fireplaces. I highly recommend it as a more robust alternative to the Somfy URTSI, and at a much better price point.

## Plugin Development Dashboard
This is mostly of interest to the true developer nerds amongst us.

[![License](https://img.shields.io/npm/l/homebridge-blinds-cmd?color=%23333333&logo=open%20source%20initiative&logoColor=%23FFFFFF&style=for-the-badge)](https://github.com/hjdhjd/homebridge-blinds-cmd/blob/master/LICENSE.md)
[![Build Status](https://img.shields.io/github/workflow/status/hjdhjd/homebridge-blinds-cmd/Continuous%20Integration?color=%23333333&logo=github-actions&logoColor=%23FFFFFF&style=for-the-badge)](https://github.com/hjdhjd/homebridge-blinds-cmd/actions?query=workflow%3A%22Continuous+Integration%22)
[![Dependencies](https://img.shields.io/librariesio/release/npm/homebridge-blinds-cmd?color=%23333333&logo=dependabot&style=for-the-badge)](https://libraries.io/npm/homebridge-blinds-cmd)
[![GitHub commits since latest release (by SemVer)](https://img.shields.io/github/commits-since/hjdhjd/homebridge-blinds-cmd/latest?color=%23333333&logo=github&sort=semver&style=for-the-badge)](https://github.com/hjdhjd/homebridge-blinds-cmd/commits/master)