bramstroker / homeassistant-powercalc

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

IntegrationSensor.__init__() missing 1 required keyword-only argument: 'max_sub_interval' #2299

Closed frenck closed 1 week ago

frenck commented 2 weeks ago

⚠️ Not addressing this issue will break this integration in Home Assistant 2024.7.

System Health details

System Information

version core-2024.7.0.dev202406160221
installation_type Home Assistant OS
dev true
hassio true
docker true
user root
virtualenv false
python_version 3.12.2
os_name Linux
os_version 6.6.32-haos
arch x86_64
timezone Europe/Amsterdam
config_dir /config
Home Assistant Supervisor host_os | Home Assistant OS 12.4.dev20240612 -- | -- update_channel | dev supervisor_version | supervisor-2024.06.2.dev1002 agent_version | 1.6.0 docker_version | 26.1.4 disk_total | 468.7 GB disk_used | 103.6 GB healthy | true supported | true host_connectivity | true supervisor_connectivity | true ntp_synchronized | true virtualization | board | generic-x86-64 supervisor_api | ok version_api | ok

Checklist

Describe the issue

The current nightly/dev version of Home Assistant, in combination with the latest version of this integration at the time of writing (v1.12.10) will not fully work and throw the error listed below in the log.

This issue is caused by the following upstream PR / change:

https://github.com/home-assistant/core/pull/110685

Reproduction steps

  1. Update Home Assistant to 2024.7.0.dev202406160221 or newer
  2. Use this integration...

Debug logs

2024-06-16 22:39:41.025 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up powercalc platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 366, in _async_setup_platform
    await asyncio.shield(awaitable)
  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 631, in create_sensors
    new=await create_general_standby_sensors(hass, global_config),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/powercalc/sensors/group_standby.py", line 47, in create_general_standby_sensors
    energy_sensor = await create_energy_sensor(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/powercalc/sensors/energy.py", line 132, in create_energy_sensor
    return VirtualEnergySensor(
           ^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/powercalc/sensors/energy.py", line 224, in __init__
    super().__init__(
TypeError: IntegrationSensor.__init__() missing 1 required keyword-only argument: 'max_sub_interval'

Diagnostics dump or YAML config

No diagnostics dump is possible in this case. Sorry.

bramstroker commented 1 week ago

@frenck Thanks for reporting this in early stage, fixed with #2302. Will be in next release. Just out of interest, how did you discover this. Are you running powercalc in your dev instance or have that integrated in some CI/CD pipelines?

frenck commented 1 week ago

Are you running powercalc in your dev instance

I run Home Assistant dev on my prod instance @ home; updating every morning. (You can switch to nightly as well if you like, run ha supervisor options --channel dev from a terminal).

bramstroker commented 1 week ago

Are you running powercalc in your dev instance

I run Home Assistant dev on my prod instance @ home; updating every morning. (You can switch to nightly as well if you like, run ha supervisor options --channel dev from a terminal).

Thanks will do that on my test HA instance. Good to have that running bleeding edge version. Have that running through proxmox, so can easily set that to dev channel. Don't want to use dev channel on my prod instance. You have so much faith ;-).

I also have dev instance which I'm managing manually using python virtual env, and just git pull origin dev there once every few weeks. However don't have the frontend working there anymore. Posted something on discord about that few weeks ago, but was still unable to resolve. Some very strange caching issue with the JS assets there.

But mostly I'm just working with the unit tests (have 100% coverage on powercalc), which I run against https://github.com/MatthewFlamm/pytest-homeassistant-custom-component. But these releases only contain latest stable and beta versions of HA, so can't use this strategy to test against latest dev version.

frenck commented 1 week ago

You have so much faith ;-)

Honestly, it isnt't that bad. I can't remember the last time I ran into big issues (and if it happens, it's easy to roll back). That said, I love to run into issues, especially before others do.

However don't have the frontend working there anymore. Posted something on discord about that few weeks ago, but was still unable to resolve.

That is what the nightly is for, that includes latest nightly frontend and nightly intents as well.

bramstroker commented 1 week ago

You have so much faith ;-)

Honestly, it isnt't that bad. I can't remember the last time I ran into big issues (and if it happens, it's easy to roll back). That said, I love to run into issues, especially before others do.

Haha true, from your perspective it's also a good thing to to actually run the latest code on a system containing actual entities, automations etc. Higher chance you actually discover real bugs. Don't have time to fiddle with bugs in the latest nighly besides powercalc maintenance, my daily dev job and watching the European football championships ;-). Sometimes I install latest beta when I have some more spare time to help out, but that's about it.

However don't have the frontend working there anymore. Posted something on discord about that few weeks ago, but was still unable to resolve.

That is what the nightly is for, that includes latest nightly frontend and nightly intents as well.

But I need to have a supervised instance for that right? I just want to run dev version of HA where I have a working frontend and can use an actual debugger in my IDE. I have setup my dev instance using this instructions: https://developers.home-assistant.io/docs/development_environment/#manual-environment

frenck commented 1 week ago

I just want to run dev version of HA where I have a working frontend and can use an actual debugger in my IDE.

The frontend in dev should be working with the dev. We generally bump dev if the change isn't backward compatible. Right now, the version of the frontend pinned on the core dev should be fully compatible.

bramstroker commented 1 week ago

I just want to run dev version of HA where I have a working frontend and can use an actual debugger in my IDE.

The frontend in dev should be working with the dev. We generally bump dev if the change isn't backward compatible. Right now, the version of the frontend pinned on the core dev should be fully compatible.

Good news! I just tried again, and now my development instance started working again magically ;-). Glad to have that finally resolved. It was broken for 2 months it was always loading outdated JS file, which was not to be found anymore in the sources of my local. Latest git pull dev which I did today and another script/setup probably fixed it. But had done that countless times before trying to resolve, and also removed and recreated virtual envs multiple times. Clearing browser caches etc. etc.