empierre / MyDomoAtHome

MyDomoAtHome - REST interface for ImperoHome with Domoticz (ISS)
http://domoticz.com/wiki/ImperiHome
GNU General Public License v3.0
32 stars 22 forks source link

Negative values appearing as positive #173

Closed mjf2708 closed 4 years ago

mjf2708 commented 5 years ago

I'm using MDAH version 0.2.39 with Domoticz 4.9700 on a RPi 2B with Stretch Lite.

I have a custom sensor in Domoticz, which shows sun altitude. After sunset, this has negative values, but these are showing as positive in MDAH (and Imperihome). E.g., In Domoticz: Sun altitude -54.5° In MDAH: {"id":"338","name":"Sun altitude","type":"DevGenericSensor","room":"Utility","params":[{"key":"Value","value":"54.5","unit":"°","graphable":"true"}]}

mjf2708 commented 5 years ago

I think the issue occurs here: `

function DevGenericSensorT(data) {

   var ptrn = /([0-9]+(?:\.[0-9]+)?) ?(.+)/;
   var res = data.Data.match(ptrn).slice(1);
   var value = res[0];
   var suffix = res[1];

` which appears to be dropping the minus ('-') sign on a negative value. However, I don't understand regex-type patterns to be able to confirm / change this.

empierre commented 4 years ago

fixed in the git, will be soon reposted as .deb and .spk