How do I get Lovelace to display wind speed in MP/H instead off KM/H

My sensor code in configuration.yaml reads :

sensor:
 
  - platform: rflink
    automatic_add: false
    devices: 
      dkw2012_004f_temp:
        sensor_type: temperature
        unit_of_measurement: "°C"

      dkw2012_004f_wings:
        sensor_type: speed
        unit_of_measurement: "kmh"
      dkw2012_004f_winsp:
        sensor_type: speed
        unit_of_measurement: "kmh"

I’ve read that I need to convert using value_template but I’m not sure where I put that.

You can create another sensor which uses a template for it’s value, basically something like this:

sensor:
  - platform: template
    sensors:
      wind_in_mph:
        friendly_name: "Wind in mph"
        value_template: {{states('dkw2012_004f_winsp') | float / 1.6}}

Assuming 1.6 is the right factor… (i’m not sure about this)

Thanks, just needed to know where to stick everything.

Final code was for anyone else who might need it :

  - platform: template
    sensors: 
      wind_in_mph:
        friendly_name: "Wind Speed"
        unit_of_measurement: "mph"
        value_template: "{{ states('sensor.dkw2012_004f_winsp')|float|round() / 1.6 }}"
     
1 Like