I want to convert my weather station output wind speed from m/s to knots can you please help
My information is comeing from the mqttbroker using rtl 433 esp32 bord
You can do this by creating a template sensor that multiplies the m/s sensor by 1.943884.
OK but how can you please explain I’m new to home assistant can you tell me stip by stip please
And thank you in advance
Sure. I’ll reply with details tomorrow.
No problem take your time
This is an option:
template:
- sensor:
- name: "Wind Speed - Knots"
unique_id: "Wind Speed - Knots"
state: >-
{% if states('sensor.wind_speed_ms') | float(0) > 0.001 %}
{{ (states('sensor.wind_speed_ms') | float(0) * 1.9438444924 | float(0)) | round(3) }}
{% else %}
0.000
{% endif %}
unit_of_measurement: "kN"
Edit. fixed spacing error. Also removed comments so you can cut and paste.
can you tell me where to put this code in home assistant???
If this is the only one you intend to do, you can put it in your configuration.yaml
If you intent to do lots of this in the future, it is worth splitting your configuration.yaml into different files.
you saved me the effort - cheers!
i did waht you assked but its gaving me this error
2023-04-20 21:33:50.589 ERROR (MainThread) [homeassistant.config] Invalid config for [template]: [unit_of_measurement] is an invalid option for [template]. Check: template->unit_of_measurement. (See /config/configuration.yaml, line 18).
2023-04-20 21:37:23.817 ERROR (MainThread) [homeassistant.config] Invalid config for [template]: [unit_of_measurement] is an invalid option for [template]. Check: template->unit_of_measurement. (See /config/configuration.yaml, line 18).
unit_of_measurement
Is indented correctly in the example above. Indent it further to be inline with “name”
template:
- sensor:
- name: "Wind Speed - Knots"
unique_id: "Wind Speed - Knots"
state: >-
{% if states('sensor.wind_speed_ms') | float(0) > 0.001 %} #is it a number and not unknown or unavailable
{{ (states('sensor.wind_speed_ms') | float(0) * 1.9438444924 | float(0)) | round(3) }} #Keep it to 3 decimal places.
{% else %}
0.000
{% endif %}
unit_of_measurement: "kN"
this is my log file
2023-04-20 22:23:25.787 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform hassio
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 455, in async_add_entities
await asyncio.gather(*tasks)
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 512, in _async_add_entity
entity.add_to_platform_start(
File “/usr/src/homeassistant/homeassistant/components/sensor/init.py”, line 217, in add_to_platform_start
self._async_read_entity_options()
File “/usr/src/homeassistant/homeassistant/components/sensor/init.py”, line 793, in _async_read_entity_options
registry.async_update_entity_options(
File “/usr/src/homeassistant/homeassistant/helpers/entity_registry.py”, line 953, in async_update_entity_options
old = self.entities[entity_id]
File “/usr/local/lib/python3.10/collections/init.py”, line 1106, in getitem
raise KeyError(key)
KeyError: None
2023-04-20 22:23:25.818 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up hassio platform for sensor
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 312, in _async_setup_platform
await asyncio.gather(*pending)
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 455, in async_add_entities
await asyncio.gather(*tasks)
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 512, in _async_add_entity
entity.add_to_platform_start(
File “/usr/src/homeassistant/homeassistant/components/sensor/init.py”, line 217, in add_to_platform_start
self._async_read_entity_options()
File “/usr/src/homeassistant/homeassistant/components/sensor/init.py”, line 793, in _async_read_entity_options
registry.async_update_entity_options(
File “/usr/src/homeassistant/homeassistant/helpers/entity_registry.py”, line 953, in async_update_entity_options
old = self.entities[entity_id]
File “/usr/local/lib/python3.10/collections/init.py”, line 1106, in getitem
raise KeyError(key)
KeyError: None
2023-04-20 22:23:27.027 ERROR (MainThread) [homeassistant.config] Invalid config for [template]: [unit_of_measurement] is an invalid option for [template]. Check: template->unit_of_measurement. (See /config/configuration.yaml, line 16).
2023-04-20 22:24:02.300 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.battery (<class ‘homeassistant.components.mqtt.sensor.MqttSensor’>) is using native unit of measurement ‘None’ which is not a valid unit for the device class (‘battery’) it is using; expected one of [’%’]; Please update your configuration if your entity is manually configured, otherwise create a bug report at Issues · home-assistant/core · GitHub
can you show me an example??
I wrote it above.
ok i will try it now let you know thanks jchh
there is no errors now out nothing still showing im m/s
i coped the code and passted the the config file as you posted do i have to chang any thing els
this how it looks in my config file
Loads default set of integrations. Do not remove.
default_config:
Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
Text to speech
tts:
- platform: google_translate
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
template:
- sensor:
- name: “Wind Speed - Knots”
unique_id: “Wind Speed - Knots”
state: >-
{% if states(‘sensor.wind_speed_ms’) | float(0) > 0.001 %} #is it a number and not unknown or unavailable
{{ (states(‘sensor.wind_speed_ms’) | float(0) * 1.9438444924 | float(0)) | round(3) }} #Keep it to 3 decimal places.
{% else %}
0.000
{% endif %}
unit_of_measurement: “kN”
- name: “Wind Speed - Knots”
i added the new card but its not showing any thing only zeros
Is the name of your sensor “sensor.wind_speed_ms” because this it the name I used so you could replace it with your name for the real sensor that measures the wind speed.
i did waht you sad this what im gating
Entity is non-numeric: sensor.wind_speed_knots
i changed the card its gaving me thes out put
(is it a number and not unknown or unavailable)