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.6.8"
VICTRON_MQTT_VERSION = "2026.7.0"
12 changes: 12 additions & 0 deletions custom_components/victron_mqtt/_vendor/victron_mqtt/_unwrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ def unwrap_epoch(json_str: str) -> datetime | None:
return None


def unwrap_epoch_default_na(json_str: str) -> datetime | str:
"""Unwrap an integer value from a JSON string, defaulting to 0."""
try:
data = json.loads(json_str)
if data["value"] is None:
return "N/A"
return datetime.fromtimestamp(data["value"], tz=UTC)
except (json.JSONDecodeError, KeyError, ValueError, TypeError):
return "N/A"


def wrap_enum(enum_val: VictronEnum | str, enum_expected: type[VictronEnum]) -> str:
"""Wrap an Enum value into a JSON string with a 'value' key."""
if isinstance(enum_val, VictronEnum):
Expand Down Expand Up @@ -196,6 +207,7 @@ def wrap_epoch(value: datetime | None) -> str:
ValueType.ENUM: unwrap_enum,
ValueType.BITMASK: unwrap_bitmask,
ValueType.EPOCH: unwrap_epoch,
ValueType.EPOCH_DEFAULT_NA: unwrap_epoch_default_na,
ValueType.INT_SECONDS_TO_HOURS: unwrap_int_seconds_to_hours,
ValueType.INT_SECONDS_TO_MINUTES: unwrap_int_seconds_to_minutes,
ValueType.FLOAT_M3_TO_LITERS: unwrap_float_m3_to_liters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1034,10 +1034,14 @@
),
TopicDescriptor(
topic="N/{installation_id}/ev/{device_id}/ChargingStarted",
depends_on=[
"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",
name="Charging started",
metric_type=MetricType.TIMESTAMP,
value_type=ValueType.EPOCH_DEFAULT_NA,
),
TopicDescriptor(
topic="N/{installation_id}/ev/{device_id}/ChargingState",
Expand Down Expand Up @@ -2743,6 +2747,13 @@
name="DC (battery) bus current",
metric_type=MetricType.CURRENT,
),
TopicDescriptor(
topic="N/{installation_id}/solarcharger/{device_id}/Dc/0/Temperature",
message_type=MetricKind.SENSOR,
short_id="solarcharger_temperature",
name="Temperature",
metric_type=MetricType.TEMPERATURE,
),
TopicDescriptor(
topic="N/{installation_id}/solarcharger/{device_id}/Dc/0/Voltage",
message_type=MetricKind.SENSOR,
Expand Down Expand Up @@ -2976,6 +2987,14 @@
precision=2,
depends_on=["solarcharger_yield_power", "solarcharger_voltage"],
),
TopicDescriptor(
topic="N/{installation_id}/solarcharger/{device_id}/Yield/System",
message_type=MetricKind.SENSOR,
short_id="solarcharger_total_pv_yield_system",
name="Total PV yield system",
metric_type=MetricType.ENERGY,
precision=2,
),
TopicDescriptor(
topic="N/{installation_id}/solarcharger/{device_id}/Yield/User",
message_type=MetricKind.SENSOR,
Expand Down Expand Up @@ -3894,6 +3913,14 @@
name="Energy from out to inverter",
metric_type=MetricType.ENERGY,
),
TopicDescriptor(
topic="N/{installation_id}/vebus/{device_id}/Hub4/DisableCharge",
message_type=MetricKind.SWITCH,
short_id="vebus_hub4_disable_charge",
name="Hub4 disable charge",
value_type=ValueType.ENUM,
enum=GenericOnOff,
),
TopicDescriptor(
topic="N/{installation_id}/vebus/{device_id}/Hub4/DoNotFeedInOvervoltage",
message_type=MetricKind.SWITCH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class ValueType(Enum):
ENUM = "enum"
BITMASK = "bitmask"
EPOCH = "epoch"
EPOCH_DEFAULT_NA = "epoch_default_na"
INT_SECONDS_TO_HOURS = "int_seconds_to_hours"
INT_SECONDS_TO_MINUTES = "int_seconds_to_minutes"
FLOAT_M3_TO_LITERS = "float_m3_to_liters"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/victron_mqtt/_vendor/victron_mqtt/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ async def connect(self) -> None:

if self.use_ssl:
_LOGGER.info("Setting up SSL context")
ssl_context = ssl.create_default_context()
ssl_context = await asyncio.to_thread(ssl.create_default_context)
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.VerifyMode.CERT_NONE
self._client.tls_set_context(ssl_context) # type: ignore[arg-type]
Expand Down
20 changes: 20 additions & 0 deletions custom_components/victron_mqtt/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,13 @@
"on": "On"
}
},
"vebus_hub4_disable_charge": {
"name": "Hub4 disable charge",
"state": {
"off": "Off",
"on": "On"
}
},
"vebus_hub4_do_not_feed_in_overvoltage": {
"name": "Hub4 do not feed in on overvoltage",
"state": {
Expand Down Expand Up @@ -1890,6 +1897,9 @@
"sustain_alt": "Sustain alt"
}
},
"solarcharger_temperature": {
"name": "Temperature"
},
"solarcharger_time_in_absorption_today": {
"name": "Time in absorption today"
},
Expand All @@ -1899,6 +1909,9 @@
"solarcharger_time_in_float_today": {
"name": "Time in float today"
},
"solarcharger_total_pv_yield_system": {
"name": "Total PV yield system"
},
"solarcharger_tracker_tracker_current": {
"name": "PV tracker {tracker} current"
},
Expand Down Expand Up @@ -2775,6 +2788,13 @@
"on": "On"
}
},
"vebus_hub4_disable_charge": {
"name": "Hub4 disable charge",
"state": {
"off": "Off",
"on": "On"
}
},
"vebus_hub4_do_not_feed_in_overvoltage": {
"name": "Hub4 do not feed in on overvoltage",
"state": {
Expand Down
87 changes: 85 additions & 2 deletions victron_mqtt.json
Original file line number Diff line number Diff line change
Expand Up @@ -3173,7 +3173,7 @@
"unit_of_measurement": null,
"metric_type": "MetricType.TIMESTAMP",
"metric_nature": "MetricNature.NONE",
"value_type": "ValueType.EPOCH",
"value_type": "ValueType.EPOCH_DEFAULT_NA",
"precision": null,
"enum": null,
"min_max_range": "RangeType.STATIC",
Expand All @@ -3185,7 +3185,9 @@
"labels": null,
"key_values": {},
"experimental": false,
"depends_on": [],
"depends_on": [
"ev_charging_state"
],
"generic_name": "Charging started",
"is_formula": false,
"main_topic": false,
Expand Down Expand Up @@ -8750,6 +8752,33 @@
"hidden": false,
"sub_device_key": null
},
{
"topic": "N/{installation_id}/solarcharger/{device_id}/Dc/0/Temperature",
"message_type": "MetricKind.SENSOR",
"short_id": "solarcharger_temperature",
"name": "Temperature",
"unit_of_measurement": "\u00b0C",
"metric_type": "MetricType.TEMPERATURE",
"metric_nature": "MetricNature.MEASUREMENT",
"value_type": "ValueType.FLOAT",
"precision": 1,
"enum": null,
"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": "Temperature",
"is_formula": false,
"main_topic": false,
"hidden": false,
"sub_device_key": null
},
{
"topic": "N/{installation_id}/solarcharger/{device_id}/Dc/0/Voltage",
"message_type": "MetricKind.SENSOR",
Expand Down Expand Up @@ -9566,6 +9595,33 @@
"hidden": false,
"sub_device_key": null
},
{
"topic": "N/{installation_id}/solarcharger/{device_id}/Yield/System",
"message_type": "MetricKind.SENSOR",
"short_id": "solarcharger_total_pv_yield_system",
"name": "Total PV yield system",
"unit_of_measurement": "kWh",
"metric_type": "MetricType.ENERGY",
"metric_nature": "MetricNature.TOTAL",
"value_type": "ValueType.FLOAT",
"precision": 2,
"enum": null,
"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": "Total PV yield system",
"is_formula": false,
"main_topic": false,
"hidden": false,
"sub_device_key": null
},
{
"topic": "N/{installation_id}/solarcharger/{device_id}/Yield/User",
"message_type": "MetricKind.SENSOR",
Expand Down Expand Up @@ -12679,6 +12735,33 @@
"hidden": false,
"sub_device_key": null
},
{
"topic": "N/{installation_id}/vebus/{device_id}/Hub4/DisableCharge",
"message_type": "MetricKind.SWITCH",
"short_id": "vebus_hub4_disable_charge",
"name": "Hub4 disable charge",
"unit_of_measurement": null,
"metric_type": "MetricType.ENUM",
"metric_nature": "MetricNature.NONE",
"value_type": "ValueType.ENUM",
"precision": null,
"enum": "GenericOnOff",
"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": "Hub4 disable charge",
"is_formula": false,
"main_topic": false,
"hidden": false,
"sub_device_key": null
},
{
"topic": "N/{installation_id}/vebus/{device_id}/Hub4/DoNotFeedInOvervoltage",
"message_type": "MetricKind.SWITCH",
Expand Down
Loading