GithubHelp home page GithubHelp logo

homebridge-particle's Introduction

Particle device plugin for Homebridge

As you all know in the new version of Homebridge, the plugin architecture is changed. In new Homebridge, plugins are published through NPM with name starts with homebridge-. Users can install the plugin using NPM.

My previous example of Particle and Homebridge uses old plugin architecture. I have been thinking for a long time to upgrade my previous plugin to the new architecture. But because of many reasons it is delayed. Luckily last week I was able to complete and publish to NPM.

You can install it using NPM like all other modules, you can install using:

npm install -g homebridge-particle.

In this version, I have made some changes from the older version. Mainly the plugin is now a Homebridge Platform. Also in this version accessories are defined in config.json file. The plugin loads the accessories from the config.json file and create accessory dynamically. A sample configuration file is like:

{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:22:3D:E3:CE:39",
        "port": 51826,
        "pin": "031-45-154"
    },
    
    "description": "This is an example configuration file with one Particle platform and 3 accessories, two lights and a temperature sensor. You should replace the access token and device id placeholder with your access token and device id",

    "platforms": [
        {
            "platform": "Particle",
            "name": "Particle Devices",
			"access_token": "<<access token>>",
			"cloudurl": "https://api.spark.io/v1/devices/",
			"devices": [
				{
					"accessory": "BedroomLight",
					"name": "Bedroom Light",
				    "deviceid": "<<device id>>",
					"type": "LIGHT",
					"function_name": "onoff",
					"args": "0={STATE}"
				},
				{
					"accessory": "KitchenLight",
					"name": "Kitchen Light",
					"deviceid": "<<device id>>",
					"type": "LIGHT",
					"function_name": "onoff",
					"args": "1={STATE}"
				},
				{
					"accessory": "KitchenTemperature",
					"name": "Kitchen Temperature",
					"deviceid": "<<device id>>",
					"type": "SENSOR",
					"sensorType": "temperature",
					"key": "temperature",
					"event_name": "tvalue"
				}
			]
        }
    ]
}

As you can see from the above example this config.json file defines 3 accessories. 2 Lights and one Temperature Sensor. The access_token defines the Particle Access Token and cloudurl defines the base Particle API url. If you are using the Particle Cloud, then the value of cloudurl should be https://api.spark.io/v1/devices/. If you are using local cloud, then replace with your sensor address.

The devices array contains all the accessories. You can see the accessory object defines following string objects:

  • accessory - Accessory name, this is the name of the accessory.
  • name - Display name, this is the name to be displayed on the HomeKit app.
  • deviceid - Device ID of the Particle Device (Core, Photon or Electron). It is defined in accessory so that you can use different Particle Devices for different accessory.
  • type - Type of the accessoy. As of now, the plugin supports 2 type, LIGHT and SENSOR. Type LIGHT represents a light, such as bedroom light, kitchen light, living room light, etc... Type SENSOR represents sensor accessory such as Temperature sensor, Humidity sensor, Light sensor, etc...
  • sensorType - Optional Sensor Type, this string object is optional. This is only valid when the accessory type is SENSOR. As of now the plugin supports 3 types of sensors, Temperature Sensor, Humidity Sensor and Light Sensor. More sensor will be supports in future versions.
  • event_name - The name of the event to listen for sensor value update. This is only valid if the accessory type is SENSOR. If the accessory is a type of SENSOR, then the plugin listens for events published from Particle Device (using Particle.publish). The device firmware should publish the sensor values in the format key=value. The key identifies the sensor value. For a temperature sensor the key should be temperature. For a humidity sensor the key should be humidity. For light sensor it should be light.
  • key - Name of the key, this is not used in this version of the plugin. This is included for future purpose.

homebridge-particle's People

Contributors

krvarma avatar moors7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

homebridge-particle's Issues

Issues with Sensor

Hi,
I am trying to use your solution for a temperature monitor. I have successfully installed the plugin and configured the config.json as below

"accessory": "DiningTempSensor",
"name": "Dining Room",
"deviceid": "XXXXXXX", - removed for privacy
"type": "SENSOR",
"sensorType": "temperature",
"key": "temp",
"event_name": "temperature"

my Particle Photon sketch is publishing the following event info

event Name: temperature
Data: temperature=19.10000000

the homebridge log is showing the following

temperature = 19.100000, Dining Room, temperature, temp, temperature
false

The accessory has appeared on my phone under homekit for my house, but the value 19.1 is not being shown, it just shows default.

Am I doing something wrong here? what is the false flag that is shown on the homebridge log

thanks for your help, this is a great project

Particle Data mismatch

Hi @krvarma,

I am running a PietteTech_DHT code on my particle photon, and the data that is being sent to Particle is in a different format to what the plugin is looking for:

Particle reports:
{"data":"23","ttl":"60","published_at":"2016-06-10T11:47:51.192Z","coreid":"390031001347353236343033","name":"Temperature"}

The API call, actually reports this as:

event: Temperature
data: {"data":"23","ttl":"60","published_at":"2016-06-10T11:47:51.192Z","coreid":"390031001347353236343033"}

the plugin is expecting:

console.log(tokens[0] + " = " + tokens[1] + ", " + this.services[1].displayName + ", " + this.sensorType + ", " + this.key.toLowerCase() + ", " + tokens[0].toLowerCase()); console.log(this.services[1] != undefined && this.key.toLowerCase() ===tokens[0].toLowerCase());``

So in this case, it is actually receiving the temperature in token 0, rather than in token 1.

As the data on Particle is in the key:value format, could the plugin be re-written as:

console.log(tokens.name + " = " + tokens.data ?

multiple sensors on single device

@krvarma:

how would you publish two sensors on the same device?
In your example config.json:


     {
                    "accessory": "KitchenTemperature",
                    "name": "Kitchen Temperature",
                    "deviceid": "<<device id>>",
                    "type": "SENSOR",
                    "sensorType": "temperature",
                    "key": "temperature",
                    "event_name": "tvalue"
                }

Yet, if you were to publish like this:

    {
                    "accessory": "KitchenTemperature",
                    "name": "Kitchen Temperature",
                    "deviceid": "<<device id>>",
                    "type": "SENSOR",
                    "sensorType": "temperature",
                    "key": "temperature",
                    "event_name": "tvalue"
                },
                {
                    "accessory": "KitchenHumidity",
                    "name": "Kitchen Humidity",
                    "deviceid": "<<device id>>",
                    "type": "SENSOR",
                    "sensorType": "humidity",
                    "key": "humidity",
                    "event_name": "hvalue"
                }

Yet using the same Device ID (as the result is coming from the same particle device), HomeKit reports that you cannot use the same device UUID as another accessory.

Temperature is always 20

The homebridge-particle module is visible to the iOS Home app, but it always shows 20 โ„ƒ and I know the temperature is actually different because I can see it in the Particle iOS app. I don't know JS, but it looks like 20 is some sort of default value in the module.

I have since changed my Photon to publish the temperature this format:

Particle.publish("temperature", "temperature=23.000000", 60, PRIVATE);

and I now see correct temperatures displayed by the Home app. The docs should make this a little clearer, though it'd be nice to just be able to publish the raw value instead.

Call Particle Proton Function

I have installed homebridge-particle and have it successfully subscribed to events and working. I am trying to get a successful function call

my Proton has the following function exposed
get ACStatus
it accepted a string Args and I have made is accept a string in the format "1=1" and "1=0". If I type these strings into the particle iPhone app, the function works as expected

my accessoryr section in config.json is
"accessory": "Airconditioner",
"name": "Air Conditioner",
"deviceid": "removed for privacy",
"type": "LIGHT",
"function_name": "setACStatus",
"args": "1={STATE}"

The accessory is visible in Homekit and I can toggle the button, however the function is not sucessfully called and is not triggered, what am I doing wrong

thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.