NRCHKB / node-red-contrib-homekit-bridged

Node-RED Contribution - HomeKit Bridged : Node-RED nodes to simulate Apple HomeKit devices.
https://nrchkb.github.io
MIT License
423 stars 52 forks source link

Is it possible to add support for any custom characteristic ? #52

Open faronov opened 5 years ago

faronov commented 5 years ago

I think this will be a good idea for the roadmap just add a possibility to create any custom characteristic like add any UUID type and name for that? it will be allowed to add any custom characteristic to EVE app.

faronov commented 5 years ago

You can check an example of how it can be extended that will add the possibility to create any services and any accessories https://github.com/RavenSystem/esp-homekit-devices/blob/master/devices/common/custom_characteristics.h

fschaefer commented 5 years ago

Please see: https://github.com/KhaosT/HAP-NodeJS/blob/master/lib/Characteristic.js#L21

Shouldn't be difficult to integrate, i.e. probably just setting a custom UUID.

An example of an custom characteristic AtmosphericPressureLevel can be found here: https://github.com/rxseger/homebridge-bme280/blob/master/lib/CustomCharacteristic.js#L12

Shaquu commented 5 years ago

@faronov @fschaefer I finally made up my mind to look at this and add it in near future.

How do you see it to be used actually? Is it for using Eve? Or other apps? How do you see adding custom characteristics? Should we add them to code or allow users to add them?

Shaquu commented 5 years ago

Bump. Your opinion is important for me.

faronov commented 5 years ago

Currently this available for Eve, not sure about other apps I think we must allow a user to specify any UUID for custom characteristic and add details

Shaquu commented 5 years ago

Can you make an example of such? I mean details of custom characteristics.

faronov commented 5 years ago

check this https://github.com/RavenSystem/esp-homekit-devices/blob/master/devices/common/custom_characteristics.h#L27 it has a bunch of custom characteristics

faronov commented 5 years ago

this also a good example https://github.com/rxseger/homebridge-bme280/blob/master/lib/CustomCharacteristic.js#L12 Apple did not support pressure for sensor but eve support it if you wish to add this information to show in eve app you just add eve defined UUID for that and it will show up in eve app

faronov commented 5 years ago

this is also a good example https://github.com/simont77/homebridge-weather-station-eve it will not only show all weather details, but it will show graphic history like that https://i.imgur.com/8opO7hel.png

sjorge commented 5 years ago

@Shaquu maybe some sort of config option to 'define' them on the bridge, and then have the available by pretty name on the services? (Or in the fancy UI once that gets implemented)

I'll probably also be using a few of them to map some of the stuff my Aqara zigbee sensors data so that I can view it in Eve.

lslomczynski commented 4 years ago

Hello! A good example for custom characteristics is Samsung's air conditioner with WindFree mode. Right now neither "thermostat" nor "coolerheater" item allows to push such a mode to the A/C and of course - this is the one I use most often :-) Only the standard ones like: Heat / Cool / Dry / Auto are available.

Part of the device status response: "airConditionerMode": { "supportedAcModes": { "value": [ "aIComfort", "cool", "dry", "wind", "auto", "heat"

After update of Samsung Automation Studio (v 1.0.11) my device accepts / reports following parameters: Samsung_Avant_Windfree_1.0.11

Shaquu commented 3 years ago

Feature is ready to be tested on dev branch.

  1. Drag and drop new node called NRCHKB (it is an optional node, used only for changing Custom Characteristics, after you add them you can remove node from flow)
  2. Specify Characteristics in NRCHKB node editor (for example we add Characteristic called Test)
  3. Add Test to Characteristic Properties for your Service ({"Test": true} should be enough)
crxporter commented 3 years ago

Heads up all, this is being built now. We are looking for feedback on the best way to handle it. Please join the discussion on discord if you have thoughts!

https://discord.gg/uvYac5u

Shaquu commented 3 years ago

From now on this feature is labeled as experimental. To enable it run node-red with NRCHKB_EXPERIMENTAL=true env variable.

CaseyRo commented 3 years ago

hi everyone, I’d like to test the functionality and with some tinkering have the newest dev version (38) running on nodered 1.2.9 (in a docker container).

The package shows up and so does the nodes relevant to this, but for some reason the NRC* node doesn’t show up in my palette:

Bookmarks

Am I missing something? Some hidden handshake to drag it to my flows?

crxporter commented 3 years ago

Are you running with experimental mode as described by Shaquu in the comment just above yours? I haven't actually tried this feature yet but I'm following along a bit.

Shaquu commented 3 years ago

As said @CaseyRo read my previous comment :) You need to start NodeRED with special parameter.

https://github.com/NRCHKB/node-red-contrib-homekit-bridged/issues/52#issuecomment-790752453

CaseyRo commented 3 years ago

I was aware of that part - so I added it to the docker composer setup as an environment variable (and the node specific project variable too, to make sure this works):

PNG image

unfortunately, still no node showing up in my palette. I could build a separate docker image to have this env variable around when launching, would that make a difference? (I guess not, but you’re the expert here!)

Shaquu commented 3 years ago

First thing, add DEBUG=NRCHKB* env variable. Start container and share the logs from boot.

Second consider using our image nrchkb/node-red-homekit

CaseyRo commented 3 years ago

2021-03-23T17:30:39.676Z NRCHKB:HAPHostNode [CYB:7371888d.19c8e] Creating Bridge with UUID 00989278-93fe-4160-a9a0-2d8265ffef59

2021-03-23T17:30:42.303Z NRCHKB:HAPServiceNode [testkees:a177d0d.8518bb] Starting Parent Service

2021-03-23T17:30:42.314Z NRCHKB:AccessoryUtils [testkees:a177d0d.8518bb] Looking for accessory with service subtype 7504ba4e-507a-4ced-aba9-ada697d1958e ...

2021-03-23T17:30:42.315Z NRCHKB:AccessoryUtils [testkees:a177d0d.8518bb] ... didn't find it. Adding new accessory with name testkees and UUID 0c3e7fad-ad90-41f3-9d37-ea8395cd233c

2021-03-23T17:30:42.322Z NRCHKB:AccessoryUtils [testkees:a177d0d.8518bb] Bridge now has 1 accessories.

2021-03-23T17:30:42.323Z NRCHKB:ServiceUtils [testkees:a177d0d.8518bb] Looking for service with UUID 7504ba4e-507a-4ced-aba9-ada697d1958e ...

2021-03-23T17:30:42.324Z NRCHKB:ServiceUtils [testkees:a177d0d.8518bb] ... didn't find it. Adding new ServiceLabel service.

2021-03-23T17:30:47.330Z NRCHKB:HAPHostNode [CYB:7371888d.19c8e] Publishing Bridge with pin code 123-45-678 and 1 accessories

2021-03-23T17:30:47.359Z NRCHKB:BridgeUtils [testkees:a177d0d.8518bb] Bridge published

Logs filtered on NRCHKB.

Why would I use your docker image? I'm a bit cautious to simply assume that is better - happy to run a separate docker instance to test if that makes sense (for testing)

Shaquu commented 3 years ago

Regarding the image I would say that if you are comfortable with your own set up then there is no need to move to ours. Thing is that sometimes people use strange images/setup like iostack which is less easy for us to debug.

Regarding logs, are you sure you did not skip some? Check first lines after node-red starts. If you don't see what I see then probably you are not passing the experimental flag properly.

Welcome to Node-RED
===================

24 Mar 23:51:53 - [info] Node-RED version: v1.2.9-git
24 Mar 23:51:53 - [info] Node.js  version: v14.15.4
24 Mar 23:51:53 - [info] Windows_NT 10.0.19042 x64 LE
24 Mar 23:51:55 - [info] Loading palette nodes
24 Mar 23:51:57 NRCHKB-Error Experimental features enabled +0ms
CaseyRo commented 3 years ago

Here you go @Shaquu:

CleanShot 2021-03-25 at 10 36 07

I already spotted I'm running NR on an older Node version - maybe that's a key here?

Shaquu commented 3 years ago

Great. I think I have found a bug so please update to latest dev.

CaseyRo commented 3 years ago

Thanks @Shaquu! It's there! I'm testing it once my workday is over! excited

Shaquu commented 3 years ago

@CaseyRo just be careful and backup what you have ;) It's called experimental for a reason.

CaseyRo commented 3 years ago

@CaseyRo just be careful and backup what you have ;) It's called experimental for a reason.

yes sir, especially with adding new accesoires to homekit 😀 (home+ is great for backups of that)

Tyraenor commented 3 years ago

@Shaquu I've added an custom characteristic but it seems that it is not loaded into HomeKit. I want to add PowerUsage for a Fritz DECT 200, so I can build an automation based on the current power usage. I called it "Watts" and added {"Watts":true} to characteristics properties. But nothing happens.

BTW: Would it be possible to make the unit field not a dropdown but an input field? Because I need the unit "W" and "kWh"

Shaquu commented 3 years ago

@Tyraenor few things. Custom Characteristic will not appear in Home.app most of the time. You can see it in alternative apps like Eve. Possibly Custom Service will bring additional features.

Regarding watts, list is made from HomeKit specification so there is no possibility to add custom I believe.

Tyraenor commented 3 years ago

@Shaquu Yes I know that, sorry for not being clear about the fact, that I looked into Eve app for that. My problem is, that I want to see the current power consumption in the Eve app. It works when using other platforms like Homebridge or ioBroker. So I was hoping that I can achieve a similar thing in Node-RED, too.

What I basically want is the service Outlet, with the Community Characteristic "Watts" or "PowerUsage", which has the UUID E863F10D-079E-48FF-8F27-9C2605A29F52.

Shaquu commented 3 years ago

This feature is experimental and still in active development. If it does not work I can promise it will once we are done with it. Can you give me details regarding your configuration for custom characteristic? I might try it myself later :)

Tyraenor commented 3 years ago

The first issue is, that I cannot select the correct unit in the custom characteristic editor, which would be "W".

See my screenshot of the editor and my homekit node.

Screen Shot 2021-05-26 at 22 56 06 Screen Shot 2021-05-26 at 22 57 54
sjorge commented 3 years ago

Currently there is no way to remove a custom one after it has been added right?

Edit: I guess one could delete .node-red/nrchkb/:hash: while node-red is not running, but not tried yet.

rufusgor commented 3 years ago

If "String" is selected, the parameter is not passed to the device.

sjorge commented 3 years ago

Edit: I guess one could delete .node-red/nrchkb/:hash: while node-red is not running, but not tried yet.

I removed the file and node-red no longer complians, I've abanonded this for now :( It kept complaining about validValues.

Shaquu commented 3 years ago

@Tyraenor Units are set up according to HomeKit Specification. If you believe that other values are allowed (will not break HK) then I can add an option for a custom value.

@sjorge

  1. to remove, go to nrchkb node. You have X icon on the right. Then "Done" and redeploy. Also remove that characteristic from Custom Characteristic on Service node. image
  2. I tried to fix validValues complains in the latest master release
Shaquu commented 3 years ago

IMG_2242

Characteristic Properties

{
    "Volt": true,
    "Ampere": true,
    "Kilowatt-Hour": true,
    "Watt": true
}
Custom Characteristics ```json { "key":"customCharacteristics", "value":[ { "name":"Volt", "UUID":"E863F10A-079E-48FF-8F27-9C2605A29F52", "format":"uint16", "unit":"", "perms":[ "pr", "pw", "ev", "tw", "wr" ], "ev":"true", "description":"Eve Volt", "minValue":"0", "maxValue":"400", "minStep":"", "maxLen":"", "maxDataLen":"", "validValues":"", "adminOnlyAccess":[ "0", "1", "2" ] }, { "name":"Ampere", "UUID":"E863F126-079E-48FF-8F27-9C2605A29F52", "format":"uint16", "unit":"", "perms":[ "pr", "pw", "ev", "tw", "wr" ], "ev":"true", "description":"Eve Ampere", "minValue":"0", "maxValue":"16", "minStep":"", "maxLen":"", "maxDataLen":"", "validValues":"", "adminOnlyAccess":[ "0", "1", "2" ] }, { "name":"Watt", "UUID":"E863F10D-079E-48FF-8F27-9C2605A29F52", "format":"uint16", "unit":"", "perms":[ "pr", "pw", "ev", "tw", "wr" ], "ev":"true", "description":"Eve Watt", "minValue":"0", "maxValue":"3500", "minStep":"", "maxLen":"", "maxDataLen":"", "validValues":"", "adminOnlyAccess":[ "0", "1", "2" ] }, { "name":"Kilowatt-Hour", "UUID":"E863F10C-079E-48FF-8F27-9C2605A29F52", "format":"uint32", "unit":"", "perms":[ "pr", "pw", "ev", "tw", "wr" ], "ev":"true", "description":"Eve Kilowatt-Hour", "minValue":"0", "maxValue":"4294967295", "minStep":"", "maxLen":"", "maxDataLen":"", "validValues":"", "adminOnlyAccess":[ "0", "1", "2" ] }, { "name":"Volt-Ampere", "UUID":"E863F110-079E-48FF-8F27-9C2605A29F52", "format":"uint16", "unit":"", "perms":[ "pr", "pw", "ev", "tw", "wr" ], "ev":"true", "description":"Eve Volt-Ampere", "minValue":"", "maxValue":"", "minStep":"", "maxLen":"", "maxDataLen":"", "validValues":"", "adminOnlyAccess":[ "0", "1", "2" ] } ] } ```
Shaquu commented 3 years ago

Changes to this feature will be released in 1.4.0 and Custom Characteristics will remain as experimental. To enable start node-red with NRCHKB_EXPERIMENTAL=true

https://nrchkb.github.io/wiki/discover-more/experimental/#getting-started

foorschtbar commented 1 year ago

@Shaquu thank u for this nice feature. It is possible to enter custom units in the form? When i update the json, it works fine, but the UI overwrite it :(

GogoVega commented 1 year ago

Hi, for your first question change Uint to Int and for the second, unfortunately no it is not possible to have custom units 😭

sjorge commented 5 months ago

Just to note, upgrading to 1.7.0-dev.1 I needed to re-add my custom ones. It seems the hash changed to a more secure one.

djiwondee commented 5 months ago

@sjorge

upgrading to 1.7.0-dev.1 I needed to re-add my custom ones. It seems the hash changed to a more secure one.

can you please figure out what in particular you have done? The first issue I saw with 1.7.0.dev.1 , none of my custom characteristics setup is working anymore. After restoring backup of the 1.6.0.dev, the custom characteristic was working fine again.

sjorge commented 5 months ago

I just added them all again manually.

After I noticed that the file they are saved under had a new hash, that is longer.

djiwondee commented 5 months ago

@sjorge

I just added them all again manually.

...means what inparticular Deleteing this from your flow:

image image

and add it completely new from scratch?

sjorge commented 5 months ago

Yes