bramstroker / homeassistant-powercalc

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

Error after update to V 0.25 #1018

Closed Desaydrone closed 2 years ago

Desaydrone commented 2 years ago

Hello,

I got this error after updating to the last version of powercalc and restart HA :

Logger: homeassistant.setup
Source: custom_components/powercalc/power_profile/library.py:132
Integration: Powercalc (documentation, issues)
First occurred: 08:11:06 (1 occurrences)
Last logged: 08:11:06

Error during setup of component powercalc
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 235, in _async_setup_component
    result = await task
  File "/config/custom_components/powercalc/__init__.py", line 185, in async_setup
    await autodiscover_entities(config, domain_config, hass)
  File "/config/custom_components/powercalc/__init__.py", line 268, in autodiscover_entities
    power_profile = await get_power_profile(
  File "/config/custom_components/powercalc/power_profile/model_discovery.py", line 46, in get_power_profile
    profile = await libary.get_profile(
  File "/config/custom_components/powercalc/power_profile/library.py", line 82, in get_profile
    profiles = await self.get_profiles_by_manufacturer(model_info.manufacturer)
  File "/config/custom_components/powercalc/power_profile/library.py", line 119, in get_profiles_by_manufacturer
    await self._create_power_profile(
  File "/config/custom_components/powercalc/power_profile/library.py", line 132, in _create_power_profile
    with open(model_json_path) as file:
FileNotFoundError: [Errno 2] No such file or directory: '/config/custom_components/powercalc/power_profile/../data/aqara/model.json'

I'm on home assistant v 2022.8.6

bramstroker commented 2 years ago

Looking into this currently, but unable to reproduce yet. Do you guys happen to have custom models in config/powercalc-custom-models directory?

Also could you enable debug log and share the complete log after startup?

bramstroker commented 2 years ago

Also are you running Home Assistant OS or you are running supervised or any other installation method?

Desaydrone commented 2 years ago

Also are you running Home Assistant OS or you are running supervised or any other installation method?

I use HA in docker, and for now no problem with all the update of powercalc, i look today to give you the debug log. I can't do it for now.

ralfbosz commented 2 years ago

I get the same error, even with update v25.1

Logger: custom_components.powercalc.power_profile.library
Source: custom_components/powercalc/power_profile/library.py:83
Integration: powercalc (documentation, issues)
First occurred: 11:23:32 (9 occurrences)
Last logged: 11:23:32

model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/yeelight
model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/paulmann licht
model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/mueller-licht
model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/gledopto
model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/anko

and:

Logger: homeassistant.setup
Source: custom_components/powercalc/power_profile/library.py:137
Integration: powercalc (documentation, issues)
First occurred: 11:23:32 (1 occurrences)
Last logged: 11:23:32

Error during setup of component powercalc
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 235, in _async_setup_component
    result = await task
  File "/config/custom_components/powercalc/__init__.py", line 185, in async_setup
    await autodiscover_entities(config, domain_config, hass)
  File "/config/custom_components/powercalc/__init__.py", line 268, in autodiscover_entities
    power_profile = await get_power_profile(
  File "/config/custom_components/powercalc/power_profile/model_discovery.py", line 46, in get_power_profile
    profile = await libary.get_profile(
  File "/config/custom_components/powercalc/power_profile/library.py", line 83, in get_profile
    profiles = await self.get_profiles_by_manufacturer(model_info.manufacturer)
  File "/config/custom_components/powercalc/power_profile/library.py", line 120, in get_profiles_by_manufacturer
    power_profile = await self._create_power_profile(
  File "/config/custom_components/powercalc/power_profile/library.py", line 137, in _create_power_profile
    with open(model_json_path) as file:
NotADirectoryError: [Errno 20] Not a directory: '/config/custom_components/powercalc/power_profile/../data/model_schema.json/model.json'

Running HomeAssistant on HassOS.

ralfbosz commented 2 years ago

Think I found it, there is a model_schema.json in de data directory, when I 'remove' this, the plugin loads correctly when restarting !

This file:

https://github.com/bramstroker/homeassistant-powercalc/blob/master/custom_components/powercalc/data/model_schema.json

bramstroker commented 2 years ago

@ralfbosz You have hit another bug in the same code which iterates the directory to check if a certain manufacturer/model exists. There seem to be an inconsistence in directory listing accross multiple OS's (locally it's working for me, but in Home Assistant OS it's breaking). I will have another look tomorrow to fix it in the code.

pejotigrek commented 2 years ago

updated to 25.0 - errors show up, then updated to 25.1 and still with errors. downgraded to v24.8 and... errors are not gone:

2022-08-24 14:29:10.594 WARNING (MainThread) [custom_components.powercalc] The 'scan_interval' option is deprecated, please replace it with 'force_update_frequency'
2022-08-24 14:29:10.641 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/yeelight
2022-08-24 14:29:10.644 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/paulmann licht
2022-08-24 14:29:10.646 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/anko
2022-08-24 14:29:10.648 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/belkin
2022-08-24 14:29:10.649 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/aqara
2022-08-24 14:29:10.651 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/wiz
2022-08-24 14:29:10.653 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/lidl
2022-08-24 14:29:10.655 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/lexman
2022-08-24 14:29:10.659 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/tuya
2022-08-24 14:29:10.663 ERROR (MainThread) [homeassistant.setup] Error during setup of component powercalc
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 235, in _async_setup_component
    result = await task
  File "/config/custom_components/powercalc/__init__.py", line 185, in async_setup
    await autodiscover_entities(config, domain_config, hass)
  File "/config/custom_components/powercalc/__init__.py", line 268, in autodiscover_entities
    power_profile = await get_power_profile(
  File "/config/custom_components/powercalc/power_profile/model_discovery.py", line 46, in get_power_profile
    profile = await libary.get_profile(
  File "/config/custom_components/powercalc/power_profile/library.py", line 83, in get_profile
    profiles = await self.get_profiles_by_manufacturer(model_info.manufacturer)
  File "/config/custom_components/powercalc/power_profile/library.py", line 120, in get_profiles_by_manufacturer
    power_profile = await self._create_power_profile(
  File "/config/custom_components/powercalc/power_profile/library.py", line 137, in _create_power_profile
    with open(model_json_path) as file:
NotADirectoryError: [Errno 20] Not a directory: '/config/custom_components/powercalc/power_profile/../data/model_schema.json/model.json'
2022-08-24 14:29:10.689 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform powercalc.sensor: Unable to set up component.

I've got no custom models, pure installation. Home Assistant 2022.8.6 [supervised install, on ubuntu server] Supervisor 2022.08.3

bramstroker commented 2 years ago

Very busy at work today, so will be tomorrow when I can have a look and a fix.

@pejotigrek very strange that downgrading does not solve your issue as the code you reference was only introduced in v0.25. I suspect the downgrade was unsuccesfull somehow, so I suggest to double check that.

pejotigrek commented 2 years ago

Very busy at work today, so will be tomorrow when I can have a look and a fix.

can relate, don't worry, work first! just wanted to add additional report.

@pejotigrek very strange that downgrading does not solve your issue as the code you reference was only introduced in v0.25. I suspect the downgrade was unsuccesfull somehow, so I suggest to double check that.

tried twice. as of right now I'm "too afraid" to uninstall and make a clean install [don't want to loose all sensor readings/history - I don't know if they will re-attach after reinstall], but will investigate further when I'll come back from work

pejotigrek commented 2 years ago

ok, one last update for now: after seeing error with model_schema.json/model.json this is what I've tried now with success:

  1. /config/custom_components/powercalc/power_profile/../data/model_schema.json renamed to model.json
  2. at the same path made directory named model_schema.json
  3. moved model.json into this new directory
  4. reset HA
  5. system starts without errors

so I can call this a temporary fix - for situations similar to mine

EDIT: about pt. 5 - powercalc sensors are created, so component starts without critical errors, but I still can see in the log:

2022-08-24 15:19:04.453 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/yeelight
2022-08-24 15:19:04.654 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/paulmann licht
2022-08-24 15:19:04.695 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/anko
2022-08-24 15:19:04.730 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/belkin
2022-08-24 15:19:04.751 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/aqara
2022-08-24 15:19:04.794 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/wiz
2022-08-24 15:19:04.834 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/lidl
2022-08-24 15:19:04.875 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/lexman
2022-08-24 15:19:04.880 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/tuya
2022-08-24 15:19:04.883 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/mueller-licht
2022-08-24 15:19:04.886 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/arlec
2022-08-24 15:19:04.889 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/ikea
2022-08-24 15:19:04.892 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/malmbergs
2022-08-24 15:19:04.894 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/signify
2022-08-24 15:19:04.897 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/ledvance
2022-08-24 15:19:04.900 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/innr
2022-08-24 15:19:04.903 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/melitec
2022-08-24 15:19:04.907 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/lifx
2022-08-24 15:19:04.910 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/elgato
2022-08-24 15:19:04.914 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/sonoff
2022-08-24 15:19:04.915 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/gledopto
2022-08-24 15:19:04.916 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/genio
2022-08-24 15:19:04.918 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/osram
bramstroker commented 2 years ago

Just found 30 minutes to have a quick look. Was unable to reproduce in my test Hass OS installation. But I made a change in #1024 which should hopefully resolve for you.

Can any of you install the master branch and verify?

philippsandhaus commented 2 years ago

Hi, I had the exact same issue in my installation and I can confirm that the change in #1024 fixes it for me.

Desaydrone commented 2 years ago

Hi, i can confirm that the change in #1024 fixed the errors for me too

bramstroker commented 2 years ago

Nice, thanks for confirming. Will release v0.25.2 now.

pejotigrek commented 2 years ago

thank you for quick update!

don't know if I should move it to new issue, but after update to v0.25.2 powercalc starts and creates sensors as it should [first I've reverted changes mentioned by me here], but I still found this in the log:

2022-08-24 23:20:16.323 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/yeelight
2022-08-24 23:20:16.342 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/paulmann licht
2022-08-24 23:20:16.345 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/anko
2022-08-24 23:20:16.348 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/belkin
2022-08-24 23:20:16.350 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/aqara
2022-08-24 23:20:16.353 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/wiz
2022-08-24 23:20:16.355 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/lidl
2022-08-24 23:20:16.357 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/lexman
2022-08-24 23:20:16.360 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/tuya
2022-08-24 23:20:16.364 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/mueller-licht
2022-08-24 23:20:16.367 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/arlec
2022-08-24 23:20:16.370 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/ikea
2022-08-24 23:20:16.372 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/malmbergs
2022-08-24 23:20:16.376 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/signify
2022-08-24 23:20:16.380 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/ledvance
2022-08-24 23:20:16.385 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/innr
2022-08-24 23:20:16.390 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/melitec
2022-08-24 23:20:16.393 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/lifx
2022-08-24 23:20:16.396 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/elgato
2022-08-24 23:20:16.401 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/sonoff
2022-08-24 23:20:16.403 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/gledopto
2022-08-24 23:20:16.405 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/genio
2022-08-24 23:20:16.407 ERROR (MainThread) [custom_components.powercalc.power_profile.library] model.json file not found in directory /config/custom_components/powercalc/power_profile/../data/osram
bramstroker commented 2 years ago

This errors in the log still needs solving. There shouldn't be any errors. COuld you please create a new issue for that? Thanks in advance.