Page 1 of 1
Temperature units in virtual devices
Posted: 07 Oct 2015 18:05
by jensmoes
I have created some virtual devices which collect temperature (among other things) from an old weather station.
Is there any way I can access the Defaults.xml from my module to determine whether to convert the data to Fahrenheit for display?
Re: Temperature units in virtual devices
Posted: 07 Oct 2015 23:26
by pofs
You'd better create an option in module settings, like OpenWeather module does.
Re: Temperature units in virtual devices
Posted: 08 Oct 2015 00:28
by jensmoes
So it is not possible to create virtual devices that obey the system defaults? It doesn't make much sense to have multiple temperature unit settings for each module.
Re: Temperature units in virtual devices
Posted: 08 Oct 2015 01:36
by pofs
Defaults.xml is intended for z-wave subsystem, which operates at a lower level than JS automation and virtual devices.
But you may still load value from Defaults.xml if you want it that bad. To do so, first make a symlink to config directory inside automation (because fs.load() is restricted to work only under automation folder):
Code: Select all
cd /opt/z-way-server/automation
ln -s ../config
then use the following code to load value:
Code: Select all
var xml = new ZXmlDocument(fs.load('config/Defaults.xml'));
var isFahrenheit = parseInt(xml.findOne('/Defaults/CommandClass/SensorMultilevel/Fahrenheit/text()')) || 0;
Re: Temperature units in virtual devices
Posted: 10 Oct 2015 10:05
by jensmoes
Thanks pofs. That will solve my problem.
Are there any plans to implement full locale support in the automation layer?