Sensor template with only 2 decimals

Hi
I cant get my template sensor to work, these are the sensors in quistion and i need them rounded to 2 decimal
sensor.varmestyring_1128468
sensor.varmestyring_1128724

Could someone pleas show me how its setup in config file.

i can get it to work in templates in ha but not in then config file.

Best regard
Michael

Put this:
| round(2)
In the template at the end

This is my template and it works HA template tester but not in my config yalm

value_template:"{{ states.sensor.varmestyring_1128724.state | round(1) }}"

I think i might put in the wrong way

Try:

value_template: "{{ states('sensor.varmestyring_1128724') | float | round(1) }}"

Then the quistion is where in the config should it go.

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

# Checks for available updates
# Note: This component will send some information about your system to
# the developers to assist with development of Home Assistant.
# For more information, please see:
# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
updater:
  # Optional, allows Home Assistant developers to focus on popular components.
  # include_used_components: true

# Discover some devices automatically
#discovery:

# Allows you to issue voice commands from the frontend in enabled browsers
conversation:

# Enables support for tracking state changes over time
history:

# View all events in a logbook
logbook:

# Enables a map showing the location of tracked devices
map:

# Track the sun
sun:

hassio:

# Weather prediction

homekit:

# Text to speech
tts:
  - platform: google

# Cloud
cloud:

ihc:
  url: 'http://192.168.1.xx
  username: xxxxx
  password: xxxxx
  info: True
  auto_setup: true
#
ios:

sensor:
  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /home
      - type: memory_free
      - type: load_1m
      - type: load_5m
      - type: processor_use











light:
  - platform: ihc
    lights:
      - id: 21554193
        name: spot kontor
        dimmable: True
      - id: 21730833
        name: spot gang
      - id: 21760017
        name: spot køkken
      - id: 21701649
        name: spot lille bad
      - id: 21672465
        name: spot stort bad
      - id: 21643281
        name: spot Frederik
      - id: 21614097
        name: spot soveværelse
      - id: 21584913
        name: spot Christine


zone:
  - name: School
    latitude: 56.025524
    longitude: 12.191228
    radius: 100
    icon: mdi:school

  - name: mc Work
    latitude: 55.992193
    longitude: 12.499925
    radius: 500
    icon: mdi:Factory

  - name: anja Work
    latitude: 56.022852
    longitude: 12.173066
    radius: 200
    icon: mdi:Factory

  # This will override the default home zone
  - name: Home
    latitude: 56.021374
    longitude: 12.189273
    radius: 75
    icon: mdi:Home Outline


##
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

Hard to say - from inital question I understood that you already have 2 sensors whose rounded values/states you want to wrap in other sensors:
sensor.varmestyring_1128468
sensor.varmestyring_1128724
but I don not see them in your provided config in sensor: section.

Basically all those sensors should be in sensor: section.

To HA it doesn’t matter but to retain your sanity in the future I recommend you have a section dedicated to sensors.

It’s because they are auto detected from IHC

In that case just add in sensors block or extract all sensors to separate file containing following:

sensor:
  - platform: template
    sensors:
      varmestyring_1128468_rounded:
        value_template: "{{ states('sensor.varmestyring_1128468') | float | round(1) }}"
      varmestyring_1128724_rounded:
        value_template: "{{ states('sensor.varmestyring_1128724') | float | round(1) }}"

Consider adding other parameters like friendly name to above sensors as per docs.

SUPER that works beautifully.
Thank you very much.