Dark Sky not able to convert pressure units from millibars to in Hg

I’m trying to change the pressure units from millibars to inches HG which I’m much more accustomed. When I check my configurateion, it kepps yelling at me. Can someone see what I may be doing wrong? I’ve copied the template information into my configuration file. It looks like this:

sensor:
  - platform: darksky
    api_key: [redacted]
    monitored_conditions:
      - summary
      - icon
      - nearest_storm_distance
      - dew_point
      - wind_speed
      - wind_bearing
      - pressure
      - precip_type
      - precip_intensity
      - apparent_temperature
    update_interval: 00:15:00
    units: us
  - platform: template
    sensors:
      sensor.dark_sky_pressure:
      friendly_name: Pressure
      unit_of_measurement: 'in Hg'
      value_template: "{{ states('sensor.dark_sky_pressure')|float * 0.02953 }}"

And when I check my config, this is the error I’m getting:

Configuration invalid
Testing configuration at /config
ERROR:homeassistant.config:Invalid config for [sensor.template]: [sensor.dark_sky_pressure] is an invalid option for [sensor.template]. Check: sensor.template->sensors->sensor.dark_sky_pressure. (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.template/
Failed config
  sensor.template: 
    platform: template
    sensors: [source /config/configuration.yaml:247]
      friendly_name: Pressure
      sensor.dark_sky_pressure: None
      unit_of_measurement: in Hg
      value_template: {{ states('sensor.dark_sky_pressure')|float * 0.02953 }}

Successful config (partial)
  sensor.template:

Looking at the states under the developer options, this is what is there:

sensor.dark_sky_pressure	1013.0	attribution: Powered by Dark Sky
unit_of_measurement: inHg
friendly_name: Pressure
icon: mdi:gauge
value_template: {{ states('sensor.dark_sky_pressure'|float * 0.02953 }}

It will not perform the math calculation to covert the pressure. I’m sure it’s something simple but very frustrating. Thanks in advance for help.

Give your sensor a different entity and intent the values 2 spaces more.

  - platform: template
    sensors:
      dark_sky_pressure_hg:
        friendly_name: Pressure
        unit_of_measurement: 'in Hg'
        value_template: "{{ states('sensor.dark_sky_pressure')|float * 0.02953 }}"

Thanks for your response.

sensor:
  - platform: darksky
    api_key: [redacted]
    monitored_conditions:
      - pressure
    units: us
  - platform: template
    sensors:
      sensor.dark_sky_pressure_hg:
        friendly_name: Pressure
        unit_of_measurement: 'in Hg'
        value_template: "{{ states('sensor.dark_sky_pressure')|float * 0.02953 }}"

Returned this:

Configuration invalid
Testing configuration at /config
ERROR:homeassistant.config:Invalid config for [sensor.template]: [sensor.dark_sky_pressure_hg] is an invalid option for [sensor.template]. Check: sensor.template->sensors->sensor.dark_sky_pressure_hg. (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.template/
Failed config
  sensor.template: 
    platform: template
    sensors: [source /config/configuration.yaml:251]
      sensor.dark_sky_pressure_hg: [source /config/configuration.yaml:252]
        friendly_name: Pressure
        unit_of_measurement: in Hg
        value_template: {{ states('sensor.dark_sky_pressure')|float * 0.02953 }}

Successful config (partial)
  sensor.template:

States shows this:

sensor.dark_sky_pressure	1006.6	attribution: Powered by Dark Sky
unit_of_measurement: mbar
friendly_name: Dark Sky Pressure
icon: mdi:gauge

It would be so much easier if there was a unit_of_measurement: for inHg. It would calculate to 29.724898 in Hg. I would eventually like to round this number to 2 decimal places, too if we can get this to work.

Read the template sensor from my first response.

Add round(2) to the template

{{ (states('sensor.dark_sky_pressure')|float * 0.02953) | round(2) }}

My fault, I copied the sensor from the group and did not remove the sensor prefix. I see what I did wrong, thank you for your patience with me.

1 Like