I’ve written a custom sensor which can check Dutch license plate id’s in the database of the RDW (the governmental department for road traffic). It will create sensors for the APK due date, the insured flag and a flag which signals if the manufacturer of the car has issues a recall because of a serious safety problem.
Hi, nice component! Thanks for your good work. I had to make a few changes since the RDW date syntax for my car was changed some time ago.
line 37 I to change to: RDW_DATEFORMAT = '%Y%m%d'
And for my own convenience I changed line 204 to : self.expdate = datetime.strptime(rdw_data['vervaldatum_apk'], RDW_DATEFORMAT).date().strftime('%d-%m-%Y')
Now the date is presented in a more natural way for me. Perhaps the last addition could be parameterised, but I lack the time and experience with custom components to figure that out myself
Thank you for your feedback, and for notifying me that the RDW changed the date format in their API
I’ve updated the RDW sensor to 1.0.3 which includes your fix. I’ve also added the dateformat configuration value so that you can pick your own date format without editing the python file, e.g.:
@Sjeff: thanks for the tip, but I’m working on an update so that the RDW sensor will be an official part of the Home Assistant repository It could take a couple of weeks, but after that you won’t need the custom updater for the RDW sensor anymore.
Yes I’ve definitely made some progress. I’ve updated most of the code for the newest home assistant functions like:
configuration by GUI entity register
async calls
the API is now called using the sodapy library, which is the recommended by RDW themselves
moved from @Throttle to async_track_time_interval()
more efficient managing of update() calls so sensors get updated according to SCAN_INTERVAL instead of the default of every 10 seconds or so
Only thing not working right now is the old configuration.yaml style setup. I’m working on that and hope to fix that in a couple of days (don’t hold me to it; I’m doing this in my spare time as well )
AFAIK the RDW hasn’t changed their website in any way. They do sometimes take the API website offline for maintenance, I’ve had 503 errors reported to me from time to time.
I’ve just updated the master branch on GitHub to v2.9.0. Please note that this is a breaking change to your configuration.yaml settings!
Changes in v2.9.0:
Rewritten all functions to async variants
Added configuration by GUI entity register (config_flow)
The API is now called using the sodapy library, which is the recommended by RDW themselves
Moved from @Throttle to async_track_time_interval()
More efficient managing of update() calls so sensors get updated according to SCAN_INTERVAL instead of the default of every 10 seconds or so
From now on you can set up your RDW component from the GUI using the Add Entity option
If you prefer setting it up with configuration.yaml, you’ll have to change your existing setup:
Simple setup:
I upgraded to the new RDW application. I installed v2.9.0. I used HA Integrations to define 2 license plates. Both were created successfully.
However, after rebooting HA, I get errors for one license plate:
Logboekdetails ( ERROR )
Logger: homeassistant.components.binary_sensor
Integration: Binaire sensor (documentation, issues)
First occured: 23:38:22 (1 occurences)
Last logged: 23:38:22
Error while setting up rdw platform for binary_sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 179, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
return fut.result()
File "/config/custom_components/rdw/binary_sensor.py", line 40, in async_setup_entry
hass.data[DOMAIN][entry.data[CONF_PLATE]],
KeyError: '<license-plate>'
===================================================================
Logboekdetails ( ERROR )
Logger: homeassistant.components.sensor
Integration: Sensor (documentation, issues)
First occured: 23:38:22 (1 occurences)
Last logged: 23:38:22
Error while setting up rdw platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 179, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
return fut.result()
File "/config/custom_components/rdw/sensor.py", line 44, in async_setup_entry
hass.data[DOMAIN][entry.data[CONF_PLATE]],
KeyError: '<license-plate>'
===================================================================
Logboekdetails ( WARNING )
Logger: root
First occured: 23:38:16 (2 occurences)
Last logged: 23:38:16
Requests made without an app_token will be subject to strict throttling limits.
When I delete one license plate ( doesn’t matter which one ) the errors disappear and only the warning is displayed after a reboot of HA. Any idea would might go wrong?
My real license plate was changed in the error logging to: license-plate
Thanks for letting me know about this problem. I’ll try and look into it this weekend. Have you set the cars up by configuration.yaml or by using the GUI integrations?
Thank you for your feedback. There was indeed an error when rebooting after setting up multiple RDW entities.
I’ve pushed v2.9.1 to the GitHub repository which should fix the problem you encountered. Can you try this new version? To update from old versions to the latest version please use this procedure:
Remove all RDW entities from the GUI Integrations menu
Move the./custom_components/rdw/ folder to a safe location
Install the latest version by using git clone https://github.com/eelcohn/home-assistant-rdw/ rdw and move the rdw folder to ./custom_components/rdw
thank you for the quick fix. RDW v2.9.1 solves the problem. I can now define multiple RDW entities. I have one more question. What is the meaning of the warning:
Logboekdetails ( WARNING )
Logger: root
First occured: 15:39:53 (2 occurences)
Last logged: 15:39:54
Requests made without an app_token will be subject to strict throttling limits.
That warning comes from the sodapy Python library. sodapy is the recommended way by RDW and Socrata to interact with OpenData databases. I’ve decided to use the official library, and stop using my own custom code to interact with OpenData.
IMO that warning is a bit useless, but it has to be fixed in the sodapy repository because at this time I haven’t found a way to disable that warning (see issue #68 in the sodapy repository)