Skip to content

Commit

Permalink
Import mqtt from homeasssistant.components instead of using directly …
Browse files Browse the repository at this point in the history
…through hass.components (#56)

Co-authored-by: Tom Rosenback <[email protected]>
  • Loading branch information
tomrosenback and Tom Rosenback authored Apr 11, 2024
1 parent 4a164a1 commit b2a8cf9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions custom_components/thermiq_mqtt/heatpump/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
ATTR_OPTION,
)
from homeassistant.core import HomeAssistant
from homeassistant.components import mqtt


from ..const import (
Expand Down Expand Up @@ -234,7 +235,8 @@ def __init__(self, hass, entry: ConfigEntry):

async def setup_mqtt(self):
self._hpstate["time_str"] = self._data_topic
self.unsubscribe_callback = await self._hass.components.mqtt.async_subscribe(
self.unsubscribe_callback = await mqtt.async_subscribe(
self._hass,
self._data_topic,
self.message_received,
)
Expand Down Expand Up @@ -290,8 +292,8 @@ def update_state(self, command, state_command):
_LOGGER.debug("update_state:" + command + " " + state_command)
# self._data[state_command] = self._client.command(command)
# hass.async_create_task(
# hass.components.mqtt.async_publish(
# conf.cmd_topic, self._data[state_command]
# mqtt.async_publish(
# self._hass, conf.cmd_topic, self._data[state_command]
# )
# )

Expand Down Expand Up @@ -343,7 +345,7 @@ async def send_mqtt_reg(self, register_id, value, bitmask) -> None:
_LOGGER.debug("topic:[%s]", topic)
_LOGGER.debug("payload:[%s]", payload)
self._hass.async_create_task(
self._hass.components.mqtt.async_publish(
mqtt.async_publish(
self._hass, topic, payload, qos=2, retain=False
)
)

0 comments on commit b2a8cf9

Please sign in to comment.