HomeGenie Forum
Automation Program Plugins and Wizard Scripting => Help => Topic started by: nolio on April 20, 2014, 02:47:55 PM
-
Hi,
I try a simple automation wizard script :
If the temperature is more than 19
Then close shutter
But after some test (value at 19.1) :
1/ Greater than 19 => No close shutter
2/ Equal 19.1 => Shutter close
So my question, is the comparison : "greater than" and "less than" doesn't manage decimal value ?
Bye
-
After a look in the source code, i think i can confirm :) "ComparisonOperator.cs" :
.......
public enum ComparisonOperator
{
LessThan = -1,
Equals = 0,
GreaterThan = 1
}
....
-
It manages decimal value:
https://github.com/genielabs/HomeGenie/blob/master/HomeGenie/Automation/ProgramEngine.cs#L677
Cheers,
g.
-
I think there might be a bug with parsing "," and "." as decimal separator with different locales.
What locale is set in the hg hosting server?
g.
-
I don't understand why but :
- greater than "18.0" => doesn't work
- greater than "18.1" => work
My "locale" :
LANG=en_GB.UTF-8
-
Look how the sensor value is store by searching for it in the modules list:
http://192.168.0.2/api/HomeAutomation.HomeGenie/Config/Modules.List (http://192.168.0.2/api/HomeAutomation.HomeGenie/Config/Modules.List)
Does it have a comma separator or a dot one?
Btw... one question... why would you close the shutter on a temperature basis? =D
g.
-
I have dot separator.
I prepare for hot summer, with some parameters (interior+exterior temperature, interior luminance, and alarm on), it will close the shutter to prevent south windows to have so much sun. So it won't be 19 or 18 for interior temperature but probably 25 ;).
-
Cool idea =)
In the meantime I changed some lines of code that should fix the issue.
https://github.com/genielabs/HomeGenie/blob/master/HomeGenie/Automation/ProgramEngine.cs#L677
else if (double.TryParse(parameter.Value, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out dval))
{
lvalue = dval;
rvalue = double.Parse(comparisonValue, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture);
}
perhaps with LANG=en_GB.UTF-8 locale, by default double.Parse is looking for comma separator.
Specifying InvariantCulture may fix the bug.
I also remove the surrounding try...catch so that any parsing error will be reported to the UI.
Do you have any chance to recompile and test by yourself? After compiling you've to copy just the HomeGenie.exe file.
g.
-
Hi nolio can you test the fix I posted here:
http://www.homegenie.it/forum/index.php?topic=156.msg843#msg843 (http://www.homegenie.it/forum/index.php?topic=156.msg843#msg843)
it also fixes the Wizard Script values comparison bug.
g.
-
Thank you for compilation.
I try again, but it doesn't work.
I got the following message :
Errors:
[{"Line":0,"Column":0,"ErrorMessage":"String was not recognized as a valid DateTime.","ErrorNumber":"-1","CodeBlock":"TC"}]
Program disabled, fix errors first.
Bye
-
My gosh! :) this has never worked since any number was interpreted as a DateTime =/
I switched the two if blocks so that it first tries to parse the value as a number and then, if it fails, it tries to parse the value as a date.
Let me know if this work now. I did a quick test and it worked.
g.
-
Yes, it work fine.
But when i save the script (several times), i have still a pop "Errors" but with nothing else in the popup ... Juste the "close" button :)
-
I think that updating to r366 from the Configure->Maintenance section should fix this too (refresh the browser by pressing F5 after the update).
Cheers,
g.
-
Hi,
Woo. I updated from webUI, but now when i
- save = error with nothing
- run = Errors:
[{"Line":0,"Column":0,"ErrorMessage":"String was not recognized as a valid DateTime.","ErrorNumber":"-1","CodeBlock":"TC"}]
Program disabled, fix errors first.
So i don't really understand :/
Bye
-
If you updated from HG < r364 probably the HomeGenie.exe got overwritten.
So copy the fixed HomeGenie.exe again.
Let me know if it fixes the problem.
g.
-
I try to replace the HomeGenie.exe again and replace the html dir by the one here :
http://www.homegenie.it/forum/index.php?topic=129.75 (http://www.homegenie.it/forum/index.php?topic=129.75)
But it still does the same problem with "save" and "run".
-
woo, this pop-up message doesn't appear again, after a copy of the "html" dir of the zip file to update from r364->r366 (because i erase then whitout backup (not good;))).
So it's probably a trouble
- between html_fix and update or
- i perhaps do a mistake with my manipulation.
So, no trouble with my running version ...