Skip to content
This repository was archived by the owner on Jul 4, 2024. It is now read-only.

Add humidifier and dehumidifier as seperate entities#44

Open
nberardi wants to merge 1 commit intochamberlain2007:developfrom
nberardi:develop
Open

Add humidifier and dehumidifier as seperate entities#44
nberardi wants to merge 1 commit intochamberlain2007:developfrom
nberardi:develop

Conversation

@nberardi
Copy link
Copy Markdown

I am going to start this off by saying, I am not as comfortable in Python as other languages, so if you see something say something. That being said, I have been wanting to control my dehumidifier as a separate entity when I export to HomeKit, and the current setup under the climate domain doesn't expose all the services that are available in order to control my dehumidifier. Which is why I am creating the below pull request. Let me know your thoughts.

added support for aux_heat

added support for aux_heat
Copy link
Copy Markdown
Owner

@chamberlain2007 chamberlain2007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nberardi Thanks for doing this! I provided some feedback inline.

def mode(self) -> str | None:
"""Get dehumidifier mode."""

mode = self.coordinator.data.get(Attribute.MODE)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nberardi I think this should be controlled via the main climate entity. Otherwise, someone will think they are changing the mode for the humidifier and actually be setting it on the whole system.


async def async_set_mode(self, mode: str) -> None:
"""Set the mode of the thermostat."""
await self.coordinator.client.read_scheduling()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nberardi This doesn't set the mode.

_attr_supported_features = HumidifierEntityFeature.MODES
_attr_device_class = HumidifierDeviceClass.DEHUMIDIFIER
_attr_available_modes = [MODE_MANUAL]
_attr_min_humidity = 10
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nberardi Dehumidifier has a range of 40-90%


available = self.coordinator.data.get(Attribute.HUMIDIFICATION_AVAILABLE)

if (available == 1):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nberardi As far as I can tell, there is not a case where only auto OR manual is available. In all cases, it should be [MODE_AUTO, MODE_MANUAL]

setpoint = self.coordinator.data.get(Attribute.HUMIDIFICATION_SETPOINT)
"""Don't set last target humidity if off."""
self._last_is_on = setpoint != 0
self._last_target_humidity = setpoint if self._last_is_on else self._last_target_humidity
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nberardi I think I see where you're going with this, which is storing the last humidity so that if the device is turned off and then on, that it uses the last humidity to turn it back on. This has an edge case which you didn't consider which is that if the integration starts with the device off (eg humidity == 0) then it won't be able to turn on. Since there's no way for us to know the previous setpoint in that case, I think we need to set a reasonable default humidity to restore to in that case.

"""Return the target humidity."""
setpoint = self.coordinator.data.get(Attribute.DEHUMIDIFICATION_SETPOINT)
"""Don't set last target humidity if off."""
self._last_is_on = setpoint != 0
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nberardi This doesn't need to be stored, we never read it outside of this function. This can just be

self._last_target_humidity = setpoint if setpoint != 0 else self._last_target_humidity

config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Add humidifier and dehumdifier for passed config_entry in HA."""
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nberardi Typo

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants