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

A collection of node-red nodes, representing various preconfigured Homekit devices, supporting their full functionality

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting numeric characteristics in HK-thermostat

jensflorian opened this issue · comments

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/

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.

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!

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.