Page 1 of 1

Rova API changed

Posted: Wednesday 09 June 2021 10:08
by akamming
So i fixed my Rova Garbage Calender dzVents script to make it work again:

Code: Select all

-- This script updates the "Afvalkalender" and gives notifications when action is needed

PostalCode='<your postal code>'               
HouseNumber='<your housenumer>'
Addition='<your addition to housenumber, can be empty>'
AfvalDevice="<name of the textdevice which should containt the garbage calendar"

return {
	on = {
		timer = {
		    'at 20:00',
		    'at 19:00',
		    'at 18:00',           -- Update frequency of the  virtual device, set to whatever you like, make sure there is at least one at 20.00 (to get the notification)
	    },
    		httpResponses = {
			'Rova' -- must match with the callback passed to the openURL command
		},
		devices = {
			'test'  -- can be removed, a device name if you want to trigger the script
		}

    },
    logging = {
	        level = domoticz.LOG_DEBUG,  -- adjust to your needs
	        marker = "Rova"
    },
	execute = function(domoticz, item)
	    if (item.isDevice or item.isTimer) then
	        domoticz.openURL({
				url = 'https://www.rova.nl/api/waste-calendar/upcoming?postalcode='..PostalCode..'&houseNumber='..HouseNumber..'&addition='..Addition..'&take=3',
				method = 'GET',
				callback = 'Rova', -- see httpResponses above.
			})
        end
        if (item.isHTTPResponse) or (item.isShellCommandResponse) then
            if (item.ok) then
                domoticz.log("Data received: "..item.data,domoticz.LOG_DEBUG)
    
                -- convert dates
        	    local RovaDate=string.sub(item.json[1].date,1,-10)
        	    local RovaDate2=string.sub(item.json[2].date,1,-10)
        	    local RovaDate3=string.sub(item.json[3].date,1,-10)
    
                -- log result
        	    domoticz.log("Next Garbage Collection: ["..item.json[1].garbageType..' at '..RovaDate..']',domoticz.LOG_FORCE)
        	    
        	    -- update device
        	    domoticz.devices(AfvalDevice).updateText(item.json[1].garbageType.." "..RovaDate..", "..item.json[2].garbageType.." "..RovaDate2..", "..item.json[3].garbageType.." "..RovaDate3)
        	    
        	    -- check if we have to send notification
    	        domoticz.log("minutes="..domoticz.time.minutes..", hours="..domoticz.time.hour,domoticz.LOG_DEBUG)
        	    if (domoticz.time.minutes<5 and domoticz.time.hour==20) then
        	        domoticz.log("20.00: notification timestamp event, checking if we have to notify",domoticz.LOG_DEBUG)

            	    local Time = require('Time')
                    local t = Time(RovaDate..' 00:00:00')
                    domoticz.log("Secondsago = "..t.secondsAgo..", minutesAgo="..t.minutesAgo..", hoursago="..t.hoursAgo..", daysago="..t.daysAgo,domoticz.LOG_DEBUG)
                    
                    -- check if we have to notify
                    if (t.daysAgo==0 and t.secondsAgo<0) then -- timestamp is within 1 day
                        -- Yes we do: notify
                        domoticz.log("Rova will be there within 1 day, sending notification [".."Afvaltype "..item.json[1].garbageType.." wordt opgehaald op "..RovaDate .."]", domoticz.LOG_FORCE) 
                        domoticz.notify("Rova","Afvaltype "..item.json[1].garbageType.." wordt opgehaald op "..RovaDate,domoticz.PRIORITY_NORMAL)
                    else
                        -- no we don't 
                        domoticz.log("no need to notify",domoticz.LOG_DEBUG)
                    end
    	        end
    	    else
                domoticz.log("Script error: "..item.statusCode,domoticz.LOG_ERROR)
                domoticz.log(item,domoticz.LOG_ERROR)
    	    end
        end
    
    end
}


Re: Rova API changed

Posted: Thursday 17 June 2021 11:37
by annegerben
thanks for the script!
the notification was not working for me because ..item.json[1].GarbageType.. was with a capital instead of ..item.json[1].garbageType.. in the below line:
domoticz.notify("Rova","Afvaltype "..item.json[1].garbageType.." wordt opgehaald op "..RovaDate,domoticz.PRIORITY_NORMAL)

Re: Rova API changed

Posted: Saturday 19 June 2021 11:29
by akamming
annegerben wrote: Thursday 17 June 2021 11:37 thanks for the script!
the notification was not working for me because ..item.json[1].GarbageType.. was with a capital instead of ..item.json[1].garbageType.. in the below line:
domoticz.notify("Rova","Afvaltype "..item.json[1].garbageType.." wordt opgehaald op "..RovaDate,domoticz.PRIORITY_NORMAL)
ah you're right. I did debug this on my own system, but forgot to fix the bug in the uploaded script. It is corrected now in the code above..

Re: Rova API changed

Posted: Monday 01 January 2024 17:18
by Ctenberge
I installed the garbagecalendar on my raspberry pi and followed the instructions supplied.
It does not work.
JvanderZande offered suggestions for testing and debugging, which I all followed, including changing TLS-version.
No result.
The only solution left was sending the logfiles and the lua file to jvanderzandes email address at Github. No idea and no way to find his email-address in Github, and neither supplied in the test and debugging area, so I try this way, the Domoticz forum
Here are the requested files.
My apologies to Jvanderzande, I really tried to get it in Github but I failed.

Re: Rova API changed

Posted: Monday 01 January 2024 17:53
by jvdz
No worries ;) thought it should show in GitHub when you are loggedin.
it is jvdzande ADD Yahoo DOT com.
I will have a look to see what changed for rova.

Re: Rova API changed

Posted: Monday 01 January 2024 19:15
by jvdz
It indeed doesn't work anymore with the API version I've made.
Looking at the website it seems to be the exact same as mijnafvalwijzer, so I modified that module a bit to accommodate rova, now available in the branch "development". https://raw.githubusercontent.com/jvand ... wijzer.lua
Copy this version to the m_mijnafvalwijzer.lua in your setup and change your config to:

Code: Select all

wmodule= 'm_mijnafvalwijzer'
Hostname='afvalkalender.rova.nl'
Zipcode='1234AA'
Housenr='11'
That should give something like this:

Code: Select all

Schedule: woe 3 jan: pmd ; woe 10 jan: gft ; woe 17 jan: papier ; woe 24 jan: gft ; woe 31 jan: pmd ;
Let me know if this works for you so I can update the master when all is ok.

EDIT: Also added rova support to the m_mijnafvalwijzer_api: https://raw.githubusercontent.com/jvand ... er_API.lua

Code: Select all

wmodule='m_mijnafvalwijzer_api'
Hostname='api.inzamelkalender.rova.nl'
Zipcode='1234AA'
Housenr='11'

Re: Rova API changed

Posted: Tuesday 02 January 2024 11:17
by abc1000
This solution helped me too 8-)

Re: Rova API changed

Posted: Tuesday 02 January 2024 14:01
by Ctenberge
I have followed your instructions but no succes.
The Domoticz logfile and the 2 files that where changed are here:
So tou can check if I did it right.

Re: Rova API changed

Posted: Tuesday 02 January 2024 14:37
by jvdz
You mixed the setting for API and Normal for the Hostname!
You need to use:

Code: Select all

wmodule='m_mijnafvalwijzer_api'
Hostname='api.inzamelkalender.rova.nl'
I assume you did fill in your correct postalcode and housnr? as both the log and config show my example ;)

Re: Rova API changed

Posted: Tuesday 02 January 2024 14:41
by Ctenberge
Looking at your instructions again, I realized I took the wrong m_file to use. Instead of m_mijnafvalwijzer.lua I selected m_mijnafvalwijzer_API.lua. (In
But even after correcting this it's not working right. The Domoticz log changed in an interesting way, it shows (among others) Error: 1234AA not specified. So I changed the garbagecalendarconfig.lua to my real zip-code and that does not work either.
Again I do the files involved hereby.

Re: Rova API changed

Posted: Tuesday 02 January 2024 14:48
by jvdz
Did you also check the this log as indicated in the runlog as that is not there?

Code: Select all

2024-01-02 14:15:00.510 Status: LUA: 14:15:00 gc_main: 369: -< Module m_mijnafvalwijzer stopped! 
Look at /home/pi/domoticz/scripts/lua/garbagecalendar/data/garbagecalendar_m_mijnafvalwijzer_run.log for more information.
I really need all generated logfiles preferably in original TXT format (not rtf) . ;)
You can also email then offline if you want.

Re: Rova API changed

Posted: Tuesday 02 January 2024 15:01
by Ctenberge
Oké, I will send all the files offline and in dos-format to

Re: Rova API changed

Posted: Tuesday 02 January 2024 15:22
by Ctenberge
I used your @yahoo.com address but it bounced. "mailbox not found"
Here is a new zip with all the files that where changed today, including the last domoticz log

Re: Rova API changed

Posted: Tuesday 02 January 2024 15:49
by jvdz
Ctenberge wrote: Tuesday 02 January 2024 15:22 I used your @yahoo.com address but it bounced. "mailbox not found"
Here is a new zip with all the files that where changed today, including the last domoticz log
Solution send in my reply to the Email i did receive later. :)

The master in Github is updated with these changes.

Re: Rova API changed

Posted: Saturday 09 March 2024 8:12
by akamming
API changed again. For whoever uses my script, here's the corrected script:

Code: Select all

-- This script updates the "Afvalkalender" and gives notifications when action is needed

PostalCode='1234AB' -- change to your own postal code                
HouseNumber='123' -- change to your own house number
Addition='' -- if your housenumber has an addition
AfvalDevice="Rova Afvalkalender" -- the name of a textdevice containing the calendar. had to be created manually
ForceNotification=false -- for debugging purposes

return {
	on = {
		timer = {
		    'at 20:00',
		    'at 19:00',
		    'at 18:00',           -- Update frequency of the  virtual device, set to whatever you like, make sure there is at least one at 20.00 (to get the notification)
	    },
    		httpResponses = {
			'Rova' -- must match with the callback passed to the openURL command
		},
		devices = {
			'test'  -- can be removed, a device name if you want to trigger the script
		}

    },
    logging = {
	        level = domoticz.LOG_DEBUG,  -- adjust to your needs
	        marker = "Rova"
    },
	execute = function(domoticz, item)
	    if (item.isDevice or item.isTimer) then
	        domoticz.openURL({
				-- url = 'https://www.rova.nl/api/waste-calendar/upcoming?postalcode=8017BA&houseNumber=11&addition=&take=3',
				url = 'https://www.rova.nl/api/waste-calendar/upcoming?postalcode='..PostalCode..'&houseNumber='..HouseNumber..'&addition='..Addition..'&take=3',
				method = 'GET',
				callback = 'Rova', -- see httpResponses above.
			})
        end
        if (item.isHTTPResponse) or (item.isShellCommandResponse) then
            if (item.ok) then
                domoticz.log("Data received: "..item.data,domoticz.LOG_DEBUG)
    
                -- convert dates
        	    local RovaDate=string.sub(item.json[1].date,1,-11)
        	    local RovaDate2=string.sub(item.json[2].date,1,-11)
        	    local RovaDate3=string.sub(item.json[3].date,1,-11)
    
                -- log result
        	    domoticz.log("Next Garbage Collection: ["..item.json[1].wasteType.code..' at '..RovaDate..']',domoticz.LOG_FORCE)
        	    
        	    -- update device
        	    domoticz.devices(AfvalDevice).updateText(RovaDate..": "..item.json[1].wasteType.title.."\n"..RovaDate2..": "..item.json[2].wasteType.title.."\n"..RovaDate3..": "..item.json[3].wasteType.title)
        	    
        	    -- check if we have to send notification
    	        domoticz.log("minutes="..domoticz.time.minutes..", hours="..domoticz.time.hour,domoticz.LOG_DEBUG)
        	    if ((domoticz.time.minutes<5 and domoticz.time.hour==20) or ForceNotification) then
        	        domoticz.log("20.00: notification timestamp event, checking if we have to notify",domoticz.LOG_DEBUG)

            	    local Time = require('Time')
                    local t = Time(RovaDate..' 00:00:00')
                    domoticz.log("Secondsago = "..t.secondsAgo..", minutesAgo="..t.minutesAgo..", hoursago="..t.hoursAgo..", daysago="..t.daysAgo,domoticz.LOG_DEBUG)
                    
                    -- check if we have to notify
                    if ((t.daysAgo==0 and t.secondsAgo<0) or ForceNotification) then -- timestamp is within 1 day
                        -- Yes we do: notify
                        domoticz.log("Rova will be there within 1 day, sending notification ["..item.json[1].wasteType.notificationText.."]", domoticz.LOG_FORCE) 
                        domoticz.notify(item.json[1].wasteType.notificationTitle,item.json[1].wasteType.notificationText,domoticz.PRIORITY_NORMAL)
                    else
                        -- no we don't 
                        domoticz.log("no need to notify",domoticz.LOG_DEBUG)
                    end
    	        end
    	    else
                domoticz.log("Script error: "..item.statusCode,domoticz.LOG_ERROR)
                domoticz.log(item,domoticz.LOG_ERROR)
    	    end
        end
    
    end
}

Re: Rova API changed

Posted: Sunday 17 March 2024 20:04
by eightyeight
thanks for the updates, works like a charm again! :D