hristo-atanasov / Tasmota-IRHVAC

Home Assistant platform for controlling IR Air Conditioners via Tasmota IRHVAC command and compatible hardware
200 stars 67 forks source link

Remove unnecessary assignments #66

Closed nao-pon closed 2 years ago

nao-pon commented 2 years ago

Probably don't need to assign return of subscription.async_subscribe_topics.

https://github.com/home-assistant/core/blob/f3a89de71f6fa693016a41397b051bd48c86f841/homeassistant/components/mqtt/subscription.py#L118-L121

hristo-atanasov commented 2 years ago

You are right .. It was late in the night and I've missed the retun type None

hristo-atanasov commented 2 years ago

But as I see in the old async_subscribe_topics function there is a retun and it returns dictionary with the new state, so in the backward compatibility part we still need to assign the return to self._sub_state

https://github.com/home-assistant/core/blob/4d32e1ed01d6bd6cbf52e193acb33fb8e14d8462/homeassistant/components/mqtt/subscription.py

nao-pon commented 2 years ago

Yes, assignments are made in the code part that guarantees backward compatibility. This part is for HA after 2022.3. However, I think it's okay to substitute None. I'm just a little worried because the other components of Core don't do the assignment, so I'll follow your instructions.😃

hristo-atanasov commented 2 years ago

I prefer to assign the returned result, just because HA have implemented a logic, that automatically unsubscribe the old subscriptions or those that have not been passed to the "async_subscribe_topics" function .. Otherwise I dont mind both variants. As you say others don't assign it. The truth is that in HA you never know what is the right descision, and what comes next (release) .. :D https://github.com/home-assistant/core/blob/4d32e1ed01d6bd6cbf52e193acb33fb8e14d8462/homeassistant/components/mqtt/subscription.py#L96-L105