# HomeKit Windows

**URL:** <https://discourse.nodered.org/t/homekit-windows/4285>\
**Category:** General\
**Created:** [25 October 2018 12:46 UTC](https://discourse.nodered.org/t/homekit-windows/4285 "2018-10-25T12:46:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Capioka](https://avatars.discourse-cdn.com/v4/letter/c/ee59a6/32.png) [@Capioka](https://discourse.nodered.org/u/Capioka)\
**Post date:** [25 October 2018 12:46 UTC](https://discourse.nodered.org/t/homekit-windows/4285/1 "2018-10-25T12:46:03Z")

</div>

Hello, i have a problem with the return of the value CurrentPosition,

The value return to the module is good, but, my iPhone not actualized.

The iPhone rest on open or closed et delay for take the state.

This my code, please Help me, many thanks

> Blockquote[{"id":"4566347f.0bf994","type":"function","z":"9a4084c6.4ee038","name":"Convert to","func":"msg.payload;\nif ((msg.payload == "TargetPosition") || (msg.payload == "CurrentPosition") )\nreturn msg;\nelse\nreturn;","outputs":1,"noerr":0,"x":486,"y":119,"wires":[["f46f09aa.12d9"]]}]

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [25 October 2018 12:57 UTC](https://discourse.nodered.org/t/homekit-windows/4285/2 "2018-10-25T12:57:09Z")

</div>

Add a debug node and copy & paste the message here.

---

<div class="post-metadata">

**Author:** ![Capioka](https://avatars.discourse-cdn.com/v4/letter/c/ee59a6/32.png) [@Capioka](https://discourse.nodered.org/u/Capioka)\
**Post date:** [25 October 2018 14:51 UTC](https://discourse.nodered.org/t/homekit-windows/4285/3 "2018-10-25T14:51:47Z")

</div>

```auto
[{"id":"66a2cc99.e78494","type":"mqtt in","z":"9a4084c6.4ee038","name":"homebridge/to/set/cortina","topic":"homebridge/to/set/cortina","qos":"2","broker":"fd3aed2f.d2703","x":115,"y":114,"wires":[["7b67f9ae.7f35e8"]]},{"id":"e3859695.099e6","type":"ui_slider","z":"9a4084c6.4ee038","name":"Manuel Value","label":"slider","group":"9e71132e.07a13","order":0,"width":0,"height":0,"passthru":true,"topic":"CurrentPosition:","min":0,"max":"100","step":1,"x":85,"y":339,"wires":[["7b67f9ae.7f35e8","1264ba1c.a874de"]]},{"id":"7b67f9ae.7f35e8","type":"function","z":"9a4084c6.4ee038","name":"Conversion to","func":"msg.payload = {\n CurrentPosition:(msg.payload)\n};\nreturn msg;\n","outputs":1,"noerr":0,"x":284.2500228881836,"y":295.75000381469727,"wires":[["6028aad4.b180ec","867d4c4.181a93"]]},{"id":"6028aad4.b180ec","type":"homekit-service","z":"9a4084c6.4ee038","bridge":"abb92c0a.8b0db","name":"youpie","serviceName":"Window","manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","characteristicProperties":"{}","x":499.5,"y":346,"wires":[["4566347f.0bf994","df8af572.aa5cd8"]]},{"id":"4566347f.0bf994","type":"function","z":"9a4084c6.4ee038","name":"Convert to","func":"msg.payload;\nif ((msg.payload == \"TargetPosition\") || (msg.payload == \"CurrentPosition\") )\nreturn msg;\nelse\nreturn;","outputs":1,"noerr":0,"x":668.0000076293945,"y":346.5000047683716,"wires":[["f46f09aa.12d9","7fe268e6.bdedc"]]},{"id":"f46f09aa.12d9","type":"mqtt out","z":"9a4084c6.4ee038","name":"","topic":"homebridge/from/set","qos":"","retain":"","broker":"fd3aed2f.d2703","x":888.0000114440918,"y":345.0000047683716,"wires":[]},{"id":"c32e37c5.c3ded8","type":"mqtt in","z":"9a4084c6.4ee038","name":"CP1","topic":"CP1","qos":"2","broker":"fd3aed2f.d2703","x":55,"y":431,"wires":[["380bff2f.65c408"]]},{"id":"380bff2f.65c408","type":"function","z":"9a4084c6.4ee038","name":"Conversion to ","func":"msg.payload = {\n PositionState:(msg.payload)\n};\nreturn msg;\n","outputs":1,"noerr":0,"x":281,"y":399,"wires":[["6028aad4.b180ec","e4fbed12.491238"]]},{"id":"1264ba1c.a874de","type":"ui_text","z":"9a4084c6.4ee038","group":"9e71132e.07a13","order":5,"width":"3","height":"1","name":"","label":"Temp :","format":"{{msg.payload}}","layout":"row-center","x":275,"y":338,"wires":[]},{"id":"7fe268e6.bdedc","type":"debug","z":"9a4084c6.4ee038","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":856.8750114440918,"y":496.25000762939453,"wires":[]},{"id":"df8af572.aa5cd8","type":"debug","z":"9a4084c6.4ee038","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":641.875,"y":496.25,"wires":[]},{"id":"867d4c4.181a93","type":"debug","z":"9a4084c6.4ee038","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":447.5,"y":497.5,"wires":[]},{"id":"e4fbed12.491238","type":"debug","z":"9a4084c6.4ee038","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":258,"y":500,"wires":[]},{"id":"fd3aed2f.d2703","type":"mqtt-broker","z":"","name":"MQTT-BROKER","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"9e71132e.07a13","type":"ui_group","z":"","name":"Home","tab":"6b756c01.9822f4","disp":true,"width":"17","collapse":true},{"id":"abb92c0a.8b0db","type":"homekit-bridge","z":"","bridgeName":"Mee","pinCode":"111-11-111","port":"","manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number"},{"id":"6b756c01.9822f4","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]

```

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [25 October 2018 14:53 UTC](https://discourse.nodered.org/t/homekit-windows/4285/4 "2018-10-25T14:53:03Z")

</div>

@Capioka I have edited your post to properly format the flow. When sharing code or flows do not use the Blockquote you have been using. You should add three backtick characters (```) on a newline before and after your code/flow json. That will ensure it gets displayed properly

---

<div class="post-metadata">

**Author:** ![Capioka](https://avatars.discourse-cdn.com/v4/letter/c/ee59a6/32.png) [@Capioka](https://discourse.nodered.org/u/Capioka)\
**Post date:** [27 October 2018 09:36 UTC](https://discourse.nodered.org/t/homekit-windows/4285/5 "2018-10-27T09:36:25Z")

</div>

Ok @knolleary thanks,

I was able to find the problem, when I send a PositionTarget, my program reads it and once the position reached, it sends to node red. On the other hand, what happens is that once the CurrentTarget arrives on the HomeKit block, the latter sends the target position again but at 0 and thus the flap goes back to the closed position. the position is confirmed closed.  
What can I do to not have this problem sending value to 0? Namely that 0 is the total close command.

---

<div class="post-metadata">

**Author:** ![Capioka](https://avatars.discourse-cdn.com/v4/letter/c/ee59a6/32.png) [@Capioka](https://discourse.nodered.org/u/Capioka)\
**Post date:** [28 October 2018 11:25 UTC](https://discourse.nodered.org/t/homekit-windows/4285/7 "2018-10-28T11:25:53Z")

</div>

Hello,

Ok, i find a solution, i put a if in my code and de script run .

Many thanks
