Skip to content

Commit 8264a3b

Browse files
Update victron_mqtt to 2026.7.0 (#453)
## Changes - Add solarcharger lifetime yield and temperature sensors @pos-ei-don (#108) - Add vebus DisableCharge: #451 - Fix blocking call issue: home-assistant/core#175390 - Improve ev_charging_started to show NA when charger is disconnected instead of losing the metric: #430 ## Contributors @tomer-w, @pos-ei-don Co-authored-by: tomer-w <57483589+tomer-w@users.noreply.github.com>
1 parent f86b400 commit 8264a3b

7 files changed

Lines changed: 147 additions & 4 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Vendored third-party packages."""
22

3-
VICTRON_MQTT_VERSION = "2026.6.8"
3+
VICTRON_MQTT_VERSION = "2026.7.0"

custom_components/victron_mqtt/_vendor/victron_mqtt/_unwrappers.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ def unwrap_epoch(json_str: str) -> datetime | None:
126126
return None
127127

128128

129+
def unwrap_epoch_default_na(json_str: str) -> datetime | str:
130+
"""Unwrap an integer value from a JSON string, defaulting to 0."""
131+
try:
132+
data = json.loads(json_str)
133+
if data["value"] is None:
134+
return "N/A"
135+
return datetime.fromtimestamp(data["value"], tz=UTC)
136+
except (json.JSONDecodeError, KeyError, ValueError, TypeError):
137+
return "N/A"
138+
139+
129140
def wrap_enum(enum_val: VictronEnum | str, enum_expected: type[VictronEnum]) -> str:
130141
"""Wrap an Enum value into a JSON string with a 'value' key."""
131142
if isinstance(enum_val, VictronEnum):
@@ -196,6 +207,7 @@ def wrap_epoch(value: datetime | None) -> str:
196207
ValueType.ENUM: unwrap_enum,
197208
ValueType.BITMASK: unwrap_bitmask,
198209
ValueType.EPOCH: unwrap_epoch,
210+
ValueType.EPOCH_DEFAULT_NA: unwrap_epoch_default_na,
199211
ValueType.INT_SECONDS_TO_HOURS: unwrap_int_seconds_to_hours,
200212
ValueType.INT_SECONDS_TO_MINUTES: unwrap_int_seconds_to_minutes,
201213
ValueType.FLOAT_M3_TO_LITERS: unwrap_float_m3_to_liters,

custom_components/victron_mqtt/_vendor/victron_mqtt/_victron_topics.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,10 +1034,14 @@
10341034
),
10351035
TopicDescriptor(
10361036
topic="N/{installation_id}/ev/{device_id}/ChargingStarted",
1037+
depends_on=[
1038+
"ev_charging_state"
1039+
], # This is just so this topic will not show up with the default value if there is no EV charger at all
10371040
message_type=MetricKind.SENSOR,
10381041
short_id="ev_charging_started",
10391042
name="Charging started",
10401043
metric_type=MetricType.TIMESTAMP,
1044+
value_type=ValueType.EPOCH_DEFAULT_NA,
10411045
),
10421046
TopicDescriptor(
10431047
topic="N/{installation_id}/ev/{device_id}/ChargingState",
@@ -2743,6 +2747,13 @@
27432747
name="DC (battery) bus current",
27442748
metric_type=MetricType.CURRENT,
27452749
),
2750+
TopicDescriptor(
2751+
topic="N/{installation_id}/solarcharger/{device_id}/Dc/0/Temperature",
2752+
message_type=MetricKind.SENSOR,
2753+
short_id="solarcharger_temperature",
2754+
name="Temperature",
2755+
metric_type=MetricType.TEMPERATURE,
2756+
),
27462757
TopicDescriptor(
27472758
topic="N/{installation_id}/solarcharger/{device_id}/Dc/0/Voltage",
27482759
message_type=MetricKind.SENSOR,
@@ -2976,6 +2987,14 @@
29762987
precision=2,
29772988
depends_on=["solarcharger_yield_power", "solarcharger_voltage"],
29782989
),
2990+
TopicDescriptor(
2991+
topic="N/{installation_id}/solarcharger/{device_id}/Yield/System",
2992+
message_type=MetricKind.SENSOR,
2993+
short_id="solarcharger_total_pv_yield_system",
2994+
name="Total PV yield system",
2995+
metric_type=MetricType.ENERGY,
2996+
precision=2,
2997+
),
29792998
TopicDescriptor(
29802999
topic="N/{installation_id}/solarcharger/{device_id}/Yield/User",
29813000
message_type=MetricKind.SENSOR,
@@ -3894,6 +3913,14 @@
38943913
name="Energy from out to inverter",
38953914
metric_type=MetricType.ENERGY,
38963915
),
3916+
TopicDescriptor(
3917+
topic="N/{installation_id}/vebus/{device_id}/Hub4/DisableCharge",
3918+
message_type=MetricKind.SWITCH,
3919+
short_id="vebus_hub4_disable_charge",
3920+
name="Hub4 disable charge",
3921+
value_type=ValueType.ENUM,
3922+
enum=GenericOnOff,
3923+
),
38973924
TopicDescriptor(
38983925
topic="N/{installation_id}/vebus/{device_id}/Hub4/DoNotFeedInOvervoltage",
38993926
message_type=MetricKind.SWITCH,

custom_components/victron_mqtt/_vendor/victron_mqtt/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class ValueType(Enum):
8080
ENUM = "enum"
8181
BITMASK = "bitmask"
8282
EPOCH = "epoch"
83+
EPOCH_DEFAULT_NA = "epoch_default_na"
8384
INT_SECONDS_TO_HOURS = "int_seconds_to_hours"
8485
INT_SECONDS_TO_MINUTES = "int_seconds_to_minutes"
8586
FLOAT_M3_TO_LITERS = "float_m3_to_liters"

custom_components/victron_mqtt/_vendor/victron_mqtt/hub.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ async def connect(self) -> None:
340340

341341
if self.use_ssl:
342342
_LOGGER.info("Setting up SSL context")
343-
ssl_context = ssl.create_default_context()
343+
ssl_context = await asyncio.to_thread(ssl.create_default_context)
344344
ssl_context.check_hostname = False
345345
ssl_context.verify_mode = ssl.VerifyMode.CERT_NONE
346346
self._client.tls_set_context(ssl_context) # type: ignore[arg-type]

custom_components/victron_mqtt/translations/en.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,13 @@
336336
"on": "On"
337337
}
338338
},
339+
"vebus_hub4_disable_charge": {
340+
"name": "Hub4 disable charge",
341+
"state": {
342+
"off": "Off",
343+
"on": "On"
344+
}
345+
},
339346
"vebus_hub4_do_not_feed_in_overvoltage": {
340347
"name": "Hub4 do not feed in on overvoltage",
341348
"state": {
@@ -1890,6 +1897,9 @@
18901897
"sustain_alt": "Sustain alt"
18911898
}
18921899
},
1900+
"solarcharger_temperature": {
1901+
"name": "Temperature"
1902+
},
18931903
"solarcharger_time_in_absorption_today": {
18941904
"name": "Time in absorption today"
18951905
},
@@ -1899,6 +1909,9 @@
18991909
"solarcharger_time_in_float_today": {
19001910
"name": "Time in float today"
19011911
},
1912+
"solarcharger_total_pv_yield_system": {
1913+
"name": "Total PV yield system"
1914+
},
19021915
"solarcharger_tracker_tracker_current": {
19031916
"name": "PV tracker {tracker} current"
19041917
},
@@ -2775,6 +2788,13 @@
27752788
"on": "On"
27762789
}
27772790
},
2791+
"vebus_hub4_disable_charge": {
2792+
"name": "Hub4 disable charge",
2793+
"state": {
2794+
"off": "Off",
2795+
"on": "On"
2796+
}
2797+
},
27782798
"vebus_hub4_do_not_feed_in_overvoltage": {
27792799
"name": "Hub4 do not feed in on overvoltage",
27802800
"state": {

victron_mqtt.json

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3173,7 +3173,7 @@
31733173
"unit_of_measurement": null,
31743174
"metric_type": "MetricType.TIMESTAMP",
31753175
"metric_nature": "MetricNature.NONE",
3176-
"value_type": "ValueType.EPOCH",
3176+
"value_type": "ValueType.EPOCH_DEFAULT_NA",
31773177
"precision": null,
31783178
"enum": null,
31793179
"min_max_range": "RangeType.STATIC",
@@ -3185,7 +3185,9 @@
31853185
"labels": null,
31863186
"key_values": {},
31873187
"experimental": false,
3188-
"depends_on": [],
3188+
"depends_on": [
3189+
"ev_charging_state"
3190+
],
31893191
"generic_name": "Charging started",
31903192
"is_formula": false,
31913193
"main_topic": false,
@@ -8750,6 +8752,33 @@
87508752
"hidden": false,
87518753
"sub_device_key": null
87528754
},
8755+
{
8756+
"topic": "N/{installation_id}/solarcharger/{device_id}/Dc/0/Temperature",
8757+
"message_type": "MetricKind.SENSOR",
8758+
"short_id": "solarcharger_temperature",
8759+
"name": "Temperature",
8760+
"unit_of_measurement": "\u00b0C",
8761+
"metric_type": "MetricType.TEMPERATURE",
8762+
"metric_nature": "MetricNature.MEASUREMENT",
8763+
"value_type": "ValueType.FLOAT",
8764+
"precision": 1,
8765+
"enum": null,
8766+
"min_max_range": "RangeType.STATIC",
8767+
"min": null,
8768+
"max": null,
8769+
"step": null,
8770+
"is_adjustable_suffix": null,
8771+
"output_type": null,
8772+
"labels": null,
8773+
"key_values": {},
8774+
"experimental": false,
8775+
"depends_on": [],
8776+
"generic_name": "Temperature",
8777+
"is_formula": false,
8778+
"main_topic": false,
8779+
"hidden": false,
8780+
"sub_device_key": null
8781+
},
87538782
{
87548783
"topic": "N/{installation_id}/solarcharger/{device_id}/Dc/0/Voltage",
87558784
"message_type": "MetricKind.SENSOR",
@@ -9566,6 +9595,33 @@
95669595
"hidden": false,
95679596
"sub_device_key": null
95689597
},
9598+
{
9599+
"topic": "N/{installation_id}/solarcharger/{device_id}/Yield/System",
9600+
"message_type": "MetricKind.SENSOR",
9601+
"short_id": "solarcharger_total_pv_yield_system",
9602+
"name": "Total PV yield system",
9603+
"unit_of_measurement": "kWh",
9604+
"metric_type": "MetricType.ENERGY",
9605+
"metric_nature": "MetricNature.TOTAL",
9606+
"value_type": "ValueType.FLOAT",
9607+
"precision": 2,
9608+
"enum": null,
9609+
"min_max_range": "RangeType.STATIC",
9610+
"min": null,
9611+
"max": null,
9612+
"step": null,
9613+
"is_adjustable_suffix": null,
9614+
"output_type": null,
9615+
"labels": null,
9616+
"key_values": {},
9617+
"experimental": false,
9618+
"depends_on": [],
9619+
"generic_name": "Total PV yield system",
9620+
"is_formula": false,
9621+
"main_topic": false,
9622+
"hidden": false,
9623+
"sub_device_key": null
9624+
},
95699625
{
95709626
"topic": "N/{installation_id}/solarcharger/{device_id}/Yield/User",
95719627
"message_type": "MetricKind.SENSOR",
@@ -12679,6 +12735,33 @@
1267912735
"hidden": false,
1268012736
"sub_device_key": null
1268112737
},
12738+
{
12739+
"topic": "N/{installation_id}/vebus/{device_id}/Hub4/DisableCharge",
12740+
"message_type": "MetricKind.SWITCH",
12741+
"short_id": "vebus_hub4_disable_charge",
12742+
"name": "Hub4 disable charge",
12743+
"unit_of_measurement": null,
12744+
"metric_type": "MetricType.ENUM",
12745+
"metric_nature": "MetricNature.NONE",
12746+
"value_type": "ValueType.ENUM",
12747+
"precision": null,
12748+
"enum": "GenericOnOff",
12749+
"min_max_range": "RangeType.STATIC",
12750+
"min": null,
12751+
"max": null,
12752+
"step": null,
12753+
"is_adjustable_suffix": null,
12754+
"output_type": null,
12755+
"labels": null,
12756+
"key_values": {},
12757+
"experimental": false,
12758+
"depends_on": [],
12759+
"generic_name": "Hub4 disable charge",
12760+
"is_formula": false,
12761+
"main_topic": false,
12762+
"hidden": false,
12763+
"sub_device_key": null
12764+
},
1268212765
{
1268312766
"topic": "N/{installation_id}/vebus/{device_id}/Hub4/DoNotFeedInOvervoltage",
1268412767
"message_type": "MetricKind.SWITCH",

0 commit comments

Comments
 (0)