Stookalert

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

Post Reply
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Stookalert

Post by FireWizard »

Hi all,

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.

Screenshot_stookalert.png
Screenshot_stookalert.png (65.91 KiB) Viewed 2678 times

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.

Screenshot_stookalert2.png
Screenshot_stookalert2.png (13.5 KiB) Viewed 2678 times

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;
For the colors of the "Alert" Sensor I use green in case the weather conditions are good enough to burn wood and orange in case a wood fire is not recommended. However, it is not forbidden.

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":""}]
Best regards
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Stookalert

Post by EddyG »

I am getting: "Invalid payload" And the output of the first function is: 1610992303392
Any idea?
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Stookalert

Post by FireWizard »

Hello @EddyG,

You wrote:
And the output of the first function is: 1610992303392
That is not a problem. What you see is the Unix timestamp.
This time stamp is not used.

The first Function node uses this timestamp to extract the date. This date is used in the URL.

Code: Select all

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";
return msg;
Check the contents of the first Function node with the above string.

If you connect a Debug node after the first "Function" node and look to the complete message object, you should see:

Screenshot_stookalert3.png
Screenshot_stookalert3.png (17.64 KiB) Viewed 2666 times

Screenshot_stookalert4.png
Screenshot_stookalert4.png (11.67 KiB) Viewed 2666 times

You wrote:
I am getting: "Invalid payload"
Where did you get that? After which node?

Regards
Last edited by FireWizard on Friday 20 August 2021 9:03, edited 1 time in total.
Roedii66
Posts: 6
Joined: Saturday 31 March 2018 10:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Stookalert

Post by Roedii66 »

Hi all,

Since December 2018 I had used the script mentioned on the wiki page: https://www.domoticz.com/wiki/StookAlert
The used url in that script isn't from RIVM but from Stichting Nederlandse Haarden- en Kachelbranche (NHK) actually it's predecessor https://sfeerverwarmingsgilde.nl.
Unfortunately around Februari/March 2021 they changed the site or existence and it doesn't work anymore. You can now find their Stookalert information at url https://stookalert.nl

I don't have the knowledge to adapt the script on the wiki page to the new stookalert site.

The difference between the RIVM site (https://www.rivm.nl/stookalert) and the NHK-stookalert site (https://stookalert.nl) are
the weather params. Described at https://stichting-nhk.nl/stookalert/

I will give the RIVM way described in this thread a try. Thx.

With regards.
BlueMotion
Posts: 10
Joined: Thursday 04 June 2020 15:10
Target OS: NAS (Synology & others)
Domoticz version: 2020.2
Location: Subtropical Scandinavia (Fryslan)
Contact:

Re: Stookalert

Post by BlueMotion »

My Stookalert isn't working anymore. Was working for a long time.

The thing I had to change was the https-node in stead of a http-node. (due to version 2.* of Node-Red)
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Stookalert

Post by FireWizard »

Hello @BlueMotion

You wrote:
The thing I had to change was the https-node in stead of a http-node. (due to version 2.* of Node-Red)
I never used http and has always used https.

So my questions is:

What did/do you use:

1. The Node Red flow, as presented above.
2. Some kind of script

The (current) link is, and so far I have always used:

Code: Select all

https://www.rivm.nl/media/lml/stookalert/stookalert_20210819.json
If you copy and paste this link in your browser, you will get the JSON returned for all provinces and you will find that for all provinces the value "waarde" equals "0" (as a number).

Regards
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Stookalert

Post by waltervl »

I made a dzVents script for the RIVM site. You can copy and paste in with Setup - More Options - Events. Create a new dzvents script with trigger HTTP and paste the contents over the template.
Create a dummy Alert Sensor, it will appear in the utility tab.
Modify the script with your province and the idx of the Alert Sensor.

Code: Select all

-- StookAlert. 
-- The stookalert sensor platform queries the RIVM Stookalert API for unfavorable weather conditions or poor air quality. 
-- With a Stookalert, the RIVM calls on people not to burn wood. 
-- This can prevent health problems in people in the area.

local Provincie = 'Noord-Brabant' --  Set Provincie to correct value: Drenthe, Flevoland, Friesland, Gelderland, Groningen, Limburg, Noord-Brabant, Noord-Holland, Overijssel, Utrecht, Zeeland or Zuid-Holland
local Alertidx = 359 -- Change to your idx for the Virtual Alert sensor you have created for this script

-- no changes needed below this section

return {
	on = {
		timer = {
			'at 12:15' -- RIVM updates the json at 12:00 hrs, running it between 0:00 and 12:00 results in an error.
		},
		httpResponses = {
			'triggerSA' -- must match with the callback passed to the openURL command
		}
	},
	logging = {
		level = domoticz.LOG_INFO,
		marker = 'StookAlert',
	},
	execute = function(domoticz, item)

		if (item.isTimer) then
		    local Currentdate = domoticz.time.dateToDate(tostring(domoticz.time.rawDate),'yyyy-mm-dd', 'yyyymmdd')
		    domoticz.openURL({
				url = 'https://www.rivm.nl/media/lml/stookalert/stookalert_' .. Currentdate .. '.json',
				method = 'GET',
				callback = 'triggerSA', -- see httpResponses above.
			})
		end

		if (item.isHTTPResponse) then

			if (item.ok) then
				if (item.isJSON) then

					local result_table = item.json
					local tc = #result_table
					
					for i = 1, tc do
					    if result_table[i].naam == Provincie then
                            StookAlertValue = result_table[i].waarde
                        end
                    end
					domoticz.log('StookAlertValue = ' .. StookAlertValue, domoticz.LOG_INFO)
					
					if StookAlertValue == 0 then
					    level = domoticz.ALERTLEVEL_GREEN 	-- domoticz.ALERTLEVEL_GREY, ALERTLEVEL_GREEN, ALERTLEVEL_YELLOW, ALERTLEVEL_ORANGE, ALERTLEVEL_RED
					    AlertText = 'Geen Stookalert'	
					else
					    level = domoticz.ALERTLEVEL_RED 	
					    AlertText = 'Stookalert!'
                    end
					-- update some device in Domoticz
					domoticz.devices(Alertidx).updateAlertSensor(level, AlertText)
				end
			else
				domoticz.log('There was a problem handling the request' .. url, domoticz.LOG_ERROR)
				-- domoticz.log(item, domoticz.LOG_ERROR)
			end

		end

	end
}
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
janpep
Posts: 212
Joined: Thursday 14 March 2024 10:11
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Stookalert

Post by janpep »

I took this good idea from the wiki and then made a few minor adjustments for myself. e.g. Yellow if no response and mail notification as the level increases. See result below.
RIVM-Stookalert-JanPep.png
RIVM-Stookalert-JanPep.png (15.74 KiB) Viewed 1199 times

Code: Select all

-- The stookalert script queries the RIVM Stookalert API for unfavorable weather conditions or poor air quality. 
-- With a Stookalert, the RIVM calls on people not to burn wood.
-- This can prevent inconvenience for people in the area.
------------
-- Original StookAlert script taken from https://www.domoticz.com/wiki/StookAlert. 
-- 04-11-2022 modified by Jan Peppink, https://ict.peppink.nl
-- 1. Modification for URL and trigger timer based on contact with RIVM. See URL and timer comments.
-- 2. Added Send email notification. Only at the first occurance or increased alertLevel for an alert
-- 3. Added alertText 'Geen json response!' or 'Fout in verbinding!' when json file could not be retreived.
-- 6. Changed alert collors.  Green = No alert, Yellow = Connection/file problem, Red = RIVM Stookalert.
--		Setting alertLevel by constant:  domoticz.ALERTLEVEL_GREY, ALERTLEVEL_GREEN, ALERTLEVEL_YELLOW, ALERTLEVEL_ORANGE, ALERTLEVEL_RED
--		Getting alertLevel by number:    0=gray, 1=green, 2=yellow, 3=orange, 4=red
					    
return {
	on = {
		timer = {
			-- RIVM says they update the json data at 12:00 PM.
			-- Data on website RIVM is also refreshed at 3:00 AM.
			'at 8:14',      -- at time of waking up, get the nightly update.
			'at 12:14',     -- RIVM updated at 12:00 PM.
		},
		httpResponses = {
			'triggerSA'     -- must match with the callback passed to the openURL command
		},
	},
	logging = {
		level = domoticz.LOG_INFO,
		marker = 'Stook-Alert',
	},
	execute = function(domoticz, triggeredItem)
		-- Set Local environment =================
		local mailto = '[email protected]'     -- Set E-mail adres to sent to.
		local Provincie = 'Zuid-Holland'    -- Set Provincie to correct value: Drenthe, Flevoland, Friesland, Gelderland, Groningen, Limburg,
                                            -- Noord-Brabant, Noord-Holland, Overijssel, Utrecht, Zeeland or Zuid-Holland.
		local alertIdx = 611                -- Set to the idx of the Virtual Alert sensor you have to create for this script
		local alertLevel = domoticz.ALERTLEVEL_GREY -- Holds the alertLevel (color) to set
		local currentDate = domoticz.time.dateToDate(tostring(domoticz.time.rawDate),'yyyy-mm-dd', 'yyyymmdd')  -- used in URL to get the last json file for today.

		-- Now start to do something ============
		if (triggeredItem.isTimer) then
			domoticz.openURL({
				-- Original URL = 'https://www.rivm.nl/media/lml/stookalert/stookalert_' .. currentDate .. '.json', was not working for a while.
				-- New URL given by RIVM after contact dd 03-11-2022 is without a date:
				-- URL = 'https://www.lml.rivm.nl/stookalert/stookalert.json', but this appears to be an old file.
				url = 'https://www.rivm.nl/media/lml/stookalert/stookalert_' .. currentDate .. '.json',
				method = 'GET',
				callback = 'triggerSA', -- see httpResponses above.
			})
		end

		if (triggeredItem.isHTTPResponse) then
			if (triggeredItem.ok) then
				if (triggeredItem.isJSON) then
					-- We have some result. Store in table.
					local result_table = triggeredItem.json
					local tc = #result_table
					for i = 1, tc do
						if result_table[i].naam == Provincie then
							StookAlertValue = result_table[i].waarde
						end
					end

					-- Evaluate the results	============				
					if StookAlertValue == 0 then
						-- No RIVM alert.
						alertText = 'Geen RIVM stookalert ' .. Provincie .. '.'
						-- Set alertLevel Green.
						alertLevel = domoticz.ALERTLEVEL_GREEN
						-- Update with new alertLevel and alertText.
						domoticz.devices(alertIdx).updateAlertSensor(alertLevel, alertText)
					else
						-- RIVM alert!
						alertText = 'RIVM stookalert ' .. Provincie .. '!'
						-- Set alertLevel Red,
						alertLevel = domoticz.ALERTLEVEL_RED
						-- Only send notification when RIVM alert increases the last stored alertLevel to red (=4).
						if domoticz.devices(alertIdx).color < 4 then
							-- alertLevel increased, so send notification.
							domoticz.email( alertText, '', mailto )
						end
						-- Update with new alertLevel and alertText.
						domoticz.devices(alertIdx).updateAlertSensor(alertLevel, alertText)
					end
				else
					-- triggeredItem HTTPResponse is not JSON
					alertText = 'Stookalert: Geen json response!'
					-- Set alertLevel Yellow.
					alertLevel = domoticz.ALERTLEVEL_YELLOW
					-- Only send notification when level increases.
					if domoticz.devices(alertIdx).color < 2 then
						-- No RIVM alert, technical problem so send notification
						domoticz.email( alertText, '', mailto )
					end
					-- Update with new alertLevel and alertText.
					domoticz.devices(alertIdx).updateAlertSensor(alertLevel, alertText)
				end 
			else
				-- triggeredItem HTTPResponse is not OK
				alertText = 'Stookalert: Fout met verbinding!'
				-- Set alertLevel Yellow.
				alertLevel = domoticz.ALERTLEVEL_YELLOW
				-- Only send notification when level increases.
				if domoticz.devices(alertIdx).color < 2 then
					-- No RIVM alert, technical problem so send notification
					domoticz.email( alertText, '', mailto )
				end
				-- Update with new alertLevel and alertText.
				domoticz.devices(alertIdx).updateAlertSensor(alertLevel, alertText)
			end
		end
	end
}
However, the RIVM report concerns the entire province, where there may be large local differences.
So, in addition to this, I have therefore created my own 'Lokale Stookwijzer'.
Based on 'Air Quality Index' (Luchtkwaliteitsindex - LKI) for the entered postal code and the local wind speed (from Buienradar) with a calculation according to the Dutch Informatiepunt leefomgeving.
It also provides a forecast for the average expected air quality index.
LocaleStookwijzer-JanPep.png
LocaleStookwijzer-JanPep.png (18.79 KiB) Viewed 1199 times
LuchtkwaliteitsIndex-JanPep.png
LuchtkwaliteitsIndex-JanPep.png (18.23 KiB) Viewed 1199 times
If there is interest, I am willing to share it in a separate post.
Domoticz in Ubuntu virtual machine on Synology DS718+ behind FRITZ!Box.
Using: EvoHome; MELCloud; P1 meter; Z-Stick GEN5; Z-Wave-js-ui; MQTT; Greenwave powernodes 1+6; Fibaro switch, plugs, smoke; FRITZ!DECT 200. Scripts listed in profile interests.
User avatar
gizmocuz
Posts: 2350
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Stookalert

Post by gizmocuz »

Thanks for the script Jan! Working great!
I am interested in your other script as well. It has indeed more information and specific for the address!
I looked at the json result and in my opinion the 'lookup' request results returns a bit to much information for a public site ;)
Maybe you could post it here as it is still about the Stoke-Alert? Other topic is great too!
Quality outlives Quantity!
janpep
Posts: 212
Joined: Thursday 14 March 2024 10:11
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Stookalert

Post by janpep »

I will put it in a another topic and leave this topic for the RIVM alert.
Although the goal is the same, the approach is completely different and also a bit more complex.
I think it would be confusing to mix both approaches in one topic.
I make use of two scripts (1. LKI (gets t-LKI triggerd by time hourly) and 2. d-StookwijzerLokaal (triggerd by changed LKI device)).
These scripts share data via 'global_data' and combine this with values from the Buienradar wind direction and wind speed.
So it takes some preparation and I still have to check whether all comments in the scripts are also clear to others before I publish it.
I will put a link here when it is done.
Domoticz in Ubuntu virtual machine on Synology DS718+ behind FRITZ!Box.
Using: EvoHome; MELCloud; P1 meter; Z-Stick GEN5; Z-Wave-js-ui; MQTT; Greenwave powernodes 1+6; Fibaro switch, plugs, smoke; FRITZ!DECT 200. Scripts listed in profile interests.
Fredom
Posts: 140
Joined: Saturday 19 September 2020 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Krimpen aan den IJssel
Contact:

Re: Stookalert

Post by Fredom »

Hi Jan,

I'm also interested in the script
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Buster - Domoticz 2022.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
Fredom
Posts: 140
Joined: Saturday 19 September 2020 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Krimpen aan den IJssel
Contact:

Re: Stookalert

Post by Fredom »

janpep wrote: Friday 22 March 2024 13:16 I will put it in a another topic and leave this topic for the RIVM alert.
Although the goal is the same, the approach is completely different and also a bit more complex.
I think it would be confusing to mix both approaches in one topic.
I make use of two scripts (1. LKI (gets t-LKI triggerd by time hourly) and 2. d-StookwijzerLokaal (triggerd by changed LKI device)).
These scripts share data via 'global_data' and combine this with values from the Buienradar wind direction and wind speed.
So it takes some preparation and I still have to check whether all comments in the scripts are also clear to others before I publish it.
I will put a link here when it is done.
Hi Jan,
Is it possible to send a message to Telegram?
If so, how do I adjust that?
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Buster - Domoticz 2022.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
janpep
Posts: 212
Joined: Thursday 14 March 2024 10:11
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Stookalert

Post by janpep »

Fredom wrote: Friday 22 March 2024 13:59 Is it possible to send a message to Telegram?
If so, how do I adjust that?

I personally prefer email notifications and do not use Telegram, so I do not really know.
I think there will be some information and examples on the forum on how to send such a message.
I saw something like:

Code: Select all

domoticz.notify('subject', 'message' , domoticz.PRIORITY_NORMAL,nil,nil,domoticz.NSS_TELEGRAM)
which you probably can use in stead of

Code: Select all

domoticz.email( 'subject', 'message', 'mailtoaddress' )
Domoticz in Ubuntu virtual machine on Synology DS718+ behind FRITZ!Box.
Using: EvoHome; MELCloud; P1 meter; Z-Stick GEN5; Z-Wave-js-ui; MQTT; Greenwave powernodes 1+6; Fibaro switch, plugs, smoke; FRITZ!DECT 200. Scripts listed in profile interests.
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Stookalert

Post by waltervl »

Alerts you can also set on the device itself (Notification button) so no need to do notifications through DzVents. Let DzVents do the data gathering and default notification through the device. Makes life easier....
See https://www.domoticz.com/wiki/Telegram_notification
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
janpep
Posts: 212
Joined: Thursday 14 March 2024 10:11
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Stookalert

Post by janpep »

waltervl wrote: Friday 22 March 2024 14:39 Alerts you can also set on the device itself (Notification button) so no need to do notifications through DzVents.
In general that is correct, but it will be very complicated to set the conditions for whether or not to send a notification in a dummy alert device. So THAT doesn't apply here.
Domoticz in Ubuntu virtual machine on Synology DS718+ behind FRITZ!Box.
Using: EvoHome; MELCloud; P1 meter; Z-Stick GEN5; Z-Wave-js-ui; MQTT; Greenwave powernodes 1+6; Fibaro switch, plugs, smoke; FRITZ!DECT 200. Scripts listed in profile interests.
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Stookalert

Post by waltervl »

Indeed, if you want to set more logic to control sending Alerts than the standard notification function is giving you are correct.
For a StookAlert I only want to know if I am not able to Stook today. That is perfectly doable with the standard notification function on the dummy alert device.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
ajongen70
Posts: 10
Joined: Sunday 25 February 2024 0:28
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.3
Location: Netherlands
Contact:

Re: Stookalert

Post by ajongen70 »

janpep wrote: Friday 22 March 2024 13:16 I will put it in a another topic and leave this topic for the RIVM alert.
Although the goal is the same, the approach is completely different and also a bit more complex.
I think it would be confusing to mix both approaches in one topic.
I make use of two scripts (1. LKI (gets t-LKI triggerd by time hourly) and 2. d-StookwijzerLokaal (triggerd by changed LKI device)).
These scripts share data via 'global_data' and combine this with values from the Buienradar wind direction and wind speed.
So it takes some preparation and I still have to check whether all comments in the scripts are also clear to others before I publish it.
I will put a link here when it is done.
Also very much interested in such a script!

A few months ago I contacted https://www.atlasleefomgeving.nl/ to ask if there was a possibility to use a json-call simular to the one used in Stookalert that would return the local information based on location/zipcode. That was not available yet apparently.
Fredom
Posts: 140
Joined: Saturday 19 September 2020 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Krimpen aan den IJssel
Contact:

Re: Stookalert

Post by Fredom »

janpep wrote: Friday 22 March 2024 14:33
Fredom wrote: Friday 22 March 2024 13:59 Is it possible to send a message to Telegram?
If so, how do I adjust that?

I personally prefer email notifications and do not use Telegram, so I do not really know.
I think there will be some information and examples on the forum on how to send such a message.
I saw something like:

Code: Select all

domoticz.notify('subject', 'message' , domoticz.PRIORITY_NORMAL,nil,nil,domoticz.NSS_TELEGRAM)
which you probably can use in stead of

Code: Select all

domoticz.email( 'subject', 'message', 'mailtoaddress' )
Hi Jan,

Thanks
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Buster - Domoticz 2022.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
janpep
Posts: 212
Joined: Thursday 14 March 2024 10:11
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Stookalert

Post by janpep »

I shared the entire project setup in Dutch local 'Stookwijzer'
Domoticz in Ubuntu virtual machine on Synology DS718+ behind FRITZ!Box.
Using: EvoHome; MELCloud; P1 meter; Z-Stick GEN5; Z-Wave-js-ui; MQTT; Greenwave powernodes 1+6; Fibaro switch, plugs, smoke; FRITZ!DECT 200. Scripts listed in profile interests.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests