User defined symbol (dynamic symbols) do not work in HABpanel

Hello community!

First of all: I have been using OpenHABian for almost exactly half a year now and I’m completely enthusiastic about the possibilities and have already successfully put several dozen things together. I use the PaperUI exclusively to manage and configure my things, rules are written with VSC and possibly a few items are also defined in VSC, if the rules require it. HABPanel is the only frontend I use for visualization and control of my smarthome.

My current “problem” (ok, it’s just a minor issue, but… :smiley:):
I have an item from my Netatmo weather station that provides the air pressure. This is a float or maybe even a double item with 380 decimal places (felt :smiley:). In a rule with number I cast that to int var, because I would like to have / need only an integer for displaying the item value in HABPanel.

It looks something like this:
var tWZ_Pressure = (netatmo_NAMain_e3a674ca_70ee5017dcbc_Pressure.state as QuantityType<Number>).intValue

The int var tWZ_Pressure is then written to an item WZ_Pressure (postUpdate) and WZ_Pressure is then displayed in the HABPanel using a dummy widget (such as humidity, volume, etc. also already are). So far everything is good and works!
I also use the integrated symbols, which adapt the display themselve accordingly based on the value of the item. Sometimes I also use self-created SVGs, which also work.

BUT: In contrast to (e.g.) air humidity, this does not work with the air pressure item. Here I have used the standard “pressure” icon as a user-defined icon, and have created the following SVG files:

  • pressure.svg
  • pressure-0.svg
  • pressure-100.svg
  • pressure-950.svg
  • pressure-966.svg
  • pressure-983.svg
  • pressure-1000.svg
  • pressure-1016.svg
  • pressure-1033.svg
  • pressure-1050.svg

The idea was now that the symbols being displayed are selected according to the value of the item (usually between 0 and 100, on or off, or 0 and 4) to implement the same here for the air pressure based on the corresponding value (WZ_Pressure is in the range between 950 and 1050). I.e. with a WZ_Pressure value of 1023 the symbol “pressure-1016” should be displayed - but it isn’t! HABPanel only uses the standard “pressure.svg” symbol regardless of the value (which is always correctly displayed as a number in the dummy widget).

So does the correct representation of the value-dependent symbol only work for values ​​between 0 and 100? With the QualityOfService Icon it works with 0,1,2,3,4 - with the volume it works with 0,33,66,100 - with the light also from 0 - 100 in steps of 10, etc.

Does anybody knows if/why the auto-selecting of self-created symbols according to the value of an item works with values above 100? Or do these auto-selected symbols only work with values up to 100?

Maybe someone has tried that and has a solution for it or can kick me in the right direction… :slight_smile:

Thank you!

That’s right.

As you already have a dummy “scaled” Item, you might be interested in this workaround to use it with 0-100icons

See also

Thank you Ross!

In the meanwhile I found exactly this solution with the rpm of that pump and “transformed” it to my usecase. Successful! At least finally, because I had to face some problems with the interpretation of the JS transforming when dealing with my dummy item (string vs. numbers).

I will post the complete solution of my case here, but I’m extremely busy actually and need some more time. Hopefully, somebody will find it useful for his/her usecase. :wink:

I suppose for a 950-1050 range, your “scale”/reconstruct transforms could subtract/re-add 950.

Yes exactly, but need to typecast the downscaled “number type item” which is pushed as a string (%s) to the JS inside the JS first to a real number before applying the math operator “+” correctly. Otherwise if one operates with the “+” operator on a string, the JS simply appends the numbers together (68+950 = 68950) what is not what I needed here (should be 1018) :smiley:

Well, yes; values are always passed in and out of transforms as strings. Sometimes you need to consider unit symbols too.

1 Like

OK, so here we go:


Number  T_WZ_Pressure     "Air pressure Living Room transformed [JS(pressure.js):%s]"


rule "Downscale air pressure value for displaying a dynamic symbol in HABpanel (with JS upscaling)"
    // when pressure update received
    Item netatmo_NAMain_e3a674ca_70ee5017dcbc_Pressure received update
    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)


// 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;

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 !

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
1 Like