npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

homebridge-redis

v2.1.1-alpha.1

Published

Redis Plugin for Homebridge

Downloads

44

Readme

homebridge-redis

verified-by-homebridge

NPM version

Homebridge-redis is a Plugin for Homebridge. The design is based on MVC pattern, have a look at homebridge-mvc. Homebridge-redis is a dynamic Plugin that allows you to add and control accessories from a "Bridge" or "Device" with a redis API. Node-RED is the perfect platform to use with homebridge-redis.

Note-RED is a visual tool for wiring together hardware devices, APIs and online services.

Installation

If you are new to Homebridge, please first read the documentation to install Homebridge.

Install the homebridge-redis plugin through Homebridge Config UI X.

Configuration/Setting

Go to Homebridge Config UI X, select Plugins > Homebridge redis and click SETTINGS.

config.json

"platforms": [
  {
    "platform": "redis",
    "name": "redis",
    "url": "redis://127.0.0.1",
    "port": "1883",
    "username": "foo",
    "password": "bar",
    "qos": 1,
    "cert": "/path/to/certificate.pem",
    "key": "path/to/key.pem",
    "ca": "/path/to/ca_certificate.pem",
    "client_id": "some-string",
    "topic_type": "multiple",
    "topic_prefix": "homebridge"
  }
]

Replace 127.0.0.1 with the ip-address of your redis broker.

topic_type multiple: the data is sent to all devices, e.g.

topic : homebridge/from/set

topic_type single: the data is sent to a single device, the accessory name is added to the topic, e.g.

topic : homebridge/from/set/flex_lamp

redis API

The data (payload) is sent/received in a JSON format using following topics:

  • homebridge/to/add
  • homebridge/to/add/service
  • homebridge/to/remove
  • homebridge/to/remove/service
  • homebridge/to/get
  • homebridge/to/set
  • homebridge/to/set/reachability
  • homebridge/to/set/accessoryinformation
  • homebridge/from/get
  • homebridge/from/set
  • homebridge/from/response
  • homebridge/from/identify

Version 0.3.0 and higher supports multiple services. To handle multiple services a new property service_name has been introduced.

Note: To add a service to an existing accessory (created prior version 0.3.0) please first remove the accessory and add it again.

Note 2:

Optional parameter request_id: A unique (user defined) value may be added to any request, it will be included in the corresponding response.

request_id : 4711

Howto examples

add accessory

topic: homebridge/to/add
payload: {"name": "flex_lamp", "service_name": "light", "service": "Switch"}

or with the additional accessory informations

topic: homebridge/to/add
payload: 
{
  "name": "flex_lamp",
  "service_name": "light",
  "service": "Switch",
  "manufacturer": "lamp_manu",
  "model": "flex_007",
  "serialnumber": "4711",
  "firmwarerevision": "1.0.0"
}

response:

topic: homebridge/from/response
payload: {"ack": true, "message": "accessory 'flex_lamp' service_name 'light' is added."}

add service

Note: an accessory with the same name must be added before.

topic: homebridge/to/add/service
payload: {"name": "multi_sensor", "service_name": "humidity", "service": "HumiditySensor"}

response:

topic: homebridge/from/response
payload: {"ack": true, "message": "service_name 'humidity', service 'HumiditySensor' is added."}

remove accessory

topic: homebridge/to/remove
payload: {"name": "flex_lamp"}

response:

topic: homebridge/from/response
payload: {"ack": true, "message": "accessory 'flex_lamp' is removed."}

remove service

topic: homebridge/to/remove/service
payload: {"name": "multi_sensor", "service_name": "humidity"}

response:

topic: homebridge/from/response
payload: {"ack": true, "message": "accessory 'multi_sensor' service_name 'humidity' is removed."}

get accessory/accessories

The purpose of this topic is to retrieve accessory configurations. Use homebridge/from/set to control your devices.

topic: homebridge/to/get
payload: {"name": "outdoor_temp"}

homebridge sends the accessory configuration:

topic: homebridge/from/response
payload:
{
  "outdoor_temp": {
    "services": {
      "Temperature": "TemperatureSensor"
    },
    "characteristics": {
      "Temperature": {
        "CurrentTemperature": 13.4
      }
    }
  }
}
topic: homebridge/to/get
payload: {"name": "*"}

homebridge sends all accessory configurations:

topic: homebridge/from/response
payload:
{
  "node_switch": {
    "services": {
      "light": "Switch"
    },
    "characteristics": {
      "Light": {
        "On": true
      }
    }
  },
  "office_lamp": {
    "services": {
      "office_light": "Lightbulb"
    },
    "characteristics": {
      "office_light": {
        "On": "blank",
        "Brightness": 65
      }
    }
  },
  "living_temp": {
    "services": {
      "living_temperature": "TemperatureSensor"
    },
    "characteristics": {
      "living_temperature": {
        "CurrentTemperature": 19.6
      }
    }
  }
}
topic: homebridge/to/get
payload: {"name": "*_props"}

homebridge sends all accessory configurations, including properties:

topic: homebridge/from/response
payload:
{
  "node_switch": {
    "services": {
      "light": "Switch"
    },
    "characteristics": {
      "Light": {
        "On": true
      }
    },
    "properties": {
      "Light": {
        "On": {
          "format": "bool",
          "unit": null,
          "minValue": null,
          "maxValue": null,
          "minStep": null,
          "perms": [
            "pr",
            "pw",
            "ev"
          ]
        }
      }
    },
    "office_lamp": {
      "services": {
        "office_light": "Lightbulb"
      },
      "characteristics": {
        "office_light": {
          "On": "blank",
          "Brightness": 65
        }
      },
      "properties": {
        "office_light": {
          "On": {
            "format": "bool",
            "unit": null,
            "minValue": null,
            "maxValue": null,
            "minStep": null,
            "perms": [
              "pr",
              "pw",
              "ev"
            ]
          },
          "Brightness": {
            "format": "int",
            "unit": "percentage",
            "minValue": 0,
            "maxValue": 100,
            "minStep": 1,
            "perms": [
              "pr",
              "pw",
              "ev"
            ]
          }
        }
      }
    },
    "living_temp": {
      "services": {
        "living_temperature": "TemperatureSensor"
      },
      "characteristics": {
        "living_temperature": {
          "CurrentTemperature": 19.6
        }
      },
      "properties": {
        "living_temperature": {
          "CurrentTemperature": {
            "format": "float",
            "unit": "celsius",
            "minValue": 0,
            "maxValue": 100,
            "minStep": 0.1,
            "perms": [
              "pr",
              "ev"
            ]
          }
        }
      }
    }
  }
}

set value (to homebridge)

topic: homebridge/to/set
payload: {"name": "flex_lamp", "service_name": "light", "characteristic": "On", "value": true}

get value (from homebridge)

topic: homebridge/from/get
payload: {"name": "flex_lamp", "service_name": "light", "service_type":"Switch", "characteristic": "On", "cachedValue": true}

Homebridge-redis will return the cached value to HomeKit. Optionally you can publish the actual value using homebridge/to/set.

set value (from homebridge)

topic: homebridge/from/set
payload: {"name": "flex_lamp", "service_name": "light", "service_type":"Switch", "characteristic": "On", "value": true}

get (cached) value (to homebridge)

topic: homebridge/to/get/characteristic
payload: {"name": "flex_lamp", "service_name": "light", "characteristic": "On"}

response:

topic: homebridge/from/response
payload: {"name": "flex_lamp", "service_name": "light", "characteristic": "On", "cachedValue": true}

set accessory information

topic: homebridge/to/set/accessoryinformation
payload: {"name": "flex_lamp", "manufacturer": "espressif", "model": "esp8266-12", "serialnumber": "4711", "firmwarerevision": "1.1.0"}

identify accessory

topic: homebridge/from/identify
payload: {"name":"indoor_temp","manufacturer":"homebridge-redis","model":"v0.3.0","serialnumber":"2017-02-13T12:17"}

define characterstic

The required characteristics are added with the default properties. If you need to change the default, define the characteristic-name with the properties. e.g.:

topic: homebridge/to/add
payload:
  {
    "name": "living_temp",
    "service_name": "temperature",
    "service": "TemperatureSensor",
    "CurrentTemperature": {"minValue": -20, "maxValue": 60, "minStep": 1}
  }

To add an optional charachteristic define the characteristic-name with "default" or with the properties. e.g.:

topic: homebridge/to/add
payload: 
  {
    "name": "living_lamp",
    "service_name": "light",
    "service": "Lightbulb",
    "Brightness": "default"
  }
topic: homebridge/to/add
payload:
  {
    "name": "bathroom_blind",
    "service_name": "blind",
    "service": "WindowCovering",
    "CurrentPosition": {"minStep": 5},
    "TargetPosition": {"minStep": 5},
    "CurrentHorizontalTiltAngle": {"minValue": 0, "minStep": 5},
    "TargetHorizontalTiltAngle": {"minValue": 0, "minStep": 5}
  }

HomeKit.ts describes all the predifined Services, Characteristcs, format and properties for the value e.g.:

/**
 * Service "Contact Sensor"
 */

Service.ContactSensor = function(displayName, subtype) {
  Service.call(this, displayName, '00000080-0000-1000-8000-0026BB765291', subtype);

  // Required Characteristics
  this.addCharacteristic(Characteristic.ContactSensorState);

  // Optional Characteristics
  this.addOptionalCharacteristic(Characteristic.StatusActive);
  this.addOptionalCharacteristic(Characteristic.StatusFault);
  this.addOptionalCharacteristic(Characteristic.StatusTampered);
  this.addOptionalCharacteristic(Characteristic.StatusLowBattery);
  this.addOptionalCharacteristic(Characteristic.Name);
};

/**
 * Characteristic "Contact Sensor State"
 */

Characteristic.ContactSensorState = function() {
  Characteristic.call(this, 'Contact Sensor State', '0000006A-0000-1000-8000-0026BB765291');
  this.setProps({
    format: Characteristic.Formats.UINT8,
    perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY]
  });
  this.value = this.getDefaultValue();
};

inherits(Characteristic.ContactSensorState, Characteristic);

Characteristic.ContactSensorState.UUID = '0000006A-0000-1000-8000-0026BB765291';

// The value property of ContactSensorState must be one of the following:
Characteristic.ContactSensorState.CONTACT_DETECTED = 0;
Characteristic.ContactSensorState.CONTACT_NOT_DETECTED = 1;

Derived from this:

service = ContactSensor
characteristic = ContactSensorState
format = UINT8
property = 0 or 1

Node-red example

node-red-redis

For more examples take a look at the wiki