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

Add support for Matter EVSE devicetype #137189

Open
wants to merge 19 commits into
base: dev
Choose a base branch
from

Conversation

lboue
Copy link
Contributor

@lboue lboue commented Feb 2, 2025

Proposed change

Support for Matter EVSE - EnergyEvse cluster

Matter 1.3’s energy features enable new energy-centric devices, the first of which is Electric Vehicle Supply Equipment (EVSE).

  • This enables EV charging equipment manufacturers to present a consumer-friendly way to control how and when they charge their vehicles.
  • It features the ability to manually start or stop charging, adjust the charging rate, or specify how many miles of range to be added by a set departure time, leaving the charging station to automatically optimize the charging to happen at the cheapest and lowest carbon times.

I was asked to replace the buttons with a switch in the PR#133662.
As discussed with Marcel, the second step would be to create a specific entity for EVSE in Home Assistant for better integration.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Changes
Add command_timeout attribute in MatterGenericCommandSwitch class. This is mandatory for EnergyEvse commands.

image

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@home-assistant
Copy link

home-assistant bot commented Feb 2, 2025

Hey there @home-assistant/matter, mind taking a look at this pull request as it has been labeled with an integration (matter) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of matter can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign matter Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@lboue lboue changed the title Support for Matter EVSE (switch entity version Support for Matter EVSE (switch entity version) Feb 2, 2025
@lboue lboue marked this pull request as ready for review February 2, 2025 21:56
@lboue lboue requested a review from a team as a code owner February 2, 2025 21:56
@lboue lboue changed the title Support for Matter EVSE (switch entity version) Matter EVSE (switch entity version) Feb 2, 2025
@marcelveldt marcelveldt changed the title Matter EVSE (switch entity version) Add support for Matter EVSE devicetype Feb 5, 2025
Comment on lines +152 to +193
@pytest.mark.parametrize("node_fixture", ["silabs_evse_charging"])
async def test_evse_sensor(
hass: HomeAssistant,
matter_client: MagicMock,
matter_node: MatterNode,
) -> None:
"""Test evse sensors."""
entity_id = "binary_sensor.evse_charging_status"
state = hass.states.get(entity_id)
assert state
assert state.state == "on"
# switch to PluggedInDemand state
set_node_attribute(matter_node, 1, 153, 0, 2)
await trigger_subscription_callback(
hass, matter_client, data=(matter_node.node_id, "1/153/0", 2)
)
state = hass.states.get(entity_id)
assert state
assert state.state == "off"

# binary_sensor.evse_plug
state = hass.states.get("binary_sensor.evse_plug")
assert state
assert state.state == "on"
# switch to NotPluggedIn state
set_node_attribute(matter_node, 1, 153, 0, 0)
await trigger_subscription_callback(
hass, matter_client, data=(matter_node.node_id, "1/153/0", 0)
)
state = hass.states.get(entity_id)
assert state
assert state.state == "off"

# binary_sensor.evse_supply_charging_state
state = hass.states.get("binary_sensor.evse_supply_charging_state")
assert state
assert state.state == "on"
# switch to Disabled state
set_node_attribute(matter_node, 1, 153, 0, 0)
await trigger_subscription_callback(
hass, matter_client, data=(matter_node.node_id, "1/153/1", 0)
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is using an existing sensor class that already has tests for the generic behavior, this does not need explicit extra tests and the snapshot testing is sufficient. It doesn't harm either.

Will leave this up to @joostlek

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants