fredrike / pytfiac

Python3 library to communicate with AC-units that follows the tfiac protocol.
GNU General Public License v3.0
1 stars 5 forks source link

Return off state when the host is not reachable #1

Closed mellado closed 5 years ago

mellado commented 5 years ago

If the wifi module of the AC is off because the power of the AC is off, then the state should be off. I think that is a better feedback than an exception. On the other hand it will not be possible to switch the AC on.

fredrike commented 5 years ago

No, if the wifi module is offline it should be reported as unavailable.

Are you saying that it is not possible to turn on the AC via wifi?

mellado commented 5 years ago

I did not know there was a possibility of having an unavailable state.

It is possible to turn on the AC via wifi as long as the wifi module is reachable in the network. The wifi module will not be reachable if, for instance, it has no power.

fredrike commented 5 years ago

https://developers.home-assistant.io/docs/en/entity_index.html#generic-properties

Name Type Default Description
available boolean True Indiciate if Home Assistant is able to read the state and control the underlying device.

You are however right, there should be a check for this that updates the available property from here https://github.com/fredrike/home-assistant/blob/4ef82d00910ae0b965fe4d3a6325816bec90415a/homeassistant/components/climate/tfiac.py#L72

What kind of exception do you currently get when you can't access the wifi-module?

mellado commented 5 years ago

What kind of exception do you currently get when you can't access the wifi-module?

I will let you know when I can test it but you could test it yourself because I think you do not need the AC in this case.

mellado commented 5 years ago

https://github.com/fredrike/home-assistant/blob/4ef82d00910ae0b965fe4d3a6325816bec90415a/homeassistant/components/climate/tfiac.py#L225 raises a socket.timeout exception. Do you think it is a good idea to catch that exception in that line and raise a new one of a different kind like "tfiac.unavailable"?

fredrike commented 5 years ago

I did add this to both sides now..

mellado commented 5 years ago

I would set up available property to true again once you get back the connection. Don't you think?

fredrike commented 5 years ago

Yes, sorry, Must have missed that. Could you fix it?

mellado commented 5 years ago

Done