Hop til indhold
  • 0

Afrunding af tal


Astronaut
 Share

Spørgsmål

Jeg roder med home assistant. Jeg har nogle temperatursensorer og har fået dem til at afrunde til 1 decimal sådan at tallene ser fornuftige ud. Er der nogen der har fundet en bedre måde? Jeg har gjort sådan her:

configuration.yaml

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

homeassistant:
  customize: !include customize.yaml
  customize_glob: !include customize_glob.yaml

# ... lots of goo

ihc:
  - url: "http://192.168.67.7"
    username: secret
    password: verysecret
    auto_setup: false
    info: true
    sensor:
      - id: 6583828
        name: entre_temperatur_raw
        unit_of_measurement: "°C"
        note: På væggen
        position: Entre
      - id: 6583591
        name: entre_relativfugtighed_raw
        unit_of_measurement: "%RH"
        note: På væggen
        position: Entre
      - id: 5297172
        name: bad_temperatur_raw
        unit_of_measurement: "°C"
        note: På væggen
        position: Badeværelse
      - id: 5296935
        name: bad_relativfugtighed_raw
        unit_of_measurement: "%RH"
        note: På væggen
        position: Badeværelse

sensor:
  - platform: template
    sensors:
      entre_temperatur:
        unit_of_measurement: "°C"
        value_template: "{{ states('sensor.entre_temperatur_raw') | float | round(1) }}"
      bad_temperatur:
        unit_of_measurement: "°C"
        value_template: "{{ states('sensor.bad_temperatur_raw') | float | round(1) }}"
      entre_relativfugtighed:
        unit_of_measurement: "%RH"
        value_template: "{{ states('sensor.entre_relativfugtighed_raw') | float | round(1) }}"
      bad_relativfugtighed:
        unit_of_measurement: "%RH"
        value_template: "{{ states('sensor.bad_relativfugtighed_raw') | float | round(1) }}"

customize_glob.yaml

"sensor.*_temperatur_raw":
  hidden: true
"sensor.*_relativfugtighed_raw":
  hidden: true

 

Link til kommentar
Del på andre sites

1 svar på dette spørgsmål

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gæst
Svar på dette spørgsmål

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loader...
 Share

×
×
  • Tilføj...

Important Information

Privatlivspolitik og We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

1200x630bb.png

ok