-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to use custom characteristics? #2
Comments
The actual version doesn't support custom characteristics. It's on the todo list. |
how can i use the topic just like [homebridge/to/set],to set an TemperatureSensor of value's ? |
+1 Let me explain: I like to switch from several device plug-ins (Sony-Bravia tv, Yamaha amp) to mqtt and a python deamon. As with the device plugins the "string" chacateristic holds the name of the input like "HDMI1" or the name of the tv channel "NGC HD". Within HomeKit (EVE does work with those, like some other apps, apples "home" does not) I can create scenes with the name "National Geographic" where I need to set the amp input characteristic to "Audio1" and the tv channel characteristic to the appropriate URI given by the TV. Tinkering with the device plugins I was able to do this by creating a "STRING" type characteristic, where the props are set to READ/WRITE/NOTIFY. I have looked into the sources of homebridge-Mqtt. And as far as I can see the "STRING" values are dropped, which could be a quick fix. I am not really a nodesjs fan nor expert as 99% of my dev work is python related, the whole concept of prototypes confuses me a bit. Dealing with props of a characteristic seems in order except for the interface to the HB-Mqtt API. As for now, hb-Mqtt seems to support all default types, defined in the hab layer. I might be able to contribute, but with a lot of overhead (digging into the inner workings of this plugin and stuff like GIT, never forked and contributed to a project). Without these options I get a bit stuck in continuing building what is needed. Martijn |
I have confirmed the adding of my own types in HomeKitTypes.js and that the handling of STRING characteristics is broken in the repo as we speak. More info in a new posted Issue, where I report on how to create custom services and characteristics and found out that STRING support is an easy fix. I am seriously considering implementing custom charactereristics an services to the mqtt API. There seem two things which needs to be done: Topic homebridge/to/characteristic Likewise for defining a service. Afterwards, the service instance can be made like any other. Additional management (remove/list) might be useful, not sure yet. Any comments or tips might come in handy. Most of the code seems already there I guess just some additional glue seems needed. Helmsman |
The string issue should be fixed with the new version. |
A solution with a separate file:
var inherits = require('util').inherits;
var Characteristic = require('../Characteristic').Characteristic;
var Service = require('../Service').Service;
/**
* Characteristic "Current Air Pressure"
*/
Characteristic.CurrentAirPressure = function() {
Characteristic.call(this, 'CurrentAirPressure', '00000102-0000-1000-8000-0026BB765291');
this.setProps({
format: Characteristic.Formats.UINT16,
perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY]
});
this.value = this.getDefaultValue();
};
inherits(Characteristic.CurrentAirPressure, Characteristic);
Characteristic.CurrentAirPressure.UUID = '00000102-0000-1000-8000-0026BB765291';
/**
* Service "Air Pressure Sensor"
*/
Service.AirPressureSensor = function(displayName, subtype) {
Service.call(this, displayName, '00000101-0000-1000-8000-0026BB765291', subtype);
// Required Characteristics
this.addCharacteristic(Characteristic.CurrentAirPressure);
// Optional Characteristics
this.addOptionalCharacteristic(Characteristic.Name);
};
inherits(Service.AirPressureSensor, Service);
Service.AirPressureSensor.UUID = '00000101-0000-1000-8000-0026BB765291';
var HomeKitTypesCustom = require('./HomeKitTypes-Custom');
|
... how to use: add an accessory: topic: homebridge/to/add
payload:
{
"name": "netatmo",
"service_name": "outdoor_temp",
"service": "TemperatureSensor",
"CurrentTemperature": {
"minValue": -20,
"maxValue": 60,
"minStep": 1
}
} add the new service: topic: homebridge/to/add/service
payload:
{
"name": "netatmo",
"service_name": "outdoor_pressure",
"service": "AirPressureSensor"
} set the value: topic: hoembridge/to/set
payload:
{
"name": "netatmo",
"service_name": "outdoor_pressure",
"characteristic": "CurrentAirPressure",
"value": 1025
} |
This is indeed what I do, except that I patch the configs in the homekittypes.js As it is now, this is not really a homebridge-mqtt issue, as we patch a required library of homebridge. In fact this something hap-node should allow. At the other end, many plugins do create characteristics and service at init of the plugin.. I need to dig into it a bit further somehow this must be tackled in a way that does not confuse people after upgrades etc. There is tons of code to be read, so be patient please. Helmsman |
I think I have found a solution on implementing custom characteristics and services. I might need Some help with forking this repo and putting the changes back. I have messed up something in git hub once majorly and never got a clue wat went wrong. First I must see if my theory actually works. After I have a proof of concept, I will start some discussion about how to integrate this in the mqtt API. I'm committed to get this working, as said before It would be really cool and useful! Helmsman |
Would cfluin's solution make it possible to have both a fan and a light under the same accessory? So i wouldn't have to add two separate accessories for the same hardware accessory. For example if I add the characteristics for a fan and a light in the same service when it gets exposed to homekit would it have a light and a fan control or would I have to do something else to accomplish this? |
I am slowly progressing mainly because I am not a Javascript/NodeJS fan nor expert. @CaptiveCreeper: yes. In homekit a Accessory can have multiple characteristics this module supports that fully. If you scroll up, you can see a code example of how to Add a "Service" read that as "Accessory" and you probably have your question answered. I am adding some code to add the Service and Characteristics at runtime (probably over mqtt). This way an MQTT endpoint can configure itself for use with homebridge over MQTT via this plugin |
@helmsman35 Any progress on your method to add custom services/characteristics? I'd go with the method @cflurin said, but I worry it'll break updating homebridge or would be overwritten upon updating homebridge. |
I sort of stopped using homebridge, since i’m a python guy and sort of hate prototype languages (like JavaScript). So I got rid of my nodejs Installation in favor of homeassistant. As we speak I am implementing HomeKit support for that.
Homebridge has it all wrong, homekit is not a set of predefined stuff, it is open and extendable.
Use the way @cflurin supposes with the single line include. That will be the only line to be added after upgrades.
… Op 30 nov. 2017 om 00:20 heeft Ian ***@***.***> het volgende geschreven:
@helmsman35 Any progress on your method to add custom services/characteristics?
I'd go with the method @cflurin said, but I worry it'll break updating homebridge or would be overwritten upon updating homebridge.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I agree with the above; HomeKit of course supports custom characteristics and services, not just Home.app (yet). Have things changed since this with regard to custom properties? @cflurin |
Nick Farina just now on how to implement custom characteristics homebridge/homebridge#1453 (comment) |
You are right of course. I got momentarily confused. That would of course also be “ahead of time” and not dynamic custom. |
So just to try and clarify a confusing situation - custom characteristics really aren't very magical. Characteristics are just UUIDs with a small "props" dictionary that defines the kind of value they accept and some other metadata. The only magic is that all the characteristics pre-defined in But you can easily, and at any time, create new instances of the Characteristic class (or subclass it if you want, but it's just syntactic sugar) with your own randomly-generated UUID and props. There's nothing special about it. If |
@nfarina as far as I understand, only the "known" UUID's show up in the home app for anything else one needs to use an app that supports those ? Looking at the netatmo plugin, it adds a noiselevel/dB icon to the home app, which is something custom but does shows up. How does this work ? |
So you can add all the "unknown" custom characteristics you want, and the main limitation is Siri won't know what to do with them. But you can still add them to Automations and Scenes and view their values directly in the Home app (if you know where to look). |
How can i set custom characteristics from node-red, for example the type that Eve has for power consumption?
(see example here on row 38, for the UUID that the Eve App recognises):
https://github.com/Samfox2/homebridge-domotiga/blob/3319c01317a8b0e55af821869cdd81d19e3478d1/index.js
The text was updated successfully, but these errors were encountered: