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

IQVIA: Not enough values to unpack #122186

Closed
droans opened this issue Jul 19, 2024 · 2 comments · Fixed by #125114
Closed

IQVIA: Not enough values to unpack #122186

droans opened this issue Jul 19, 2024 · 2 comments · Fixed by #125114
Assignees

Comments

@droans
Copy link

droans commented Jul 19, 2024

The problem

IQVIA is running into issues loading the asthma index sensors with this section of code. It looks like the issue first started appearing 7/16.

This seems to be an issue with IQVIA itself. When I use the pyiqvia client or the Python requests module to load the data myself, I receive data which is inconsistent with the rest of the endpoints. The IQVIA and Asthma Forecast websites both seem to be having issues which are possibly related. I don't believe anything can be done by HA at this time.

For the current (today) data, I receive no data under periods.

For the extended (tomorrow) data, it appears the data is both stale (today is 7/19 and it returns data from 7/15-7/19) and it is missing the Type key which lists the date.

Current asthma forecast:

{
    'Type': 'asthma', 
    'ForecastDate': '2024-07-19T00:00:00+00:00', 
    'Location': {
        'ZIP': 'XXXXX', 
        'periods': []
    }
}

Returns ValueError due to the missing data.

Extended asthma forecast:

{
    'Type': 'asthma', 
    'ForecastDate': '2024-07-19T00:00:00+00:00', 
    'Location': {
        'ZIP': 'XXXXX', 
        'City': 'XXXXX', 
        'State': 'XX', 
        'periods': [
            {
                'Period': '2024-07-15T05:45:01.593', 
                'Index': 4.2, 
                'Idx': '4.2'
            }, 
            {
                'Period': '2024-07-16T05:45:01.593', 
                'Index': 2.7, 
                'Idx': '2.7'
            }, 
            {
                'Period': '2024-07-17T05:45:01.593', 
                'Index': 4.8, 
                'Idx': '4.8'
            }, 
            {
                'Period': '2024-07-18T05:45:01.593', 
                'Index': 3.3, 
                'Idx': '3.3'
            }, 
            {
                'Period': '2024-07-19T05:45:01.593', 
                'Index': 4.5, 
                'Idx': '4.5'
            }
        ], 
        'DisplayLocation': 'XXXXX, XX'
    }
}

Returns TypeError but is handled by the code.

What version of Home Assistant Core has the issue?

2024.7.2

What was the last working version of Home Assistant Core?

2024.7.2

What type of installation are you running?

Home Assistant Container

Integration causing the issue

IQVIA

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

ERROR (MainThread) [homeassistant.components.sensor] Error adding entity sensor.asthma_index_tomorrow for domain sensor with platform iqvia
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 598, in _async_add_entities
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 912, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1361, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/usr/src/homeassistant/homeassistant/components/iqvia/__init__.py", line 156, in async_added_to_hass
    self.update_from_latest_data()
  File "/usr/src/homeassistant/homeassistant/components/iqvia/sensor.py", line 247, in update_from_latest_data
    [period] = [p for p in data["periods"] if p["Type"] == key]  # type: ignore[index]
    ^^^^^^^^
ValueError: not enough values to unpack (expected 1, got 0)

Additional information

No response

@home-assistant
Copy link

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

Code owner commands

Code owners of iqvia 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 iqvia 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)


iqvia documentation
iqvia source
(message by IssueLinks)

@Intecpsp
Copy link

Intecpsp commented Sep 2, 2024

Wanted to throw my hat in here with this issues at well

@github-actions github-actions bot locked and limited conversation to collaborators Oct 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants