Skip to content

Commit

Permalink
Fixed Wallbox Lambda Functions in Button & Switch, Renamed Button Ent…
Browse files Browse the repository at this point in the history
…ities to include "Toggle"
  • Loading branch information
bullitt186 committed Jul 23, 2024
1 parent 9f34a5d commit 241ddd5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 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
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 241ddd5

Please sign in to comment.