OK, so here we go:
ITEM:
Number T_WZ_Pressure "Air pressure Living Room transformed [JS(pressure.js):%s]"
RULE:
rule "Downscale air pressure value for displaying a dynamic symbol in HABpanel (with JS upscaling)"
when
// when pressure update received
Item netatmo_NAMain_e3a674ca_70ee5017dcbc_Pressure received update
then
logInfo("Sensor.rules", "Pressure is: " + netatmo_NAMain_e3a674ca_70ee5017dcbc_Pressure.state.toString)
// typeCast the pressure to an int value (no float and no UoM) and downscale 950...1050 to 0...100 (for dynamic symbol update)
var tWZ_Pressure = ((netatmo_NAMain_e3a674ca_70ee5017dcbc_Pressure.state as QuantityType<Number>).intValue - 950)
logInfo("Sensor.rules", "Downscaled Pressure is: " + tWZ_Pressure.toString)
// update T_WZ_Pressure to show in HabPanel
postUpdate(T_WZ_Pressure, tWZ_Pressure)
end
PRESSURE.JS
// Transformation of already downscaled pressure value (no UoM) up to the original pressure value
(function(i) {
// convert the delivered string i to Intvalue and add 950
var value = ( parseInt(i) + 950 );
return value;
})(input)
With this, I get a correct dynamic symbol associated with a number value of 950 up to 1050 in a HABpanel dummy widget! GREAT!!!
Thank you soo much @rossko57 !
P.S.:
My pressure icons now are named like
- pressure-0.svg
- pressure-8.svg
- pressure-16.svg
- pressure-24.svg
- pressure-33.svg
- …
- pressure-66.svg
- pressure-74.svg
- pressure-83.svg
- pressure-92.svg
- pressure-100.svg