Other homekit types through node-red

Hi. I’m new to node red so i need some help.
so i got a homekit node set as lightbulb. and it send msg to mqtt.
i believe a need a function to convert my payload from homekit to a string for my mqtt. can anyone help?
TY

I’m curious, do you have speed control on your fan at all? I’m trying to figure out what commands Siri supports for setting fan speed. I’m currently using a GE fan switch, which acts like a dimmer on HK which means instead of saying “LOW”, “MEDIUM”, or “HIGH” for speed I just manually set percentages (i.e. 10%, 50%, or 100%)

@rswennen, this is some great find on this one! Kudos!!!
I just finished installing and configuring Node-Red. I did eventually figure out how to get Node-Red to show accepted info fields.
However, I was trying to configure the sensors off my bed (SleepIQ) to trigger in Homekit. I have them working just fine in OpenHab, and up until finding this, I just had them configured as items with Switchable in OH with the Homekit service. However, this had them showing up at actualy on/off switches and I need this to be a read only parameter.

I used the Occupancy sensor in NodeRed, but for some reason I can’t get it to show the changes in Homekit.
Thoughts?

I definitely think that with a bit more details this can become an excellent guide and solution for HomeKit integration with OpenHab!

To OpenHab developers:
Since this obviously is possible I really think having this capability embedded in OH by extending the existing Homekit integration would be HUGE!!!

Thank you,
Moshe

Thanks for your tutorial is great.
I am a noob bit I succeed in creating simple flow from OH to Homekit and viceversa.
I am not able to transfer a float from homekit to oh. Can you post an example?
I want to transfer the target temperature from homekit to OH

Nice to see that I’m not alone in doing this.

Here is my Fan control flow. I use the LIRC binding to control a Bionaire Fan, and I’ve added oscillation and speed, as well as the default On/Off.

Code if anyone is intrested
https://pastebin.com/raw/gXsgF0xK

1 Like

Really nice work. Just one question I’m struggling in how to send a temperature to home kit.

I have this item

Number HueTemp "Hue Temperature [%.0f]ºC" (Temp, Sensors)

and have no clue how to send the temperature to the HomeKit node the answer is always invalid payload string object

I have used a change node but no clue from what to what I must change. My guess was

{"CurrentTemperature":msg.payload.state}

but it didn’t work.

Any suggestions?

Thanks

I do it with a function node.

msg.payload = {
CurrentTemperature: + parseFloat(msg.payload).toFixed(1)
};
return msg;

Hi @ptweety,

may it be possible that you share your Flow-Code of your implementation for the heating thermostats? I’m in trouble with the conversion from the HomeKit item to the values for open hab…

Greetings
n30ngruu3n

Hi @n30ngruu3n,
it took me a while to find the flow since I’ve moved my nodered stuff from one machine to the other weeks ago.

[{"id":"6fec27bb.58b038","type":"homekit-service","z":"7e9c5c41.22019c","accessory":"1e16dd99.a42552","name":"Thermostat Kinderzimmer","serviceName":"Thermostat","x":1050,"y":1040,"wires":[["803aaaa3.19749"]]},{"id":"67cf024a.82a66c","type":"switch","z":"7e9c5c41.22019c","name":"","property":"hap.context","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","outputs":1,"x":530,"y":1340,"wires":[["1bbcb2c8.7fac95","2d6ff3d9.423abc"]]},{"id":"62b442c6.c6e02c","type":"openhab2-out","z":"7e9c5c41.22019c","name":"SetPointTemperature","controller":"486ba9fc.3908a","itemname":"","topic":"ItemCommand","payload":"","x":1040,"y":1320,"wires":[]},{"id":"af7bc2b1.2f9e2","type":"openhab2-in","z":"7e9c5c41.22019c","name":"KidsRadiator","controller":"486ba9fc.3908a","itemname":"vKidsRadiator_summary","x":330,"y":1040,"wires":[["c976ee18.4d4ec8"],[]]},{"id":"ae33ffec.7caf38","type":"openhab2-get","z":"7e9c5c41.22019c","name":"ActualTemperature","controller":"486ba9fc.3908a","itemname":"","x":1030,"y":920,"wires":[["800e5a54.43bbe"]]},{"id":"26a3a63f.7907ba","type":"openhab2-get","z":"7e9c5c41.22019c","name":"SetPointTemperature","controller":"486ba9fc.3908a","itemname":"","x":1040,"y":960,"wires":[["800e5a54.43bbe"]]},{"id":"c976ee18.4d4ec8","type":"change","z":"7e9c5c41.22019c","name":"change","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"_1_ACTUAL_TEMPERATURE\":\"\",\"_1_SET_POINT_TEMPERATURE\":\"\",\"_heatingCoolingMode\":\"\"}","tot":"json"},{"t":"change","p":"item","pt":"msg","from":"v(.*)_summary","fromt":"re","to":"$1","tot":"str"},{"t":"move","p":"item","pt":"msg","to":"rawitem","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":1060,"wires":[["14296d42.373bdb","b3fa61c8.a4046"]]},{"id":"14296d42.373bdb","type":"split","z":"7e9c5c41.22019c","name":"","splt":"","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"topic","x":530,"y":960,"wires":[["554158ad.998c38"]]},{"id":"554158ad.998c38","type":"switch","z":"7e9c5c41.22019c","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"_1_ACTUAL_TEMPERATURE","vt":"str"},{"t":"eq","v":"_1_SET_POINT_TEMPERATURE","vt":"str"},{"t":"eq","v":"_heatingCoolingMode","vt":"str"}],"checkall":"true","outputs":3,"x":650,"y":960,"wires":[["c6b0095d.3528a"],["c6b0095d.3528a"],["f60b73fc.7f8218"]]},{"id":"e1b210b5.397fa","type":"join","z":"7e9c5c41.22019c","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":false,"timeout":"","count":"","x":1410,"y":960,"wires":[["6be54f3e.532698"]]},{"id":"800e5a54.43bbe","type":"change","z":"7e9c5c41.22019c","name":"","rules":[{"t":"delete","p":"payload.link","pt":"msg"},{"t":"delete","p":"payload.stateDescription","pt":"msg"},{"t":"delete","p":"payload.category","pt":"msg"},{"t":"delete","p":"payload.tags","pt":"msg"},{"t":"delete","p":"payload.groupNames","pt":"msg"},{"t":"delete","p":"payload.label","pt":"msg"},{"t":"delete","p":"payload.type","pt":"msg"},{"t":"move","p":"topic","pt":"msg","to":"payload.extension","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1260,"y":960,"wires":[["e1b210b5.397fa"]]},{"id":"7878e1f8.5e47d","type":"change","z":"7e9c5c41.22019c","name":"change","rules":[{"t":"set","p":"topic","pt":"msg","to":"ItemCommand","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"payload.*{extension: state}","tot":"jsonata"},{"t":"delete","p":"item","pt":"msg"},{"t":"delete","p":"payload_in","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":1140,"wires":[["d9bd530c.40b478"]]},{"id":"d9bd530c.40b478","type":"function","z":"7e9c5c41.22019c","name":"transform","func":"\nvar name = msg.rawitem;\nvar actTemp = +msg.payload._1_ACTUAL_TEMPERATURE;\nvar setTemp = +msg.payload._1_SET_POINT_TEMPERATURE;\nvar mode = msg.payload._heatingCoolingMode;\n\n//node.log(\"ActTemp: \"+actTemp);\n//node.log(\"SetTemp: \"+setTemp);\n//node.log(\"Mode: \"+mode);\n\nvar targetHeatCoolState = 0; // OFF\nswitch (mode) {\n    case \"HeatOn\": targetHeatCoolState = 1; break;\n    case \"CoolOn\": targetHeatCoolState = 2; break;\n    case \"Auto\": targetHeatCoolState = 3; break;\n}\n\n//node.log(\"TargetHeatingCoolingState: \"+targetHeatCoolState);\n\nmsg.payload = {\n    \"CurrentHeatingCoolingState\": targetHeatCoolState,\n    \"TargetHeatingCoolingState\": targetHeatCoolState,\n    \"CurrentTemperature\": actTemp,\n    \"TargetTemperature\": setTemp,\n    \"TemperatureDisplayUnits\": \"0\", // celsius\n    \"Name\": name\n};\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"target: \"+mode+\" -> \"+targetHeatCoolState});   \nreturn msg;","outputs":1,"noerr":0,"x":680,"y":1180,"wires":[["efa7f982.d60e3","8cf7ea53.db7ef"]]},{"id":"4f8be336.a2708c","type":"openhab2-get","z":"7e9c5c41.22019c","name":"HeatingCoolingMode","controller":"486ba9fc.3908a","itemname":"","x":1040,"y":1000,"wires":[["800e5a54.43bbe"]]},{"id":"efa7f982.d60e3","type":"debug","z":"7e9c5c41.22019c","name":"","active":false,"console":"false","complete":"true","x":830,"y":1240,"wires":[]},{"id":"b37b43bc.38c768","type":"openhab2-in","z":"7e9c5c41.22019c","name":"BathRadiator","controller":"486ba9fc.3908a","itemname":"vBathRadiator_summary","x":330,"y":1240,"wires":[["c976ee18.4d4ec8"],[]]},{"id":"1232466.b0b51ba","type":"openhab2-in","z":"7e9c5c41.22019c","name":"HallRadiator","controller":"486ba9fc.3908a","itemname":"vHallRadiator_summary","x":330,"y":1280,"wires":[["c976ee18.4d4ec8"],[]]},{"id":"8cdadd36.09392","type":"openhab2-in","z":"7e9c5c41.22019c","name":"LivingRadiatorLeft","controller":"486ba9fc.3908a","itemname":"vLivingRadiatorLeft_summary","x":310,"y":1160,"wires":[["c976ee18.4d4ec8"],[]]},{"id":"15fa0612.332742","type":"openhab2-in","z":"7e9c5c41.22019c","name":"LivingRadiatorRight","controller":"486ba9fc.3908a","itemname":"vLivingRadiatorRight_summary","x":310,"y":1200,"wires":[["c976ee18.4d4ec8"],[]]},{"id":"fa80c078.e14c48","type":"openhab2-in","z":"7e9c5c41.22019c","name":"BedRadiatorRight","controller":"486ba9fc.3908a","itemname":"vBedRadiatorRight_summary","x":310,"y":1120,"wires":[["c976ee18.4d4ec8"],[]]},{"id":"a7aaf886.106778","type":"openhab2-in","z":"7e9c5c41.22019c","name":"BedRadiatorLeft","controller":"486ba9fc.3908a","itemname":"vBedRadiatorLeft_summary","x":320,"y":1080,"wires":[["c976ee18.4d4ec8"],[]]},{"id":"c6b0095d.3528a","type":"change","z":"7e9c5c41.22019c","name":"","rules":[{"t":"set","p":"item","pt":"msg","to":"\"a\" & rawitem & topic","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":940,"wires":[["ae33ffec.7caf38","26a3a63f.7907ba"]]},{"id":"f60b73fc.7f8218","type":"change","z":"7e9c5c41.22019c","name":"","rules":[{"t":"set","p":"item","pt":"msg","to":"\"v\" & rawitem & topic","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":980,"wires":[["4f8be336.a2708c"]]},{"id":"8cf7ea53.db7ef","type":"switch","z":"7e9c5c41.22019c","name":"","property":"rawitem","propertyType":"msg","rules":[{"t":"eq","v":"KidsRadiator","vt":"str"},{"t":"eq","v":"BedRadiatorLeft","vt":"str"},{"t":"eq","v":"BedRadiatorRight","vt":"str"},{"t":"eq","v":"LivingRadiatorLeft","vt":"str"},{"t":"eq","v":"LivingRadiatorRight","vt":"str"},{"t":"eq","v":"BathRadiator","vt":"str"},{"t":"eq","v":"HallRadiator","vt":"str"}],"checkall":"true","outputs":7,"x":830,"y":1160,"wires":[["6fec27bb.58b038"],["cf598aa8.31de98"],["c706866c.a11e58"],["3c0525e.028a0da"],["255fd055.482648"],["f9bb1760.02fbf"],["74e30d6.0b8acf4"]]},{"id":"c706866c.a11e58","type":"homekit-service","z":"7e9c5c41.22019c","accessory":"896c6a5b.232748","name":"Thermostat Schlafzimmer Rechts","serviceName":"Thermostat","x":1080,"y":1120,"wires":[["5f22a494.6bc3d4"]]},{"id":"3c0525e.028a0da","type":"homekit-service","z":"7e9c5c41.22019c","accessory":"9e061e0a.3d52c","name":"Thermostat Wohnzimmer Links","serviceName":"Thermostat","x":1070,"y":1160,"wires":[["b5234297.a0ba38"]]},{"id":"255fd055.482648","type":"homekit-service","z":"7e9c5c41.22019c","accessory":"a9f808ab.3bbd58","name":"Thermostat Wohnzimmer Rechts","serviceName":"Thermostat","x":1080,"y":1200,"wires":[["3e96acc5.afa364"]]},{"id":"f9bb1760.02fbf","type":"homekit-service","z":"7e9c5c41.22019c","accessory":"c4fa0c0f.35dee8","name":"Thermostat Badezimmer","serviceName":"Thermostat","x":1050,"y":1240,"wires":[["5f2a8fad.f4533"]]},{"id":"74e30d6.0b8acf4","type":"homekit-service","z":"7e9c5c41.22019c","accessory":"b67b2d61.6e9a6","name":"Thermostat Flur","serviceName":"Thermostat","x":1020,"y":1280,"wires":[["c37a7431.920488"]]},{"id":"74ad9a9f.fecd7c","type":"link in","z":"7e9c5c41.22019c","name":"","links":["6be54f3e.532698"],"x":575,"y":1140,"wires":[["7878e1f8.5e47d"]]},{"id":"6be54f3e.532698","type":"link out","z":"7e9c5c41.22019c","name":"","links":["74ad9a9f.fecd7c"],"x":1495,"y":960,"wires":[]},{"id":"803aaaa3.19749","type":"change","z":"7e9c5c41.22019c","name":"KidsRadiator","rules":[{"t":"set","p":"rawitem","pt":"msg","to":"KidsRadiator","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1350,"y":1040,"wires":[["7b89529d.1065f4"]]},{"id":"d0cf8e7e.630658","type":"change","z":"7e9c5c41.22019c","name":"BedRadiatorLeft","rules":[{"t":"set","p":"rawitem","pt":"msg","to":"BedRadiatorLeft","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1340,"y":1080,"wires":[["7b89529d.1065f4"]]},{"id":"5f22a494.6bc3d4","type":"change","z":"7e9c5c41.22019c","name":"BedRadiatorRight","rules":[{"t":"set","p":"rawitem","pt":"msg","to":"BedRadiatorRight","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1330,"y":1120,"wires":[["7b89529d.1065f4"]]},{"id":"b5234297.a0ba38","type":"change","z":"7e9c5c41.22019c","name":"LivingRadiatorLeft","rules":[{"t":"set","p":"rawitem","pt":"msg","to":"LivingRadiatorLeft","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1330,"y":1160,"wires":[["7b89529d.1065f4"]]},{"id":"3e96acc5.afa364","type":"change","z":"7e9c5c41.22019c","name":"LivingRadiatorRight","rules":[{"t":"set","p":"rawitem","pt":"msg","to":"LivingRadiatorRight","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1330,"y":1200,"wires":[["7b89529d.1065f4"]]},{"id":"5f2a8fad.f4533","type":"change","z":"7e9c5c41.22019c","name":"BathRadiator","rules":[{"t":"set","p":"rawitem","pt":"msg","to":"BathRadiator","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1350,"y":1240,"wires":[["7b89529d.1065f4"]]},{"id":"c37a7431.920488","type":"change","z":"7e9c5c41.22019c","name":"HallRadiator","rules":[{"t":"set","p":"rawitem","pt":"msg","to":"HallRadiator","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1350,"y":1280,"wires":[["7b89529d.1065f4"]]},{"id":"2d6ff3d9.423abc","type":"switch","z":"7e9c5c41.22019c","name":"","property":"payload.TargetHeatingCoolingState","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","outputs":1,"x":670,"y":1360,"wires":[["33ee203a.1d4d18"]]},{"id":"55a81e9a.54a918","type":"change","z":"7e9c5c41.22019c","name":"set msg.item","rules":[{"t":"set","p":"topic","pt":"msg","to":"_1_SET_POINT_TEMPERATURE","tot":"str"},{"t":"set","p":"item","pt":"msg","to":"\"a\" & rawitem & topic","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"payload.TargetTemperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":1320,"wires":[["62b442c6.c6e02c"]]},{"id":"33ee203a.1d4d18","type":"change","z":"7e9c5c41.22019c","name":"set msg.item","rules":[{"t":"set","p":"topic","pt":"msg","to":"_heatingCoolingMode","tot":"str"},{"t":"set","p":"item","pt":"msg","to":"\"v\" & rawitem & topic","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"payload.TargetHeatingCoolingState","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":1360,"wires":[["a7761c35.d80778"]]},{"id":"489f0254.38fb9c","type":"debug","z":"7e9c5c41.22019c","name":"","active":false,"console":"false","complete":"true","x":990,"y":1400,"wires":[]},{"id":"1bbcb2c8.7fac95","type":"switch","z":"7e9c5c41.22019c","name":"","property":"payload.TargetTemperature","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","outputs":1,"x":670,"y":1320,"wires":[["55a81e9a.54a918"]]},{"id":"a7761c35.d80778","type":"function","z":"7e9c5c41.22019c","name":"transform","func":"\nvar targetHeatCoolState = +msg.payload;\n\n//node.log(\"TargetHeatingCoolingState: \"+targetHeatCoolState);\n\nvar mode = \"Off\"; // 0\nswitch (targetHeatCoolState) {\n    case 1: mode = \"HeatOn\"; break;\n    case 2: mode = \"CoolOn\"; break;\n    case 3: mode = \"Auto\"; break;\n}\n\n//node.log(\"Mode: \"+mode);\n\nmsg.payload = mode;\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"target: \"+targetHeatCoolState+\" -> \"+mode});   \nreturn msg;","outputs":1,"noerr":0,"x":820,"y":1400,"wires":[["5df9e3a0.7615dc","489f0254.38fb9c"]]},{"id":"5df9e3a0.7615dc","type":"openhab2-out","z":"7e9c5c41.22019c","name":"HeatingCoolingMode","controller":"486ba9fc.3908a","itemname":"","topic":"ItemCommand","payload":"","x":1040,"y":1360,"wires":[]},{"id":"7b89529d.1065f4","type":"link out","z":"7e9c5c41.22019c","name":"","links":["3db55130.b40bd6"],"x":1515,"y":1160,"wires":[]},{"id":"3db55130.b40bd6","type":"link in","z":"7e9c5c41.22019c","name":"","links":["7b89529d.1065f4"],"x":435,"y":1340,"wires":[["67cf024a.82a66c"]]},{"id":"f8ade1f2.760278","type":"inject","z":"7e9c5c41.22019c","name":"RawEvent","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":340,"y":960,"wires":[["c634c9f5.7fcfd"]]},{"id":"c634c9f5.7fcfd","type":"change","z":"7e9c5c41.22019c","name":"change","rules":[{"t":"set","p":"item","pt":"msg","to":"vBedRadiatorLeft_summary","tot":"str"},{"t":"set","p":"event","pt":"msg","to":"RawEvent","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":1000,"wires":[["c976ee18.4d4ec8"]]},{"id":"86d4b784.85018","type":"inject","z":"7e9c5c41.22019c","name":"TargetTemperature","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":310,"y":1320,"wires":[["fc7ce283.034d68"]]},{"id":"fc7ce283.034d68","type":"change","z":"7e9c5c41.22019c","name":"change","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"TargetTemperature\":23}","tot":"json"},{"t":"set","p":"hap","pt":"msg","to":"{\"oldValue\":25,\"newValue\":23,\"context\":{\"keepalive\":true,\"1.10\":true,\"1.11\":true,\"1.12\":true,\"1.13\":true,\"1.14\":true},\"characteristic\":{\"displayName\":\"Target Temperature\",\"UUID\":\"00000035-0000-1000-8000-0026BB765291\",\"iid\":13,\"value\":23,\"eventOnlyCharacteristic\":false,\"props\":{\"format\":\"float\",\"unit\":\"celsius\",\"minValue\":10,\"maxValue\":38,\"minStep\":0.1,\"perms\":[\"pr\",\"pw\",\"ev\"]},\"subscriptions\":2,\"_events\":{},\"_eventsCount\":1}}","tot":"json"},{"t":"delete","p":"topic","pt":"msg"},{"t":"set","p":"rawitem","pt":"msg","to":"KidsRatiator","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":1300,"wires":[["1bbcb2c8.7fac95"]]},{"id":"b7678ce3.5c94f8","type":"inject","z":"7e9c5c41.22019c","name":"TargetHeatingCoolingState","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":290,"y":1360,"wires":[["c51df478.0cbea"]]},{"id":"c51df478.0cbea","type":"change","z":"7e9c5c41.22019c","name":"change","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"TargetHeatingCoolingState\":1}","tot":"json"},{"t":"set","p":"hap","pt":"msg","to":"{\"oldValue\":2,\"newValue\":1,\"context\":{\"keepalive\":true,\"1.14\":true,\"1.10\":true,\"1.13\":true,\"1.12\":true,\"1.11\":true},\"characteristic\":{\"displayName\":\"Target Heating Cooling State\",\"UUID\":\"00000033-0000-1000-8000-0026BB765291\",\"iid\":11,\"value\":1,\"eventOnlyCharacteristic\":false,\"props\":{\"format\":\"uint8\",\"unit\":null,\"minValue\":0,\"maxValue\":3,\"minStep\":null,\"perms\":[\"pr\",\"pw\",\"ev\"],\"validValues\":[0,1,2,3]},\"subscriptions\":2,\"_events\":{},\"_eventsCount\":1}}","tot":"json"},{"t":"delete","p":"topic","pt":"msg"},{"t":"set","p":"rawitem","pt":"msg","to":"KidsRadiator","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":1380,"wires":[["2d6ff3d9.423abc"]]},{"id":"dc31f175.fbdbc","type":"homekit-service","z":"7e9c5c41.22019c","accessory":"896c6a5b.232748","name":"Batterie Schlafzimmer Rechts","serviceName":"BatteryService","x":1070,"y":1600,"wires":[[]]},{"id":"cf598aa8.31de98","type":"homekit-service","z":"7e9c5c41.22019c","accessory":"aa346129.5269f8","name":"Thermostat Schlafzimmer Links","serviceName":"Thermostat","x":1070,"y":1080,"wires":[["d0cf8e7e.630658"]]},{"id":"255f980.dbc4d68","type":"homekit-service","z":"7e9c5c41.22019c","accessory":"aa346129.5269f8","name":"Batterie Schlafzimmer Links","serviceName":"BatteryService","x":1060,"y":1560,"wires":[[]]},{"id":"2d3093ac.230844","type":"homekit-service","z":"7e9c5c41.22019c","accessory":"9e061e0a.3d52c","name":"Batterie Wohnzimmer Links","serviceName":"BatteryService","x":1060,"y":1640,"wires":[[]]},{"id":"42aeb303.4c565c","type":"homekit-service","z":"7e9c5c41.22019c","accessory":"1e16dd99.a42552","name":"Batterie Kinderzimmer","serviceName":"BatteryService","x":1040,"y":1520,"wires":[[]]},{"id":"d798dc63.f293f8","type":"homekit-service","z":"7e9c5c41.22019c","accessory":"c4fa0c0f.35dee8","name":"Batterie Badezimmer","serviceName":"BatteryService","x":1040,"y":1720,"wires":[[]]},{"id":"913a594b.612b4","type":"homekit-service","z":"7e9c5c41.22019c","accessory":"b67b2d61.6e9a6","name":"Batterie Flur","serviceName":"BatteryService","x":1010,"y":1760,"wires":[[]]},{"id":"bb1bdc1.03bffa","type":"homekit-service","z":"7e9c5c41.22019c","accessory":"a9f808ab.3bbd58","name":"Batterie Wohnzimmer Rechts","serviceName":"BatteryService","x":1060,"y":1680,"wires":[[]]},{"id":"ed98c974.62c06","type":"openhab2-get","z":"7e9c5c41.22019c","name":"OperatingVoltage","controller":"486ba9fc.3908a","itemname":"","x":1030,"y":1440,"wires":[["1409b8ce.5e5257"]]},{"id":"6da81891.937cc","type":"openhab2-get","z":"7e9c5c41.22019c","name":"LowBat","controller":"486ba9fc.3908a","itemname":"","x":1000,"y":1480,"wires":[["1409b8ce.5e5257"]]},{"id":"c1b09eb5.f3bb2","type":"change","z":"7e9c5c41.22019c","name":"change","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"_0_OPERATING_VOLTAGE\":\"\",\"_0_LOW_BAT\":\"\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":1500,"wires":[["7db5bd52.2083ac"]]},{"id":"7db5bd52.2083ac","type":"split","z":"7e9c5c41.22019c","name":"","splt":"","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"topic","x":530,"y":1460,"wires":[["c968ce3f.066c08"]]},{"id":"c968ce3f.066c08","type":"switch","z":"7e9c5c41.22019c","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"_0_OPERATING_VOLTAGE","vt":"str"},{"t":"eq","v":"_0_LOW_BAT","vt":"str"}],"checkall":"true","outputs":2,"x":650,"y":1460,"wires":[["878613fc.5ff74"],["878613fc.5ff74"]]},{"id":"878613fc.5ff74","type":"change","z":"7e9c5c41.22019c","name":"","rules":[{"t":"set","p":"item","pt":"msg","to":"\"a\" & rawitem & topic","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":1460,"wires":[["ed98c974.62c06","6da81891.937cc"]]},{"id":"9e23f22b.31ead","type":"join","z":"7e9c5c41.22019c","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":false,"timeout":"","count":"","x":1390,"y":1460,"wires":[["d573eaf.31c8698"]]},{"id":"1409b8ce.5e5257","type":"change","z":"7e9c5c41.22019c","name":"","rules":[{"t":"delete","p":"payload.link","pt":"msg"},{"t":"delete","p":"payload.stateDescription","pt":"msg"},{"t":"delete","p":"payload.category","pt":"msg"},{"t":"delete","p":"payload.tags","pt":"msg"},{"t":"delete","p":"payload.groupNames","pt":"msg"},{"t":"delete","p":"payload.label","pt":"msg"},{"t":"delete","p":"payload.type","pt":"msg"},{"t":"move","p":"topic","pt":"msg","to":"payload.extension","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1240,"y":1460,"wires":[["9e23f22b.31ead"]]},{"id":"1c06534.7e433ad","type":"change","z":"7e9c5c41.22019c","name":"change","rules":[{"t":"set","p":"topic","pt":"msg","to":"ItemCommand","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"payload.*{extension: state}","tot":"jsonata"},{"t":"delete","p":"item","pt":"msg"},{"t":"delete","p":"payload_in","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":1620,"wires":[["6772a92b.9aa3b8"]]},{"id":"6772a92b.9aa3b8","type":"function","z":"7e9c5c41.22019c","name":"transform","func":"\nvar name = msg.rawitem;\nvar volt = +msg.payload._0_OPERATING_VOLTAGE;\nvar low = msg.payload._0_LOW_BAT;\n\n//  = (volt - minV) * 100/(maxV - minV);\n//             = 1          = 3    = 1\n\nvar batteryLevel = (volt - 1) * 50;\n\n//node.log(\"BatteryLevel: \"+batteryLevel);\n\nvar statusLowBattery = 0; // OFF\nif (low == \"ON\") statusLowBattery = 1;\n\n//node.log(\"StatusLowBattery: \"+statusLowBattery);\n\nmsg.payload = {\n    \"BatteryLevel\": batteryLevel,\n    \"ChargingState\": 0,\n    \"StatusLowBattery\": statusLowBattery\n};\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"level: \"+batteryLevel});   \nreturn msg;","outputs":1,"noerr":0,"x":680,"y":1660,"wires":[["91f3fd4.82127","aba85f27.15cad"]]},{"id":"d573eaf.31c8698","type":"link out","z":"7e9c5c41.22019c","name":"","links":["d3d72905.652a4"],"x":1475,"y":1460,"wires":[]},{"id":"d3d72905.652a4","type":"link in","z":"7e9c5c41.22019c","name":"","links":["d573eaf.31c8698"],"x":575,"y":1620,"wires":[["1c06534.7e433ad"]]},{"id":"91f3fd4.82127","type":"debug","z":"7e9c5c41.22019c","name":"","active":false,"console":"false","complete":"true","x":830,"y":1720,"wires":[]},{"id":"aba85f27.15cad","type":"switch","z":"7e9c5c41.22019c","name":"","property":"rawitem","propertyType":"msg","rules":[{"t":"eq","v":"KidsRadiator","vt":"str"},{"t":"eq","v":"BedRadiatorLeft","vt":"str"},{"t":"eq","v":"BedRadiatorRight","vt":"str"},{"t":"eq","v":"LivingRadiatorLeft","vt":"str"},{"t":"eq","v":"LivingRadiatorRight","vt":"str"},{"t":"eq","v":"BathRadiator","vt":"str"},{"t":"eq","v":"HallRadiator","vt":"str"}],"checkall":"true","outputs":7,"x":830,"y":1640,"wires":[["42aeb303.4c565c"],["255f980.dbc4d68"],["dc31f175.fbdbc"],["2d3093ac.230844"],["bb1bdc1.03bffa"],["d798dc63.f293f8"],["913a594b.612b4"]]},{"id":"b3fa61c8.a4046","type":"link out","z":"7e9c5c41.22019c","name":"","links":["9b1c955b.6e587"],"x":635,"y":1060,"wires":[]},{"id":"9b1c955b.6e587","type":"link in","z":"7e9c5c41.22019c","name":"","links":["b3fa61c8.a4046"],"x":415,"y":1500,"wires":[["c1b09eb5.f3bb2"]]},{"id":"a12141ee.27043","type":"comment","z":"7e9c5c41.22019c","name":"Update Battery","info":"","x":1580,"y":1460,"wires":[]},{"id":"e4d4431f.f3bb88","type":"comment","z":"7e9c5c41.22019c","name":"Update Thermostat","info":"","x":1610,"y":960,"wires":[]},{"id":"c9af7fcc.4c8848","type":"comment","z":"7e9c5c41.22019c","name":"Set Thermostat Data","info":"","x":1630,"y":1160,"wires":[]},{"id":"49d91db9.9e387c","type":"comment","z":"7e9c5c41.22019c","name":"Get Battery Data","info":"","x":740,"y":1060,"wires":[]},{"id":"f856f57f.493868","type":"comment","z":"7e9c5c41.22019c","name":"Get Thermostat Data","info":"","x":780,"y":900,"wires":[]},{"id":"1e16dd99.a42552","type":"homekit-accessory","z":"","accessoryName":"Thermostat Kinderzimmer","pinCode":"837-80-212","port":"","manufacturer":"EQ-3 / Homematic-IP","model":"HMIP-eTRV","serialNo":"xxx","accessoryType":"9"},{"id":"486ba9fc.3908a","type":"openhab2-controller","z":"","name":"openHAB2","protocol":"http","host":"localhost","port":"8080","path":"","username":"","password":""},{"id":"896c6a5b.232748","type":"homekit-accessory","z":"","accessoryName":"Thermostat Schlafzimmer Rechts","pinCode":"837-80-214","port":"","manufacturer":"EQ-3 / Homematic-IP","model":"HMIP-eTRV","serialNo":"xxx","accessoryType":"9"},{"id":"9e061e0a.3d52c","type":"homekit-accessory","z":"","accessoryName":"Thermostat Wohnzimmer Links","pinCode":"837-80-215","port":"","manufacturer":"EQ-3 / Homematic-IP","model":"HMIP-eTRV","serialNo":"xxx","accessoryType":"9"},{"id":"a9f808ab.3bbd58","type":"homekit-accessory","z":"","accessoryName":"Thermostat Wohnzimmer Rechts","pinCode":"837-80-216","port":"","manufacturer":"EQ-3 / Homematic-IP","model":"HMIP-eTRV","serialNo":"xxx","accessoryType":"9"},{"id":"c4fa0c0f.35dee8","type":"homekit-accessory","z":"","accessoryName":"Thermostat Badezimmer","pinCode":"837-80-217","port":"","manufacturer":"EQ-3 / Homematic-IP","model":"HMIP-eTRV","serialNo":"xxx","accessoryType":"9"},{"id":"b67b2d61.6e9a6","type":"homekit-accessory","z":"","accessoryName":"Thermostat Flur","pinCode":"837-80-218","port":"","manufacturer":"EQ-3 / Homematic-IP","model":"HMIP-eTRV","serialNo":"xxx","accessoryType":"9"},{"id":"aa346129.5269f8","type":"homekit-accessory","z":"","accessoryName":"Thermostat Schlafzimmer Links","pinCode":"837-80-213","port":"","manufacturer":"EQ-3 / Homematic-IP","model":"HMIP-eTRV","serialNo":"xxx","accessoryType":"9"}]

Hi @ptweety,

thank you very much! This helped me a lot! :slight_smile:

Have a nice day,

n30ngruu3n

[SOLVED] Missed out on the fact that npm version on my raspi was super-outdated.
Uplifted to most recent - all good now.

Are you using Openhab with Homekit binding and Node-Red on the same server?
I did install Node-Red and followed your how-to (kudos), but none of the homekit accessories created in node-red are found by Home App - any advise how to resolve?

I used to run all on a rpi but recently migrated OH and node red to docker containers. So should not have any impact at all.

Haven’t come across any issue like that. Would it be possible your NR server with HomeKit is on a different lan or segment or your home app can’t see the nr server or some ports are filtered.

That’s the only thing I can think about

Hello,

thx for this Thread so i wars able to adde my Window Sensors :slight_smile:

Question:
I wanne watch only Status from i item
I have a “ping Binding” which shows me the status of my bridges/server so the thing give me a “on or Off” status.

How i make this information visible in node-red (sorry i am very bad at this).
i tryed:


15
41

but this didnt work.

What “service” are you using for your HomeKit node?

There’s no reason this won’t work - but if you’re using “switch” as the type then you’ll need to send:

{"On":true}
{"On":false}

As your payloads.

We’ve had a lot of recent discussion in another thread - I even put together a pretty detailed tutorial of how I handle all of my items. Perhaps you’ll find something helpful over there:

Hi there, I need some help on this:
I have Roller Shutters and I would like to set the position on them from a Node Red HomeKit item. Can somebody tell me what items I need and how to setup them?
I get the CurrentPosition from the HomeKit item, but I don’t know the payload I have to set on the openHab item.

There’s a roller shutter example in my link just above your post - I call it “curtains”

My openhanded item is a dimmer, accepts 0-100 where 0 is closed and 100 is all the way open. I don’t know what hardware you’re using, but it should be a pretty easy to convert to your hardware. Maybe a matter of scaling numbers if anything?

My curtain motor is controlled by an Insteon micro open/close module.

Thank you for your answer Garrett. I had a look at your solution using dimmers, but i thought about a solution without a workaround. Unfortunately it looks like there is no other solution. Could you please send me your item and rule file?
I also think i have to do this with a timer. Sending the command “.SendCommand(50)” does noch set the shutter device to 50 of 100.

No need to for timer in my view
I did solve the issue the following (I am using Fibaro FGR222 in Venetian Blinds mode, which requires “TargetHorizontalTiltAngle” in addition)


I am using the blinds motor power consumption to update CurrentPosition.
Without that the blinds in homekit app would always be indidcated as Open/Close - with small spinning wheel.

CurrentPosition code:

var TargetPosition = context.get('TargetPosition');
var SensorPower = context.get('SensorPower');

if (msg.item == "ZWaveNode010FGR222RollerShutter2_ShutterPosition")
{
    TargetPosition = msg.payload;
}

if (msg.item == "ZWaveNode10FGRM222RollerShutter_SensorPower") 
{
    SensorPower = msg.payload;
}

if (SensorPower === 0);
{
msg.payload = {CurrentPosition: TargetPosition}
return msg;
}

The code for TargetPosition:

msg.payload = {TargetPosition : msg.payload}
return msg;

The code for TargetHorizontalTiltAngle:

msg.payload = { TargetHorizontalTiltAngle : msg.payload}
return msg;
your code goes here
1 Like

This is a cool approach. I wonder is it accurate enough that you could use the total power used to come up with a % open number and send a stop command once you’ve reached that?

@gegy - you’ll need to say what your hardware setup is, as you see there are many approaches that could work. Pick one and run with it!