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
412 stars 52 forks source link

Added msg.ident input message to the service node. See the wiki about… #451

Closed Supergiovane closed 2 years ago

Supergiovane commented 2 years ago

By passing msg.ident = true to a service node, it emits a list of useful properties. This is useful for the other linked node, to know the service name of the homekit node and to dinamically adapt the input/output property names of the flow msg.

Output from msg.ident = true:

"identification":{
      "name":"Luce Banana",
      "serviceName":"Lightbulb",
      "topic":"",
      "id":"ce7a66f97370c33b",
      "bridge":"415c386714f794ee",
      "parentService":"",
      "supported":[
         "Name",
         "On",
         "Brightness",
         "CharacteristicValueActiveTransitionCount",
         "CharacteristicValueTransitionControl",
         "ColorTemperature",
         "Hue",
         "Name",
         "Saturation",
         "SupportedCharacteristicValueTransitionConfiguration"
      ]
   }
Shaquu commented 2 years ago

@Supergiovane thanks for the input!

Look at our current msg:

{
    "payload": {
        "On": false
    },
    "hap": {
        "session": {
            "sessionID": "",
            "username": "",
            "remoteAddress": "",
            "localAddress": "",
            "httpPort": 123456
        },
        "context": {},
        "allChars": {
            "Name": "Bedroom Main Light Switch",
            "On": false
        },
        "newValue": false
    },
    "name": "Bedroom Main Light Switch",
    "topic": "",
    "_msgid": "8daed9c20a34f5d3"
}
  1. We have name of the Service already in msg. One as node-red value typed by user (msg.name) and another is value from Characteristic (msg.hap.allChars.Name) which is not mandatory.
  2. Service name - to be added to msg.hap
  3. Node ID - to be discussed why it is required
  4. Bridge ID - to be discussed why it is required
  5. Parent Node ID - to be discussed why it is required
  6. Supported - we got it previously in allChars but got removed

In short, @Supergiovane if you could tell at each field separately why you need it? Maybe we can find easier solution not involving more code in nrchkb node and being just simplier?

Supergiovane commented 2 years ago

Hi Yes, you are right, but... you must already know, what msg to pass to the node. In your sample, it's msg.payload.On.

Imagine that: 1) You put a service node into the flow. I cannot open that node to view their properties, so i don't know what service name you've set. It's a light? It's a contact sensor? I don't know.

If i send a random msg to your node, it simply throws a debug message. No msg is output to the flow. So i'm totally blind. I don't know what msg your node does accept.

So, i send msg.ident to it and... voilà... your node responds "Hey, i'm a lightbulb". Then, after knowing that your node is a lightbulb, i know i must pass msg.payload.on = true to lit the light.

I hope i'm clear now.

Supergiovane commented 2 years ago

I’ll do in another way. Pull reuest closed