Skip to content

Commit

Permalink
Merge pull request #66 from nao-pon/finetune
Browse files Browse the repository at this point in the history
Remove unnecessary assignments
  • Loading branch information
hristo-atanasov authored Mar 4, 2022
2 parents 8b48f15 + 7d75e79 commit 72a4389
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions custom_components/tasmota_irhvac/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,34 +652,30 @@ async def state_message_received(msg):
state = self.hass.states.get(self._power_sensor)
await self._async_power_sensor_changed(self._power_sensor, None, state)

if hasattr(mqtt.subscription, 'async_prepare_subscribe_topics'):
self._sub_state = mqtt.subscription.async_prepare_subscribe_topics(
self.hass,
self._sub_state,
{
topics = {
CONF_STATE_TOPIC: {
"topic": self.state_topic,
"msg_callback": state_message_received,
"qos": 1,
}
},
)
}

self._sub_state = await mqtt.subscription.async_subscribe_topics(
if hasattr(mqtt.subscription, 'async_prepare_subscribe_topics'):
# for HA Core >= 2022.3.0
self._sub_state = mqtt.subscription.async_prepare_subscribe_topics(
self.hass,
self._sub_state
self._sub_state,
topics,
)

await mqtt.subscription.async_subscribe_topics(self.hass, self._sub_state)

else:
# for HA Core < 2022.3.0
self._sub_state = await mqtt.subscription.async_subscribe_topics(
self.hass,
self._sub_state,
{
CONF_STATE_TOPIC: {
"topic": self.state_topic,
"msg_callback": state_message_received,
"qos": 1,
}
},
topics,
)

async def async_will_remove_from_hass(self):
Expand Down

0 comments on commit 72a4389

Please sign in to comment.