question

laurenceh avatar image
laurenceh asked

Persistent storage of setting for Temperature scale and offset.

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


BMV Battery MonitorVenus OStemperaturedriver
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

1 Answer
wkirby avatar image
wkirby answered ·

Did you try to create a bash script and call it /data/rc.local ?
/data is preserved and rc.local will be called at startup.

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

laurenceh avatar image laurenceh commented ·

What would go in the script to make sure the new temperature scale and offset configuration settings are saved ?
I am familiar with /data/rc.local and have already written a number of scripts which are called from there.

0 Likes 0 ·

Related Resources

Victron BMV battery monitors product page

Victron Venus OS Open Source intro page

Venus OS GitHub (please do not post to this)

Additional resources still need to be added for this topic