This application is only suitable for Dutch users
This application uses a Node Red solution, which polls an undocumented API of https://www.rivm.nl/stookalert from RIVM and sends its value with MQTT to a virtual Domoticz sensor.
Especially in the winter period it is quite popular to burn wood in your fireplace, pellet stove or use a fire pit.
Sometimes the weather conditions are very bad, like wind still weather or fog, and that will hinder your neighbours, because the smoke lingers.
RIVM maintains a website, where you can see in which province a smoke alert is given. (https://www.rivm.nl/stookalert)
Normally the smoke alert is given at around 12:00 h at noon and is valid for the afternoon and the evening of the day.
This flow checks an undocumented api (at least I could not find it at the RIVM site) hourly and sends a text to a virtual alert sensor.
Usage:
Insert in the Inject node, called "Select Provincie" your preferred province as a string to msg.topic.
In the function node, you have to insert your Domoticz IDX number of the created virtual "Alert" Sensor at line 4.
At line 6 and 7, you can change the texts, you want to see in the virtual "Alert" sensor.
Code: Select all
// Stookalert (only available in The Netherlands)
// Insert Domoticz IDX number of virtual "Alert" sensor below.
var idx = 483;
var stookalert = "De weersomstandigheden zijn de komende uren ongunstig, zodat het afgeraden wordt om hout te stoken.";
var no_stookalert = "Er kan hout gestookt worden.";
switch (msg.topic) {
case "Groningen":
if (msg.payload[0].waarde === 0) {
msg.payload = {"command":"udevice","idx":idx,"nvalue":1,"svalue":no_stookalert};
} else {
msg.payload = {"command":"udevice","idx":idx,"nvalue":3,"svalue":stookalert};
}
break;
case "Friesland":
if (msg.payload[1].waarde === 0) {
msg.payload = {"command":"udevice","idx":idx,"nvalue":1,"svalue":no_stookalert};
} else {
msg.payload = {"command":"udevice","idx":idx,"nvalue":3,"svalue":stookalert};
}
break;
case "Drenthe":
if (msg.payload[2].waarde === 0) {
msg.payload = {"command":"udevice","idx":idx,"nvalue":1,"svalue":no_stookalert};
} else {
msg.payload = {"command":"udevice","idx":idx,"nvalue":3,"svalue":stookalert};
}
break;
case "Overijssel":
if (msg.payload[3].waarde === 0) {
msg.payload = {"command":"udevice","idx":idx,"nvalue":1,"svalue":no_stookalert};
} else {
msg.payload = {"command":"udevice","idx":idx,"nvalue":3,"svalue":stookalert};
}
break;
case "Gelderland":
if (msg.payload[4].waarde === 0) {
msg.payload = {"command":"udevice","idx":idx,"nvalue":1,"svalue":no_stookalert};
} else {
msg.payload = {"command":"udevice","idx":idx,"nvalue":3,"svalue":stookalert};
}
break;
case "Utrecht":
if (msg.payload[5].waarde === 0) {
msg.payload = {"command":"udevice","idx":idx,"nvalue":1,"svalue":no_stookalert};
} else {
msg.payload = {"command":"udevice","idx":idx,"nvalue":3,"svalue":stookalert};
}
break;
case "Noord-Holland":
if (msg.payload[6].waarde === 0) {
msg.payload = {"command":"udevice","idx":idx,"nvalue":1,"svalue":no_stookalert};
} else {
msg.payload = {"command":"udevice","idx":idx,"nvalue":3,"svalue":stookalert};
}
break;
case "Zuid-Holland":
if (msg.payload[7].waarde === 0) {
msg.payload = {"command":"udevice","idx":idx,"nvalue":1,"svalue":no_stookalert};
} else {
msg.payload = {"command":"udevice","idx":idx,"nvalue":3,"svalue":stookalert};
}
break;
case "Zeeland":
if (msg.payload[8].waarde === 0) {
msg.payload = {"command":"udevice","idx":idx,"nvalue":1,"svalue":no_stookalert};
} else {
msg.payload = {"command":"udevice","idx":idx,"nvalue":3,"svalue":stookalert};
}
break;
case "Noord-Brabant":
if (msg.payload[9].waarde === 0) {
msg.payload = {"command":"udevice","idx":idx,"nvalue":1,"svalue":no_stookalert};
} else {
msg.payload = {"command":"udevice","idx":idx,"nvalue":3,"svalue":stookalert};
}
break;
case "Limburg":
if (msg.payload[10].waarde === 0) {
msg.payload = {"command":"udevice","idx":idx,"nvalue":1,"svalue":no_stookalert};
} else {
msg.payload = {"command":"udevice","idx":idx,"nvalue":3,"svalue":stookalert};
}
break;
case "Flevoland":
if (msg.payload[11].waarde === 0) {
msg.payload = {"command":"udevice","idx":idx,"nvalue":1,"svalue":no_stookalert};
} else {
msg.payload = {"command":"udevice","idx":idx,"nvalue":3,"svalue":stookalert};
}
break;
}
return msg;
Please find the flow below:
Code: Select all
[{"id":"9733298a.68c738","type":"tab","label":"Stookalert","disabled":false,"info":""},{"id":"f4c7f323.283a6","type":"function","z":"9733298a.68c738","name":"","func":"// Stookalert (only available in The Netherlands)\n\n// Insert Domoticz IDX number of virtual \"Alert\" sensor below.\nvar idx = 483;\n\nvar stookalert = \"De weersomstandigheden zijn de komende uren ongunstig, zodat het afgeraden wordt om hout te stoken.\";\nvar no_stookalert = \"Er kan hout gestookt worden.\";\n\n switch (msg.topic) {\n\n case \"Groningen\":\n if (msg.payload[0].waarde === 0) {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":1,\"svalue\":no_stookalert};\n } else {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":3,\"svalue\":stookalert};\n }\n break;\n\n case \"Friesland\":\n if (msg.payload[1].waarde === 0) {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":1,\"svalue\":no_stookalert};\n } else {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":3,\"svalue\":stookalert};\n }\n break;\n\n case \"Drenthe\":\n if (msg.payload[2].waarde === 0) {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":1,\"svalue\":no_stookalert};\n } else {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":3,\"svalue\":stookalert};\n }\n break;\n\n case \"Overijssel\":\n if (msg.payload[3].waarde === 0) {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":1,\"svalue\":no_stookalert};\n } else {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":3,\"svalue\":stookalert};\n }\n break;\n \n case \"Gelderland\":\n if (msg.payload[4].waarde === 0) {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":1,\"svalue\":no_stookalert};\n } else {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":3,\"svalue\":stookalert};\n }\n break;\n\n case \"Utrecht\":\n if (msg.payload[5].waarde === 0) {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":1,\"svalue\":no_stookalert};\n } else {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":3,\"svalue\":stookalert};\n }\n break;\n\n case \"Noord-Holland\":\n if (msg.payload[6].waarde === 0) {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":1,\"svalue\":no_stookalert};\n } else {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":3,\"svalue\":stookalert};\n }\n break;\n\n case \"Zuid-Holland\":\n if (msg.payload[7].waarde === 0) {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":1,\"svalue\":no_stookalert};\n } else {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":3,\"svalue\":stookalert};\n }\n break;\n\n case \"Zeeland\":\n if (msg.payload[8].waarde === 0) {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":1,\"svalue\":no_stookalert};\n } else {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":3,\"svalue\":stookalert};\n }\n break;\n\n case \"Noord-Brabant\":\n if (msg.payload[9].waarde === 0) {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":1,\"svalue\":no_stookalert};\n } else {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":3,\"svalue\":stookalert};\n }\n break;\n\n case \"Limburg\":\n if (msg.payload[10].waarde === 0) {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":1,\"svalue\":no_stookalert};\n } else {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":3,\"svalue\":stookalert};\n }\n break;\n\n case \"Flevoland\":\n if (msg.payload[11].waarde === 0) {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":1,\"svalue\":no_stookalert};\n } else {\n msg.payload = {\"command\":\"udevice\",\"idx\":idx,\"nvalue\":3,\"svalue\":stookalert};\n }\n break;\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":840,"y":80,"wires":[["9ada7858.066e08"]]},{"id":"5fd59141.006298","type":"inject","z":"9733298a.68c738","name":"Select Provincie","props":[{"p":"topic","vt":"str"},{"p":"payload"}],"repeat":"3600","crontab":"","once":true,"onceDelay":0.1,"topic":"Gelderland","payload":"","payloadType":"date","x":170,"y":80,"wires":[["13f74ed3.21c921"]]},{"id":"f3a46cd4.084518","type":"http request","z":"9733298a.68c738","name":"Request RIVM Stookalert","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":610,"y":80,"wires":[["f4c7f323.283a6"]]},{"id":"13f74ed3.21c921","type":"function","z":"9733298a.68c738","name":"","func":"msg.url = \"https://www.rivm.nl/media/lml/stookalert/stookalert_\" + ((new Date()).toISOString()).substring(0,4) + ((new Date()).toISOString()).substring(5,7) + ((new Date()).toISOString()).substring(8,10) + \".json\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":380,"y":80,"wires":[["f3a46cd4.084518"]]},{"id":"9ada7858.066e08","type":"mqtt out","z":"9733298a.68c738","name":"Domoticz In","topic":"domoticz/in","qos":"0","retain":"false","broker":"8591549f.77809","x":1030,"y":80,"wires":[]},{"id":"8591549f.77809","type":"mqtt-broker","name":"Jonas_MQTT_Server","broker":"192.168.10.24","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]