Victron GX switch platform#167859
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…_binary_sensor
There was a problem hiding this comment.
Pull request overview
Adds a new switch entity platform to the Victron GX integration so writable “switch” metrics (e.g., EV charger start/stop) are exposed as Home Assistant switch entities with translations and tests.
Changes:
- Add
SwitchEntityimplementation and discovery wiring forMetricKind.SWITCH. - Register the switch platform in the integration’s platform list.
- Add entity name translations and new switch-focused tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
homeassistant/components/victron_gx/__init__.py |
Adds Platform.SWITCH so config entries set up the new platform. |
homeassistant/components/victron_gx/switch.py |
Implements switch entity discovery, state updates, and on/off commands for writable switch metrics. |
homeassistant/components/victron_gx/strings.json |
Adds switch entity translation keys/names used by the new platform. |
tests/components/victron_gx/test_switch.py |
Introduces tests covering switch creation, updates, and service calls. |
|
Wasn't this recently closed, due too much PRs are being submitted and first ones need to be merged? |
Yes, and I did get 2 platforms merged so I'm moving to the next set. |
erwindouna
left a comment
There was a problem hiding this comment.
Shouldn't we also cover faulty situations? For instance if toggle failed to update raise a Home assistant error?
|
@erwindouna, thanks for the quick review. I fix all comments. |
@erwindouna , the update is just sending mqtt message. I have no idea if the other side actually got it. When they do get it they change another topic which will actually change the switch position but theoretically that message can get for state change for other reasons. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@erwindouna, thanks for your review. Can you mark it as approved by you? |
erwindouna
left a comment
There was a problem hiding this comment.
Looks good to me, thanks @tomer-w!
| "name": "Relay on Multi RS state" | ||
| }, | ||
| "solarcharger_relay_state": { | ||
| "name": "Relay state" | ||
| }, | ||
| "switch_output_state": { | ||
| "name": "Switch {output} state" | ||
| }, | ||
| "switchable_output_output_state": { | ||
| "name": "Switchable output {output} state" | ||
| }, |
There was a problem hiding this comment.
Noticed this while translating: We should drop "state" from these entities as this results in really clumsy translations. In many languages you cannot simply place 4 nouns in a row, so this has to be reworded as
State of switchable output X : On
But you would just say something like "Switchable output X is on", and not "The state of (the) switchable output X is on". Thus those entities work just fine as:
Switchable output X : On
Shortening also helps a lot on mobile and with small column widths in general.
There was a problem hiding this comment.
@NoRi2909, I will take it to the dedupe PR which I will publish the moment we get all the platforms in. I hope early next week.
Proposed change
Adding switch platform for Victron GX integration
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: