# Customize unit of measurement and chart view

Hi guys. I need help with newly developed custom weather station I have built.
WStation is based on tasmota firmware and built on ESP12-f (wemos d1 mini) chip. All about project you can read here: https://3dtoday.ru/blogs/elik745i/moya-pogodnaya-stanciya
So integration into Home Assistant went well, but I need to customize few things:

First of all I need Tasmota ANALOG A0 (this can be changed to Battery Voltage, sensor.tasmota_analog_a0) to be in percentage and to be calculated based on the below formula:
((sensor.tasmota_analog_a0/224 - 3)*100)/(4.2-3)

WindSpeed: to be in m/sec and to be calculated like this:

sensor.tasmota_counter_c1/30

Also WindSpeed shows the following when hit:

I need it to show graph.

Also WindDirection:

to be in Deg and to show additionally direction based on below formulas taken from OPENHAB:

``````    var correctionToNorth = 260
var WindDirectDeg = WindDirectDeg_WS.state as Number

if(WindDirectDeg >= 260){
WindDirectDeg = WindDirectDeg - correctionToNorth
}
else{
WindDirectDeg = 360 - (correctionToNorth - WindDirectDeg)
}

WindDirectDeg_WSC.postUpdate(WindDirectDeg)

if(WindDirectDeg > 355 || WindDirectDeg <= 5 ){
WindDirection_WS.postUpdate("NORTH")
}
else if(WindDirectDeg > 5 && WindDirectDeg <= 85 ){
WindDirection_WS.postUpdate("North-West")
}
else if(WindDirectDeg > 85 && WindDirectDeg <= 95 ){
WindDirection_WS.postUpdate("WEST")
}
else if(WindDirectDeg > 95 && WindDirectDeg <= 175 ){
WindDirection_WS.postUpdate("South-West")
}
else if(WindDirectDeg > 175 && WindDirectDeg <= 185 ){
WindDirection_WS.postUpdate("SOUTH")
}
else if(WindDirectDeg > 185 && WindDirectDeg <= 265 ){
WindDirection_WS.postUpdate("South-East")
}
else if(WindDirectDeg > 265 && WindDirectDeg <= 275 ){
WindDirection_WS.postUpdate("EAST")
}
else if(WindDirectDeg > 275 && WindDirectDeg <= 355 ){
WindDirection_WS.postUpdate("North-East")
}
else{
WindDirection_WS.postUpdate(WindDirectDeg)
}
``````

OK I think I found the way to show unit_of_measurement and apply calculations added the following in sensor.yaml:

• platform: template
sensors:
wstation_battery:
value_template: “{{((((states(‘sensor.tasmota_analog_a0’))|float/224 - 3)*100)/(4.2-3))|round(1)}}”
unit_of_measurement: ‘%’
wstation_windspeed:
value_template: “{{(states(‘sensor.tasmota_counter_c1’)|float/30)|round(1)}}”
unit_of_measurement: ‘m/sec’

and here is the compass with icons in sensor.yaml:

• platform: template
sensors:
wind_compass:
friendly_name: “Wind direction”
value_template: ‘{{ states.sensor.weather_wind_direction.state }}’
friendly_name_template: “Wind direction - {{ states.sensor.wind_compass_point.state }}”
unit_of_measurement: ‘°’
entity_picture_template: >-
{% if 354.38 <= states(‘sensor.weather_wind_direction’)|float <= 5.62 %}
/local/WindCompass/0.png
{% elif 5.63 <= states(‘sensor.weather_wind_direction’)|float <= 16.87 %}
/local/WindCompass/11.png
{% elif 16.88 <= states(‘sensor.weather_wind_direction’)|float <= 28.12 %}
/local/WindCompass/22.png
{% elif 28.13 <= states(‘sensor.weather_wind_direction’)|float <= 39.37 %}
/local/WindCompass/33.png
{% elif 39.38 <= states(‘sensor.weather_wind_direction’)|float <= 50.62 %}
/local/WindCompass/45.png
{% elif 50.63 <= states(‘sensor.weather_wind_direction’)|float <= 61.87 %}
/local/WindCompass/56.png
{% elif 61.88 <= states(‘sensor.weather_wind_direction’)|float <= 73.12 %}
/local/WindCompass/67.png
{% elif 73.13 <= states(‘sensor.weather_wind_direction’)|float <= 84.37 %}
/local/WindCompass/78.png
{% elif 84.38 <= states(‘sensor.weather_wind_direction’)|float <= 95.62 %}
/local/WindCompass/90.png
{% elif 95.63 <= states(‘sensor.weather_wind_direction’)|float <= 106.87 %}
/local/WindCompass/101.png
{% elif 106.88 <= states(‘sensor.weather_wind_direction’)|float <= 118.12 %}
/local/WindCompass/112.png
{% elif 118.13 <= states(‘sensor.weather_wind_direction’)|float <= 129.37 %}
/local/WindCompass/123.png
{% elif 129.38 <= states(‘sensor.weather_wind_direction’)|float <= 140.62 %}
/local/WindCompass/135.png
{% elif 140.63 <= states(‘sensor.weather_wind_direction’)|float <= 151.87 %}
/local/WindCompass/146.png
{% elif 151.88 <= states(‘sensor.weather_wind_direction’)|float <= 163.12 %}
/local/WindCompass/157.png
{% elif 163.13 <= states(‘sensor.weather_wind_direction’)|float <= 174.37 %}
/local/WindCompass/168.png
{% elif 174.38 <= states(‘sensor.weather_wind_direction’)|float <= 185.62 %}
/local/WindCompass/180.png
{% elif 185.63 <= states(‘sensor.weather_wind_direction’)|float <= 196.87 %}
/local/WindCompass/191.png
{% elif 196.88 <= states(‘sensor.weather_wind_direction’)|float <= 208.12 %}
/local/WindCompass/202.png
{% elif 208.13 <= states(‘sensor.weather_wind_direction’)|float <= 219.37 %}
/local/WindCompass/213.png
{% elif 219.38 <= states(‘sensor.weather_wind_direction’)|float <= 230.62 %}
/local/WindCompass/225.png
{% elif 230.63 <= states(‘sensor.weather_wind_direction’)|float <= 241.87 %}
/local/WindCompass/236.png
{% elif 241.88 <= states(‘sensor.weather_wind_direction’)|float <= 253.12 %}
/local/WindCompass/247.png
{% elif 253.13 <= states(‘sensor.weather_wind_direction’)|float <= 264.37 %}
/local/WindCompass/258.png
{% elif 264.38 <= states(‘sensor.weather_wind_direction’)|float <= 275.62 %}
/local/WindCompass/270.png
{% elif 275.63 <= states(‘sensor.weather_wind_direction’)|float <= 286.87 %}
/local/WindCompass/281.png
{% elif 286.88 <= states(‘sensor.weather_wind_direction’)|float <= 298.12 %}
/local/WindCompass/292.png
{% elif 298.13 <= states(‘sensor.weather_wind_direction’)|float <= 309.37 %}
/local/WindCompass/303.png
{% elif 309.38 <= states(‘sensor.weather_wind_direction’)|float <= 320.62 %}
/local/WindCompass/315.png
{% elif 320.63 <= states(‘sensor.weather_wind_direction’)|float <= 331.87 %}
/local/WindCompass/326.png
{% elif 331.88 <= states(‘sensor.weather_wind_direction’)|float <= 343.12 %}
/local/WindCompass/337.png
{% elif 343.13 <= states(‘sensor.weather_wind_direction’)|float <= 354.37 %}
/local/WindCompass/348.png
{% endif %}