bramstroker / homeassistant-powercalc

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

None of my virtual manual fixed sensors are loading anymore #2212

Closed bdormael closed 2 months ago

bdormael commented 2 months ago

System Health details

System Information

version core-2024.4.3
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.1.73-haos-raspi
arch aarch64
timezone Europe/Brussels
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4910 Installed Version | 1.34.0 Stage | running Available Repositories | 1404 Downloaded Repositories | 52 HACS Data | ok
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | 27 november 2024 om 01:00 relayer_connected | true relayer_region | eu-central-1 remote_enabled | true remote_connected | true alexa_enabled | false google_enabled | false remote_server | eu-central-1-5.ui.nabu.casa certificate_status | ready instance_id | 8d76d97a9e614bcb81d58783d9a20264 can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 12.2 -- | -- update_channel | stable supervisor_version | supervisor-2024.04.0 agent_version | 1.6.0 docker_version | 25.0.5 disk_total | 116.7 GB disk_used | 12.8 GB healthy | true supported | true board | rpi4-64 supervisor_api | ok version_api | ok installed_addons | MariaDB (2.7.1), Mosquitto broker (6.4.0), Terminal & SSH (9.13.0), phpMyAdmin (0.9.1), Volvo2Mqtt (1.8.27), Node-RED (17.0.12), Studio Code Server (5.15.0), Z-Wave JS (0.5.0), eufy-security-ws (1.8.0-2), HassOS I2C Configurator (0.14), ArgonOne Active Linear Cooling (30a), Matter Server (5.5.1), Zigbee2MQTT (1.36.1-1), ZigStar TI CC2652P7 FW Flasher (0.2.0), diyHue (2.0.14)
Dashboards dashboards | 4 -- | -- resources | 32 views | 12 mode | storage
Recorder oldest_recorder_run | 22 maart 2024 om 11:01 -- | -- current_recorder_run | 21 april 2024 om 08:18 estimated_db_size | 1325.42 MiB database_engine | mysql database_version | 10.11.6
Solcast PV Forecast can_reach_server | ok -- | -- used_requests | 2 rooftop_site_count | 2

Checklist

Describe the issue

since 21st of April after a restart of home assistant (2024.4.3) my manually added sensors (via yaml or gui) are not loading anymore. I always get an error that powercalc is not able to load at startup

I was using powercalc version 1.12.0.beta-5 , I switched to the master version but same issue

Reproduction steps

  1. Restart home assistant
  2. an error is thrown that powercalc cannot load (see error logs)
  3. ...

Debug logs

Logger: homeassistant.setup
Bron: setup.py:398
Eerst voorgekomen: 08:19:02 (1 gebeurtenissen)
Laatst gelogd: 08:19:02

Error during setup of component powercalc
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 398, 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 64, 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 31, in initialize
    self.library_contents = await self.load_library_json()
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/powercalc/power_profile/loader/remote.py", line 52, in load_library_json
    with open(get_library_json_path()) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/config/custom_components/powercalc/../../profile_library/library.json'

Logger: homeassistant.setup
Bron: setup.py:475
Eerst voorgekomen: 08:19:02 (8 gebeurtenissen)
Laatst gelogd: 08:19:02

Unable to prepare setup for platform 'powercalc.sensor': Unable to set up component.

Deze fout is ontstaan door een aangepaste integratie.

Logger: custom_components.powercalc.power_profile.loader.remote
Bron: custom_components/powercalc/power_profile/loader/remote.py:51
integratie: Powercalc (documentatie, problemen)
Eerst voorgekomen: 08:19:02 (1 gebeurtenissen)
Laatst gelogd: 08:19:02

Failed to download library.json from github, falling back to local copy

Diagnostics dump or YAML config

example sensor: - platform: powercalc entity_id: media_player.samsungtv unique_id: samsung_tv_energy fixed: power: 118

bramstroker commented 2 months ago

You must be using one of the beta version of powercalc, as it seems remote loading logic version is triggered. And this is not in stable release yet.

If so please let me know which beta version you are running on.

gieljnssns commented 2 months ago

1.12.0beta2

bramstroker commented 2 months ago

I see. I have moved powercalc API's to final location, tried to keep the old endpoint still available, but failed into doing that properly. I have just release v1.12-beta.6 which should resolve your issues.

I notice there is an issue were all the profiles are downloaded again after each startup. So your startup times will be a bit delayed everytime.

I'll fix that last issue after F1 race is finished ;-).

gieljnssns commented 2 months ago

Bèta 6 works. only this one

Platform powercalc does not generate unique IDs. ID Unifi POE_energy is already used by sensor.unifi_poe_verbruik_verbruik - ignoring sensor.unifi_poe_verbruik_verbruik
bramstroker commented 2 months ago

@gieljnssns That's strange, nothing really changed regarding to the sensor setup routine compared to the other beta versions.

Could you please create a new issue when you still experience this after consequetive restarts?

bramstroker commented 2 months ago

Btw, regarding the original issue. I have also fixed the old API URL, so older beta versions 1-5 should also work correctly again.

bdormael commented 2 months ago

thx for the quick fix, all working again :-)

purcell-lab commented 2 months ago

Thanks beta6 fixed my issue: https://community.home-assistant.io/t/powercalc-virtual-power-sensors/318515/941?u=markpurcell

bipsendk commented 2 months ago

Got same issue yesterday when I updated to 1.11.8 ...

Update: Solved by updating HA to 2024.4.4