Rova API changed

Moderator: leecollings

Post Reply
akamming
Posts: 344
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Rova API changed

Post 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
}

Last edited by akamming on Saturday 19 June 2021 11:28, edited 1 time in total.
annegerben
Posts: 26
Joined: Wednesday 03 August 2016 12:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Rova API changed

Post 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)
akamming
Posts: 344
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Rova API changed

Post 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..
Ctenberge
Posts: 39
Joined: Friday 03 January 2020 15:41
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Zwolle, the Netherlands
Contact:

Re: Rova API changed

Post 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.
Attachments
garbage.zip
(9.56 KiB) Downloaded 72 times
Raspberry Pi 3B, Raspberry Pi 4, RFXCOM - RFXtrx433, Z-wave, ESP8266
User avatar
jvdz
Posts: 2208
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Rova API changed

Post 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.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
jvdz
Posts: 2208
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Rova API changed

Post 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'
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
abc1000
Posts: 15
Joined: Friday 14 October 2016 20:42
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Rova API changed

Post by abc1000 »

This solution helped me too 8-)
Ctenberge
Posts: 39
Joined: Friday 03 January 2020 15:41
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Zwolle, the Netherlands
Contact:

Re: Rova API changed

Post 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.
Attachments
garbage_new.zip
(7.66 KiB) Downloaded 73 times
Raspberry Pi 3B, Raspberry Pi 4, RFXCOM - RFXtrx433, Z-wave, ESP8266
User avatar
jvdz
Posts: 2208
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Rova API changed

Post 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 ;)
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Ctenberge
Posts: 39
Joined: Friday 03 January 2020 15:41
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Zwolle, the Netherlands
Contact:

Re: Rova API changed

Post 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.
Attachments
garbage_3.zip
(7.19 KiB) Downloaded 75 times
Raspberry Pi 3B, Raspberry Pi 4, RFXCOM - RFXtrx433, Z-wave, ESP8266
User avatar
jvdz
Posts: 2208
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Rova API changed

Post 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.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Ctenberge
Posts: 39
Joined: Friday 03 January 2020 15:41
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Zwolle, the Netherlands
Contact:

Re: Rova API changed

Post by Ctenberge »

Oké, I will send all the files offline and in dos-format to
Raspberry Pi 3B, Raspberry Pi 4, RFXCOM - RFXtrx433, Z-wave, ESP8266
Ctenberge
Posts: 39
Joined: Friday 03 January 2020 15:41
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Zwolle, the Netherlands
Contact:

Re: Rova API changed

Post 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
Attachments
garbage_logging.zip
(12.38 KiB) Downloaded 61 times
Raspberry Pi 3B, Raspberry Pi 4, RFXCOM - RFXtrx433, Z-wave, ESP8266
User avatar
jvdz
Posts: 2208
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Rova API changed

Post 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.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
akamming
Posts: 344
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Rova API changed

Post 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
}
eightyeight
Posts: 2
Joined: Saturday 25 February 2023 17:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Rova API changed

Post by eightyeight »

thanks for the updates, works like a charm again! :D
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests