Hi all,
what would be the best way to do some calculations out of from measured values?
In my case I’d like to calculate the dew point from the measured temperature, humidity (DHT22) and the air pressure (openweather). The result shall be visible inside the gui. I thought of a shell script kind of, but I’m not sure how to integrate the whole thing inside the gui.
Any ideas, or comments?
-
doing calculations in pimatic and showing the result on the gui
-
@flybysun I made a VariablesDevices to display the total use of my smart energy meter.
basically it is “variable1+variable2” or “variable1-variable2”
It looks like this :
{ "id": "energiemeter_totaal", "class": "VariablesDevice", "name": "Totaal verbruik", "variables": [ { "name": "value", "type": "number", "expression": "$energiemeter.hoogtarief+$energiemeter.laagtarief", "unit": "Wh" } ] },
-
Okay, this is even more easy. So, no need of installing an additional plugin? I’ll give it a try and post the result here. Thank you!
-
no you don’t need any additional plugin.
-
I need to use a JavaScript pow() Method. Is this possible in the config.json?
When I try (for example) :{
“id”: “energiemeter_totaal”,
“class”: “VariablesDevice”,
“name”: “Totaal verbruik”,
“variables”: [
{
“name”: “value”,
“type”: “number”,
“expression”: “Math.pow(2, 5)”,
“unit”: “Wh”
}
]
},I get an error message. How can I use the pow function, is it possible to use math object methods at all?
-
you cant use pow. But what is the problem with writing out the pow?
Math.pow(2, 5) = 2x2x2x2x2pimatic rocks!!!
-
Okay, so I guess this would be more a problem to solve inside an own plugin I guess.
The formular above was just an example. Actually I wanted to solve this:
SDD(T) = 6.1078 * 10^((7.5*T)/(237.3+T)) where T is the sensor temperature. -
i make some energy % save calculation regarding the month before, but the value has to many decimals. i will send me the value with pushover, but it looks not as good as it should looks like.
is there any trick to show just 2 decimals?
thanks in advancethis is my value:
23.44475927911369
-
@p4co86
you can try to useround
within the rule somehow.
have no time to test that for myself at the moment, so give it a try and please report back if you solved your issue. thankspimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
ok thanks for that, that works, but now there is now decimal. maybe we can add some one like round (variable, 2), wich means 2 decimals.
thanks for the hint. -
@p4co86 Should work already: https://github.com/pimatic/pimatic/blob/master/lib/variables.coffee#L188-L199