Thanks all, I tried the following based on your advice but clearly missing something.
I really am a novice, I understand integrations, cards and lovelace but this is more complicated.
I am trying to pull a Beaufort number from my garden Weather station that returns wind speed in MPH.
I created a sensors.yaml in the config folder and pasted the below into it
sensor:
- platform: template
sensors:
windforce:
friendly_name: Wind force
icon_template: " mdi:weather-windy"
value_template: "{% set wind = state_attr('sensor.wind_speed', 'wind_speed')|float %}
{% set wind_round = wind|round(1) %}
{% if wind <= 1 %}Bft: 0, Calm, {{wind_round}} m/s
{% elif wind <= 5 %}Bft: 1, Light air, {{wind_round}} m/s
{% elif wind <= 11 %}Bft: 2, Light breeze, {{wind_round}} m/s
{% elif wind <= 20 %}Bft: 3, Gentle breeze, {{wind_round}} m/s
{% elif wind <= 28 %}Bft: 4, Moderate breeze, {{wind_round}} m/s
{% elif wind <= 39 %}Bft: 5, Fresh breeze, {{wind_round}} m/s
{% elif wind <= 50 %}Bft: 6, Strong breeze, {{wind_round}} m/s
{% elif wind <= 62 %}Bft: 7, Near gale, {{wind_round}} m/s
{% elif wind <= 75 %}Bft: 8, Gale, {{wind_round}} m/s
{% elif wind <= 89 %}Bft: 9, Severe gale, {{wind_round}} m/s
{% elif wind <= 103 %}Bft: 10, Storm, {{wind_round}} m/s
{% elif wind <= 117 %}Bft: 11, Violent storm, {{wind_round}} m/s
{% else %} > 117 %}Bft: 12, Hurricane, {{wind_round}} m/s
{%- endif %}"
I called the sensors.yaml file from the configuration.yaml using
sensor: !include sensors.yaml
When i verify or try and restart HA i get the following error.
Invalid config for [sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 11).
If i paste try the code in the template editor it seems to work, although it is not very windy today so hard to tell.
My configuration.yaml looks like this.
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Text to speech
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor: !include sensors.yaml