Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Home Assistant Core 2025.1.0 E Go Charger no Connection #102

Open
azazul1980 opened this issue Jan 4, 2025 · 20 comments
Open

Home Assistant Core 2025.1.0 E Go Charger no Connection #102

azazul1980 opened this issue Jan 4, 2025 · 20 comments

Comments

@azazul1980
Copy link

Describe the bug
A clear and concise description of what the bug is.

Versions (please complete the following information):

  • home-assistant 2025.1.0
  • Charger Hardware: v2
  • Charger Firmware Version: 57.1
  • Plugin Version:

Additional context

Since the Upgrade from Home Assistant Core 2025.1.0 the Charger Don t connected more after i go back to Version Home Assistant Core 2024.12.5 all Connections are back.

@AfRotaker
Copy link

AfRotaker commented Jan 4, 2025

Yeah so while I can access the charger as far as turning it on and off, every other sensor from the device is unavailable, with power consumption the most prominent

I reverted back to the last 2024 version as well, for now

• home-assistant: 2025.1.0
• Charger Hardware: v3
• Charger Firmware Version: 57.1

@iflowmac
Copy link

iflowmac commented Jan 4, 2025

Same problem here, only turning on and off is available.

• home-assistant: 2025.1.0
• Charger Hardware: v2
• Charger Firmware Version: 042.0

@vistalba
Copy link

vistalba commented Jan 4, 2025

I run into the same issue this morning. Reverted back to 2024.12.5 solves the problem.
Unfortunately this integration looks quite unmaintained as the last commit was 2 years ago.

@azazul1980
Copy link
Author

Ok thank you for response. There is a Bug/problem with the Integration and the New Home Assistant Core.

@PieBa
Copy link

PieBa commented Jan 4, 2025

After the ha upgrade I received those two messages, one error, one warning in the ha logs:


Logger: homeassistant.setup
Quelle: setup.py:497
Erstmals aufgetreten: 11:23:49 (1 Vorkommnisse)
Zuletzt protokolliert: 11:23:49

Unable to prepare setup for platform 'goecharger.sensor': Platform not found (cannot import name 'TEMP_CELSIUS' from 'homeassistant.const' (/usr/src/homeassistant/homeassistant/const.py)).
Logger: homeassistant.util.loop
Quelle: util/loop.py:77
Erstmals aufgetreten: 11:23:49 (1 Vorkommnisse)
Zuletzt protokolliert: 11:23:49

Detected blocking call to import_module with args ('custom_components.goecharger.sensor',) in /usr/src/homeassistant/homeassistant/loader.py, line 1304: return importlib.import_module(f"{self.pkg_path}.{platform_name}") inside the event loop; This is causing stability issues. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#import_module Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 227, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 213, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 154, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.13/asyncio/base_events.py", line 707, in run_until_complete self.run_forever() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 678, in run_forever self._run_once() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 2033, in _run_once handle._run() File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 166, in _async_component_platform_discovered await self.async_setup_platform(platform, {}, info) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 291, in async_setup_platform platform = await async_prepare_setup_platform( File "/usr/src/homeassistant/homeassistant/setup.py", line 538, in async_prepare_setup_platform platform = await integration.async_get_platform(domain) File "/usr/src/homeassistant/homeassistant/loader.py", line 1108, in async_get_platform platforms = await self.async_get_platforms((platform_name,)) File "/usr/src/homeassistant/homeassistant/loader.py", line 1173, in async_get_platforms platforms.update(self._load_platforms(platform_names)) File "/usr/src/homeassistant/homeassistant/loader.py", line 1098, in _load_platforms platform_name: self._load_platform(platform_name) File "/usr/src/homeassistant/homeassistant/loader.py", line 1272, in _load_platform cache[full_name] = self._import_platform(platform_name) File "/usr/src/homeassistant/homeassistant/loader.py", line 1304, in _import_platform return importlib.import_module(f"{self.pkg_path}.{platform_name}")

@gerhardvilsecker
Copy link

According to this article: home-assistant/core#108991
TEMP_CELSIUS has been removed from home assistant core in 2025.1 release. This has been announced in jan. 20244! So I agree: This integrations does not seem to be maintained any more...
It should not be a big deal to correct this bug. However I am not a python expert at all :-(

@cathiele
Copy link
Owner

cathiele commented Jan 4, 2025

should be fixed in version 0.26.0 ( PR #103 )

@PieBa
Copy link

PieBa commented Jan 4, 2025

should be fixed in version 0.26.0 ( PR #103 )

I can confirm that it works for me again with 0.26.0
Thanks @cathiele for the very quick fix!

@andyhomea
Copy link

Same here, 0.26.0 fixed it.
Thanks a lot!

@FelixK-creator
Copy link

FelixK-creator commented Jan 5, 2025

Hi,
I just installed my new configuration with Home Assitant Core.
As I try to connect I get following message in the protocol:

Dieser Fehler stammt von einer benutzerdefinierten Integration

Logger: custom_components.goecharger
Quelle: custom_components/goecharger/init.py:98
Integration: go-eCharger (Dokumentation, Probleme)
Erstmals aufgetreten: 17:50:12 (8 Vorkommnisse)
Zuletzt protokolliert: 17:52:32

Unable to fetch state for Charger charger1

• home-assistant: 2025.1.1
• Charger Hardware: v4
• Charger Firmware Version: 057.1

Any hints? No data is pulled. V2 enabled.

@rmayr
Copy link

rmayr commented Jan 8, 2025

All entries still show as unavailable for me as well, with Home Assistant v2025.1.1 and go- integration v0.26.0, updated from Git main branch today. When adding a new device (having deleted the old one before), the configure dialog comes up, but after adding, clicking on Configure always yields "Error: Config flow could not be loaded: 500 Internal Server Error Server got itself in trouble".

@iflowmac
Copy link

I run into the same problem: Error: Config flow could not be loaded: 500 Internal Server Error Server got itself in trouble
All entries unavailable :-(

@Woodstockskipper
Copy link

Same Message to me after update to 0.26.0

@Woodstockskipper
Copy link

I restarted the go-e charger and HA after this all works fine.

@iflowmac
Copy link

I restarted the go-e charger and HA after this all works fine.

A restart of go-e charger helped! THX!

@rmayr
Copy link

rmayr commented Jan 15, 2025

Restarting unfortunately didn't help for me.

@Derektar
Copy link

Derektar commented Jan 18, 2025

Restarting unfortunately didn't help for me.

Same problem here. I even restarted HA and Go-E multiple times and in different orders.
Problem solved: See comment below

@Derektar
Copy link

Restarting unfortunately didn't help for me.

Found the problem with my instance: I overlooked a problem with HACS that caused HACS to fail to start at all. Therefor no available updates were displayed anymore. Since I filtered the log for the integrations that were shown as faulty, I didn't immediately saw the HACS problem.

Could that maybe the case with your instance, too?
In that case a repository within HACS is doubled. To fix that manually do the following

  1. Go to to the File Editor addon
  2. Within its configurations tab remove the ignore-pattern for .storage
  3. Restart the File Editor addon and start its user interface
  4. Navigate to /homeassistant/.storage/hacs.repositories
  5. Remove one of the two music-assistant/hass-music-assistant entries
  6. Reload the HACS integration (maybe restart Home Assistant itself, too)
  7. Now you can apply missing updates

Got that solution here (german language, but the screenshots may help nevertheless): https://community.simon42.com/t/hacs-einrichtungsfehler-aus-seitenleiste-verschwunden-doppelte-repo/43697/3

@rmayr
Copy link

rmayr commented Jan 19, 2025

Thanks for the additional potential solution! However, I have not installed the component through HACS but manually through copying the subdirectory (because my homeassistant config directory is managed through Salt stack). So there should be no issue with two conflicting versions.

@SchmidSP
Copy link

Hello,

also had the total failure of the plugin since 2025.1.x
I then searched for the error in the logs (depraced functions) and adjusted the init_.py.
Now it works again and I have a connection to the two go-e chargers.

I am not a good programmer, so use the modified file at your own risk!

"""go-eCharger integration"""

import voluptuous as vol
import ipaddress
import logging
from datetime import timedelta
import homeassistant.helpers.config_validation as cv
from homeassistant.const import CONF_HOST, CONF_SCAN_INTERVAL
from homeassistant.core import valid_entity_id
from homeassistant import core
from homeassistant.helpers.discovery import async_load_platform
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator

from .const import DOMAIN, CONF_SERIAL, CONF_CHARGERS, CONF_CORRECTION_FACTOR, CONF_NAME, CHARGER_API
from goecharger import GoeCharger

_LOGGER = logging.getLogger(__name__)

ABSOLUTE_MAX_CURRENT = "charger_absolute_max_current"
SET_CABLE_LOCK_MODE_ATTR = "cable_lock_mode"
SET_ABSOLUTE_MAX_CURRENT_ATTR = "charger_absolute_max_current"
CHARGE_LIMIT = "charge_limit"
SET_MAX_CURRENT_ATTR = "max_current"
CHARGER_NAME_ATTR = "charger_name"

MIN_UPDATE_INTERVAL = timedelta(seconds=10)
DEFAULT_UPDATE_INTERVAL = timedelta(seconds=20)

CONFIG_SCHEMA = vol.Schema(
    {
        DOMAIN: vol.Schema(
            {
                vol.Optional(CONF_CHARGERS, default=[]): vol.All([
                    cv.ensure_list, [
                        vol.All({
                            vol.Required(CONF_NAME): vol.All(cv.string),
                            vol.Required(CONF_HOST): vol.All(ipaddress.ip_address, cv.string),
                            vol.Optional(
                                CONF_CORRECTION_FACTOR, default="1.0"
                            ): vol.All(cv.string),
                        })
                    ]
                ]),
                vol.Optional(CONF_HOST): vol.All(ipaddress.ip_address, cv.string),
                vol.Optional(CONF_SERIAL): vol.All(cv.string),
                vol.Optional(
                    CONF_CORRECTION_FACTOR, default="1.0"
                ): vol.All(cv.string),
                vol.Optional(
                    CONF_SCAN_INTERVAL, default=DEFAULT_UPDATE_INTERVAL
                ): vol.All(cv.time_period, vol.Clamp(min=MIN_UPDATE_INTERVAL)),
            }
        )
    },
    extra=vol.ALLOW_EXTRA,
)


async def async_setup_entry(hass, config):
    _LOGGER.debug("Setting up entry for go-eCharger")
    
    name = config.data[CONF_NAME]
    charger = GoeCharger(config.data[CONF_HOST])
    hass.data[DOMAIN]["api"][name] = charger

    await hass.data[DOMAIN]["coordinator"].async_refresh()

    # Neue Methode verwenden
    await hass.config_entries.async_forward_entry_setups(config, ["sensor", "switch"])
    return True



async def async_unload_entry(hass, entry):
    _LOGGER.debug(f"Unloading charger '{entry.data[CONF_NAME]}")
    hass.data[DOMAIN]["api"].pop(entry.data[CONF_NAME])
    return True


class ChargerStateFetcher:
    def __init__(self, hass):
        self._hass = hass

    async def fetch_states(self):
        """Fetches the state of all chargers."""
        _LOGGER.debug('Updating status...')
        
        goeChargers = self._hass.data[DOMAIN]["api"]
        
        # Erstellen einer statischen Liste der Schlüssel, um Änderungen zu vermeiden
        charger_names = list(goeChargers.keys())

        data = self.coordinator.data if self.coordinator and self.coordinator.data else {}
        
        for chargerName in charger_names:
            _LOGGER.debug(f"Fetching update for charger '{chargerName}'...")
            try:
                fetchedStatus = await self._hass.async_add_executor_job(
                    goeChargers[chargerName].requestStatus
                )
                if fetchedStatus.get("car_status", "unknown") != "unknown":
                    data[chargerName] = fetchedStatus
                else:
                    _LOGGER.error(f"Unable to fetch state for charger '{chargerName}'")
            except Exception as e:
                _LOGGER.error(f"Error fetching state for charger '{chargerName}': {e}")
        
        return data



async def async_setup(hass: core.HomeAssistant, config: dict) -> bool:
    """Set up go-eCharger platforms and services."""

    _LOGGER.debug("async_setup")
    scan_interval = DEFAULT_UPDATE_INTERVAL

    hass.data[DOMAIN] = {}
    chargerApi = {}
    chargers = []
    if DOMAIN in config:
        scan_interval = config[DOMAIN].get(CONF_SCAN_INTERVAL, DEFAULT_UPDATE_INTERVAL)

        host = config[DOMAIN].get(CONF_HOST, False)
        serial = config[DOMAIN].get(CONF_SERIAL, "unknown")
        try:
            correctionFactor = float(config[DOMAIN].get(CONF_CORRECTION_FACTOR, "1.0"))
        except:
            _LOGGER.warn("can't convert correctionFactor, using 1.0")
            correctionFactor = 1.0

        chargers = config[DOMAIN].get(CONF_CHARGERS, [])

        if host:
            if not serial:
                goeCharger = GoeCharger(host)
                status = goeCharger.requestStatus()
                serial = status["serial_number"]
            chargers.append([{CONF_NAME: serial, CONF_HOST: host, CONF_CORRECTION_FACTOR: correctionFactor}])
        _LOGGER.debug(repr(chargers))

        for charger in chargers:
            chargerName = charger[0][CONF_NAME]
            host = charger[0][CONF_HOST]
            _LOGGER.debug(f"charger: '{chargerName}' host: '{host}' ")

            goeCharger = GoeCharger(host)
            chargerApi[chargerName] = goeCharger

    hass.data[DOMAIN]["api"] = chargerApi

    chargeStateFecher = ChargerStateFetcher(hass)

    coordinator = DataUpdateCoordinator(
        hass,
        _LOGGER,
        name=DOMAIN,
        update_method=chargeStateFecher.fetch_states,
        update_interval=scan_interval,
    )
    chargeStateFecher.coordinator = coordinator

    hass.data[DOMAIN]["coordinator"] = coordinator

    await coordinator.async_refresh()

    async def async_handle_set_max_current(call):
        """Handle the service call to set the absolute max current."""
        chargerNameInput = call.data.get(CHARGER_NAME_ATTR, '')

        maxCurrentInput = call.data.get(
            SET_MAX_CURRENT_ATTR, 32  # TODO: dynamic based on chargers absolute_max-setting
        )
        maxCurrent = 0
        if isinstance(maxCurrentInput, str):
            if maxCurrentInput.isnumeric():
                maxCurrent = int(maxCurrentInput)
            elif valid_entity_id(maxCurrentInput):
                maxCurrent = int(hass.states.get(maxCurrentInput).state)
            else:
                _LOGGER.error(
                    "No valid value for '%s': %s", SET_MAX_CURRENT_ATTR, maxCurrent
                )
                return
        else:
            maxCurrent = maxCurrentInput

        if maxCurrent < 6:
            maxCurrent = 6
        if maxCurrent > 32:
            maxCurrent = 32

        if len(chargerNameInput) > 0:
            _LOGGER.debug(f"set max_current for charger '{chargerNameInput}' to {maxCurrent}")
            try:
                await hass.async_add_executor_job(hass.data[DOMAIN]["api"][chargerNameInput].setTmpMaxCurrent, maxCurrent)
            except KeyError:
                _LOGGER.error(f"Charger with name '{chargerName}' not found!")

        else:
            for charger in hass.data[DOMAIN]["api"].keys():
                try:
                    _LOGGER.debug(f"set max_current for charger '{charger}' to {maxCurrent}")
                    await hass.async_add_executor_job(hass.data[DOMAIN]["api"][charger].setTmpMaxCurrent, maxCurrent)
                except KeyError:
                    _LOGGER.error(f"Charger with name '{chargerName}' not found!")

        await hass.data[DOMAIN]["coordinator"].async_refresh()

    async def async_handle_set_absolute_max_current(call):
        """Handle the service call to set the absolute max current."""
        chargerNameInput = call.data.get(CHARGER_NAME_ATTR, '')
        absoluteMaxCurrentInput = call.data.get(SET_ABSOLUTE_MAX_CURRENT_ATTR, 16)
        if isinstance(absoluteMaxCurrentInput, str):
            if absoluteMaxCurrentInput.isnumeric():
                absoluteMaxCurrent = int(absoluteMaxCurrentInput)
            elif valid_entity_id(absoluteMaxCurrentInput):
                absoluteMaxCurrent = int(hass.states.get(absoluteMaxCurrentInput).state)
            else:
                _LOGGER.error(
                    "No valid value for '%s': %s",
                    SET_ABSOLUTE_MAX_CURRENT_ATTR,
                    absoluteMaxCurrentInput,
                )
                return
        else:
            absoluteMaxCurrent = absoluteMaxCurrentInput

        if absoluteMaxCurrent < 6:
            absoluteMaxCurrent = 6
        if absoluteMaxCurrent > 32:
            absoluteMaxCurrent = 32

        if len(chargerNameInput) > 0:
            _LOGGER.debug(f"set absolute_max_current for charger '{chargerNameInput}' to {absoluteMaxCurrent}")
            try:
                await hass.async_add_executor_job(
                    hass.data[DOMAIN]["api"][chargerNameInput].setAbsoluteMaxCurrent, absoluteMaxCurrent
                )
            except KeyError:
                _LOGGER.error(f"Charger with name '{chargerName}' not found!")

        else:
            for charger in hass.data[DOMAIN]["api"].keys():
                try:
                    _LOGGER.debug(f"set absolute_max_current for charger '{charger}' to {absoluteMaxCurrent}")
                    await hass.async_add_executor_job(
                        hass.data[DOMAIN]["api"][charger].setAbsoluteMaxCurrent, absoluteMaxCurrent
                    )
                except KeyError:
                    _LOGGER.error(f"Charger with name '{chargerName}' not found!")

        await hass.data[DOMAIN]["coordinator"].async_refresh()

    async def async_handle_set_cable_lock_mode(call):
        """Handle the service call to set the absolute max current."""
        chargerNameInput = call.data.get(CHARGER_NAME_ATTR, '')
        cableLockModeInput = call.data.get(SET_CABLE_LOCK_MODE_ATTR, 0)
        if isinstance(cableLockModeInput, str):
            if cableLockModeInput.isnumeric():
                cableLockMode = int(cableLockModeInput)
            elif valid_entity_id(cableLockModeInput):
                cableLockMode = int(hass.states.get(cableLockModeInput).state)
            else:
                _LOGGER.error(
                    "No valid value for '%s': %s",
                    SET_CABLE_LOCK_MODE_ATTR,
                    cableLockModeInput,
                )
                return
        else:
            cableLockMode = cableLockModeInput

        cableLockModeEnum = GoeCharger.CableLockMode.UNLOCKCARFIRST
        if cableLockModeInput == 1:
            cableLockModeEnum = GoeCharger.CableLockMode.AUTOMATIC
        if cableLockMode >= 2:
            cableLockModeEnum = GoeCharger.CableLockMode.LOCKED

        if len(chargerNameInput) > 0:
            _LOGGER.debug(f"set set_cable_lock_mode for charger '{chargerNameInput}' to {cableLockModeEnum}")
            try:
                await hass.async_add_executor_job(
                    hass.data[DOMAIN]["api"][chargerNameInput].setCableLockMode, cableLockModeEnum
                )
            except KeyError:
                _LOGGER.error(f"Charger with name '{chargerName}' not found!")

        else:
            for charger in hass.data[DOMAIN]["api"].keys():
                try:
                    _LOGGER.debug(f"set set_cable_lock_mode for charger '{charger}' to {cableLockModeEnum}")
                    await hass.async_add_executor_job(hass.data[DOMAIN]["api"][charger].setCableLockMode, cableLockModeEnum)
                except KeyError:
                    _LOGGER.error(f"Charger with name '{chargerName}' not found!")

        await hass.data[DOMAIN]["coordinator"].async_refresh()

    async def async_handle_set_charge_limit(call):
        """Handle the service call to set charge limit."""
        chargerNameInput = call.data.get(CHARGER_NAME_ATTR, '')
        chargeLimitInput = call.data.get(CHARGE_LIMIT, 0.0)
        if isinstance(chargeLimitInput, str):
            if chargeLimitInput.isnumeric():
                chargeLimit = float(chargeLimitInput)
            elif valid_entity_id(chargeLimitInput):
                chargeLimit = float(hass.states.get(chargeLimitInput).state)
            else:
                _LOGGER.error(
                    "No valid value for '%s': %s", CHARGE_LIMIT, chargeLimitInput
                )
                return
        else:
            chargeLimit = chargeLimitInput

        if chargeLimit < 0:
            chargeLimit = 0

        if len(chargerNameInput) > 0:
            _LOGGER.debug(f"set set_charge_limit for charger '{chargerNameInput}' to {chargeLimit}")
            try:
                await hass.async_add_executor_job(hass.data[DOMAIN]["api"][chargerNameInput].setChargeLimit, chargeLimit)
            except KeyError:
                _LOGGER.error(f"Charger with name '{chargerName}' not found!")

        else:
            for charger in hass.data[DOMAIN]["api"].keys():
                try:
                    _LOGGER.debug(f"set set_charge_limit for charger '{charger}' to {chargeLimit}")
                    await hass.async_add_executor_job(hass.data[DOMAIN]["api"][charger].setChargeLimit, chargeLimit)
                except KeyError:
                    _LOGGER.error(f"Charger with name '{chargerName}' not found!")

        await hass.data[DOMAIN]["coordinator"].async_refresh()

    hass.services.async_register(DOMAIN, "set_max_current", async_handle_set_max_current)
    hass.services.async_register(
        DOMAIN, "set_absolute_max_current", async_handle_set_absolute_max_current
    )
    hass.services.async_register(DOMAIN, "set_cable_lock_mode", async_handle_set_cable_lock_mode)
    hass.services.async_register(DOMAIN, "set_charge_limit", async_handle_set_charge_limit)

    hass.async_create_task(async_load_platform(
        hass, "sensor", DOMAIN, {CONF_CHARGERS: chargers, CHARGER_API: chargerApi}, config)
    )
    hass.async_create_task(async_load_platform(
        hass, "switch", DOMAIN, {CONF_CHARGERS: chargers, CHARGER_API: chargerApi}, config)
    )

    return True

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests