Skip to content

Commit

Permalink
OMG!
Browse files Browse the repository at this point in the history
added 'wallbox_min_charging_current' & 'wallbox_set_icmax'
  • Loading branch information
marq24 committed Oct 4, 2023
1 parent 7bec88f commit a2af50d
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 7 deletions.
2 changes: 1 addition & 1 deletion custom_components/senec/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(self, hass: HomeAssistant, session, config_entry):
self.senec = Inverter(self._host, websession=session)

# WEB-API Version...
if CONF_TYPE in config_entry.data and config_entry.data[CONF_TYPE] == CONF_SYSTYPE_WEB:
elif CONF_TYPE in config_entry.data and config_entry.data[CONF_TYPE] == CONF_SYSTYPE_WEB:
self._host = "mein-senec.de"

a_master_plant_number = 0
Expand Down
4 changes: 2 additions & 2 deletions custom_components/senec/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities):
coordinator = hass.data[DOMAIN][config_entry.entry_id]
if (CONF_TYPE in config_entry.data and config_entry.data[CONF_TYPE] == CONF_SYSTYPE_INVERTER):
if CONF_TYPE in config_entry.data and config_entry.data[CONF_TYPE] == CONF_SYSTYPE_INVERTER:
_LOGGER.info("No binary_sensors for Inverters...")
if (CONF_TYPE in config_entry.data and config_entry.data[CONF_TYPE] == CONF_SYSTYPE_WEB):
elif CONF_TYPE in config_entry.data and config_entry.data[CONF_TYPE] == CONF_SYSTYPE_WEB:
_LOGGER.info("No binary_sensors for WebPortal...")
else:
entities = []
Expand Down
80 changes: 80 additions & 0 deletions custom_components/senec/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -1847,6 +1847,26 @@ class ExtBinarySensorEntityDescription(BinarySensorEntityDescription):
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.MEASUREMENT,
),
ExtSensorEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
entity_registry_enabled_default=False,
key="wallbox_min_charging_current",
name="Wallbox MIN charging current",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
icon="mdi:current-dc",
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.MEASUREMENT,
),
ExtSensorEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
entity_registry_enabled_default=False,
key="wallbox_set_icmax",
name="Wallbox set ICMAX",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
icon="mdi:current-dc",
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.MEASUREMENT,
),

ExtSensorEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
Expand Down Expand Up @@ -1906,6 +1926,26 @@ class ExtBinarySensorEntityDescription(BinarySensorEntityDescription):
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.MEASUREMENT,
),
ExtSensorEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
entity_registry_enabled_default=False,
key="wallbox_2_min_charging_current",
name="Wallbox II MIN charging current",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
icon="mdi:current-dc",
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.MEASUREMENT,
),
ExtSensorEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
entity_registry_enabled_default=False,
key="wallbox_2_set_icmax",
name="Wallbox II set ICMAX",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
icon="mdi:current-dc",
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.MEASUREMENT,
),

ExtSensorEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
Expand Down Expand Up @@ -1965,6 +2005,26 @@ class ExtBinarySensorEntityDescription(BinarySensorEntityDescription):
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.MEASUREMENT,
),
ExtSensorEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
entity_registry_enabled_default=False,
key="wallbox_3_min_charging_current",
name="Wallbox III MIN charging current",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
icon="mdi:current-dc",
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.MEASUREMENT,
),
ExtSensorEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
entity_registry_enabled_default=False,
key="wallbox_3_set_icmax",
name="Wallbox III set ICMAX",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
icon="mdi:current-dc",
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.MEASUREMENT,
),

ExtSensorEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
Expand Down Expand Up @@ -2024,6 +2084,26 @@ class ExtBinarySensorEntityDescription(BinarySensorEntityDescription):
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.MEASUREMENT,
),
ExtSensorEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
entity_registry_enabled_default=False,
key="wallbox_4_min_charging_current",
name="Wallbox IV MIN charging current",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
icon="mdi:current-dc",
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.MEASUREMENT,
),
ExtSensorEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
entity_registry_enabled_default=False,
key="wallbox_4_set_icmax",
name="Wallbox IV set ICMAX",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
icon="mdi:current-dc",
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.MEASUREMENT,
),
]

INVERTER_SENSOR_TYPES = [
Expand Down
52 changes: 51 additions & 1 deletion custom_components/senec/pysenec_ha/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,18 @@ def wallbox_l3_charging_current(self) -> float:
SENEC_SECTION_WALLBOX]:
return self._raw[SENEC_SECTION_WALLBOX]["L3_CHARGING_CURRENT"][0]

@property
def wallbox_min_charging_current(self) -> float:
if hasattr(self, '_raw') and SENEC_SECTION_WALLBOX in self._raw and "MIN_CHARGING_CURRENT" in self._raw[
SENEC_SECTION_WALLBOX]:
return self._raw[SENEC_SECTION_WALLBOX]["MIN_CHARGING_CURRENT"][0]

@property
def wallbox_set_icmax(self) -> float:
if hasattr(self, '_raw') and SENEC_SECTION_WALLBOX in self._raw and "SET_ICMAX" in self._raw[
SENEC_SECTION_WALLBOX]:
return self._raw[SENEC_SECTION_WALLBOX]["SET_ICMAX"][0]

@property
def wallbox_2_power(self) -> float:
"""
Expand Down Expand Up @@ -1142,6 +1154,18 @@ def wallbox_2_l3_charging_current(self) -> float:
SENEC_SECTION_WALLBOX]:
return self._raw[SENEC_SECTION_WALLBOX]["L3_CHARGING_CURRENT"][1]

@property
def wallbox_2_min_charging_current(self) -> float:
if hasattr(self, '_raw') and SENEC_SECTION_WALLBOX in self._raw and "MIN_CHARGING_CURRENT" in self._raw[
SENEC_SECTION_WALLBOX]:
return self._raw[SENEC_SECTION_WALLBOX]["MIN_CHARGING_CURRENT"][1]

@property
def wallbox_2_set_icmax(self) -> float:
if hasattr(self, '_raw') and SENEC_SECTION_WALLBOX in self._raw and "SET_ICMAX" in self._raw[
SENEC_SECTION_WALLBOX]:
return self._raw[SENEC_SECTION_WALLBOX]["SET_ICMAX"][1]

@property
def wallbox_3_power(self) -> float:
"""
Expand Down Expand Up @@ -1218,6 +1242,18 @@ def wallbox_3_l3_charging_current(self) -> float:
SENEC_SECTION_WALLBOX]:
return self._raw[SENEC_SECTION_WALLBOX]["L3_CHARGING_CURRENT"][2]

@property
def wallbox_3_min_charging_current(self) -> float:
if hasattr(self, '_raw') and SENEC_SECTION_WALLBOX in self._raw and "MIN_CHARGING_CURRENT" in self._raw[
SENEC_SECTION_WALLBOX]:
return self._raw[SENEC_SECTION_WALLBOX]["MIN_CHARGING_CURRENT"][2]

@property
def wallbox_3_set_icmax(self) -> float:
if hasattr(self, '_raw') and SENEC_SECTION_WALLBOX in self._raw and "SET_ICMAX" in self._raw[
SENEC_SECTION_WALLBOX]:
return self._raw[SENEC_SECTION_WALLBOX]["SET_ICMAX"][2]

@property
def wallbox_4_power(self) -> float:
"""
Expand Down Expand Up @@ -1294,6 +1330,18 @@ def wallbox_4_l3_charging_current(self) -> float:
SENEC_SECTION_WALLBOX]:
return self._raw[SENEC_SECTION_WALLBOX]["L3_CHARGING_CURRENT"][3]

@property
def wallbox_4_min_charging_current(self) -> float:
if hasattr(self, '_raw') and SENEC_SECTION_WALLBOX in self._raw and "MIN_CHARGING_CURRENT" in self._raw[
SENEC_SECTION_WALLBOX]:
return self._raw[SENEC_SECTION_WALLBOX]["MIN_CHARGING_CURRENT"][3]

@property
def wallbox_4_set_icmax(self) -> float:
if hasattr(self, '_raw') and SENEC_SECTION_WALLBOX in self._raw and "SET_ICMAX" in self._raw[
SENEC_SECTION_WALLBOX]:
return self._raw[SENEC_SECTION_WALLBOX]["SET_ICMAX"][3]

@property
def fan_inv_lv(self) -> bool:
if hasattr(self, '_raw') and SENEC_SECTION_FAN_SPEED in self._raw and "INV_LV" in self._raw[
Expand Down Expand Up @@ -1411,7 +1459,9 @@ async def read_senec_v31(self):
"L2_USED": "",
"L3_CHARGING_CURRENT": "",
"L3_USED": "",
"EV_CONNECTED": ""}
"EV_CONNECTED": "",
"MIN_CHARGING_CURRENT": "",
"SET_ICMAX": ""}
})

async with self.websession.post(self.url, json=form, ssl=False) as res:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/senec/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry,
entity = SenecSensor(coordinator, description)
entities.append(entity)

if CONF_TYPE in config_entry.data and config_entry.data[CONF_TYPE] == CONF_SYSTYPE_WEB:
elif CONF_TYPE in config_entry.data and config_entry.data[CONF_TYPE] == CONF_SYSTYPE_WEB:
for description in WEB_SENSOR_TYPES:
entity = SenecSensor(coordinator, description)
entities.append(entity)
Expand Down
4 changes: 2 additions & 2 deletions custom_components/senec/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities):
"""Initialize sensor platform from config entry."""
coordinator = hass.data[DOMAIN][config_entry.entry_id]
if (CONF_TYPE in config_entry.data and config_entry.data[CONF_TYPE] == CONF_SYSTYPE_INVERTER):
if CONF_TYPE in config_entry.data and config_entry.data[CONF_TYPE] == CONF_SYSTYPE_INVERTER:
_LOGGER.info("No switches for Inverters...")
if (CONF_TYPE in config_entry.data and config_entry.data[CONF_TYPE] == CONF_SYSTYPE_WEB):
elif CONF_TYPE in config_entry.data and config_entry.data[CONF_TYPE] == CONF_SYSTYPE_WEB:
_LOGGER.info("No switches for WebPortal...")
else:
entities = []
Expand Down

0 comments on commit a2af50d

Please sign in to comment.