To many numbers after comma with hafloorplan

Hello together,

since an update of hafloorplan I have too many numbers after the comma. It seems like numeric issue. It looks for example as follows:

How can I limit the number of decimals to 1 or 2 in the floorplan configuration? When I click on one of the green values I see 66.4°C. So I assume the sensor in HA is correctly configured:

grafik

Accuracy is set to Standard:
grafik

The relevant part of the configuration looks as follows:

          rules:
            - name: Analogvalues
              entities:
                - entity: sensor.heizung_hk1_vorlauftemperatur_sollwert
                  element: THK1_soll
                - entity: sensor.heizung_hk1_vorlauftemperatur_istwert
                  element: THK1-v3.1
              state_action:
                service: floorplan.text_set
                service_data: ${entity.state} ${entity.attributes.unit_of_measurement}

Accuracy is only used by HA auto-generated frontend values I believe. You can use the filter round() on the state template, Jinja Docs - round().

# DON'T DO THIS!
service_data: ${entity.state|round(2)} ${entity.attributes.unit_of_measurement}

Edit: It took my brain a moment to realise that this isn’t a jinja template, sorry about that.

Let me try this again…
I believe this should work

          rules:
            - name: Analogvalues
              entities:
                - entity: sensor.heizung_hk1_vorlauftemperatur_sollwert
                  element: THK1_soll
                - entity: sensor.heizung_hk1_vorlauftemperatur_istwert
                  element: THK1-v3.1
              state_action:
                service: floorplan.text_set
                service_data: |
                  >
                  const entityState = entity.state;
                  const roundedState = entityState.toFixed(2);
                  return `${roundedState} ${entity.attributes.unit_of_measurement}`;

Disclaimer: See my sig :point_down:

Thanks a lot for your support and sorry for the delay. You brought me on the right track. Your proposel did not work 1:1 but as follows:

          rules:
            - name: Analogvalues
              entities:
                - entity: sensor.heizung_hk1_vorlauftemperatur_sollwert
                  element: THK1_soll
                - entity: sensor.heizung_hk1_vorlauftemperatur_istwert
                  element: THK1-v3.1
              state_action:
                service: floorplan.text_set
                service_data: >
                  >
                  const entityState = +entity.state;
                  const roundedState = entityState.toFixed(2);
                  return `${roundedState} ${entity.attributes.unit_of_measurement}`;

So only a > after service_data instead of | I had to add and a + was missing in front of entitiy.state in the third last line.

1 Like