Skip to content

Commit

Permalink
Wallbox release fixes (#167)
Browse files Browse the repository at this point in the history
Fixes based on 3.8 Beta 4 included (so far):
- Erroneous Lambda-Functions when calling Services (Bug was introduced
when adding wallbox as a device)
- Wallbox Consumption is now a) only available if a Wallbox is installed
b) enabled by default
  • Loading branch information
torbennehmer authored Jul 29, 2024
2 parents 9f34a5d + becd9c6 commit d368cb2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 29 deletions.
4 changes: 2 additions & 2 deletions custom_components/e3dc_rscp/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ async def async_setup_entry(
key=f"{wallbox_key}-toggle-wallbox-phases",
translation_key="wallbox-toggle-wallbox-phases",
icon="mdi:sine-wave",
async_press_action=lambda coordinator: coordinator.async_toggle_wallbox_phases(wallbox["index"]),
async_press_action=lambda coordinator, index=wallbox["index"]: coordinator.async_toggle_wallbox_phases(index),
)
entities.append(E3DCButton(coordinator, wallbox_toggle_wallbox_phases_description, unique_id, wallbox["deviceInfo"]))

wallbox_toggle_wallbox_charging_description = E3DCButtonEntityDescription(
key=f"{wallbox_key}-toggle-wallbox-charging",
translation_key="wallbox-toggle-wallbox-charging",
icon="mdi:car-electric",
async_press_action=lambda coordinator: coordinator.async_toggle_wallbox_charging(wallbox["index"]),
async_press_action=lambda coordinator, index=wallbox["index"]: coordinator.async_toggle_wallbox_charging(index),
)
entities.append(E3DCButton(coordinator, wallbox_toggle_wallbox_charging_description, unique_id, wallbox["deviceInfo"]))

Expand Down
23 changes: 12 additions & 11 deletions custom_components/e3dc_rscp/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,6 @@
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="wallbox-consumption",
translation_key="wallbox-consumption",
icon="mdi:ev-station",
native_unit_of_measurement=UnitOfPower.WATT,
suggested_unit_of_measurement=UnitOfPower.KILO_WATT,
suggested_display_precision=2,
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="grid-netchange",
translation_key="grid-netchange",
Expand Down Expand Up @@ -532,6 +521,18 @@ async def async_setup_entry(
)
entities.append(E3DCSensor(coordinator, wallbox_soc_description, unique_id, wallbox["deviceInfo"]))

if len(coordinator.wallboxes) > 0:
wallbox_consumption_description = SensorEntityDescription(
key="wallbox-consumption",
translation_key="wallbox-consumption",
icon="mdi:ev-station",
native_unit_of_measurement=UnitOfPower.WATT,
suggested_unit_of_measurement=UnitOfPower.KILO_WATT,
suggested_display_precision=2,
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
)
entities.append(E3DCSensor(coordinator, wallbox_consumption_description, entry.unique_id))

async_add_entities(entities)

Expand Down
4 changes: 2 additions & 2 deletions custom_components/e3dc_rscp/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@
},
"button": {
"wallbox-toggle-wallbox-charging": {
"name": "Charging"
"name": "Toggle charging"
},
"wallbox-toggle-wallbox-phases": {
"name": "Phases"
"name": "Toggle phases"
}
},
"number": {
Expand Down
16 changes: 4 additions & 12 deletions custom_components/e3dc_rscp/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,8 @@ async def async_setup_entry(
on_icon="mdi:weather-sunny",
off_icon="mdi:weather-sunny-off",
device_class=SwitchDeviceClass.SWITCH,
async_turn_on_action=lambda coordinator: coordinator.async_set_wallbox_sun_mode(
True, wallbox["index"]
),
async_turn_off_action=lambda coordinator: coordinator.async_set_wallbox_sun_mode(
False, wallbox["index"]
),
async_turn_on_action=lambda coordinator, index=wallbox["index"]: coordinator.async_set_wallbox_sun_mode(True, index),
async_turn_off_action=lambda coordinator, index=wallbox["index"]: coordinator.async_set_wallbox_sun_mode(False, index),
)
entities.append(E3DCSwitch(coordinator, wallbox_sun_mode_description, unique_id, wallbox["deviceInfo"]))

Expand All @@ -110,12 +106,8 @@ async def async_setup_entry(
on_icon="mdi:power-plug",
off_icon="mdi:power-plug-off",
device_class=SwitchDeviceClass.OUTLET,
async_turn_on_action=lambda coordinator: coordinator.async_set_wallbox_schuko(
True, wallbox["index"]
),
async_turn_off_action=lambda coordinator: coordinator.async_set_wallbox_schuko(
False, wallbox["index"]
),
async_turn_on_action=lambda coordinator, index=wallbox["index"]: coordinator.async_set_wallbox_schuko(True, index),
async_turn_off_action=lambda coordinator, index=wallbox["index"]: coordinator.async_set_wallbox_schuko(False, index),
entity_registry_enabled_default=False, # Disabled per default as only Wallbox multi connect I provides this feature
)
entities.append(E3DCSwitch(coordinator, wallbox_schuko_description, unique_id, wallbox["deviceInfo"]))
Expand Down
4 changes: 2 additions & 2 deletions custom_components/e3dc_rscp/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@
},
"button": {
"wallbox-toggle-wallbox-charging": {
"name": "Charging"
"name": "Toggle charging"
},
"wallbox-toggle-wallbox-phases": {
"name": "Phases"
"name": "Toggle phases"
}
},
"number": {
Expand Down

0 comments on commit d368cb2

Please sign in to comment.