-
Notifications
You must be signed in to change notification settings - Fork 4
CO2 Notification
cflurin edited this page Sep 13, 2018
·
24 revisions
In this use case the CO2 value (e.g. from a netatmo weather station) is triggered periodically.
{
"currentState": "neutral_range",
"states": {
"low_level": {
"greater_high": "high_level"
},
"high_level": {
"less_low": "low_level"
},
"neutral_range": {
"greater_high": "high_level",
"less_low": "low_level"
}
},
"data": {
"high": 1000,
"low": 800
},
"methods": {
"onBeforeTransition": [
"if(msg.payload.value < sm.data.low) {",
" msg.topic = 'less_low';",
"} else if(msg.payload.value > sm.data.high) {",
" msg.topic = 'greater_high';",
"} else {",
" sm.fill = 'yellow';",
" sm.text = 'neutral_range '+msg.payload.value;",
"}"
],
"greater_high": [
"sm.fill = 'red';",
"sm.text = sm.currentState+' '+msg.payload.value;"
],
"less_low": [
"sm.fill = 'green';",
"sm.text = sm.currentState+' '+msg.payload.value;"
],
"onAfterTransition": [
"msg.topic = 'netatmo';",
"msg.payload = sm.currentState+' co2 = '+msg.payload.value+' ppm';"
],
"status": {
"fill": {
"get": "sm.fill;"
},
"shape": "dot",
"text": {
"get": "sm.text;"
}
}
}
}
[{"id":"85a8e75.de99018","type":"inject","z":"57ef434a.058a6c","name":"900","topic":"","payload":"{\"value\": 900}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":3080,"wires":[["5c0b9679.49d238"]]},{"id":"8bb567e2.eb33d8","type":"inject","z":"57ef434a.058a6c","name":"1050","topic":"","payload":"{\"value\": 1050}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":3000,"wires":[["5c0b9679.49d238"]]},{"id":"fc024b3b.4235c8","type":"debug","z":"57ef434a.058a6c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","x":430,"y":3080,"wires":[]},{"id":"92878a5f.9c2ad8","type":"inject","z":"57ef434a.058a6c","name":"750","topic":"","payload":"{\"value\": 750}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":3120,"wires":[["5c0b9679.49d238"]]},{"id":"69edfb38.7e8754","type":"comment","z":"57ef434a.058a6c","name":"send a notification e.g to pushover","info":"","x":380,"y":3020,"wires":[]},{"id":"5c0b9679.49d238","type":"dsm","z":"57ef434a.058a6c","name":"CO2 level","sm_config":"{\n \"currentState\": \"neutral_range\",\n \"states\": {\n \"low_level\": {\n \"greater_high\": \"high_level\"\n },\n \"high_level\": {\n \"less_low\": \"low_level\"\n },\n \"neutral_range\": {\n \"greater_high\": \"high_level\",\n \"less_low\": \"low_level\"\n }\n },\n \"data\": {\n \"high\": 1000,\n \"low\": 800\n },\n \"methods\": {\n \"onBeforeTransition\": [\n \"if(msg.payload.value < sm.data.low) {\",\n \" msg.topic = 'less_low';\",\n \"} else if(msg.payload.value > sm.data.high) {\",\n \" msg.topic = 'greater_high';\",\n \"} else {\",\n \" sm.fill = 'yellow';\",\n \" sm.text = 'neutral_range '+msg.payload.value;\",\n \"}\"\n ],\n \"greater_high\": [\n \"sm.fill = 'red';\",\n \"sm.text = sm.currentState+' '+msg.payload.value;\"\n ],\n \"less_low\": [\n \"sm.fill = 'green';\",\n \"sm.text = sm.currentState+' '+msg.payload.value;\"\n ],\n \"onAfterTransition\": [\n \"msg.topic = 'netatmo';\",\n \"msg.payload = sm.currentState+' co2 = '+msg.payload.value+' ppm';\"\n ],\n \"status\": {\n \"fill\": {\n \"get\": \"sm.fill;\"\n },\n \"shape\": \"dot\",\n \"text\": {\n \"get\": \"sm.text;\"\n }\n }\n }\n}","x":270,"y":3080,"wires":[["fc024b3b.4235c8"]]},{"id":"e4854e5a.54c0d","type":"inject","z":"57ef434a.058a6c","name":"920","topic":"","payload":"{\"value\": 920}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":3040,"wires":[["5c0b9679.49d238"]]}]