File tree Expand file tree Collapse file tree 4 files changed +27
-4
lines changed
custom_components/fronius_local Expand file tree Collapse file tree 4 files changed +27
-4
lines changed Original file line number Diff line number Diff line change 88from homeassistant .helpers import httpx_client
99
1010from . import auth
11+ from . import const as fl
1112
1213if TYPE_CHECKING :
1314 from homeassistant .core import HomeAssistant
@@ -23,6 +24,18 @@ def meta(item: str) -> str:
2324 return "_" + item + "_meta"
2425
2526
27+ def get_type (data : dict , key : str ) -> Platform :
28+ """Get type of sensor."""
29+ if key in fl .FILTER :
30+ return Platform .SENSOR
31+ if (
32+ data [meta (key )]["writePermission" ]["RoleCustomer" ]
33+ and data [meta (key )]["displayType" ] == "Integer"
34+ ):
35+ return Platform .NUMBER
36+ return Platform .SENSOR
37+
38+
2639class FroniusApiClient :
2740 """Fronius auth class."""
2841
@@ -67,10 +80,7 @@ async def async_get_data(self) -> dict:
6780 battery = {
6881 "conf_batteries_" + k : {
6982 "value" : v ,
70- "type" : Platform .NUMBER
71- if battery [meta (k )]["writePermission" ]["RoleCustomer" ]
72- and battery [meta (k )]["displayType" ] == "Integer"
73- else Platform .SENSOR ,
83+ "type" : get_type (battery , k ),
7484 "name" : (await self .async_get_translation (self .hass .config .language ))[
7585 "BATTERIES"
7686 ].get (k )
Original file line number Diff line number Diff line change 1010LOGGER : logging .Logger = logging .getLogger (DOMAIN )
1111
1212UPDATE_INTERVAL = 9
13+
14+ FILTER = [
15+ "PV_PEAK_POWER" ,
16+ "supportSoc" ,
17+ "supportSocHysteresisMin" ,
18+ "supportSocHysteresisEnergy" ,
19+ ]
Original file line number Diff line number Diff line change @@ -49,6 +49,9 @@ def __init__(
4949 """Initialize the sensor class."""
5050 super ().__init__ (coordinator , unique_id )
5151 self .entity_description = entity_description
52+ self .entity_id = "number." + unique_id
53+
54+ self .extra_state_attributes = {"id" : self .data ()["id" ]}
5255
5356 self .mode = "box"
5457 self .native_unit_of_measurement = self .data ()["unit" ]
Original file line number Diff line number Diff line change @@ -54,6 +54,9 @@ def __init__(
5454 """Initialize the sensor class."""
5555 super ().__init__ (coordinator , unique_id )
5656 self .entity_description = entity_description
57+ self .entity_id = "sensor." + unique_id
58+
59+ self .extra_state_attributes = {"id" : self .data ()["id" ]}
5760
5861 if self .data ()["unit" ] is not None :
5962 self .native_unit_of_measurement = self .data ()["unit" ]
You can’t perform that action at this time.
0 commit comments