briis / hass-weatherflow2mqtt

WeatherFlow to MQTT for Home Assistant. Use UDP to get local weather data in to Home Assistant using MQTT Discovery
MIT License
129 stars 29 forks source link

error from the weather entity configuration.yaml #239

Closed hmjgriffon1 closed 10 months ago

hmjgriffon1 commented 1 year ago

Home Assistant Version?

2023.8.4

Add-On or Self Hosted?

HA Supervised (Add-On)

Weatherflow2MQTT version?

3.0.2.

What happened?

sometime after I set this up it started complaining in the HA logs, I don't know how these are supposed to be configured but I assume they will stop working at some point.

Relevant log output

Logger: homeassistant.helpers.event
Source: helpers/template.py:565
First occurred: 8:25:07 PM (10 occurrences)
Last logged: 8:25:07 PM

Error while processing template: Template<template=({{ states('sensor.tempest_st_00113901_temperature') | float}}) renders=2>
Error while processing template: Template<template=({{ states('sensor.tempest_st_00113901_humidity')| int }}) renders=2>
Error while processing template: Template<template=({{ states('sensor.tempest_st_00113901_sea_level_pressure')| float }}) renders=2>
Error while processing template: Template<template=({{ states('sensor.tempest_st_00113901_wind_bearing_avg')| int }}) renders=2>
Error while processing template: Template<template=({{ states('sensor.tempest_st_00113901_visibility')| float }}) renders=2>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1908, in forgiving_float_filter
    return float(value)
           ^^^^^^^^^^^^
ValueError: could not convert string to float: 'unknown'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 563, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2179, in _render_with_context
    return template.render(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1911, in forgiving_float_filter
    raise_no_default("float", value)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1609, in raise_no_default
    raise ValueError(
ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ states('sensor.tempest_st_00113901_temperature') | float}}' but no default was specified

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 684, in async_render_to_info
    render_info._result = self.async_render(variables, strict=strict, **kwargs)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 565, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ states('sensor.tempest_st_00113901_temperature') | float}}' but no default was specified
briis commented 1 year ago

Could you try and install the latest release 2.3.1 and see if this fixes the issue.

hmjgriffon1 commented 1 year ago

The other issue was fixed but this one was not sorry.

hmjgriffon1 commented 1 year ago

I also get this now which I think is new in addition to the other error.

Logger: homeassistant.helpers.template_entity Source: helpers/template_entity.py:397 First occurred: 10:36:32 PM (10 occurrences) Last logged: 10:36:32 PM

TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ states('sensor.tempest_st_00113901_temperature') | float}}' but no default was specified') while processing template 'Template<template=({{ states('sensor.tempest_st_00113901_temperature') | float}}) renders=4>' for attribute '_temperature' in entity 'weather.dogville_daily_forecast' TemplateError('ValueError: Template error: int got invalid input 'unknown' when rendering template '{{ states('sensor.tempest_st_00113901_humidity')| int }}' but no default was specified') while processing template 'Template<template=({{ states('sensor.tempest_st_00113901_humidity')| int }}) renders=4>' for attribute '_humidity' in entity 'weather.dogville_daily_forecast' TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ states('sensor.tempest_st_00113901_sea_level_pressure')| float }}' but no default was specified') while processing template 'Template<template=({{ states('sensor.tempest_st_00113901_sea_level_pressure')| float }}) renders=4>' for attribute '_pressure' in entity 'weather.dogville_daily_forecast' TemplateError('ValueError: Template error: int got invalid input 'unknown' when rendering template '{{ states('sensor.tempest_st_00113901_wind_bearing_avg')| int }}' but no default was specified') while processing template 'Template<template=({{ states('sensor.tempest_st_00113901_wind_bearing_avg')| int }}) renders=4>' for attribute '_wind_bearing' in entity 'weather.dogville_daily_forecast' TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ states('sensor.tempest_st_00113901_visibility')| float }}' but no default was specified') while processing template 'Template<template=({{ states('sensor.tempest_st_00113901_visibility')| float }}) renders=4>' for attribute '_visibility' in entity 'weather.dogville_daily_forecast'

briis commented 1 year ago

And you specified a Station ID and Personal Token. Would you mind sharing your Station ID, so I can have a look at the raw data?

hmjgriffon1 commented 1 year ago

Yeah, I am getting forecast info, I'm assuming it's telling me that the stuff I put into the config yaml is going to stop working at some point. Is there a way I can send you my station ID in a DM or something?

briis commented 1 year ago

Send your Station ID via Email to bjarne@briis.com and I will have a look.

hmjgriffon1 commented 1 year ago

sent.

hmjgriffon1 commented 1 year ago

Here is my config.

briis commented 1 year ago

Try and change the lines from temperature_template: "{{ states('sensor.tempest_st_00113901_temperature') | float}}" to temperature_template: "{{ states('sensor.tempest_st_00113901_temperature') | float(default=0)}}" This should prevent an error if no data is present.

hmjgriffon1 commented 1 year ago

I restarted the addon and I don't see that error in the logs now, I will see if it re appears, I wonder if anyone else has the same issue.

On Sat, Sep 2, 2023 at 1:27 PM Bjarne Riis @.***> wrote:

Try and change the lines from temperature_template: "{{ states('sensor.tempest_st_00113901_temperature') | float}}" to temperature_template: "{{ states('sensor.tempest_st_00113901_temperature') | float(default=0)}}" This should prevent an error if no data is present.

— Reply to this email directly, view it on GitHub https://github.com/briis/hass-weatherflow2mqtt/issues/239#issuecomment-1703894836, or unsubscribe https://github.com/notifications/unsubscribe-auth/A47NQ2BC3PYAHMBOOAZYD4LXYNUB7ANCNFSM6AAAAAA4FIYAK4 . You are receiving this because you authored the thread.Message ID: @.***>

hmjgriffon1 commented 1 year ago

I got stuff in my HA log the other day that the weather entity code I had in my configuration.yaml is deprecated so I took it out and now I see a sensor with a bunch of forecast stuff under it, how do I turn that into a weather card now?

yolani commented 1 year ago

I am also seeing this issue related to the daily_forecast:

Error validating template result '[{'datetime': '2023-09-14T22:00:00+00:00', 'conditions': 'Clear', 'condition': 'sunny', 'temperature': 23.0, 'templow': 12.0, 'precipitation': 0, 'precipitation_probability': 10, 'precip_icon': 'chance-rain', 'precip_type': 'rain', 'wind_speed': 14.0, 'wind_bearing': 84, 'wind_direction_cardinal': 'O'}, {'datetime': '2023-09-15T22:00:00+00:00', 'conditions': 'Rain Possible', 'condition': 'rainy', 'temperature': 24.0, 'templow': 10.0, 'precipitation': 0, 'precipitation_probability': 20, 'precip_icon': 'chance-rain', 'precip_type': 'rain', 'wind_speed': 6.6, 'wind_bearing': 99, 'wind_direction_cardinal': 'O'}, {'datetime': '2023-09-16T22:00:00+00:00', 'conditions': 'Rain Possible', 'condition': 'rainy', 'temperature': 25.0, 'templow': 12.0, 'precipitation': 0, 'precipitation_probability': 20, 'precip_icon': 'chance-rain', 'precip_type': 'rain', 'wind_speed': 6.2, 'wind_bearing': 131, 'wind_direction_cardinal': 'SO'}, {'datetime': '2023-09-17T22:00:00+00:00', 'conditions': 'Thunderstorms Likely', 'condition': 'lightning', 'temperature': 27.0, 'templow': 13.0, 'precipitation': 6.23, 'precipitation_probability': 100, 'precip_icon': 'chance-rain', 'precip_type': 'storm', 'wind_speed': 10.5, 'wind_bearing': 198, 'wind_direction_cardinal': 'SSW'}, {'datetime': '2023-09-18T22:00:00+00:00', 'conditions': 'Rain Likely', 'condition': 'rainy', 'temperature': 21.0, 'templow': 14.0, 'precipitation': 3.58, 'precipitation_probability': 90, 'precip_icon': 'chance-rain', 'precip_type': 'rain', 'wind_speed': 15.6, 'wind_bearing': 251, 'wind_direction_cardinal': 'WSW'}, {'datetime': '2023-09-19T22:00:00+00:00', 'conditions': 'Rain Possible', 'condition': 'rainy', 'temperature': 22.0, 'templow': 12.0, 'precipitation': 0, 'precipitation_probability': 30, 'precip_icon': 'chance-rain', 'precip_type': 'rain', 'wind_speed': 8.7, 'wind_bearing': 197, 'wind_direction_cardinal': 'SSW'}, {'datetime': '2023-09-20T22:00:00+00:00', 'conditions': 'Rain Likely', 'condition': 'rainy', 'temperature': 24.0, 'templow': 11.0, 'precipitation': 0.67, 'precipitation_probability': 70, 'precip_icon': 'chance-rain', 'precip_type': 'rain', 'wind_speed': 8.2, 'wind_bearing': 169, 'wind_direction_cardinal': 'S'}, {'datetime': '2023-09-21T22:00:00+00:00', 'conditions': 'Rain Likely', 'condition': 'rainy', 'temperature': 20.0, 'templow': 14.0, 'precipitation': 7.59, 'precipitation_probability': 70, 'precip_icon': 'chance-rain', 'precip_type': 'rain', 'wind_speed': 10.2, 'wind_bearing': 223, 'wind_direction_cardinal': 'SW'}, {'datetime': '2023-09-22T22:00:00+00:00', 'conditions': 'Rain Likely', 'condition': 'rainy', 'temperature': 17.0, 'templow': 11.0, 'precipitation': 7.27, 'precipitation_probability': 60, 'precip_icon': 'chance-rain', 'precip_type': 'rain', 'wind_speed': 11.6, 'wind_bearing': 261, 'wind_direction_cardinal': 'W'}, {'datetime': '2023-09-23T22:00:00+00:00', 'conditions': 'Rain Likely', 'condition': 'rainy', 'temperature': 18.0, 'templow': 9.0, 'precipitation': 2.9, 'precipitation_probability': 50, 'precip_icon': 'chance-rain', 'precip_type': 'rain', 'wind_speed': 10.2, 'wind_bearing': 241, 'wind_direction_cardinal': 'WSW'}]' from template 'Template<template=({{ state_attr('sensor.hub_hb_00026294_weather', 'daily_forecast') }}) renders=10>' for attribute '_forecast_daily' in entity weather.wetter_gruentegernbach validation message 'Only valid keys in Forecast are allowed, see Weather documentation https://www.home-assistant.io/integrations/weather/'

asjmcguire commented 1 year ago

As of the latest HomeAssistant - presumably since the change to the get forecast service call, the following keys are no longer allowed for daily forecast:

unallowed keys: ({'conditions', 'wind_direction_cardinal', 'precip_icon', 'precip_type'}), see Weather documentation https://www.home-assistant.io/integrations/weather/

The following keys are no longer allowed in hourly forecast:

unallowed keys: ({'uv', 'wind_gust', 'conditions', 'precip_icon', 'precip_type', 'feels_like', 'wind_direction_cardinal'}), see Weather documentation https://www.home-assistant.io/integrations/weather/

The example templated weather entity will not have forecast data if these keys are present.

briis commented 1 year ago

This should have been fixed in the latest release. Have you installed that? Have a look here: https://github.com/briis/hass-weatherflow2mqtt/issues/244

asjmcguire commented 1 year ago

I would just like to confirm that for me this is indeed fixed.

baylanger commented 10 months ago

@OP can we close this issue?