diff --git a/content/wiki/service/carbon-dioxide-sensor/CO2_basic_principle.png b/content/wiki/service/carbon-dioxide-sensor/CO2_basic_principle.png new file mode 100644 index 000000000..c494e4325 Binary files /dev/null and b/content/wiki/service/carbon-dioxide-sensor/CO2_basic_principle.png differ diff --git a/content/wiki/service/carbon-dioxide-sensor/CO2_full_example.png b/content/wiki/service/carbon-dioxide-sensor/CO2_full_example.png new file mode 100644 index 000000000..5c4a5d35f Binary files /dev/null and b/content/wiki/service/carbon-dioxide-sensor/CO2_full_example.png differ diff --git a/content/wiki/service/carbon-dioxide-sensor/CO2_monitoring.png b/content/wiki/service/carbon-dioxide-sensor/CO2_monitoring.png new file mode 100644 index 000000000..8a870ea1e Binary files /dev/null and b/content/wiki/service/carbon-dioxide-sensor/CO2_monitoring.png differ diff --git a/content/wiki/service/carbon-dioxide-sensor/index.md b/content/wiki/service/carbon-dioxide-sensor/index.md index 06e851b7a..dad7c5464 100644 --- a/content/wiki/service/carbon-dioxide-sensor/index.md +++ b/content/wiki/service/carbon-dioxide-sensor/index.md @@ -3,7 +3,7 @@ title: "Carbon Dioxide Sensor" description: "Carbon Dioxide Sensor" lead: "" date: 2021-12-05T19:21:31.768Z -lastmod: 2021-10-15T22:06:11.305Z +lastmod: 2022-02-09T13:56:57.324Z draft: false images: [] menu: @@ -12,32 +12,33 @@ menu: toc: true service: name: "CarbonDioxideSensor" -contributors: ["djiwondee","crxporter","caitken-com","Shaquu"] +contributors: ["djiwondee", "crxporter", "caitken-com", "Shaquu"] --- -## Example - -These examples are meant to be copied into your Node-RED system and adapted to your setup. +{{< alert icon="💡" text="Home.app will not display the Carbon Dioxide Level in the Accessory's bubble." />}} -**Please note:** Different from other HomeKit services (e.g. temperature sensor) the Home.app is not showing the carbon dioxide level on the device icon. To view the current value you have to open the preferences of the device in the Home.app. This works as designed by Apple and can't be changed with characteristics properties. +## Basic Principle -### Simple CO2 Sensor +This is the simplest example of a CO2 Sensor item. The input nodes are `Detected` and `Not Detected`. -This example is a simple CO2 sensor that is only ever "triggered" or "normal". -The msg.payload going in is either `{"CarbonDioxideDetected":1}` or `{"CarbonDioxideDetected":0}` where 1 is "carbon dioxide detected" and 0 is "normal conditions". +![Basic Principle](CO2_basic_principle.png) -![screen shot 2019-03-06 at 9 51 04 am](https://user-images.githubusercontent.com/38265886/53894230-5cebb780-3ff5-11e9-81d8-fb1ec6fad816.png) +Copyable Node-RED flow: ```json [{"id":"abf13091.ebbd38","type":"homekit-service","z":"54339415.36f384","bridge":"b070e578.4eca1","name":"Simple CO2","serviceName":"CarbonDioxideSensor","topic":"","manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","characteristicProperties":"{}","x":870,"y":380,"wires":[["e1bd6875.39b18"]]},{"id":"e1bd6875.39b18","type":"debug","z":"54339415.36f384","name":"CO2 Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1050,"y":380,"wires":[]},{"id":"46f9e422.63a86c","type":"inject","z":"54339415.36f384","name":"Detected","topic":"","payload":"{\"CarbonDioxideDetected\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":680,"y":360,"wires":[["abf13091.ebbd38"]]},{"id":"ea1120d0.634c88","type":"inject","z":"54339415.36f384","name":"Not Detected","topic":"","payload":"{\"CarbonDioxideDetected\":0}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":670,"y":400,"wires":[["abf13091.ebbd38"]]},{"id":"b070e578.4eca1","type":"homekit-bridge","z":"","bridgeName":"Node-Red-Homekit-Bridge","pinCode":"270-21-969","port":"34567","allowInsecureRequest":false,"manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number"}] ``` +## Example + +Below is a list of examples intended to be copied into your Node-RED system and adapted to your setup: + ### Full Featured CO2 Sensor -This is an example of a CO2 Sensor that triggers an event message in the Home.app in case the CO2 level is above a threshold level of 1000. -In this example the input nodes is an inject node just for a value of an assumed carbon dioxide level. In real life the author of that example gather the current value from a [Netatmo weather stations](https://www.netatmo.com/en-eu/weather?force_locale=en-eu) by accessing the [Netatmo Connect API](https://dev.netatmo.com/en-US/resources/technical/introduction). The debug node will return values set in the payload as it available in the Home.app on an Apple device. +This is an example of a CO2 Sensor that triggers an event message in the Home.app in case the CO2 Level is above a threshold Level of 1000. +In this example the input nodes is an inject node just for a value of an assumed Carbon Dioxide Level. In real life the author of that example gather the current value from a [Netatmo weather stations](https://www.netatmo.com/en-eu/weather?force_locale=en-eu) by accessing the [Netatmo Connect API](https://dev.netatmo.com/en-US/resources/technical/introduction). The debug node will return values set in the payload as it available in the Home.app on an Apple device. -![bildschirmfoto 2019-03-06 um 14 29 28](https://user-images.githubusercontent.com/37173958/53884669-6b00fe80-401c-11e9-8709-2cee51974111.png) +![Full Example](CO2_full_example.png) Copyable Node-RED flow: @@ -45,14 +46,14 @@ Copyable Node-RED flow: [{"id":"9753f14168949be2","type":"switch","z":"d13781c2edd7efd1","name":"Check CO2 Peaklevel","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"1000","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":480,"y":520,"wires":[["92bfc0d7d2d54d0e"],["6ee0215b3c7e8743"]]},{"id":"92bfc0d7d2d54d0e","type":"change","z":"d13781c2edd7efd1","name":"Set HkMsg CO2 PeakLevel Detected","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.CarbonDioxideLevel","tot":"msg"},{"t":"set","p":"payload.CarbonDioxidePeakLevel","pt":"msg","to":"payload.CarbonDioxideLevel","tot":"msg"},{"t":"set","p":"payload.CarbonDioxideDetected","pt":"msg","to":"1","tot":"num"},{"t":"set","p":"payload.StatusActive","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":500,"wires":[["7bbcbe8c1a25d4df"]]},{"id":"6ee0215b3c7e8743","type":"change","z":"d13781c2edd7efd1","name":"Set HkMsg CO2 No PeakLevel Detected","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.CarbonDioxideLevel","tot":"msg"},{"t":"set","p":"payload.CarbonDioxidePeakLevel","pt":"msg","to":"payload.CarbonDioxideLevel","tot":"msg"},{"t":"set","p":"payload.CarbonDioxideDetected","pt":"msg","to":"0","tot":"num"},{"t":"set","p":"payload.StatusActive","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":540,"wires":[["7bbcbe8c1a25d4df"]]},{"id":"e79fda3842fe456f","type":"debug","z":"d13781c2edd7efd1","name":"CO2 Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1210,"y":520,"wires":[]},{"id":"68e5c6f16ac5e512","type":"inject","z":"d13781c2edd7efd1","name":"Inject 567 ppm","props":[{"p":"payload","v":"567","vt":"num"},{"p":"topic","v":"","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"567","payloadType":"num","x":260,"y":500,"wires":[["9753f14168949be2"]]},{"id":"72681c56064f6f9e","type":"inject","z":"d13781c2edd7efd1","name":"Inject 1357 ppm (above peak level)","props":[{"p":"payload","v":"1357","vt":"num"},{"p":"topic","v":"","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1357","payloadType":"num","x":200,"y":540,"wires":[["9753f14168949be2"]]},{"id":"7bbcbe8c1a25d4df","type":"homekit-service","z":"d13781c2edd7efd1","bridge":"25f17d6406cfacdd","name":"CO2","serviceName":"CarbonDioxideSensor","topic":"","manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","characteristicProperties":"{\n \"StatusActive\" : true,\n \"CarbonDioxideLevel\" : 0,\n \"CarbonDioxidePeakLevel\" : 1000,\n \"CarbonDioxideDetected\" : 0\n}","outputs":2,"x":1050,"y":520,"wires":[["e79fda3842fe456f"],[]]},{"id":"cc376b99a75e5dcb","type":"comment","z":"d13781c2edd7efd1","name":"Simulate CO2 Level","info":"","x":130,"y":440,"wires":[]},{"id":"e64b903b3f084112","type":"comment","z":"d13781c2edd7efd1","name":"Set and Check Peak Level","info":"","x":490,"y":440,"wires":[]},{"id":"fe1eafa00b02eb32","type":"comment","z":"d13781c2edd7efd1","name":"Set Payload according to HAP specification","info":"","x":790,"y":440,"wires":[]},{"id":"25f17d6406cfacdd","type":"homekit-bridge","bridgeName":"Node-Red-Homekit-Bridge","pinCode":"270-21-969","port":"34567","allowInsecureRequest":false,"manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number"}] ``` -This example triggers a message in iOS if the carbon dioxide level raises above 1000 ppm a set the status of the device in the Home.app to _peak level detected_. You can now use that to create an automation in the Home.app triggered by carbon dioxide peak level. If the level would fall below the selected peak level, the Peak level detection will be deactivated. In addition to that you can now ask Siri what the carbon dioxide level in the room you assign the sensor in the Home.app. But most important, if you are using Netatmo Weather Station as the source of your in and outdoor climatic measurement you can now bridge the gap of the missing HomeKit compatibility of Netatmo. +This example triggers a message in iOS if the Carbon Dioxide Level raises above 1000 ppm a set the status of the device in the Home.app to _peak level detected_. You can now use that to create an automation in the Home.app triggered by carbon dioxide peak level. If the level would fall below the selected peak level, the Peak level detection will be deactivated. In addition to that you can now ask Siri what the Carbon Dioxide Level in the room you assign the Sensor in the Home.app. But most important, if you are using Netatmo Weather Station as the source of your in and outdoor climatic measurement you can now Bridge the gap of the missing HomeKit compatibility of Netatmo. -### Monitoring peak level and event handling +### Monitoring peak Level and event handling This is another example how to deal with the event interaction on iOS. The following flow saves the recent peak level in a context variable of the node and always updates the `CarbonDioxidePeakLevel` if it is larger than the previous measurement cycle. -If the level goes up a particular value (e.g. 1000ppm is set in the example) it changes the `CarbonDioxideDetected` property to 1 which causes an alarm in the iOS Home.app. +If the Level goes up a particular value (e.g. 1000ppm is set in the example) it changes the `CarbonDioxideDetected` property to 1 which causes an alarm in the iOS Home.app. -![Bildschirmfoto 2019-03-09 um 16 36 48](https://user-images.githubusercontent.com/37173958/54073667-4e69fe00-428a-11e9-91e7-3f29bc87ea33.png) +![CO2 Monitoring](CO2_monitoring.png) The alarm will be reset after 30sec based on the individual reset. Also, the recent peak level is set to `null` for some reasons. @@ -66,10 +67,12 @@ Some credits for this example goes to [crxporter](https://github.com/crxporter) ### Full CO2 Example from Demo -This is a copy of the [Demo](https://nrchkb.github.io/wiki/examples/demo-setup/) CO2 sensor. It has inject nodes for random "safe", random "unsafe", and a reset to 0 level. Additionally it has `active | inactive | NO_RESPONSE` handling. +This is a copy of the [Demo](https://nrchkb.github.io/wiki/examples/demo-setup/) CO2 Sensor. It has inject nodes for random "safe", random "unsafe", and a reset to 0 Level. Additionally it has `Active | Inactive | NO_RESPONSE` handling. ![CO2_demo](CO2_demo.png) +Copyable Node-RED flow: + ```json [{"id":"ab48426e.25466","type":"group","z":"58d0ac22b8a060e3","name":"CO2 Sensor: input only sensor","style":{"stroke":"#999999","fill":"none","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["88892b4.8a61bd8","3611c654.8a42f2","62cafcb0.8ade9c","a0171cdb.f209b","6f7de764.a6a688","8758b463.afb0f","69e8161b.74b7a","40010b09.c73cdc"],"x":134,"y":819,"w":752,"h":202,"info":"# CO2 Sensor\n\nThere are three inputs to this example, one for each level of Carbon Dioxide in the air. Options are:\n\n**0 ppm:** this will assume no CO2
\n**Safe level:** this will assume a level between 1 and 999 ppm, inclusive
\n**Dangerous level:** this will assume a level between 1,000 and 100,000, inclusive; this will also trigger an alert"},{"id":"88892b4.8a61bd8","type":"homekit-service","z":"58d0ac22b8a060e3","g":"ab48426e.25466","isParent":true,"hostType":"0","bridge":"409001a1.3e7a78","accessoryId":"","parentService":"","name":"CO2 Sensor","serviceName":"CarbonDioxideSensor","topic":"","filter":false,"manufacturer":"Default Manufacturer","model":"Carbon","serialNo":"Default Serial Number","firmwareRev":"22","hardwareRev":"11","softwareRev":"","cameraConfigVideoProcessor":"","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":"","cameraConfigMaxWidth":"","cameraConfigMaxHeight":"","cameraConfigMaxFPS":"","cameraConfigMaxBitrate":"","cameraConfigVideoCodec":"","cameraConfigAudioCodec":"","cameraConfigAudio":false,"cameraConfigPacketSize":"","cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"","cameraConfigMapAudio":"","cameraConfigVideoFilter":"","cameraConfigAdditionalCommandLine":"","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{ \"CarbonDioxideLevel\" : true, \"CarbonDioxidePeakLevel\": true, \"StatusActive\" : true}","waitForSetupMsg":false,"outputs":2,"x":790,"y":860,"wires":[[],[]]},{"id":"3611c654.8a42f2","type":"function","z":"58d0ac22b8a060e3","g":"ab48426e.25466","name":"Random values, peak value","func":"// Reset all values to 0 if 0ppm input\nif(msg.payload === 0){\n context.set('lastPeak',0);\n newMsg = {\n payload: {\n \"CarbonDioxideLevel\":0,\n \"CarbonDioxidePeakLevel\":0,\n \"CarbonDioxideDetected\":0\n }\n };\n return newMsg;\n}\n\n// Initialize vars\nvar CurrentLevel = 0;\nvar lastPeak = context.get('lastPeak');\n\n// Set random safe or dangerous levels\nif(msg.payload === \"Safe\"){\n CurrentLevel = Math.floor(Math.random() * (999 - 1 + 1) + 1);\n}\nif(msg.payload === \"Danger\"){\n CurrentLevel = Math.floor(Math.random() * (100000 - 1000 + 1) + 1000);\n}\n\n// Formulate output message\nvar newMsg = {\n payload: {\n \"CarbonDioxideLevel\" : CurrentLevel,\n \"CarbonDioxideDetected\" : 0\n }\n};\n\n// Set new peak level\nif(CurrentLevel > lastPeak){\n lastPeak = CurrentLevel;\n context.set('lastPeak',CurrentLevel);\n newMsg.payload.CarbonDioxidePeakLevel = CurrentLevel;\n}\n\n// Set warning if dangerous\nif (CurrentLevel >= 1000) {\n newMsg.payload.CarbonDioxideDetected = 1;\n} \n\nreturn newMsg;","outputs":1,"noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is deployed.\ncontext.set('lastPeak',0);\n","finalize":"","x":520,"y":860,"wires":[["88892b4.8a61bd8"]]},{"id":"62cafcb0.8ade9c","type":"inject","z":"58d0ac22b8a060e3","g":"ab48426e.25466","name":"Active","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"StatusActive\":true}","payloadType":"json","x":590,"y":900,"wires":[["88892b4.8a61bd8"]]},{"id":"a0171cdb.f209b","type":"inject","z":"58d0ac22b8a060e3","g":"ab48426e.25466","name":"Inactive","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"StatusActive\":false}","payloadType":"json","x":590,"y":940,"wires":[["88892b4.8a61bd8"]]},{"id":"6f7de764.a6a688","type":"inject","z":"58d0ac22b8a060e3","g":"ab48426e.25466","name":"NO RESPONSE","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"CarbonDioxideLevel\":\"NO_RESPONSE\"}","payloadType":"json","x":560,"y":980,"wires":[["88892b4.8a61bd8"]]},{"id":"8758b463.afb0f","type":"inject","z":"58d0ac22b8a060e3","g":"ab48426e.25466","name":"0 ppm","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":230,"y":860,"wires":[["3611c654.8a42f2"]]},{"id":"69e8161b.74b7a","type":"inject","z":"58d0ac22b8a060e3","g":"ab48426e.25466","name":"Safe Level","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Safe","payloadType":"str","x":240,"y":900,"wires":[["3611c654.8a42f2"]]},{"id":"40010b09.c73cdc","type":"inject","z":"58d0ac22b8a060e3","g":"ab48426e.25466","name":"Dangerous level","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Danger","payloadType":"str","x":260,"y":940,"wires":[["3611c654.8a42f2"]]},{"id":"409001a1.3e7a78","type":"homekit-bridge","bridgeName":"Demo 1","pinCode":"153-10-538","port":"","allowInsecureRequest":false,"manufacturer":"NRCHKB","model":"Demo","serialNo":"1.1.2","customMdnsConfig":false,"mdnsMulticast":true,"mdnsInterface":"","mdnsPort":"","mdnsIp":"","mdnsTtl":"","mdnsLoopback":true,"mdnsReuseAddr":true,"allowMessagePassthrough":true}] ``` diff --git a/content/wiki/service/carbon-monoxide-sensor/CO_basic_principle.png b/content/wiki/service/carbon-monoxide-sensor/CO_basic_principle.png new file mode 100644 index 000000000..02108731d Binary files /dev/null and b/content/wiki/service/carbon-monoxide-sensor/CO_basic_principle.png differ diff --git a/content/wiki/service/carbon-monoxide-sensor/CO_full_example.png b/content/wiki/service/carbon-monoxide-sensor/CO_full_example.png new file mode 100644 index 000000000..293adb9a6 Binary files /dev/null and b/content/wiki/service/carbon-monoxide-sensor/CO_full_example.png differ diff --git a/content/wiki/service/carbon-monoxide-sensor/index.md b/content/wiki/service/carbon-monoxide-sensor/index.md index 6bb8053fd..5d36156ae 100644 --- a/content/wiki/service/carbon-monoxide-sensor/index.md +++ b/content/wiki/service/carbon-monoxide-sensor/index.md @@ -3,7 +3,7 @@ title: "Carbon Monoxide Sensor" description: "Carbon Monoxide Sensor" lead: "" date: 2021-04-17T18:50:12.028Z -lastmod: 2021-10-15T22:06:11.570Z +lastmod: 2022-02-09T13:56:57.324Z draft: false images: [] menu: @@ -12,24 +12,16 @@ menu: toc: true service: name: "CarbonMonoxideSensor" -contributors: ["crxporter","caitken-com","Shaquu"] +contributors: ["crxporter", "caitken-com", "Shaquu"] --- -To have a carbon monoxide sensor appear in the Home.app, the CarbonMonoxide service is used. -Required value is `CarbonMonoxideDetected`, there will be a simple example and detailed example included below. -Characteristic Properties are not needed for this setup, the values will be updated in the Home.app based on what is being sent from your sensors. +{{< alert icon="💡" text="Home.app will not display the Carbon Monoxide Level in the Accessory's bubble." />}} -## Example - -These examples are meant to be copied into your Node-RED system and adapted to your setup. - -**Please note:** Different from other HomeKit services (e.g. temperature sensor) the Home.app is not showing the carbon monoxide level on the device icon. To view the current value you have to open the preferences of the device in the Home.app or ask Siri. This works as designed by Apple and can't be changed. - -### Simple Carbon Monoxide Sensor +## Basic Principle -This example is a simple Carbon Monoxide sensor that is only ever "triggered" or "normal". The msg.payload going in is either `{"CarbonMonoxideDetected":1}` or `{"CarbonMonoxideDetected":0}` where 1 is "carbon monoxide detected" and 0 is "normal conditions". Use this example as a starting point for simple alarms that do not send detailed levels. +This is the simplest example of a CO Sensor item. The input nodes are `Detected` and `Not Detected`. -![screen shot 2019-03-06 at 10 38 45 am](https://user-images.githubusercontent.com/38265886/53897565-059d1580-3ffc-11e9-8d69-dabb28d44aca.png) +![Basic Principle](CO_basic_principle.png) Copyable Node-RED flow: @@ -37,6 +29,10 @@ Copyable Node-RED flow: [{"id":"ac79f4f4.906df8","type":"homekit-service","z":"54339415.36f384","bridge":"d334490b.40dac","name":"Simple CO","serviceName":"CarbonMonoxideSensor","topic":"","manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","characteristicProperties":"{}","x":670,"y":800,"wires":[["933cc1a6.dc8c98"]]},{"id":"7fe97674.cbc19","type":"inject","z":"54339415.36f384","name":"Not Detected","topic":"","payload":"{\"CarbonMonoxideDetected\":0}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":470,"y":820,"wires":[["ac79f4f4.906df8"]]},{"id":"933cc1a6.dc8c98","type":"debug","z":"54339415.36f384","name":"CO Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":850,"y":800,"wires":[]},{"id":"3efd37a6.392f78","type":"inject","z":"54339415.36f384","name":"Detected","topic":"","payload":"{\"CarbonMonoxideDetected\":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":480,"y":780,"wires":[["ac79f4f4.906df8"]]},{"id":"d334490b.40dac","type":"homekit-bridge","z":"","bridgeName":"Example Bridge","pinCode":"111-11-111","port":"","allowInsecureRequest":false,"manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number"}] ``` +## Example + +Below is a list of examples intended to be copied into your Node-RED system and adapted to your setup: + ### Full Featured Carbon Monoxide Sensor This is an example of a carbon monoxide detector that reports the current amount of carbon monoxide in the air as parts per million (PPM). A threshold level of 35 has been set as the "alarm level". This level was chosen because it is the limit of what OSHA has decided is unsafe for 8 hour exposure. Please adjust to the threshold you would like in your system. @@ -49,7 +45,7 @@ There are three inject nodes in this example: **The `Reset` inject node** will send a value of 0 to both `CarbonMonoxideDetected` and `CarbonMonoxidePeakLevel` - used to clear the system after alarms have been dealt with and carbon monoxide sources have been stopped. -![screen shot 2019-03-06 at 10 38 21 am](https://user-images.githubusercontent.com/38265886/53897541-f7e79000-3ffb-11e9-9481-23e6e8246a49.png) +![Full Example](CO_full_example.png) Copyable Node-RED flow: diff --git a/content/wiki/service/contact-sensor/contact_sensor_mqtt_example.png b/content/wiki/service/contact-sensor/contact_sensor_mqtt_example.png new file mode 100644 index 000000000..5c16eee27 Binary files /dev/null and b/content/wiki/service/contact-sensor/contact_sensor_mqtt_example.png differ diff --git a/content/wiki/service/contact-sensor/index.md b/content/wiki/service/contact-sensor/index.md index 6d90e395e..17db816df 100644 --- a/content/wiki/service/contact-sensor/index.md +++ b/content/wiki/service/contact-sensor/index.md @@ -3,7 +3,7 @@ title: "Contact Sensor" description: "Contact Sensor" lead: "" date: 2021-04-17T18:50:12.028Z -lastmod: 2021-10-23T18:48:46+02:00 +lastmod: 2022-02-09T13:56:57.324Z draft: false images: [] menu: @@ -12,15 +12,14 @@ menu: toc: true service: name: "ContactSensor" -contributors: ["GogoVega","Shaquu"] - +contributors: ["GogoVega", "Shaquu"] --- ## Basic principle -This is the simplest example of a contact sensor item. The input nodes are `Open`, `Close`, `Tampered` and `Not Tampered`. +This is the simplest example of a Contact Sensor item. The input nodes are `Open`, `Close`, `Tampered` and `Not Tampered`. -![Contact Sensor](contact_sensor_example.png) +![Basic Principle](contact_sensor_example.png) Copyable Node-RED flow: @@ -30,7 +29,7 @@ Copyable Node-RED flow: ### Characteristic Properties -Use the following JSON in your characteristic properties so that the Home application displays a contact sensor with status tampered. +Use the following JSON in your Characteristic Properties so that the Home.app displays a Contact Sensor with Status Tampered. ```json { @@ -41,18 +40,32 @@ Use the following JSON in your characteristic properties so that the Home applic ## Example -### Implementation with an Omron PLC +Below is a list of examples intended to be copied into your Node-RED system and adapted to your setup: + +### MQTT Example -This is an example of a contact sensor element wired in NO with a safety if the cable is cut. +This is an example of a Contact Sensor item. The input nodes are `Open` and `Close`. + +![MQTT Example](contact_sensor_mqtt_example.png) + +Copyable Node-RED flow: + +```json +[{"id":"c775950460a1ce62","type":"function","z":"d57f90c91936790e","name":"State to HK","func":"const State = msg.payload.doorcontact_state;\nmsg.payload = {\"ContactSensorState\":State};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":1760,"wires":[["e655dc58594a534f"]]},{"id":"39f5723c2f8cf9e1","type":"inject","z":"d57f90c91936790e","name":"Close","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":"0.5","topic":"","payload":"{\"doorcontact_state\":0}","payloadType":"json","x":150,"y":1640,"wires":[["2fe650548dfb3f03"]]},{"id":"e655dc58594a534f","type":"homekit-service","z":"d57f90c91936790e","isParent":true,"hostType":"0","bridge":"4a2a4fc162440a41","accessoryId":"","parentService":"","name":"Contact Sensor","serviceName":"ContactSensor","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.2.0","serialNo":"Default Serial Number","firmwareRev":"1.2.0","hardwareRev":"1.2.0","softwareRev":"1.2.0","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{\"ContactSensorState\":0}","waitForSetupMsg":false,"outputs":2,"x":520,"y":1760,"wires":[[],[]]},{"id":"752e34d9f9bd2c80","type":"inject","z":"d57f90c91936790e","name":"Open","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":"0.5","topic":"","payload":"{\"doorcontact_state\":1}","payloadType":"json","x":150,"y":1700,"wires":[["2fe650548dfb3f03"]]},{"id":"03dc40ae4d42b92b","type":"mqtt in","z":"d57f90c91936790e","name":"Contact State","topic":"tele/CONTACT_DOOR/SENSOR","qos":"2","datatype":"auto","broker":"e17954568d0e969f","nl":false,"rap":true,"rh":0,"inputs":0,"x":150,"y":1760,"wires":[["c775950460a1ce62"]]},{"id":"2fe650548dfb3f03","type":"mqtt out","z":"d57f90c91936790e","name":"Write","topic":"tele/CONTACT_DOOR/SENSOR","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"e17954568d0e969f","x":290,"y":1640,"wires":[]},{"id":"4a2a4fc162440a41","type":"homekit-bridge","bridgeName":"Bridge Node-RED","pinCode":"605-37-162","port":"","advertiser":"ciao","allowInsecureRequest":false,"manufacturer":"NRCHKB","model":"1.4.3","serialNo":"Default Serial Number","firmwareRev":"1.4.3","hardwareRev":"1.4.3","softwareRev":"1.4.3","customMdnsConfig":false,"mdnsMulticast":true,"mdnsInterface":"","mdnsPort":"","mdnsIp":"","mdnsTtl":"","mdnsLoopback":true,"mdnsReuseAddr":true,"allowMessagePassthrough":true},{"id":"e17954568d0e969f","type":"mqtt-broker","name":"Mosquitto","broker":"localhost","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"sessionExpiry":""}] +``` + +### Implementation with an Omron PLC + +This is an example of a Contact Sensor element wired in NO with a safety if the cable is cut. -![Contact Sensor Omron PLC](contact_sensor_omron_plc_example.png) +![Omron PLC Example](contact_sensor_omron_plc_example.png) In this example our PLC address is `CIO10` Copyable Node-RED flow: ```json -[{"id":"d666fb54ed871feb","type":"inject","z":"12e297aed19dd6f4","name":"2s","props":[{"p":"time","v":"true","vt":"bool"}],"repeat":"2","crontab":"","once":false,"onceDelay":"0.5","topic":"","x":110,"y":60,"wires":[["93b4e6bbe3b1a7b2"]]},{"id":"93b4e6bbe3b1a7b2","type":"FINS Read Multiple","z":"12e297aed19dd6f4","name":"Read PLC","connection":"11b8375b.b1ee31","addressType":"str","address":"CIO10","msgPropertyType":"msg","msgProperty":"CIO_READ","outputFormatType":"signed","outputFormat":"","x":270,"y":60,"wires":[["60edd09485c09cf0"]]},{"id":"60edd09485c09cf0","type":"buffer-parser","z":"12e297aed19dd6f4","name":"Int16=>16b","data":"CIO_READ","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"16bitbe","name":"CIO10","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"CIO_READ","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":450,"y":60,"wires":[["1b23e6a98e61d44c"]]},{"id":"9e486680d55835a5","type":"homekit-service","z":"12e297aed19dd6f4","isParent":true,"hostType":"0","bridge":"5b5f6f73.10106","accessoryId":"","parentService":"","name":"Contact Sensor","serviceName":"ContactSensor","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.2.0","serialNo":"Default Serial Number","firmwareRev":"1.2.0","hardwareRev":"1.2.0","softwareRev":"1.2.0","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{\"ContactSensorState\":0,\"StatusTampered\":false}","waitForSetupMsg":false,"outputs":2,"x":820,"y":60,"wires":[[],[]]},{"id":"1b23e6a98e61d44c","type":"function","z":"12e297aed19dd6f4","name":"10.00-10.01","func":"var ContactState = msg.CIO_READ.CIO10[0].bits[0]; //10.00\nvar TamperedState = msg.CIO_READ.CIO10[0].bits[1]; //10.01\n\nmsg = {payload:{\n \"StatusTampered\":TamperedState,\n \"ContactSensorState\":ContactState\n }\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":630,"y":60,"wires":[["9e486680d55835a5"]]},{"id":"11b8375b.b1ee31","type":"FINS Connection","name":"PLC","host":"192.168.1.2","port":"9600","MODE":"","MODEType":"CS","protocol":"","protocolType":"udp","ICF":"","DNA":"","DA1":"2","DA2":"","SNA":"","SA1":"20","SA2":"","autoConnect":true},{"id":"5b5f6f73.10106","type":"homekit-bridge","bridgeName":"Pont Node-Red","pinCode":"123-45-321","port":"","allowInsecureRequest":true,"manufacturer":"NRCHKB","model":"1.2.0","serialNo":"Raspberry Pi 3 B+","firmwareRev":"1.2.0","hardwareRev":"1.2.0","softwareRev":"1.2.0","customMdnsConfig":false,"mdnsMulticast":true,"mdnsInterface":"","mdnsPort":"","mdnsIp":"","mdnsTtl":"","mdnsLoopback":true,"mdnsReuseAddr":true,"allowMessagePassthrough":true}] +[{"id":"d666fb54ed871feb","type":"inject","z":"12e297aed19dd6f4","name":"2s","props":[{"p":"time","v":"true","vt":"bool"}],"repeat":"2","crontab":"","once":false,"onceDelay":"0.5","topic":"","x":110,"y":60,"wires":[["93b4e6bbe3b1a7b2"]]},{"id":"93b4e6bbe3b1a7b2","type":"FINS Read Multiple","z":"12e297aed19dd6f4","name":"Read PLC","connection":"11b8375b.b1ee31","addressType":"str","address":"CIO10","msgPropertyType":"msg","msgProperty":"CIO_READ","outputFormatType":"signed","outputFormat":"","x":270,"y":60,"wires":[["60edd09485c09cf0"]]},{"id":"60edd09485c09cf0","type":"buffer-parser","z":"12e297aed19dd6f4","name":"Int16=>16b","data":"CIO_READ","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"16bitbe","name":"CIO10","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"CIO_READ","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":450,"y":60,"wires":[["1b23e6a98e61d44c"]]},{"id":"9e486680d55835a5","type":"homekit-service","z":"12e297aed19dd6f4","isParent":true,"hostType":"0","bridge":"5b5f6f73.10106","accessoryId":"","parentService":"","name":"Contact Sensor","serviceName":"ContactSensor","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.2.0","serialNo":"Default Serial Number","firmwareRev":"1.2.0","hardwareRev":"1.2.0","softwareRev":"1.2.0","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{\"ContactSensorState\":0,\"StatusTampered\":false}","waitForSetupMsg":false,"outputs":2,"x":820,"y":60,"wires":[[],[]]},{"id":"1b23e6a98e61d44c","type":"function","z":"12e297aed19dd6f4","name":"10.00-10.01","func":"var ContactState = msg.CIO_READ.CIO10[0].bits[0]; //10.00\nvar TamperedState = msg.CIO_READ.CIO10[0].bits[1]; //10.01\n\nmsg = {payload:{\n \"StatusTampered\":Math.abs(TamperedState -1),\n \"ContactSensorState\":ContactState\n }\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":630,"y":60,"wires":[["9e486680d55835a5"]]},{"id":"11b8375b.b1ee31","type":"FINS Connection","name":"PLC","host":"192.168.1.2","port":"9600","MODE":"","MODEType":"CS","protocol":"","protocolType":"udp","ICF":"","DNA":"","DA1":"2","DA2":"","SNA":"","SA1":"20","SA2":"","autoConnect":true},{"id":"5b5f6f73.10106","type":"homekit-bridge","bridgeName":"Bridge Node-Red","pinCode":"605-37-162","port":"","allowInsecureRequest":true,"manufacturer":"NRCHKB","model":"1.2.0","serialNo":"Raspberry Pi 3 B+","firmwareRev":"1.2.0","hardwareRev":"1.2.0","softwareRev":"1.2.0","customMdnsConfig":false,"mdnsMulticast":true,"mdnsInterface":"","mdnsPort":"","mdnsIp":"","mdnsTtl":"","mdnsLoopback":true,"mdnsReuseAddr":true,"allowMessagePassthrough":true}] ``` -Here you can read more about [OMRON PLC in Node-RED]({{< ref "/wiki/examples/omron-plc" >}} "OMRON PLC in Node-RED") +{{< alert icon="👉" >}}Find more about [OMRON PLC in Node-RED]({{< ref "/wiki/examples/omron-plc" >}} "OMRON PLC in Node-RED"){{< /alert >}} diff --git a/content/wiki/service/door/door_basic_principle.png b/content/wiki/service/door/door_basic_principle.png new file mode 100644 index 000000000..ed88e4121 Binary files /dev/null and b/content/wiki/service/door/door_basic_principle.png differ diff --git a/content/wiki/service/door/index.md b/content/wiki/service/door/index.md index b310f0ede..32016db5f 100644 --- a/content/wiki/service/door/index.md +++ b/content/wiki/service/door/index.md @@ -3,7 +3,7 @@ title: "Door" description: "Door" lead: "" date: 2021-04-17T18:50:12.029Z -lastmod: 2021-04-17T18:50:12.029Z +lastmod: 2022-02-09T13:56:57.324Z draft: false images: [] menu: @@ -12,4 +12,50 @@ menu: toc: true service: name: "Door" +contributors: ["GogoVega"] --- + +{{< alert icon="💡" text="Hold Position is only available with Siri and Eve.app." />}} + +## Precaution + +Door can be dangerous because it can damage your systeme. +This is why it is advisable to have at least 3 sensors: + +* Door fully Opened +* Door fully Closed +* Obstruction Sensor + +Button inside to open it manually also is optional. + +{{< alert icon="‼️" text="Don't forget to test your system offline before using it in real condition!" />}} + +## Basic principle + +This is the simplest example of a Door item. The input nodes are `Open`, `50%`, `Close`, `Obstruction Detected` and `Obstruction Not Detected`. + +![Basic Principle](door_basic_principle.png) + +Copyable Node-RED flow: + +```json +[{"id":"a89064dcd9fe30fc","type":"inject","z":"d57f90c91936790e","name":"Close","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"TargetPosition\":0}","payloadType":"json","x":510,"y":2320,"wires":[["f63844ce6df26dca"]]},{"id":"f63844ce6df26dca","type":"homekit-service","z":"d57f90c91936790e","isParent":true,"hostType":"0","bridge":"4a2a4fc162440a41","accessoryId":"","parentService":"","name":"Door","serviceName":"Door","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.4.3","serialNo":"Default Serial Number","firmwareRev":"1.4.3","hardwareRev":"1.4.3","softwareRev":"1.4.3","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{\"CurrentPosition\":0,\"ObstructionDetected\":0,\"PositionState\":0,\"TargetPosition\":0}","waitForSetupMsg":false,"outputs":2,"x":690,"y":2380,"wires":[[],[]]},{"id":"d5d18f10f171b60c","type":"inject","z":"d57f90c91936790e","name":"50%","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"TargetPosition\":50}","payloadType":"json","x":510,"y":2380,"wires":[["f63844ce6df26dca"]]},{"id":"b79f52691308bc7e","type":"inject","z":"d57f90c91936790e","name":"Open","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"TargetPosition\":100}","payloadType":"json","x":510,"y":2440,"wires":[["f63844ce6df26dca"]]},{"id":"a4753a173a46f3c2","type":"inject","z":"d57f90c91936790e","name":"Obstruction Not Detected","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"ObstructionDetected\":0}","payloadType":"json","x":270,"y":2340,"wires":[["f63844ce6df26dca"]]},{"id":"1dd47b920c166830","type":"inject","z":"d57f90c91936790e","name":"Obstruction Detected","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"ObstructionDetected\":1}","payloadType":"json","x":280,"y":2420,"wires":[["f63844ce6df26dca"]]},{"id":"4a2a4fc162440a41","type":"homekit-bridge","bridgeName":"Bridge Node-RED","pinCode":"605-37-162","port":"","advertiser":"ciao","allowInsecureRequest":false,"manufacturer":"NRCHKB","model":"1.4.3","serialNo":"Default Serial Number","firmwareRev":"1.4.3","hardwareRev":"1.4.3","softwareRev":"1.4.3","customMdnsConfig":false,"mdnsMulticast":true,"mdnsInterface":"","mdnsPort":"","mdnsIp":"","mdnsTtl":"","mdnsLoopback":true,"mdnsReuseAddr":true,"allowMessagePassthrough":true}] +``` + +### Characteristic Properties + +Use the following JSON in your Characteristic Properties so that the Home.app displays a Door with `ObstructionDetected`. + +```js +{ + "CurrentPosition": 0, + "ObstructionDetected": 0, + "PositionState": 0, + "TargetPosition": 0 +} +``` +