bramstroker / homeassistant-powercalc

Custom component to calculate estimated power consumption of lights and other appliances
MIT License
956 stars 252 forks source link

Detected blocking call to open inside the event loop by custom integration 'powercalc' #2289

Closed ColinRobbins closed 3 months ago

ColinRobbins commented 3 months ago

System Health details

System Information

version core-2024.6.1
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.2
os_name Linux
os_version 6.6.28-haos-raspi
arch aarch64
timezone Europe/London
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4548 Installed Version | 1.34.0 Stage | running Available Repositories | 1390 Downloaded Repositories | 20
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | 1 September 2024 at 01:00 relayer_connected | true relayer_region | eu-central-1 remote_enabled | true remote_connected | true alexa_enabled | false google_enabled | true remote_server | eu-central-1-11.ui.nabu.casa certificate_status | ready instance_id | 795d5eb01a8748dcb7323ae84de72e72 can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 12.3 -- | -- update_channel | stable supervisor_version | supervisor-2024.06.0 agent_version | 1.6.0 docker_version | 25.0.5 disk_total | 117.3 GB disk_used | 14.8 GB healthy | true supported | true host_connectivity | true supervisor_connectivity | true ntp_synchronized | true virtualization | board | rpi4-64 supervisor_api | ok version_api | ok installed_addons | Samba share (12.3.1), Terminal & SSH (9.14.0), Pluto Rsync (1.0.7), SQLite Web (4.1.2)
Dashboards dashboards | 9 -- | -- resources | 10 views | 34 mode | storage
Recorder oldest_recorder_run | 6 June 2024 at 20:10 -- | -- current_recorder_run | 8 June 2024 at 20:24 estimated_db_size | 542.49 MiB database_engine | sqlite database_version | 3.44.2

Checklist

Describe the issue

On startup, PowerCalc reports the following in the logs...

Reproduction steps

Installed HA 2024.6.1 Was working perfectly with 2024.5.3

Debug logs

Logger: homeassistant.util.loop
Source: util/loop.py:84
First occurred: 20:24:37 (103 occurrences)
Last logged: 20:24:39

Detected blocking call to open inside the event loop by custom integration 'powercalc' at custom_components/powercalc/power_profile/loader/remote.py, line 121: with open(path) as f: (offender: /config/custom_components/powercalc/power_profile/loader/remote.py, line 121: with open(path) as f:), please create a bug report at https://github.com/bramstroker/homeassistant-powercalc/issues Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/setup.py", line 165, in async_setup_component result = await _async_setup_component(hass, domain, config) File "/usr/src/homeassistant/homeassistant/setup.py", line 402, in _async_setup_component result = await task File "/config/custom_components/powercalc/__init__.py", line 238, in async_setup await discovery_manager.start_discovery() File "/config/custom_components/powercalc/discovery.py", line 123, in start_discovery power_profile = await self.get_power_profile( File "/config/custom_components/powercalc/discovery.py", line 144, in get_power_profile self.power_profiles[entity_id] = await get_power_profile( File "/config/custom_components/powercalc/power_profile/factory.py", line 39, in get_power_profile library = await ProfileLibrary.factory(hass) File "/config/custom_components/powercalc/power_profile/library.py", line 49, in factory await library.initialize() File "/config/custom_components/powercalc/power_profile/library.py", line 35, in initialize await self._loader.initialize() File "/config/custom_components/powercalc/power_profile/loader/composite.py", line 14, in initialize [await loader.initialize() for loader in self.loaders] # type: ignore[func-returns-value] File "/config/custom_components/powercalc/power_profile/loader/remote.py", line 34, in initialize self.last_update_time = self.get_last_update_time() File "/config/custom_components/powercalc/power_profile/loader/remote.py", line 121, in get_last_update_time with open(path) as f:
Detected blocking call to open inside the event loop by custom integration 'powercalc' at custom_components/powercalc/power_profile/loader/remote.py, line 107: with open(model_path) as f: (offender: /config/custom_components/powercalc/power_profile/loader/remote.py, line 107: with open(model_path) as f:), please create a bug report at https://github.com/bramstroker/homeassistant-powercalc/issues Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/setup.py", line 165, in async_setup_component result = await _async_setup_component(hass, domain, config) File "/usr/src/homeassistant/homeassistant/setup.py", line 402, in _async_setup_component result = await task File "/config/custom_components/powercalc/__init__.py", line 238, in async_setup await discovery_manager.start_discovery() File "/config/custom_components/powercalc/discovery.py", line 123, in start_discovery power_profile = await self.get_power_profile( File "/config/custom_components/powercalc/discovery.py", line 144, in get_power_profile self.power_profiles[entity_id] = await get_power_profile( File "/config/custom_components/powercalc/power_profile/factory.py", line 40, in get_power_profile profile = await library.get_profile( File "/config/custom_components/powercalc/power_profile/library.py", line 104, in get_profile profile = await self.create_power_profile(model_info, custom_directory) File "/config/custom_components/powercalc/power_profile/library.py", line 137, in create_power_profile result = await loader.load_model(manufacturer, resolved_model) File "/config/custom_components/powercalc/power_profile/loader/composite.py", line 32, in load_model result = await loader.load_model(manufacturer, model) File "/config/custom_components/powercalc/power_profile/loader/remote.py", line 107, in load_model with open(model_path) as f:
Detected blocking call to open inside the event loop by custom integration 'powercalc' at custom_components/powercalc/power_profile/loader/remote.py, line 107: with open(model_path) as f: (offender: /config/custom_components/powercalc/power_profile/loader/remote.py, line 107: with open(model_path) as f:), please create a bug report at https://github.com/bramstroker/homeassistant-powercalc/issues Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 165, in _async_component_platform_discovered await self.async_setup_platform(platform, {}, info) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 319, in async_setup_platform await self._platforms[key].async_setup(platform_config, discovery_info) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 303, in async_setup await self._async_setup_platform(async_create_setup_awaitable) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 363, in _async_setup_platform awaitable = create_eager_task(awaitable, loop=hass.loop) File "/usr/src/homeassistant/homeassistant/util/async_.py", line 37, in create_eager_task return Task(coro, loop=loop, name=name, eager_start=True) File "/config/custom_components/powercalc/sensor.py", line 313, in async_setup_platform await _async_setup_entities( File "/config/custom_components/powercalc/sensor.py", line 378, in _async_setup_entities entities = await create_sensors(hass, config, discovery_info, config_entry) File "/config/custom_components/powercalc/sensor.py", line 652, in create_sensors child_entities = await create_sensors( File "/config/custom_components/powercalc/sensor.py", line 637, in create_sensors return await create_individual_sensors( File "/config/custom_components/powercalc/sensor.py", line 769, in create_individual_sensors power_sensor = await create_power_sensor( File "/config/custom_components/powercalc/sensors/power.py", line 120, in create_power_sensor return await create_virtual_power_sensor( File "/config/custom_components/powercalc/sensors/power.py", line 140, in create_virtual_power_sensor power_profile = await get_power_profile( File "/config/custom_components/powercalc/power_profile/factory.py", line 40, in get_power_profile profile = await library.get_profile( File "/config/custom_components/powercalc/power_profile/library.py", line 104, in get_profile profile = await self.create_power_profile(model_info, custom_directory) File "/config/custom_components/powercalc/power_profile/library.py", line 137, in create_power_profile result = await loader.load_model(manufacturer, resolved_model) File "/config/custom_components/powercalc/power_profile/loader/composite.py", line 32, in load_model result = await loader.load_model(manufacturer, model) File "/config/custom_components/powercalc/power_profile/loader/remote.py", line 107, in load_model with open(model_path) as f:
Detected blocking call to open inside the event loop by custom integration 'powercalc' at custom_components/powercalc/strategy/lut.py, line 91: return gzip.open(gzip_path, "rt") # type: ignore (offender: /usr/local/lib/python3.12/gzip.py, line 192: fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')), please create a bug report at https://github.com/bramstroker/homeassistant-powercalc/issues Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 165, in _async_component_platform_discovered await self.async_setup_platform(platform, {}, info) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 319, in async_setup_platform await self._platforms[key].async_setup(platform_config, discovery_info) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 303, in async_setup await self._async_setup_platform(async_create_setup_awaitable) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 363, in _async_setup_platform awaitable = create_eager_task(awaitable, loop=hass.loop) File "/usr/src/homeassistant/homeassistant/util/async_.py", line 37, in create_eager_task return Task(coro, loop=loop, name=name, eager_start=True) File "/config/custom_components/powercalc/sensor.py", line 313, in async_setup_platform await _async_setup_entities( File "/config/custom_components/powercalc/sensor.py", line 378, in _async_setup_entities entities = await create_sensors(hass, config, discovery_info, config_entry) File "/config/custom_components/powercalc/sensor.py", line 652, in create_sensors child_entities = await create_sensors( File "/config/custom_components/powercalc/sensor.py", line 637, in create_sensors return await create_individual_sensors( File "/config/custom_components/powercalc/sensor.py", line 769, in create_individual_sensors power_sensor = await create_power_sensor( File "/config/custom_components/powercalc/sensors/power.py", line 120, in create_power_sensor return await create_virtual_power_sensor( File "/config/custom_components/powercalc/sensors/power.py", line 246, in create_virtual_power_sensor await power_sensor.validate() File "/config/custom_components/powercalc/sensors/power.py", line 373, in validate await self._strategy_instance.validate_config() File "/config/custom_components/powercalc/strategy/lut.py", line 279, in validate_config await self._lut_registry.get_lookup_dictionary( File "/config/custom_components/powercalc/strategy/lut.py", line 61, in get_lookup_dictionary with self.get_lut_file(power_profile, color_mode) as csv_file: File "/config/custom_components/powercalc/strategy/lut.py", line 91, in get_lut_file return gzip.open(gzip_path, "rt") # type: ignore

Diagnostics dump or YAML config

No response

ColinRobbins commented 3 months ago

Sorry, was not on latest PowerCalc. Fixed with upgrade