Compare commits

...

2 Commits

Author SHA1 Message Date
jbouwh ed078d3df3 Revert fallbacks, add deprecation warning 2026-05-07 06:49:51 +00:00
jbouwh e088e166ba Remove not used None defaults on MQTT publish API 2026-05-06 18:45:12 +00:00
2 changed files with 19 additions and 9 deletions
+17 -7
View File
@@ -128,8 +128,8 @@ def publish(
hass: HomeAssistant,
topic: str,
payload: PublishPayloadType,
qos: int | None = 0,
retain: bool | None = False,
qos: int = 0,
retain: bool = False,
encoding: str | None = DEFAULT_ENCODING,
) -> None:
"""Publish message to a MQTT topic."""
@@ -140,8 +140,8 @@ async def async_publish(
hass: HomeAssistant,
topic: str,
payload: PublishPayloadType,
qos: int | None = 0,
retain: bool | None = False,
qos: int = 0,
retain: bool = False,
encoding: str | None = DEFAULT_ENCODING,
) -> None:
"""Publish message to a MQTT topic."""
@@ -181,9 +181,19 @@ async def async_publish(
)
return
await mqtt_data.client.async_publish(
topic, outgoing_payload, qos or 0, retain or False
)
# Passing None for qos or retain args was deprecated.
# Custom integrations should update there code.
# Check for fallback to `None` values can be removed with HA Core 2027.6
if qos is None or retain is None:
_LOGGER.warning( # type: ignore[unreachable]
"Using None values for qos or retain on the MQTT aysnc_publish API is "
"deprecated. The qos should be of type `int`, and `retain` of type `bool`. "
"This will stop working with HA Core 2027.6"
)
qos = qos or 0
retain = retain or False
await mqtt_data.client.async_publish(topic, outgoing_payload, qos, retain)
@callback
+2 -2
View File
@@ -42,8 +42,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def _publish(
topic: str,
payload: mqtt.PublishPayloadType,
qos: int | None,
retain: bool | None,
qos: int,
retain: bool,
) -> None:
await mqtt.async_publish(hass, topic, payload, qos, retain)