marcus-j-davies / node-red-contrib-homekit-preconfigured

A collection of node-red nodes, representing various preconfigured Homekit devices, supporting their full functionality
MIT License
2 stars 0 forks source link

Setting numeric characteristics in HK-thermostat #1

Closed jensflorian closed 4 years ago

jensflorian commented 4 years ago

Hello, Setting up your nodes is really easy! Now I am currently trying to set values to a HK-thermostat node to check if changes are shown in HomeKit. When injecting as a string

"CurrentTemperature": 22

I get following debugging output:

"TypeError: Cannot read property 'setValue' of undefined".

The command GetCharacteristics works as expected and returns

msg.payload : Object object CurrentHeatingCoolingState: 0 TargetHeatingCoolingState: 0 CurrentTemperature: 21 TargetTemperature: 21 TemperatureDisplayUnits: 0

What am I doing wrong? Any help with some examples is much appreciated, as I could not find any exemplaric flows at https://flows.nodered.org/

marcus-j-davies commented 4 years ago

Hi, I'm Glad the setup is easy.

You might not be using a key:value pair for setting new Characteristics Obtaining the current values is indeed done using a simple string

{
  payload: "GetCharacteristics"
}

Setting Characteristics, should be done using a key:value pair, as multiple can be set at the same time

{
  payload: {
    "CurrentTemperature": 65
  }
}

Do let me know if this helps.

jensflorian commented 4 years ago

Finally, I got it. In the properties tab of the Inject node, you have to select JSON for Payload. Then the command is accepted.

Bildschirmfoto 2020-02-09 um 11 14 44

Thanks for the help!

marcus-j-davies commented 4 years ago

Yup! I created the node(s) in such a way that setting Characteristics needs to be done using a key:value pair (a JSON object with properties), so multiples can be set as the same time.

In essence, the inject node will always wrap what is being injected, into a payload object:

As a string:

{
  payload: "GetCharacteristics"
}

As a JSON object

{
  payload: {
    "Characteristic": value,
    "AnotherCharacteristics": value
  }
}

Glad its working for you - and you are very welcome.