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

Met office Task exception was never retrieved #141502

Open
alexd321 opened this issue Mar 26, 2025 · 5 comments
Open

Met office Task exception was never retrieved #141502

alexd321 opened this issue Mar 26, 2025 · 5 comments

Comments

@alexd321
Copy link

The problem

Visibility has wrong state class for metoffice integration, as a range is provided, not a number

What version of Home Assistant Core has the issue?

Core-2025.2.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Met office

Link to integration documentation on our website

https://www.home-assistant.io/integrations/metoffice

Diagnostics information

Logger: homeassistant
Source: components/sensor/__init__.py:642
First occurred: 25 March 2025 at 21:05:59 (164 occurrences)
Last logged: 17:21:01

Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 635, in state
    numerical_value = int(value)
ValueError: invalid literal for int() with base 10: '10-20'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 638, in state
    numerical_value = float(value)
ValueError: could not convert string to float: '10-20'

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 268, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 479, in _async_refresh
    self.async_update_listeners()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 178, in async_update_listeners
    update_callback()
    ~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 559, in _handle_coordinator_update
    self.async_write_ha_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1023, in async_write_ha_state
    self._async_write_ha_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1148, in _async_write_ha_state
    self.__async_calculate_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1085, in __async_calculate_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1029, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 642, in state
    raise ValueError(
    ...<5 lines>...
    ) from err
ValueError: Sensor sensor.exeter_visibility_distance_daily has device class 'None', state class 'None' unit 'km' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: '10-20' (<class 'str'>)

Example YAML snippet

Anything in the logs that might be useful for us?

Additional information

No response

@home-assistant
Copy link

Hey there @MrHarcombe, @avee87, mind taking a look at this issue as it has been labeled with an integration (metoffice) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of metoffice 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 metoffice Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


metoffice documentation
metoffice source
(message by IssueLinks)

@alexd321
Copy link
Author

Edited description for clarity

@avee87
Copy link
Contributor

avee87 commented Mar 27, 2025

This will be fixed by #131425 which will replace this sensor with proper numerical value

@boutch
Copy link

boutch commented Apr 5, 2025

I had the same issue. Until the PR is merged, you can replace the out of the box HA component by the one in the PR as a custom component. Here are the steps:

It worked for me and I even get hourly forecast which is much better! Thank you for the work there.

@greendoescode
Copy link

I had the same issue. Until the PR is merged, you can replace the out of the box HA component by the one in the PR as a custom component. Here are the steps:

* Install https://github.com/alandtse/pr_custom_component via HACS

* Add the PR [Met office Task exception was never retrieved #141502](https://github.com/home-assistant/core/issues/141502)

* Restart HA

* Under repair, replace the existing credentials by the new DataHub API key (see instructions in the PR)

It worked for me and I even get hourly forecast which is much better! Thank you for the work there.

So sorry to ask - I've just tried your instructions and I got the following error:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/metoffice/__init__.py", line 62, in async_setup_entry
    metoffice_hourly_coordinator = TimestampDataUpdateCoordinator(
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: DataUpdateCoordinator.__init__() got an unexpected keyword argument 'config_entry'

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

4 participants