From bfa65353c41226587eee15726d4b77fc654f240e Mon Sep 17 00:00:00 2001 From: Marc-Philip Date: Mon, 19 Aug 2024 21:45:11 +0200 Subject: [PATCH 1/6] adapt validation --- .github/workflows/hassfest.yaml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/hassfest.yaml b/.github/workflows/hassfest.yaml index 18c7d19..07d1dda 100644 --- a/.github/workflows/hassfest.yaml +++ b/.github/workflows/hassfest.yaml @@ -10,5 +10,5 @@ jobs: validate: runs-on: "ubuntu-latest" steps: - - uses: "actions/checkout@v2" + - uses: "actions/checkout@v3" - uses: home-assistant/actions/hassfest@master diff --git a/README.md b/README.md index 732b80c..c6bd887 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Home Assistant integration for the go-eCharger (WIP) [![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg)](https://github.com/custom-components/hacs) -[![Validate with hassfest](https://github.com/cathiele/homeassistant-goecharger/actions/workflows/hassfest.yaml/badge.svg?branch=main)](https://github.com/cathiele/homeassistant-goecharger/actions/workflows/hassfest.yaml) +[![Validate with hassfest](https://github.com/mpw96/homeassistant-goecharger/actions/workflows/hassfest.yaml/badge.svg?branch=main)](https://github.com/mpw96/homeassistant-goecharger/actions/workflows/hassfest.yaml) Integration for Homeassistant to view and Control the go-eCharger for electric Vehicles via the local ip-interface via API Version 1. In newer chargers the V1 API has to be enabled via the App first. From da47d7f85e0bf34e54d2ffe5a82808ff3d4cbef5 Mon Sep 17 00:00:00 2001 From: Marc-Philip Date: Mon, 19 Aug 2024 22:18:30 +0200 Subject: [PATCH 2/6] fix deprecated units --- custom_components/goecharger/sensor.py | 71 +++++++++++++------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/custom_components/goecharger/sensor.py b/custom_components/goecharger/sensor.py index 7c90191..a3a3b24 100644 --- a/custom_components/goecharger/sensor.py +++ b/custom_components/goecharger/sensor.py @@ -1,8 +1,13 @@ """Platform for go-eCharger sensor integration.""" import logging from homeassistant.const import ( - TEMP_CELSIUS, - ENERGY_KILO_WATT_HOUR + PERCENTAGE, + UnitOfElectricCurrent, + UnitOfElectricPotential, + UnitOfEnergy, + UnitOfPower, + UnitOfTemperature, + ) from homeassistant import core, config_entries @@ -16,46 +21,42 @@ from .const import CONF_CHARGERS, DOMAIN, CONF_NAME, CONF_CORRECTION_FACTOR -AMPERE = 'A' -VOLT = 'V' -POWER_KILO_WATT = 'kW' CARD_ID = 'Card ID' -PERCENT = '%' _LOGGER = logging.getLogger(__name__) _sensorUnits = { - 'charger_temp': {'unit': TEMP_CELSIUS, 'name': 'Charger Temp'}, - 'charger_temp0': {'unit': TEMP_CELSIUS, 'name': 'Charger Temp 0'}, - 'charger_temp1': {'unit': TEMP_CELSIUS, 'name': 'Charger Temp 1'}, - 'charger_temp2': {'unit': TEMP_CELSIUS, 'name': 'Charger Temp 2'}, - 'charger_temp3': {'unit': TEMP_CELSIUS, 'name': 'Charger Temp 3'}, - 'p_l1': {'unit': POWER_KILO_WATT, 'name': 'Power L1'}, - 'p_l2': {'unit': POWER_KILO_WATT, 'name': 'Power L2'}, - 'p_l3': {'unit': POWER_KILO_WATT, 'name': 'Power L3'}, - 'p_n': {'unit': POWER_KILO_WATT, 'name': 'Power N'}, - 'p_all': {'unit': POWER_KILO_WATT, 'name': 'Power All'}, - 'current_session_charged_energy': {'unit': ENERGY_KILO_WATT_HOUR, 'name': 'Current Session charged'}, - 'current_session_charged_energy_corrected': {'unit': ENERGY_KILO_WATT_HOUR, 'name': 'Current Session charged corrected'}, - 'energy_total': {'unit': ENERGY_KILO_WATT_HOUR, 'name': 'Total Charged'}, - 'energy_total_corrected': {'unit': ENERGY_KILO_WATT_HOUR, 'name': 'Total Charged corrected'}, - 'charge_limit': {'unit': ENERGY_KILO_WATT_HOUR, 'name': 'Charge limit'}, - 'u_l1': {'unit': VOLT, 'name': 'Voltage L1'}, - 'u_l2': {'unit': VOLT, 'name': 'Voltage L2'}, - 'u_l3': {'unit': VOLT, 'name': 'Voltage L3'}, - 'u_n': {'unit': VOLT, 'name': 'Voltage N'}, - 'i_l1': {'unit': AMPERE, 'name': 'Current L1'}, - 'i_l2': {'unit': AMPERE, 'name': 'Current L2'}, - 'i_l3': {'unit': AMPERE, 'name': 'Current L3'}, - 'charger_max_current': {'unit': AMPERE, 'name': 'Charger max current setting'}, - 'charger_absolute_max_current': {'unit': AMPERE, 'name': 'Charger absolute max current setting'}, + 'charger_temp': {'unit': UnitOfTemperature.CELSIUS, 'name': 'Charger Temp'}, + 'charger_temp0': {'unit': UnitOfTemperature.CELSIUS, 'name': 'Charger Temp 0'}, + 'charger_temp1': {'unit': UnitOfTemperature.CELSIUS, 'name': 'Charger Temp 1'}, + 'charger_temp2': {'unit': UnitOfTemperature.CELSIUS, 'name': 'Charger Temp 2'}, + 'charger_temp3': {'unit': UnitOfTemperature.CELSIUS, 'name': 'Charger Temp 3'}, + 'p_l1': {'unit': UnitOfPower.KILO_WATT, 'name': 'Power L1'}, + 'p_l2': {'unit': UnitOfPower.KILO_WATT, 'name': 'Power L2'}, + 'p_l3': {'unit': UnitOfPower.KILO_WATT, 'name': 'Power L3'}, + 'p_n': {'unit': UnitOfPower.KILO_WATT, 'name': 'Power N'}, + 'p_all': {'unit': UnitOfPower.KILO_WATT, 'name': 'Power All'}, + 'current_session_charged_energy': {'unit': UnitOfEnergy.KILO_WATT_HOUR, 'name': 'Current Session charged'}, + 'current_session_charged_energy_corrected': {'unit': UnitOfEnergy.KILO_WATT_HOUR, 'name': 'Current Session charged corrected'}, + 'energy_total': {'unit': UnitOfEnergy.KILO_WATT_HOUR, 'name': 'Total Charged'}, + 'energy_total_corrected': {'unit': UnitOfEnergy.KILO_WATT_HOUR, 'name': 'Total Charged corrected'}, + 'charge_limit': {'unit': UnitOfEnergy.KILO_WATT_HOUR, 'name': 'Charge limit'}, + 'u_l1': {'unit': UnitOfElectricPotential.VOLT, 'name': 'Voltage L1'}, + 'u_l2': {'unit': UnitOfElectricPotential.VOLT, 'name': 'Voltage L2'}, + 'u_l3': {'unit': UnitOfElectricPotential.VOLT, 'name': 'Voltage L3'}, + 'u_n': {'unit': UnitOfElectricPotential.VOLT, 'name': 'Voltage N'}, + 'i_l1': {'unit': UnitOfElectricCurrent.AMPERE, 'name': 'Current L1'}, + 'i_l2': {'unit': UnitOfElectricCurrent.AMPERE, 'name': 'Current L2'}, + 'i_l3': {'unit': UnitOfElectricCurrent.AMPERE, 'name': 'Current L3'}, + 'charger_max_current': {'unit': UnitOfElectricCurrent.AMPERE, 'name': 'Charger max current setting'}, + 'charger_absolute_max_current': {'unit': UnitOfElectricCurrent.AMPERE, 'name': 'Charger absolute max current setting'}, 'cable_lock_mode': {'unit': '', 'name': 'Cable lock mode'}, - 'cable_max_current': {'unit': AMPERE, 'name': 'Cable max current'}, + 'cable_max_current': {'unit': UnitOfElectricCurrent.AMPERE, 'name': 'Cable max current'}, 'unlocked_by_card': {'unit': CARD_ID, 'name': 'Card used'}, - 'lf_l1': {'unit': PERCENT, 'name': 'Power factor L1'}, - 'lf_l2': {'unit': PERCENT, 'name': 'Power factor L2'}, - 'lf_l3': {'unit': PERCENT, 'name': 'Power factor L3'}, - 'lf_n': {'unit': PERCENT, 'name': 'Loadfactor N'}, + 'lf_l1': {'unit': PERCENTAGE, 'name': 'Power factor L1'}, + 'lf_l2': {'unit': PERCENTAGE, 'name': 'Power factor L2'}, + 'lf_l3': {'unit': PERCENTAGE, 'name': 'Power factor L3'}, + 'lf_n': {'unit': PERCENTAGE, 'name': 'Loadfactor N'}, 'car_status': {'unit': '', 'name': 'Status'} } From f50984e8c769c6a38646709a7b71d0272f0565cb Mon Sep 17 00:00:00 2001 From: Marc-Philip Date: Mon, 19 Aug 2024 22:24:47 +0200 Subject: [PATCH 3/6] revert repo change --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c6bd887..732b80c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Home Assistant integration for the go-eCharger (WIP) [![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg)](https://github.com/custom-components/hacs) -[![Validate with hassfest](https://github.com/mpw96/homeassistant-goecharger/actions/workflows/hassfest.yaml/badge.svg?branch=main)](https://github.com/mpw96/homeassistant-goecharger/actions/workflows/hassfest.yaml) +[![Validate with hassfest](https://github.com/cathiele/homeassistant-goecharger/actions/workflows/hassfest.yaml/badge.svg?branch=main)](https://github.com/cathiele/homeassistant-goecharger/actions/workflows/hassfest.yaml) Integration for Homeassistant to view and Control the go-eCharger for electric Vehicles via the local ip-interface via API Version 1. In newer chargers the V1 API has to be enabled via the App first. From 7e07e951d4de45c9e97a5993bb641761f959d39f Mon Sep 17 00:00:00 2001 From: Marc-Philip Date: Mon, 19 Aug 2024 22:25:30 +0200 Subject: [PATCH 4/6] prvoke error to check checks --- custom_components/goecharger/sensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/goecharger/sensor.py b/custom_components/goecharger/sensor.py index a3a3b24..a64333f 100644 --- a/custom_components/goecharger/sensor.py +++ b/custom_components/goecharger/sensor.py @@ -1,7 +1,7 @@ """Platform for go-eCharger sensor integration.""" import logging from homeassistant.const import ( - PERCENTAGE, + PERCENTAGEX, UnitOfElectricCurrent, UnitOfElectricPotential, UnitOfEnergy, From f2451003b1a80db51bde8da458831deac081a0aa Mon Sep 17 00:00:00 2001 From: Marc-Philip Date: Mon, 19 Aug 2024 22:28:18 +0200 Subject: [PATCH 5/6] Revert "prvoke error to check checks" This reverts commit 7e07e951d4de45c9e97a5993bb641761f959d39f. --- custom_components/goecharger/sensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/goecharger/sensor.py b/custom_components/goecharger/sensor.py index a64333f..a3a3b24 100644 --- a/custom_components/goecharger/sensor.py +++ b/custom_components/goecharger/sensor.py @@ -1,7 +1,7 @@ """Platform for go-eCharger sensor integration.""" import logging from homeassistant.const import ( - PERCENTAGEX, + PERCENTAGE, UnitOfElectricCurrent, UnitOfElectricPotential, UnitOfEnergy, From e12890a941e8480fb2041fad41d131e39edfdb93 Mon Sep 17 00:00:00 2001 From: Marc-Philip Date: Mon, 19 Aug 2024 22:47:55 +0200 Subject: [PATCH 6/6] state class --- custom_components/goecharger/sensor.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/custom_components/goecharger/sensor.py b/custom_components/goecharger/sensor.py index a3a3b24..9f3e20c 100644 --- a/custom_components/goecharger/sensor.py +++ b/custom_components/goecharger/sensor.py @@ -7,15 +7,14 @@ UnitOfEnergy, UnitOfPower, UnitOfTemperature, - ) from homeassistant import core, config_entries from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.components.sensor import ( - STATE_CLASS_TOTAL_INCREASING, SensorDeviceClass, - SensorEntity + SensorEntity, + SensorStateClass ) @@ -61,10 +60,10 @@ } _sensorStateClass = { - 'energy_total': STATE_CLASS_TOTAL_INCREASING, - 'energy_total_corrected': STATE_CLASS_TOTAL_INCREASING, - 'current_session_charged_energy': STATE_CLASS_TOTAL_INCREASING, - 'current_session_charged_energy_corrected': STATE_CLASS_TOTAL_INCREASING + 'energy_total': SensorStateClass.TOTAL_INCREASING, + 'energy_total_corrected': SensorStateClass.TOTAL_INCREASING, + 'current_session_charged_energy': SensorStateClass.TOTAL_INCREASING, + 'current_session_charged_energy_corrected': SensorStateClass.TOTAL_INCREASING } _sensorDeviceClass = {