Skip to content

Commit edf3ead

Browse files
committed
binary sensors for go-eController paired/connected
1 parent 6d220d4 commit edf3ead

File tree

8 files changed

+43
-14
lines changed

8 files changed

+43
-14
lines changed

custom_components/goecharger_api2/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
from homeassistant.const import CONF_HOST, CONF_TYPE, CONF_ID, CONF_SCAN_INTERVAL, CONF_MODE, CONF_TOKEN
1111
from homeassistant.core import HomeAssistant, Event, SupportsResponse
1212
from homeassistant.exceptions import ConfigEntryNotReady
13-
from homeassistant.helpers import config_validation as config_val, entity_registry as entity_reg, device_registry as device_reg
13+
from homeassistant.helpers import config_validation as config_val, entity_registry as entity_reg, \
14+
device_registry as device_reg
1415
from homeassistant.helpers.aiohttp_client import async_get_clientsession
1516
from homeassistant.helpers.entity import Entity, EntityDescription
1617
from homeassistant.helpers.typing import UNDEFINED, UndefinedType
@@ -303,7 +304,6 @@ async def read_versions(self):
303304
self._config_entry.data.get(CONF_HOST),
304305
self._config_entry.title)},
305306
"manufacturer": MANUFACTURER,
306-
"suggested_area": "Garage",
307307
"name": self._config_entry.title,
308308
"model": self._config_entry.data.get(CONF_TYPE),
309309
"sw_version": sw_version
@@ -319,7 +319,6 @@ async def read_versions(self):
319319
self._config_entry.data.get(CONF_TOKEN),
320320
self._config_entry.title)},
321321
"manufacturer": MANUFACTURER,
322-
"suggested_area": "Garage",
323322
"name": self._config_entry.title,
324323
"model": self._config_entry.data.get(CONF_TYPE),
325324
"sw_version": self.bridge._versions[Tag.FWV.key]

custom_components/goecharger_api2/binary_sensor.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ def is_on(self) -> bool | None:
4242
value = None
4343
if self.coordinator.data is not None:
4444
if self.data_key in self.coordinator.data:
45-
if self.entity_description.idx is not None:
45+
if self.entity_description.tuple_idx is not None and len(self.entity_description.tuple_idx) > 1:
46+
subKey1 = self.entity_description.tuple_idx[0]
47+
subKey2 = self.entity_description.tuple_idx[1]
48+
value = self.coordinator.data[self.data_key][subKey1][subKey2]
49+
elif self.entity_description.idx is not None:
4650
# hacking the CAR_CONNECT state... -> "car" > 1
4751
if self.data_key == Tag.CAR_CONNECTED.key:
4852
value = int(self.coordinator.data[self.data_key]) > 1
@@ -58,9 +62,10 @@ def is_on(self) -> bool | None:
5862
value = None
5963

6064
except IndexError:
61-
if self.entity_description.idx is not None:
62-
_LOGGER.debug(
63-
f"lc-key: {self.data_key.lower()} value: {value} idx: {self.entity_description.idx} -> {self.coordinator.data[self.data_key]}")
65+
if self.entity_description.tuple_idx is not None:
66+
_LOGGER.debug(f"lc-key: {self.data_key.lower()} value: {value} tuple_idx: {self.entity_description.tuple_idx} -> {self.coordinator.data[self.data_key]}")
67+
elif self.entity_description.idx is not None:
68+
_LOGGER.debug(f"lc-key: {self.data_key.lower()} value: {value} idx: {self.entity_description.idx} -> {self.coordinator.data[self.data_key]}")
6469
else:
6570
_LOGGER.debug(f"lc-key: {self.data_key.lower()} caused IndexError")
6671
value = None

custom_components/goecharger_api2/const.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from dataclasses import dataclass
21
from typing import Final
32

43
from custom_components.goecharger_api2.pygoecharger_ha.keys import Tag, IS_TRIGGER
@@ -38,6 +37,7 @@
3837

3938
class ExtBinarySensorEntityDescription(BinarySensorEntityDescription, frozen_or_thawed=True):
4039
idx: int | None = None
40+
tuple_idx: list | None = None
4141
icon_off: str | None = None
4242

4343

@@ -164,7 +164,25 @@ class ExtSwitchEntityDescription(SwitchEntityDescription, frozen_or_thawed=True)
164164
device_class=None,
165165
icon="mdi:ab-testing",
166166
entity_registry_enabled_default=False
167-
)
167+
),
168+
ExtBinarySensorEntityDescription(
169+
key=Tag.CTRLS.key,
170+
translation_key="ctrls_0_paired", # important! 'translation_key' must be allways lower case!!!
171+
tuple_idx=[0, 2],
172+
entity_category=EntityCategory.DIAGNOSTIC,
173+
device_class=None,
174+
icon="mdi:gamepad-square-outline",
175+
entity_registry_enabled_default=False
176+
),
177+
ExtBinarySensorEntityDescription(
178+
key=Tag.CTRLS.key,
179+
translation_key="ctrls_0_connected", # important! 'translation_key' must be allways lower case!!!
180+
tuple_idx=[0, 3],
181+
entity_category=EntityCategory.DIAGNOSTIC,
182+
device_class=None,
183+
icon="mdi:gamepad-square",
184+
entity_registry_enabled_default=False
185+
),
168186
]
169187
BUTTONS = [
170188
ExtButtonEntityDescription(

custom_components/goecharger_api2/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
"iot_class": "local_polling",
1212
"issue_tracker": "https://github.com/marq24/ha-goecharger-api2/issues",
1313
"requirements": [],
14-
"version": "2024.12.1"
14+
"version": "2025.0.1"
1515
}

custom_components/goecharger_api2/pygoecharger_ha/const.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
# rbt: is the reboot time - and "looks like", that all other timestamps use the rbt "as" start point
1313
FILTER_TIMES_ADDON: Final = ",rbt,fsptws,inva,lbp,lccfc,lccfi,lcctc,lfspt,lmsc,lpsc,lcs"
1414

15-
FILTER_ALL_STATES: Final = "acu,adi,amt,atp,awcp,car,cards,cbl,ccu,ccw,cdi,cll,cus,deltaa,deltap,err,eto,ffb,fhz,fsp,fsptws,inva,lbp,lccfc,lccfi,lcctc,lck,lfspt,lmsc,loa,lpsc,mcpea,mmp,modelStatus,nif,nrg,pakku,pgrid,pha,pnp,ppv,pvopt_averagePAkku,pvopt_averagePGrid,pvopt_averagePPv,pwm,rbc,rbt,rfb,rssi,rst,tlf,tls,tma,tpa,trx,wh,wsms,wst"
15+
FILTER_ALL_STATES: Final = "acu,adi,amt,atp,awcp,car,cards,cbl,ccu,ccw,cdi,cll,cus,ctrls,deltaa,deltap,err,eto,ffb,fhz,fsp,fsptws,inva,lbp,lccfc,lccfi,lcctc,lck,lfspt,lmsc,loa,lpsc,mcpea,mmp,modelStatus,nif,nrg,pakku,pgrid,pha,pnp,ppv,pvopt_averagePAkku,pvopt_averagePGrid,pvopt_averagePPv,pwm,rbc,rbt,rfb,rssi,rst,tlf,tls,tma,tpa,trx,wh,wsms,wst"
1616
FILTER_ALL_CONFIG: Final = "acp,acs,ama,amp,ara,ate,att,awc,awe,awp,bac,cards,cch,cco,cfi,cid,clp,cmse,cwc,cwe,dwo,esk,fmt,fna,frc,frm,fst,fup,fzf,hsa,lbr,lmo,loe,lof,log,lop,lot,loty,lse,map,mca,mci,mcpd,mptwt,mpwst,nmo,pgt,po,psh,psm,psmd,rdbf,rdbs,rdef,rdes,rdre,rdpl,sch_satur,sch_sund,sch_week,sdp,sh,spl3,su,sua,sumd,tds,tof,upo,ust,zfo"
1717

1818
FILTER_NOT_USED: Final = "mcc,mcca,mce,mcr,mcs,mcu,men,mlr,mlra,mqcn,mqg,mqss,msb,msp,msr,mtp,ocppai,ocppi,rdbfe,rdbse,rdefe,rdese,rdree,rdple"
1919

2020
# found api-keys that are not documented (yet) ?!
21-
FILTER_UNKNOWN_COMON: Final = "aus,ccd,cle,clea,cmmr,cmp,cms,csa,ct,ctrls,data,di1,die,dii,dll,hai,hla,isgo,la1,la3,lbl,lopr,lrc,lri,lrr,lwf,ocppao,ocppcm,ocppcs,ocppf,ocppla,ocpplo,ocppti,pdi,pgr,rde,smd,tcl,tsi,tzt,ufa,ufe,ufm,ufs,wbw,wda,wsl"
21+
FILTER_UNKNOWN_COMON: Final = "aus,ccd,cle,clea,cmmr,cmp,cms,csa,ct,data,di1,die,dii,dll,hai,hla,isgo,la1,la3,lbl,lopr,lrc,lri,lrr,lwf,ocppao,ocppcm,ocppcs,ocppf,ocppla,ocpplo,ocppti,pdi,pgr,rde,smd,tcl,tsi,tzt,ufa,ufe,ufm,ufs,wbw,wda,wsl"
2222

2323
FILTER_UNKNOWN_FW59_X_BETA: Final = "bar,dsrc,evt,gmtr,gsa,lto,mhe,mht,ocppdp,ocppmp,ocpptp,orsch,pco,rdbfe,rdbse,rdefe,rdese,rdple,rdree,rmaf,rmav,rmif,rmiv,rsa,rsre,rsrr,tab"
2424
FILTER_UNKNOWN_FW56_2_BETA: Final = "bar,gmtr,gsa,mhe,mht,pco,rmaf,rmav,rmif,rmiv,rsa,rsre,rsrr"

custom_components/goecharger_api2/pygoecharger_ha/keys.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ def __str__(self):
100100
CUS = ApiKey(key="cus", cat=CAT.STATUS)
101101
# cloud websocket enabled"
102102
CWE = ApiKey(key="cwe", cat=CAT.CONFIG, writeable=True)
103+
# information about a paired and connected go-eController
104+
# [see https://github.com/marq24/ha-goecharger-api2/discussions/34]
105+
CTRLS = ApiKey(key="ctrls", cat=CAT.STATUS)
103106
# set this to 0-9 to clear card (erases card name, energy and rfid id)
104107
DEL = ApiKey(key="del", cat=CAT.OTHER, writeable=True, writeonly=True)
105108
# deltaA

custom_components/goecharger_api2/translations/de.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@
9494
"esk": {"name": "Gesetzte Lademenge kWh (Anzeige)"},
9595
"fsp": {"name": "1-phasiges Laden erzwingen"},
9696
"tlf": {"name": "Test-Ladung abgeschlossen"},
97-
"tls": {"name": "Test-Ladung gestartet"}
97+
"tls": {"name": "Test-Ladung gestartet"},
98+
"ctrls_0_paired": {"name": "go-eController gepaart"},
99+
"ctrls_0_connected": {"name": "go-eController verbunden"}
98100
},
99101
"button": {
100102
"rst": {"name": "go-e Neustarten"},

custom_components/goecharger_api2/translations/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@
9494
"esk": {"name": "energy set kwh (only stored for app)"},
9595
"fsp": {"name": "Force single phase"},
9696
"tlf": {"name": "Test charging finished"},
97-
"tls": {"name": "Test charging started"}
97+
"tls": {"name": "Test charging started"},
98+
"ctrls_0_paired": {"name": "go-eController paired"},
99+
"ctrls_0_connected": {"name": "go-eController connected"}
98100
},
99101
"button": {
100102
"rst": {"name": "Restart go-e device"},

0 commit comments

Comments
 (0)