Converting rainfall total from mm to inches

I am trying to use template to convert mm to inches for a Netatmo rain gauge. I have the below code which HA is not accepting as valid code so I won’t reboot. Any ideas what I’m doing wrong?

  - platform: template
    sensors:
      rain_measurement:
        entity_id:
          - sensor_netatmo_my_home_master_bedroom_smart_rain_gauge_rain_today:
        unit_of_measurement: in

Well, you actually have to give it a template.

All you did was give it a malformed entity_id.

have you looked at the template sensor docs yet?

You were on the right track. This should do it. Read the doc @finity linked to configure any other options you might want for this sensor.

 - platform: template
   sensors:
     rain_measurement:
       value_template: "{{ states('sensor.netatmo_my_home_master_bedroom_smart_rain_gauge_rain_today')|float/25.4 }}"
       unit_of_measurement: in

Thank you jazzyisj and finity for helping me. This worked perfect and added round function to truncate the decimal places. Final code for anyone that needs this in future.

  - platform: template
    sensors:
      rain_measurement:
        value_template: "{{ (states('sensor.netatmo_my_home_master_bedroom_smart_rain_gauge_rain_today') | float/25.4) | round(2) }}"
        unit_of_measurement: in
2 Likes

Some newbie help please!

  1. I cut and paste (*and change my device name) as gillman99 states to my configuration.yaml file. Right? I keep getting indention errors no matter how I try it.

  2. Do I paste the code to the developer/template tab? Then what do I do with it? Copy the result string, to where?

Either way, tired of Netatmo rainfall reading in mm.

Thanks for your help!

1 Like

Converting measurements can sometimes feel like a puzzle, right?Your code seems like it’s on the right track, but maybe there’s a tiny detail tripping it up. Don’t worry, we’ve all been there!

If you’re looking for a handy tool to help with conversions, you might want to give ruler.only a shot. Sometimes a fresh perspective can do the trick. Good luck with your code, and here’s to making those conversions seamless!