homeassistant-powercalc: JSONDecodeError and not a valid ColorMode Error during startup since v1.12.12

System Health details

System Information

version core-2024.6.4
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.33-haos
arch x86_64
timezone Europe/Berlin
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
GitHub API Calls Remaining 5000
Installed Version 1.34.0
Stage running
Available Repositories 1390
Downloaded Repositories 22
HACS Data ok
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 12.4
update_channel beta
supervisor_version supervisor-2024.06.2
agent_version 1.6.0
docker_version 26.1.4
disk_total 395.0 GB
disk_used 31.1 GB
healthy true
supported true
host_connectivity true
supervisor_connectivity true
ntp_synchronized true
virtualization kvm
board ova
supervisor_api ok
version_api ok
installed_addons ESPHome (2024.6.2), Samba share (12.3.1), Piper (1.5.0), openWakeWord (1.10.0), Terminal & SSH (9.14.0), Samba Backup (5.2.0), Studio Code Server (5.15.0), vosk (1.6.0)
Dashboards
dashboards 5
resources 15
views 36
mode storage
Miele
component_version 2024.5.0
reach_miele_cloud ok
Recorder
oldest_recorder_run 15. Juni 2024 um 15:09
current_recorder_run 25. Juni 2024 um 22:34
estimated_db_size 814.04 MiB
database_engine sqlite
database_version 3.44.2

Checklist

  • I have read the FAQ to see if there is a known solution to my problem.
  • I have enabled debug logging for my installation.
  • I have filled out the issue template to the best of my ability.
  • This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • This issue is not a duplicate issue of currently previous issues…

Describe the issue

Hello,

I get the an error in the log during startup of Home Assistant after direct updating of powercalc intergration regarding JSONDecodeError. After restarting again the JSONDecodeError disappears and invalid ColorMode error occurs.

Reproduction steps

  1. Update powercalc
  2. Restart Home Assistant
  3. Check the log (first error occurs)
  4. Restart Home Assistant
  5. Check the log (another error occurs)

Debug logs

Error direct after update of powercalc and restart of Home Assistant

Logger: homeassistant.components.sensor
Quelle: helpers/entity_platform.py:366
Integration: Sensor (Dokumentation, Probleme)
Erstmals aufgetreten: 24. Juni 2024 um 22:35:52 (1 Vorkommnisse)
Zuletzt protokolliert: 24. Juni 2024 um 22:35:52

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 353, in async_setup_entry
    await _async_setup_entities(
  File "/config/custom_components/powercalc/sensor.py", line 375, in _async_setup_entities
    entities = await create_sensors(hass, config, discovery_info, config_entry)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/powercalc/sensor.py", line 625, in create_sensors
    return await create_individual_sensors(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/powercalc/sensor.py", line 755, in create_individual_sensors
    power_sensor = await create_power_sensor(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/powercalc/sensors/power.py", line 121, in create_power_sensor
    return await create_virtual_power_sensor(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/powercalc/sensors/power.py", line 141, 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 28, in load_model
    result = await loader.load_model(manufacturer, model)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/powercalc/power_profile/loader/remote.py", line 128, in load_model
    json_data = await self.hass.async_add_executor_job(_load_json)  # type: ignore
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/powercalc/power_profile/loader/remote.py", line 126, in _load_json
    return cast(dict[str, Any], json.load(f))
                                ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/json/__init__.py", line 293, in load
    return loads(fp.read(),
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

------------

Restarting of Home Assistant:

Logger: homeassistant
Quelle: custom_components/powercalc/strategy/lut.py:196
Integration: Powercalc (Dokumentation, Probleme)
Erstmals aufgetreten: 22:34:15 (17 Vorkommnisse)
Zuletzt protokolliert: 22:34:20

Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/powercalc/sensors/power.py", line 397, in initial_update
    await self._handle_source_entity_state_change(
  File "/config/custom_components/powercalc/sensors/power.py", line 490, in _handle_source_entity_state_change
    self._power = await self.calculate_power(state)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/powercalc/sensors/power.py", line 542, in calculate_power
    power = await self._strategy_instance.calculate(entity_state)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/powercalc/strategy/lut.py", line 130, in calculate
    color_mode = await self.get_selected_color_mode(attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/powercalc/strategy/lut.py", line 196, in get_selected_color_mode
    color_mode = ColorMode(str(attrs.get(ATTR_COLOR_MODE)))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/enum.py", line 744, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/enum.py", line 1158, in __new__
    raise ve_exc
ValueError: 'None' is not a valid ColorMode

Diagnostics dump or YAML config

Two diagnostics as an example. I have different Hue lamps with powercal integration in use. Always use the library option: config_entry-powercalc-c3e34bc1f7d5d4d24f32d1cf1492a1e6.json config_entry-powercalc-9a2d46d3e74b7b4ca0b3846b2e8dd1c3.json

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

nice good to hear

Thank you very much for your great work and time! I’m looking forward for the New Release.