bramstroker / homeassistant-powercalc

Custom component to calculate estimated power consumption of lights and other appliances
MIT License
1.02k stars 262 forks source link

The Powercalc component failed to setup -> 'vacuum robot' is not a valid DeviceType #2673

Closed BernieV1977 closed 16 hours ago

BernieV1977 commented 1 day ago

System Health details

System Information

version core-2024.11.1
installation_type Unknown
dev false
hassio false
docker false
user homeassistant
virtualenv false
python_version 3.12.7
os_name Linux
os_version 6.1.0-27-amd64
arch x86_64
timezone Europe/Brussels
config_dir /mnt/dietpi_userdata/homeassistant
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok HACS Data | ok GitHub API Calls Remaining | 5000 Installed Version | 2.0.1 Stage | running Available Repositories | 1468 Downloaded Repositories | 54
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Dashboards dashboards | 4 -- | -- resources | 37 views | 11 mode | storage
Recorder oldest_recorder_run | 3 november 2024 om 13:19 -- | -- current_recorder_run | 13 november 2024 om 08:33 estimated_db_size | 1381.09 MiB database_engine | sqlite database_version | 3.40.1
Spotify api_endpoint_reachable | ok -- | --

Checklist

Describe the issue

The Powercalc component failed to setup. Error in the log: ValueError: 'vacuum robot' is not a valid DeviceType I have some virtual power entities related to my vacuum robots, so maybe related?

Reproduction steps

After upgrading the Powercalc integration and a reboot -> failed to setup

Debug logs

Logger: homeassistant.setup
Bron: setup.py:416
Eerst voorgekomen: 08:33:16 (1 gebeurtenissen)
Laatst gelogd: 08:33:16

Error during setup of component powercalc
Traceback (most recent call last):
  File "/home/homeassistant/.pyenv/versions/3.12.7/lib/python3.12/site-packages/homeassistant/setup.py", line 416, in _async_setup_component
    result = await task
             ^^^^^^^^^^
  File "/mnt/dietpi_userdata/homeassistant/custom_components/powercalc/__init__.py", line 228, in async_setup
    await discovery_manager.start_discovery()
  File "/mnt/dietpi_userdata/homeassistant/custom_components/powercalc/discovery.py", line 85, in start_discovery
    if not await self.is_entity_supported(entity_entry):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/dietpi_userdata/homeassistant/custom_components/powercalc/discovery.py", line 151, in is_entity_supported
    return power_profile.is_entity_domain_supported(source_entity)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/dietpi_userdata/homeassistant/custom_components/powercalc/power_profile/power_profile.py", line 254, in is_entity_domain_supported
    self.device_type == DeviceType.SMART_SWITCH and entity_entry and entity_entry.platform in ["hue"] and source_entity.domain == LIGHT_DOMAIN
    ^^^^^^^^^^^^^^^^
  File "/mnt/dietpi_userdata/homeassistant/custom_components/powercalc/power_profile/power_profile.py", line 179, in device_type
    return DeviceType(device_type)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.pyenv/versions/3.12.7/lib/python3.12/enum.py", line 757, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.pyenv/versions/3.12.7/lib/python3.12/enum.py", line 1171, in __new__
    raise ve_exc
ValueError: 'vacuum robot' is not a valid DeviceType

Diagnostics dump or YAML config

Schlichi83 commented 20 hours ago

I have the same problem...

bramstroker commented 18 hours ago

Hi thanks for reporting. Should be fixed with v1.15.3. It's because a new device type has been added to the library but code is not prepared for that. I will see how to make it more robust in the future, so the integration still keeps working regardless if a profile provides a device type which is not known to the code yet.

BernieV1977 commented 18 hours ago

Still no luck with v1.15.3:

Logger: homeassistant.setup Bron: setup.py:416 Eerst voorgekomen: 17:35:43 (1 gebeurtenissen) Laatst gelogd: 17:35:43

Error during setup of component powercalc Traceback (most recent call last): File "/home/homeassistant/.pyenv/versions/3.12.7/lib/python3.12/site-packages/homeassistant/setup.py", line 416, in _async_setup_component result = await task ^^^^^^^^^^ File "/mnt/dietpi_userdata/homeassistant/custom_components/powercalc/init.py", line 228, in async_setup await discovery_manager.start_discovery() File "/mnt/dietpi_userdata/homeassistant/custom_components/powercalc/discovery.py", line 85, in start_discovery if not await self.is_entity_supported(entity_entry): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/mnt/dietpi_userdata/homeassistant/custom_components/powercalc/discovery.py", line 151, in is_entity_supported return power_profile.is_entity_domain_supported(source_entity) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/mnt/dietpi_userdata/homeassistant/custom_components/powercalc/power_profile/power_profile.py", line 257, in is_entity_domain_supported self.device_type == DeviceType.SMART_SWITCH and entity_entry and entity_entry.platform in ["hue"] and source_entity.domain == LIGHT_DOMAIN ^^^^^^^^^^^^^^^^ File "/mnt/dietpi_userdata/homeassistant/custom_components/powercalc/power_profile/power_profile.py", line 182, in device_type return DeviceType(device_type) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.12.7/lib/python3.12/enum.py", line 757, in call return cls.new(cls, value) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/homeassistant/.pyenv/versions/3.12.7/lib/python3.12/enum.py", line 1171, in new raise ve_exc ValueError: 'vacuum robot' is not a valid DeviceType

bramstroker commented 17 hours ago

Did some further changes with #2675, which should hopefully fix the issue. Also added code to prevent similar issue in the future. v1.15.4 just released. Sorry for the inconvenience.

BernieV1977 commented 17 hours ago

Thx! Problem solved 👍

bramstroker commented 16 hours ago

Glad its solved. Thanks for reporting and verification.