Now, I tried to create a sensor to retrieve the price of SP95 for station id 10000002.
I use a rest sensor to return this information but i could not set the correct value-template phrase.
Yes I have it but the integration update is done once per day and often price are not updated (the price change every day but not with this integration)
The update sequence in the script states hourly (3600s) … I must admit that I am not driving to/by gas stations to see if it changed and when I just checked this and darn…it does look quite different on prices. So my guess is that the basis of this implementation is incorrect (below). The one thing I noticed though is that the liste-instantanée does not show the station name…which I like. I will have a look at the source myself and see if this is easier to fix than rewriting the whole rest
Yes, we should have the correct price.
Here, an example
Station ID: '94170002'
Gasoil: '1.989'
Last Update Gasoil: '2022-03-15T13:33:00'
E95: None
Last Update E95: ''
E98: '2.034'
Last Update E98: '2022-03-15T13:33:00'
E10: '1.918'
Last Update E10: '2022-03-15T13:33:00'
E85: None
Last Update E85: ''
GPLc: None
Last Update GPLc: ''
Station Address: 264 Avenue du Général de Gaulle 94170 Le Perreux-sur-Marne
Station name: ESSO LE PERREUX
Last update: '2022-03-17'
unit_of_measurement: €
icon: mdi:currency-eur
friendly_name: PrixCarburant_94170002
The sensor is updated march 17th but for the price we have March 15th.
I just checked the source mentioned above and this is the culprit as it is pointing to the JOUR and not INSTANTANE. I am now trying to find out how to change this as it seems not that simple as just change the link…keep you posted
Update, got it fixed by incorporating the py extracting the data and modifying that to get the ‘instantane’
link changed
filename changed
value calc changed
Ideally this should be fixed in the source but since that extract is rather different, it would have to be added to that py script as a secondary option to not disturb other users/usage… So I forked it to my own github repo…let me know if you are willing to use it and in case of issues
It works but does not update on the scan_interval (3600s)…the source prixCarburant.py assumes a daily update and I missed that yesterday… I will continue to work on it
So… it took a while and the main reason is that each sensor can kick off the load of data. In the previous setup this means that it would download data from gouv.fr. per (!) sensor, download, unzip, treat, remove…I have 20 sensors…so thsi x20…a bit much.
I have now changed the lot
prixCarburantClient: along gouv.fr, details instantanés are refreshed every 10 mins: built-in check to verify filestamp and not download if <10mins
prixCarburantClient: with above the file(s) cannot be deleted anylonger, I moved folder/file into custom_components
sensor: update no longer checks on date as the data can be updated intra-day and intra-sensor e.g. Gasoil price could change in the morning and E86 i3 hours later…too many checks to perform.
With this, I see updates entering during the day now instead of only after full refresh / daily
Thanks… it was really a bit of an odd piece.
Off the shelf it did not work as the client only runs daily. As soon as this was removed, each individual sensor kicked off the same process. I thought about it for a few hours and came up with this one, certainly not ideal but I did not want to re-invent the wheel for the client. My personal preference would be to rewrite it to mqtt but I found that too much hassle for this…effort vs. value
What I personally like is that I now have all elements in one folder, so anyone can tweak/alter it easily to their own liking without having to search for the client in the background
No probs… I learnt on the fly (sort of my new ‘hobby’)… if issues, please leave them in the github ‘issues’ area (in French is also OK). Next steps for me is to include the distance (albeit simple) in the sensor which may help to determine if a detour actually makes sense. …will be vagueish as the current distance calc is just a translation of as-the-crow-flies…nothing fancy like google