Closed nickdos closed 5 years ago
Answering my own question. I worked out a template sensor can do this:
sensor:
- platform: template
sensors:
bom_current_day_forecast:
value_template: '{{ states.sensor.bom_forecast_canberra_0.attributes.Summary }}'
friendly_name: 'Today'
icon_template: '{{ states.sensor.bom_forecast_canberra_0.attributes.icon }}'
I tried using a template for the friendly_name
but it came out as {{states.sensor.bom_forecast_canberra_0.attributes.friendly_name }}
, so went with today
instead.
Update: I've made it a bit smarter so, depending on the time of day, the output temp is the min-max range, just max or overnight min.
bom_forecast_current_day:
value_template: >-
{% if state_attr('sensor.bom_forecast_canberra_0','Min Temp C') %}
{{ state_attr('sensor.bom_forecast_canberra_0','Min Temp C') }}°–{{ state_attr('sensor.bom_forecast_canberra_0','Max Temp C') }}°
{% elif state_attr('sensor.bom_forecast_canberra_0','Max Temp C') %}
Max: {{ state_attr('sensor.bom_forecast_canberra_0','Max Temp C') }}°
{% elif state_attr('sensor.bom_forecast_canberra_1','Min Temp C') %}
Overnight min: {{ state_attr('sensor.bom_forecast_canberra_1','Min Temp C') }}°
{% endif %}
{{ state_attr('sensor.bom_forecast_canberra_0','Summary') }}
friendly_name: 'Rest of the day'
icon_template: '{{ states.sensor.bom_forecast_canberra_0.attributes.icon }}'
The current day forecast (rest of the day, I suppose) is showing both min and max temperatures as
n/a
, which looks a bit broken on the friendly card. See:Ideally, the values forecasted for the current day should remain but I'm guessing BOM is not sending them through in the feed.
I tried using template expressions (to try to check for
n/a
and then output nothing) but they came out as literal characters.Any suggestions for avoiding the
n/a
values?