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
6 changes: 3 additions & 3 deletions src/integrations/home_assistant/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _publish_select(
"command_topic": self._get_command_topic(topic),
"value_template": value_template,
"command_template": command_template,
"retain": str(retain).lower(),
"retain": retain,
"options": options,
"enabled_by_default": enabled,
}
Expand Down Expand Up @@ -87,7 +87,7 @@ def _publish_text(
"command_topic": self._get_command_topic(topic),
"value_template": value_template,
"command_template": command_template,
"retain": str(retain).lower(),
"retain": retain,
"enabled_by_default": enabled,
}
if min_value is not None:
Expand Down Expand Up @@ -153,7 +153,7 @@ def _publish_number(
"state_topic": self._get_state_topic(topic),
"command_topic": self._get_command_topic(topic),
"value_template": value_template,
"retain": str(retain).lower(),
"retain": retain,
"mode": mode,
"min": min_value,
"max": max_value,
Expand Down
8 changes: 6 additions & 2 deletions src/publisher/mqtt_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ async def __run_loop(self) -> None:
reconnect_interval,
)
await asyncio.sleep(reconnect_interval)
reconnect_interval = min(reconnect_interval * 2, _RECONNECT_INTERVAL_MAX)
reconnect_interval = min(
reconnect_interval * 2, _RECONNECT_INTERVAL_MAX
)
except aiomqtt.MqttError:
LOG.warning(
"Connection to %s:%s lost; Reconnecting in %d seconds ...",
Expand All @@ -142,7 +144,9 @@ async def __run_loop(self) -> None:
reconnect_interval,
)
await asyncio.sleep(reconnect_interval)
reconnect_interval = min(reconnect_interval * 2, _RECONNECT_INTERVAL_MAX)
reconnect_interval = min(
reconnect_interval * 2, _RECONNECT_INTERVAL_MAX
)
except asyncio.exceptions.CancelledError:
LOG.debug("MQTT publisher loop cancelled")
raise
Expand Down
4 changes: 2 additions & 2 deletions tests/integrations/home_assistant/test_discovery_retain.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_required_entities_have_retain_true(self) -> None:
assert payload is not None, (
f"No writable HA discovery payload found for topic {topic}"
)
assert payload.get("retain") == "true", (
assert payload.get("retain") is True, (
f"Expected retain=true for {topic}, got {payload.get('retain')!r}"
)

Expand All @@ -117,6 +117,6 @@ def test_non_retained_entities_keep_retain_false(self) -> None:
payload = _payload_for_state_topic_suffix(payloads, topic)
if payload is None:
continue # entity not published for this vehicle config
assert payload.get("retain") in ("false", None), (
assert payload.get("retain") in (False, None), (
f"Expected retain!=true for {topic}, got {payload.get('retain')!r}"
)