Display power usage as temperature with Node-Red in Apple HomeKit

1k views Asked by At

I would like to display the power usage in HomeKit. Unfortunately there is no category to do that in HomeKit. That's why I had the idea to display this not as a power usage but as temperature in HomeKit. The idea is to control HomeKit scenes with the fake temperature sensor.

Unfortunately I have no experience in node-red and it is new for me.

I got the following string from the electricity meter:

success: "true"
response: string
{
    "power":    3.040480,
    "relay":    true
}

I link this to the HomeKit Node which then returns the following error:

Characteristic response cannot be written. 
Try one of these: Name, CurrentTemperature, StatusActive, StatusFault, StatusLowBattery, StatusTampered, Name

After various functions and other adjustments I unfortunately don't get the "temperature" displayed in HomeKit.

I use this: https://flows.nodered.org/node/@plasma2450/node-red-contrib-homekit-bridged

1

There are 1 answers

0
Keni On

I think you cannot directly link up the 2 nodes. From the error message it suggests that you have passed the payload from meter output to HomeKit node. While the meter output contains response property and it is not supported by HomeKit, your error would occur.

Make sure your payload only consists of the supported Characteristics. You can use a change node to modify the payload, or simply with a a function node

const msg.meterOutput = msg.payload;
// Just a prototype, type checking is required
msg.payload = {
    currentTemperature: msg.meterOutput.response.power
}
return msg;