Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template weather integration broken #91620

Open
parautenbach opened this issue Apr 18, 2023 · 11 comments
Open

Template weather integration broken #91620

parautenbach opened this issue Apr 18, 2023 · 11 comments

Comments

@parautenbach
Copy link

The problem

Even with static data configured, the template weather integration has an unknown state. This seems to be the offending line.

This is a minimal configuration exhibiting the issue:

weather:
  - platform: template
    name: "Test"
    condition_template: "sunny"
    temperature_template: 23.5
    temperature_unit: "°C"
    humidity_template: 0.0

Log:

Apr 18 17:44:53 homeassistant hass[3446845]: 2023-04-18 17:44:53.487 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Apr 18 17:44:53 homeassistant hass[3446845]: Traceback (most recent call last):
Apr 18 17:44:53 homeassistant hass[3446845]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/template_entity.py", line 364, in _async_template_startup
Apr 18 17:44:53 homeassistant hass[3446845]:     result_info.async_refresh()
Apr 18 17:44:53 homeassistant hass[3446845]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/event.py", line 953, in async_refresh
Apr 18 17:44:53 homeassistant hass[3446845]:     self._refresh(None)
Apr 18 17:44:53 homeassistant hass[3446845]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/event.py", line 1133, in _refresh
Apr 18 17:44:53 homeassistant hass[3446845]:     self.hass.async_run_hass_job(self._job, event, updates)
Apr 18 17:44:53 homeassistant hass[3446845]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/core.py", line 593, in async_run_hass_job
Apr 18 17:44:53 homeassistant hass[3446845]:     hassjob.target(*args)
Apr 18 17:44:53 homeassistant hass[3446845]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/template_entity.py", line 333, in _handle_results
Apr 18 17:44:53 homeassistant hass[3446845]:     self.async_write_ha_state()
Apr 18 17:44:53 homeassistant hass[3446845]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/entity.py", line 568, in async_write_ha_state
Apr 18 17:44:53 homeassistant hass[3446845]:     self._async_write_ha_state()
Apr 18 17:44:53 homeassistant hass[3446845]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/entity.py", line 634, in _async_write_ha_state
Apr 18 17:44:53 homeassistant hass[3446845]:     attr.update(self.state_attributes or {})
Apr 18 17:44:53 homeassistant hass[3446845]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/weather/__init__.py", line 606, in state_attributes
Apr 18 17:44:53 homeassistant hass[3446845]:     data[ATTR_WEATHER_HUMIDITY] = round(humidity)
Apr 18 17:44:53 homeassistant hass[3446845]: TypeError: type str doesn't define __round__ method

Logger config:

logger:
  default: warning
  logs:
    homeassistant.components.template.weather: debug

What version of Home Assistant Core has the issue?

core-2023.4.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

Template Weather Provider

Link to integration documentation on our website

https://www.home-assistant.io/integrations/weather.template/

Diagnostics information

No response

Example YAML snippet

weather:
  - platform: template
    name: "Test"
    condition_template: "sunny"
    temperature_template: 23.5
    temperature_unit: "°C"
    humidity_template: 0.0

Anything in the logs that might be useful for us?

Apr 18 17:44:53 homeassistant hass[3446845]: 2023-04-18 17:44:53.487 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Apr 18 17:44:53 homeassistant hass[3446845]: Traceback (most recent call last):
Apr 18 17:44:53 homeassistant hass[3446845]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/template_entity.py", line 364, in _async_template_startup
Apr 18 17:44:53 homeassistant hass[3446845]:     result_info.async_refresh()
Apr 18 17:44:53 homeassistant hass[3446845]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/event.py", line 953, in async_refresh
Apr 18 17:44:53 homeassistant hass[3446845]:     self._refresh(None)
Apr 18 17:44:53 homeassistant hass[3446845]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/event.py", line 1133, in _refresh
Apr 18 17:44:53 homeassistant hass[3446845]:     self.hass.async_run_hass_job(self._job, event, updates)
Apr 18 17:44:53 homeassistant hass[3446845]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/core.py", line 593, in async_run_hass_job
Apr 18 17:44:53 homeassistant hass[3446845]:     hassjob.target(*args)
Apr 18 17:44:53 homeassistant hass[3446845]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/template_entity.py", line 333, in _handle_results
Apr 18 17:44:53 homeassistant hass[3446845]:     self.async_write_ha_state()
Apr 18 17:44:53 homeassistant hass[3446845]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/entity.py", line 568, in async_write_ha_state
Apr 18 17:44:53 homeassistant hass[3446845]:     self._async_write_ha_state()
Apr 18 17:44:53 homeassistant hass[3446845]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/entity.py", line 634, in _async_write_ha_state
Apr 18 17:44:53 homeassistant hass[3446845]:     attr.update(self.state_attributes or {})
Apr 18 17:44:53 homeassistant hass[3446845]:   File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/weather/__init__.py", line 606, in state_attributes
Apr 18 17:44:53 homeassistant hass[3446845]:     data[ATTR_WEATHER_HUMIDITY] = round(humidity)
Apr 18 17:44:53 homeassistant hass[3446845]: TypeError: type str doesn't define __round__ method

Additional information

https://github.com/home-assistant/core/blob/dev/homeassistant/components/weather/__init__.py#L606

@home-assistant
Copy link

Hey there @PhracturedBlue, @tetienne, @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (template) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of template can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign template Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


template documentation
template source
(message by IssueLinks)

@exxamalte
Copy link
Contributor

I don't disagree that this issue should probably be handled better by this integration (as it does for the temperature value), but a simple workaround is to define a template that casts the value to a float:

    humidity_template: "{{ states('sensor.humidity') | float }}"

@parautenbach
Copy link
Author

Thanks for the workaround.

The one issue is that it's not handling the given configuration properly when the humidity_template is required, but not available (as in, I don't have a value for it), and 0.0 is considered a float in Python world (I know it's a string in the config).

The bigger problem, however, is that it completely borks the integration. The rest should still work, I'd argue, with a error/warning that it doesn't understand my config for the humidity.

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@parautenbach
Copy link
Author

Still needs fixing.

@github-actions github-actions bot removed the stale label Jul 18, 2023
@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@parautenbach
Copy link
Author

.

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@parautenbach
Copy link
Author

.

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@parautenbach
Copy link
Author

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants