Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wallbox release fixes #167

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading