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

TypeError: 'NoneType' object is not subscriptable #78

Closed
metronidazole opened this issue Apr 30, 2021 · 9 comments
Closed

TypeError: 'NoneType' object is not subscriptable #78

metronidazole opened this issue Apr 30, 2021 · 9 comments

Comments

@metronidazole
Copy link

See traceback

Logger: homeassistant.components.weather
Source: custom_components/bureau_of_meteorology/weather.py:118
Integration: Weather (documentation, issues)
First occurred: 1:18:20 PM (2 occurrences)
Last logged: 1:18:20 PM

Error adding entities for domain weather with platform bureau_of_meteorology
Error while setting up bureau_of_meteorology platform for weather

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 322, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 434, in _async_add_entity
original_icon=entity.icon,
File "/config/custom_components/bureau_of_meteorology/weather.py", line 118, in icon
return self.collector.daily_forecasts_data["data"][0]["mdi_icon"]
TypeError: 'NoneType' object is not subscriptable

@SgtBatten
Copy link

Getting the exact same error after updating to the latest version some time yesterday.

@SgtBatten
Copy link

SgtBatten commented Aug 26, 2021

Also getting two other errors:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/bureau_of_meteorology/sensor.py", line 64, in async_setup_entry
    forecast_region = collector.daily_forecasts_data["metadata"]["forecast_region"]
TypeError: 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 147, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/bureau_of_meteorology/PyBoM/collector.py", line 153, in async_update
    await self.get_observations_data()
  File "/config/custom_components/bureau_of_meteorology/PyBoM/collector.py", line 86, in get_observations_data
    await self.format_observations_data()
  File "/config/custom_components/bureau_of_meteorology/PyBoM/collector.py", line 93, in format_observations_data
    flattened["wind_speed_kilometre"] = wind["speed_kilometre"]
TypeError: 'NoneType' object is not subscriptable

@cjsmns
Copy link

cjsmns commented Oct 10, 2021

I'm now getting the exact same issue.

@bremor
Copy link
Owner

bremor commented Oct 11, 2021

I'll take a look into this guys. Sorry for the poor response times.

@grantclem
Copy link

grantclem commented Oct 12, 2021

  • 1

Removed integration and attempt to re-add

image

2021-10-12 08:39:49 ERROR (MainThread) [custom_components.bureau_of_meteorology.config_flow] Unexpected exception
Traceback (most recent call last):
  File "/config/custom_components/bureau_of_meteorology/config_flow.py", line 54, in async_step_user
    await self.collector.get_observations_data()
  File "/config/custom_components/bureau_of_meteorology/PyBoM/collector.py", line 86, in get_observations_data
    await self.format_observations_data()
  File "/config/custom_components/bureau_of_meteorology/PyBoM/collector.py", line 93, in format_observations_data
    flattened["wind_speed_kilometre"] = wind["speed_kilometre"]
TypeError: 'NoneType' object is not subscriptable

@mcvicthor
Copy link

mcvicthor commented Oct 30, 2021

Having the same exact issue:
Error in the logs whilst GUI says Unknown error:
2021-10-31 10:47:43 ERROR (MainThread) [custom_components.bureau_of_meteorology.config_flow] Unexpected exception
Traceback (most recent call last):
File "/config/custom_components/bureau_of_meteorology/config_flow.py", line 54, in async_step_user
await self.collector.get_observations_data()
File "/config/custom_components/bureau_of_meteorology/PyBoM/collector.py", line 86, in get_observations_data
await self.format_observations_data()
File "/config/custom_components/bureau_of_meteorology/PyBoM/collector.py", line 93, in format_observations_data
flattened["wind_speed_kilometre"] = wind["speed_kilometre"]
TypeError: 'NoneType' object is not subscriptable

@ddp526
Copy link

ddp526 commented Nov 4, 2021

Not sure if this helps, but spent a few minutes digging through code, trying a few things (at the start, just putting an if on that missing wind data)... For me, it is tied to the observation data not being there. After about an hour, the sensors came back on their own without help.

Before that time, I removed the integration and tried re-adding it. I saw errors with the observation sensors on setting the integration up, but can move past to the forecast sensors and it works. It fails with the following error on creating/installing the observation sensor:

Traceback (most recent call last):
  File "/config/custom_components/bureau_of_meteorology/config_flow.py", line 85, in async_step_observations
    return await self.async_step_observations_monitored()
  File "/config/custom_components/bureau_of_meteorology/config_flow.py", line 114, in async_step_observations_monitored
    vol.Required(CONF_OBSERVATIONS_BASENAME, default=self.collector.observations_data["data"]["station"]["name"]): str,
TypeError: 'NoneType' object is not subscriptable

I tried with some basic print/debugs before deleting / reinstalling, and the same sort of issue, here is the output when the sensors are being filled in (as best I could tell) - notice all the observation data has a value of None, even the station...

2021-11-04 17:47:01 WARNING (MainThread) [custom_components.bureau_of_meteorology.sensor]: attr={'response_timestamp': '2021-11-04T06:47:00Z', 'issue_time': None, 'observation_time'
: None}, self=<Entity Geelong Racecourse Gust Speed Knot: None>
2021-11-04 17:47:01 WARNING (MainThread) [custom_components.bureau_of_meteorology.sensor] ob_data={'metadata': {'response_timestamp': '2021-11-04T06:47:00Z', 'issue_time': None, 'observ
ation_time': None}, 'data': {'temp': None, 'temp_feels_like': None, 'wind': None, 'gust': None, 'rain_since_9am': None, 'humidity': None, 'station': None, 'wind_speed_kilometre': None, 
'wind_speed_knot': None, 'wind_direction': None, 'gust_speed_kilometre': None, 'gust_speed_knot': None}}
2021-11-04 17:47:01 WARNING (MainThread) [custom_components.bureau_of_meteorology.sensor] ob_data2={'temp': None, 'temp_feels_like': None, 'wind': None, 'gust': None, 'rain_since_9am': 

@bremor
Copy link
Owner

bremor commented Nov 4, 2021

Hey guys, sorry for being absent, I will commit to being more active here.

I have released a version 1.0.0 as a Beta which you can access if you enable "Show Beta Versions" on HACS. This includes bug fixes and an hourly forecast weather entity

image
image

@bremor
Copy link
Owner

bremor commented Nov 19, 2021

Fixed in v1.0.0

@bremor bremor closed this as completed Nov 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants