Floor map - iconRotation from item state does not work

Hi,

I’m using the latest openhab version and I want to visualize an arrow inside a floor map. This arrow (f7:arrow_up) icon should be rotated and show the actual sun direction. (azimut).
The value is from the astro binding. Background: I want to visualize the direction of the sun in a floor map that shows my solar panels at the roof top and the panels values.

This is the item:

Using the value inside the floor map shows for state and displaystate the following output:

image

Using this value inside a marker does not work.

I think the problem is that the item state includes the degree Symbol? Or is it because it has decimal values? Is there a way to format the value as integer to use it insider the floor map?

Approach 1:

component: oh-plan-marker
config:
  name: New Marker
  coords: 477.1872878470009,43.08643103532097
  item: Astro_Sonnendaten_Azimut
  iconRotation: =item.state
  icon: f7:arrow_up
slots:
  default: []

does not work

approach 2

component: oh-plan-marker
config:
  name: New Marker
  coords: 477.1872878470009,43.08643103532097
  item: Astro_Sonnendaten_Azimut
  iconRotation: =items.Astro_Sonnendaten_Azimut.state
  icon: f7:arrow_up
slots:
  default: []

also does not work.

As Stefan showed me at github (I first thougt using rotation angle from item state is not supported yet and opened the issue floor map - Item rotation - retrieve angle from item state / value · Issue #16610 · openhab/openhab-addons · GitHub ) it should work basically - anyone maybe has a hint for me?

Thanks in advance!

Can you try a simple number item first and set it to a value without a unit. The fact it doesn’t work might be related to the unit in the value.

Removing the unit “angle” from the item definition works fine:

image

The question is now: how do I have to configure the item to have it shown as Degree in other places (widgets etc.)?

I also tried
iconRotation: =items.Astro_Sonnendaten_Azimut.state.intValue
as it can be used inside rules, but also this does not seem to work.

Update - ChatGPT helped me :wink:

The unit is still removed. I additionally added metadata (state description, pattern %.1f °) and now it works fine in the floot plan and is still displayed as ° when displayState is used.

But I think this is strange, because openhab cannot use the unit any more. And saying “this is an angle” was the idea of the unit I think. And this now get’s lost…

=Number.parseFloat(items.Astro_Sonnendaten_Azimut.state)

does work with 4.1.1.

Since 4.2 we even provide

=items.Astro_Sonnendaten_Azimut.numericState

(I haven’t updated to 4.2 my prod system which is why it didn’t work when I tried it out earlier).

(Thanks to @florian-h05 to enlighten me and @JimT for providing the PR https://github.com/openhab/openhab-core/pull/4123!)

2 Likes

Number.parseFloat works fine. OH is still 4.1. The numericState-Solution seems to be simple and fine!
Thanks a lot for your help!