I am just getting started with HA. I have units of measure set to Imperial in configuration.yaml and the Yr temperature is showing as degrees F which is good.
However, wind speed, barometric pressure, and precipitation show in metric units.
I see that there are options in Configuration|Customization for unit_of_measurement, but I can’t figure out what the allowable values are.
For instance, if I change unit_of_measurement for Weather Pressure (sensor) to inHg, and restart HA, the label on the home page changes to InHg, but the value displayed is still hPa. Likewise if I change wind speed to mph, the label changes to mph but the value displayed is still m/s.
I have looked at the source code at …/homeassistant/components/sensor/yr.py, but saw nothing there that helped. I have Googled and have not found an answer.
Here is the code from my configuration.yaml. I have tried quite a few variations but I can’t figure out the syntax of the value_template. Can you please explain? The only thing that displays is wind_speed_mph with a dash in the icon. All the other values are not displayed. The default unit of measurement is meters/sec, I want to convert to mph and display it.
Weather prediction
sensor:
platform: yr
name: Weather
forecast: 24
monitored_conditions:
It displays Weather Wind Speed in mph to one decimal point.
I have to say, to do what would appear to be a simple change of units was pretty painful.
There were several gotcha’s along the way. I found that the - platform template section had to be in the sensor section with yr. If it was in a separate sensor section, none of the yr sensors showed up. The wind speed in yr needed to be monitored, I needed to define a new sensor name wind_speed_mph, and finally hide the yr wind_speed. Finding the correct state name for the yr variable was not obvious.
Thanks to all of you who responded to my question; without your help it would have taken a lot longer to figure out. I have searched the HA docs and googled the problem for several hours. I could find nothing that helped.
If there is a cleaner way to accomplish this, please let me know!
Yes, thanks for your reply! This is essentially what I got working above. Since then I have added conversions for pressure and precipitation. These are formatted as floats. I had to change the quotes around the format string to single quotes from an example I found on the net. With double quotes around the format string HA would not start at all. Also, I found that I had to invert the conversion factors for pressure and precipitation and divide rather than multiply by a small decimal number. When multiplying by a number less than one, the result was zero. I hope these clues will help others.
I am also trying to change the YR wind speed units from m/s to km/h. The conversion factor is 3.6. I have searched in many threads to get this done with templates, however everything I have tried so far displays either a dash (-) in the new ‘bubble’ (in the frontend), or 0.0. I can’t get this to work. Can anybody help? Here’s my configuration.yaml code: