Bugga-CH / home-assistant-integration-fix

After installation of the WhatWatt Home Assistant Integration I get following error:

Logger: homeassistant.config_entries
Source: config_entries.py:769
First occurred: 12:38:28 PM (2 occurrences)
Last logged: 12:39:04 PM

Error setting up entry WhatWatt for whatwatt
Traceback (most recent call last):
File „/usr/src/homeassistant/homeassistant/config_entries.py“, line 769, in __async_setup_with_context
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File „/config/custom_components/whatwatt/init.py“, line 33, in async_setup_entry
mqtt_topic = entry.data[CONF_MQTT_TOPIC]
~~~~~~~~~~^^^^^^^^^^^^^^^^^
KeyError: ‚mqtt-topic‘

Any hints how to fix this problem?

Can you check the code and config for a misspelling? Look for “mqtt-topic” and “mqtt_topic”.
Where did you download the integration code from?

Remek

I’ve downloaded the code from this site:

GitHub - Bugga-CH/home-assistant-integration-fix: a fix for the Home Assistant integration for Whatwatt Go · GitHub . and uploaded the folder whatwatt to folder custom_components

We’ll take a look, even though it’s a community-created code fork. I’ll also get in touch with the author.

Hi hsprenger,

The KeyError: ‚mqtt-topic‘ is caused by a configuration key change in the fork. The original integration uses mqtt_topic (with an underscore), but the fork changed it to mqtt-topic (with a hyphen). If you have an existing configuration entry (e.g. from the official integration or a previous version), the new code looks for mqtt-topic but only finds the old key mqtt_topic — hence the KeyError.

Solution: Remove the WhatWatt integration in Home Assistant under Settings → Devices & Services, restart Home Assistant, and add the integration again. This will create a new configuration entry with the correct key name and the error should be resolved.

We are already working on a fix for the official integration that will address this and other issues.

Best regards

Mateusz

1 Like

Hi Mateusz,

Thanks very much for the solution. No more error

messages now.

Best regards

hsprenger