As I dont feel like good time to play with experimental jsr or jython yet, I would like to ask some brains to help me convert existing python code which I use somewhere else, to the DSL format for OH
much appreciated
round(pressure/pow(1.0 - 0.0065 * alt / (temperature + 273.15),5.255),1)
pressure and temperature will be taken from Item.state and alt is constant but I’m especially interested if DSL can have pow and how’s correct syntax
(if anyone wondering, this is formula to re-calculate absolute pressure to the sealevel pressure)
Thank you
till it requires ssh console to get it work, yes it is
(and on docker image where is not openhab-console it’s not doable anyways)
well this bit i know indeed …
not sure about pow, it’s not working like this
val pressure = (MyPressure.state as Number).doubleValue
val temperature = (MyPressure.state as Number).doubleValue
val alt = 305
Math.round(pressure/Math.pow(1.0 - 0.0065 * alt / (temperature + 273.15),5.255),1)
Then it’s been experimental for about 8 years, which is when JSR223 was first introduced and it may forever remain so long after Rules DSL is deprecated. Though if you have openHABian it’s completely possible to configure it for use through the samba share.
The result of your calculation needs to be converted to a primitive too. All results of calculations are stored in BigDecimal Objects in Rules DSL.