How do I change from the UI showing km for Wind / Visibility when the weather config code shows m/s & m
That just gives me the cannot be changed in UI blurp
This entity (âweather.met_office_datahubâ) does not have a unique ID, therefore its settings cannot be managed from the UI. See the documentation for more detail.
Huh, I must have added that to my config after making this topic.
Add a unique_id:
line to the top of your weather
file, like this:
- platform: template
name: "Met Office Datahub"
unique_id: 884233c7-4b31-4181-bef7-d5562110df5f
It can be anything you like: I use this site: https://www.uuidgenerator.net/
Now to update the original postâŚ
Yep that sorted it cheers
Iâm almost embarrassed to ask this question, as itâs almost certain that Iâve just missed something obvious, butâŚ
Having followed your fantastic guidance in this topic, @Troon, it all looks good for forecast data, but the âlocal_current_weatherâ sensor has not been created. What am I missing? Any thoughts would be massively appreciated!
There are a couple of log warnings:
Logger: homeassistant.helpers.template
Source: helpers/template.py:2651
First occurred: 19:21:43 (2 occurrences)
Last logged: 19:21:44
Template variable warning: 'None' has no attribute 'screenTemperature' when rendering '{{ state_attr('sensor.local_current_weather','status')['screenTemperature'] }}'
Logger: homeassistant.components.recorder.db_schema
Source: components/recorder/db_schema.py:625
integration: Recorder (documentation, issues)
First occurred: 19:21:52 (6 occurrences)
Last logged: 20:19:48
State attributes for sensor.local_datahub_hourly exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
State attributes for sensor.local_datahub_3_hourly exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
My template yaml is below (which I think is a direct copy of the original) & resides in my configuration.yaml. Iâve set up separate yaml files for ârestâ (named MetOffice-rest.yaml) and âweatherâ (MetOffice-weather.yaml), again pasted from the original (with the appropriate api key & latitude/longitude), with the following in my configuration.yaml:
rest: !include MetOffice-rest.yaml
weather: !include MetOffice-weather.yaml
template:
- sensor:
- name: Local current weather
state: >
{% set tsl = state_attr('sensor.local_datahub_hourly','timeSeries')|map(attribute='time')|map('as_timestamp')|list %}
{% set ts = tsl|select('>=',(now()-timedelta(minutes=30))|as_timestamp())|first %}
{{ tsl.index(ts) }}
attributes:
status: "{{ state_attr('sensor.local_datahub_hourly','timeSeries')[this.state|int(0)] }}"
availability: "{{ states('sensor.local_datahub_hourly') not in ('unavailable', 'unknown') }}"
- sensor:
- name: Local weather condition
state: >
{% from 'met_office_codes.jinja' import code2ha %}
{{ code2ha(state_attr('sensor.local_current_weather','status')['significantWeatherCode']) }}
attributes:
timestamp: "{{ state_attr('sensor.local_current_weather','status')['time'] }}"
availability: "{{ states('sensor.local_current_weather') not in ('unavailable', 'unknown') }}"
- sensor:
- name: Local wind bearing
state: >
{% from 'direction.jinja' import dir %}
{{ dir(state_attr('sensor.local_current_weather','status')['windDirectionFrom10m']) }}
attributes:
timestamp: "{{ state_attr('sensor.local_current_weather','status')['time'] }}"
availability: "{{ states('sensor.local_current_weather') not in ('unavailable', 'unknown') }}"
Can you check that sensor.local_datahub_hourly
works? It should look something like this Settings â Developer Tools:
Thx for your reply. Yes it does work.
Panic over. All working now. I had another âtemplate:â statement in my configuration.yaml file. All moved to a separate templates.yaml file and allâs well. YAML syntax strikes again!
glad you got it working as I was unable to find any typos in your yaml!
So i have this working now for a few weeks, and now see this in the log:
2024-10-21 21:28:11.250 WARNING (Recorder) [homeassistant.components.recorder.db_schema] State attributes for sensor.local_datahub_hourly exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
2024-10-21 21:28:11.251 WARNING (Recorder) [homeassistant.components.recorder.db_schema] State attributes for sensor.local_datahub_3_hourly exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
Anyway to set it up to periodic empty this? No point keeping old json-dumps in the sqlite database, no? I donât want to disable this entirely (the typical suggestion i get when googling for that message).
I exclude both those from recorder entirely.
I tried that but then the weather object broke for me.
Hereâs what i came up with, an automation to purge entries older than 5 days:
- id: '1729615371955'
alias: purge-old-metoffice-datahub
description: Clean up the very-verbose REST api json results from MetOffice Datahub
service
triggers:
- trigger: time
at: 02:45:00
conditions: []
actions:
- action: recorder.purge_entities
data:
keep_days: 5
entity_id: sensor.local_datahub_3_hourly
- action: recorder.purge_entities
data:
keep_days: 5
entity_id:
- sensor.local_datahub_hourly
- action: recorder.purge_entities
data:
keep_days: 5
entity_id:
- sensor.local_datahub_daily
Is it still working for you guys?
I have all 3 sensors âunknownââŚ
The setup seems to be pretty simple, have no idea whatâs wrong.
I tried it with !secret first, now I have details directly, still âunknownââŚ
Working for me, have you reloaded?