Temperature units in virtual devices

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
jensmoes
Posts: 57
Joined: 10 Jan 2015 21:48
Location: San Diego
Contact:

Temperature units in virtual devices

Post 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?
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: Temperature units in virtual devices

Post by pofs »

You'd better create an option in module settings, like OpenWeather module does.
jensmoes
Posts: 57
Joined: 10 Jan 2015 21:48
Location: San Diego
Contact:

Re: Temperature units in virtual devices

Post 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.
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: Temperature units in virtual devices

Post 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;
jensmoes
Posts: 57
Joined: 10 Jan 2015 21:48
Location: San Diego
Contact:

Re: Temperature units in virtual devices

Post by jensmoes »

Thanks pofs. That will solve my problem.
Are there any plans to implement full locale support in the automation layer?
Post Reply