How do I make the settings for Temperature scale and Offset permanent for my own temperature dBus services?
I have written a driver for the three spare sensors on an 8 channel DAC connected to my Venus Rpi. (the other 5 channels are driven correctly by the Venus tank and temperature channels)
The service starts OK and implements the Scale and Offest inputs like this:-
self.add_path('/Scale', 1.0, writeable=True) self.add_path('/Offset', 0, writeable=True)
This works fine and the Venus setting UI see the new services and the settings and you can change the scale and offset which my code can then read:
scale = dbusservice['myservicename']['/Scale'] offset = dbusservice['myservicename']['/Offset'] value = offset +round(2.1+(value-2015)*0.135*scale,1)
But when I restart the system the settings are lost
I have tried adding a callback:
self.add_path('/Scale', 1.0, writeable=True, onchangecallback = mycallbackhandler) self.add_path('/Offset', 0, writeable=True), onchangecallback = mycallbackhandler)
But the callback handler is never called (and now the Venus setting UI can not change the values)
What could I be doing wrong?
I was going to store the changed value in my own local file in /data and then re-read the file when the service restarts but Venus must be doing something like that already?
Do I need to do something with the com.victronenergy.settings service to provide some storage in a local file for the settings to make them non volatile ?
If so what do I do ?
Any code snippets, guidance or reference to some example would be most welcome.
Laurence