Fix: Retrieve topic_prefix from config_entry for set_config_key service#197
Open
4homeassistant wants to merge 1 commit intosyssi:mainfrom
Open
Fix: Retrieve topic_prefix from config_entry for set_config_key service#1974homeassistant wants to merge 1 commit intosyssi:mainfrom
4homeassistant wants to merge 1 commit intosyssi:mainfrom
Conversation
Fixes syssi#159 The set_config_key service was using the hardcoded DEFAULT_TOPIC_PREFIX instead of reading the actual topic_prefix from the config entry. This caused the service to fail when the user's configured topic_prefix differed from the default value. Changes: - Store config entries in hass.data for service access - Retrieve topic_prefix from config_entry instead of using hardcoded default - Add debug logging to show the actual topic being published to - Add cleanup of stored config entries on unload Tested with my own topic_prefix configurations: - With leading slash: /go-eCharger
Author
|
Hey @syssi, I developed and tested a fix for that issue with the help of Perplexity and Claude. I am not really aware of the code but tried a vibe coding approach and tested it on my own installation. The concept of the change makes sense to me. What do you say? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #159
Problem
The
set_config_keyservice was using the hardcodedDEFAULT_TOPIC_PREFIXinstead of reading the actualtopic_prefixfrom the config entry. This caused the service to fail when the user's configuredtopic_prefixdiffered from the default value.After version 0.24, the
DEFAULT_TOPIC_PREFIXwas changed from/go-eChargertogo-eCharger(without leading slash), breaking the service for users who had the leading slash in their configuration.Solution
hass.datafor service accesstopic_prefixfrom config_entry instead of using hardcoded defaultTesting
Tested successfully with topic_prefix configurations with leading slash:
/go-eChargerThe service now correctly uses the user's configured topic_prefix regardless of the default value.