Skip to content
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
2 changes: 1 addition & 1 deletion custom_components/victron_mqtt/_vendor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Vendored third-party packages."""

VICTRON_MQTT_VERSION = "2026.7.0"
VICTRON_MQTT_VERSION = "2026.7.2"
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ACSystemMode,
ActiveInputEnum,
BatteryState,
BMSMode,
ChargerMode,
ChargeSchedule,
DESSErrorCode,
Expand Down Expand Up @@ -68,6 +69,7 @@
"AcInputTypeEnum",
"ActiveInputEnum",
"AuthenticationError",
"BMSMode",
"BatteryState",
"CannotConnectError",
"ChargeSchedule",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ class ChargerMode(VictronEnum):
OFF = (4, "off", "Off")


class BMSMode(VictronEnum):
"""BMS contactor mode enum."""

ON = (3, "on", "On")
OFF = (4, "off", "Off")
STANDBY = (252, "standby", "Standby")


class InverterMode(VictronEnum):
"""Inverter Mode Enum"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ACSystemMode,
ActiveInputEnum,
BatteryState,
BMSMode,
ChargerMode,
ChargeSchedule,
DESSErrorCode,
Expand Down Expand Up @@ -625,6 +626,15 @@
value_type=ValueType.ENUM,
enum=GenericOnOff,
),
TopicDescriptor(
topic="N/{installation_id}/battery/{device_id}/Mode",
message_type=MetricKind.SELECT,
short_id="battery_bms_mode",
name="BMS mode",
value_type=ValueType.ENUM,
enum=BMSMode,
main_topic=True,
),
TopicDescriptor(
topic="N/{installation_id}/battery/{device_id}/Soc",
message_type=MetricKind.SENSOR,
Expand Down Expand Up @@ -1035,7 +1045,7 @@
TopicDescriptor(
topic="N/{installation_id}/ev/{device_id}/ChargingStarted",
depends_on=[
"ev_charging_state"
"ev_{device_id}_ev_charging_state"
], # This is just so this topic will not show up with the default value if there is no EV charger at all
message_type=MetricKind.SENSOR,
short_id="ev_charging_started",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,27 +456,6 @@ def unique_id(self) -> str:
assert self._unique_id is not None, f"unique_id is None for topic: {self.full_topic}"
return self._unique_id

@property
def display_id(self) -> str:
"""Get a display identifier with the device-type prefix de-duplicated.

The ``unique_id`` has a known formatting quirk: when ``short_id`` already
starts with the device-type prefix (e.g. ``solarcharger_total_pv_yield``
under device ``solarcharger_3``), the resulting id contains the prefix
twice — ``solarcharger_3_solarcharger_total_pv_yield``. ``display_id``
strips the redundant leading prefix, yielding ``solarcharger_3_total_pv_yield``.

``unique_id`` is intentionally left unchanged for backward compatibility
with existing consumers. ``display_id`` is provided for new consumers
that can adopt the cleaner form going forward.
"""
assert self._short_id is not None, f"short_id is None for topic: {self.full_topic}"
device_prefix = f"{self.device_type.code}_"
short = self._short_id
if short.startswith(device_prefix):
short = short[len(device_prefix):]
return ParsedTopic.make_unique_id(self.get_device_unique_id(), short)

@property
def key_values(self) -> dict[str, str]:
"""Get the key values of the ParsedTopic."""
Expand Down
2 changes: 0 additions & 2 deletions custom_components/victron_mqtt/_vendor/victron_mqtt/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ def _create_metric_from_placeholder(
name=name,
descriptor=new_topic_desc,
unique_id=metric_placeholder.parsed_topic.unique_id,
display_id=metric_placeholder.parsed_topic.display_id,
short_id=metric_placeholder.parsed_topic.short_id,
key_values=metric_placeholder.parsed_topic.key_values,
topic=metric_placeholder.parsed_topic.full_topic,
Expand All @@ -270,7 +269,6 @@ def _create_metric_from_placeholder(
name=name,
descriptor=new_topic_desc,
unique_id=metric_placeholder.parsed_topic.unique_id,
display_id=metric_placeholder.parsed_topic.display_id,
short_id=metric_placeholder.parsed_topic.short_id,
key_values=metric_placeholder.parsed_topic.key_values,
hub=hub,
Expand Down
13 changes: 0 additions & 13 deletions custom_components/victron_mqtt/_vendor/victron_mqtt/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def __init__(
name: str | None = None,
descriptor: TopicDescriptor | None = None,
unique_id: str | None = None,
display_id: str | None = None,
short_id: str | None = None,
key_values: dict[str, str] | None = None,
hub: Hub | None = None,
Expand All @@ -59,7 +58,6 @@ def __init__(
self._device: Device = device
self._descriptor: TopicDescriptor = descriptor
self._unique_id: str = unique_id
self._display_id: str = display_id if display_id is not None else unique_id
self._value: Any = None
self._short_id: str = short_id
self._name: str = name
Expand Down Expand Up @@ -199,17 +197,6 @@ def unique_id(self) -> str:
"""Return the unique id of the metric."""
return self._unique_id

@property
def display_id(self) -> str:
"""Return the display identifier with the device-type prefix de-duplicated.

Equal to ``unique_id`` for most metrics. Where ``short_id`` starts with
the device-type prefix, the redundant copy is stripped, giving a cleaner
identifier. See :attr:`ParsedTopic.display_id` for details.
The ``unique_id`` is never modified.
"""
return self._display_id

@property
def key_values(self) -> dict[str, str]:
"""Return the key_values dictionary as read-only."""
Expand Down
14 changes: 14 additions & 0 deletions custom_components/victron_mqtt/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,13 @@
"passthrough": "Passthrough"
}
},
"battery_bms_mode": {
"state": {
"off": "Off",
"on": "On",
"standby": "Standby"
}
},
"evcharger_mode": {
"name": "Mode",
"state": {
Expand Down Expand Up @@ -772,6 +779,13 @@
"warning": "Warning"
}
},
"battery_bms_mode": {
"state": {
"off": "Off",
"on": "On",
"standby": "Standby"
}
},
"battery_capacity": {
"name": "Capacity"
},
Expand Down
49 changes: 48 additions & 1 deletion victron_mqtt.json
Original file line number Diff line number Diff line change
Expand Up @@ -1707,6 +1707,33 @@
"hidden": false,
"sub_device_key": null
},
{
"topic": "N/{installation_id}/battery/{device_id}/Mode",
"message_type": "MetricKind.SELECT",
"short_id": "battery_bms_mode",
"name": "BMS mode",
"unit_of_measurement": null,
"metric_type": "MetricType.ENUM",
"metric_nature": "MetricNature.NONE",
"value_type": "ValueType.ENUM",
"precision": null,
"enum": "BMSMode",
"min_max_range": "RangeType.STATIC",
"min": null,
"max": null,
"step": null,
"is_adjustable_suffix": null,
"output_type": null,
"labels": null,
"key_values": {},
"experimental": false,
"depends_on": [],
"generic_name": "BMS mode",
"is_formula": false,
"main_topic": true,
"hidden": false,
"sub_device_key": null
},
{
"topic": "N/{installation_id}/battery/{device_id}/Soc",
"message_type": "MetricKind.SENSOR",
Expand Down Expand Up @@ -3186,7 +3213,7 @@
"key_values": {},
"experimental": false,
"depends_on": [
"ev_charging_state"
"ev_{device_id}_ev_charging_state"
],
"generic_name": "Charging started",
"is_formula": false,
Expand Down Expand Up @@ -13166,6 +13193,26 @@
}
]
},
{
"name": "BMSMode",
"EnumValues": [
{
"id": "on",
"name": "On",
"value": 3
},
{
"id": "off",
"name": "Off",
"value": 4
},
{
"id": "standby",
"name": "Standby",
"value": 252
}
]
},
{
"name": "BatteryState",
"EnumValues": [
Expand Down
Loading