Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Add current_humidity attribute (#24)
Browse files Browse the repository at this point in the history
* Add current_humidity attribute

* fix linter

* ignore brand in validate

* same

* improve extra attributes
  • Loading branch information
vlebourl authored Jun 4, 2022
1 parent c0b9adc commit 4f3c7fd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 31 deletions.
1 change: 1 addition & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ jobs:
- name: HACS validation
uses: "hacs/action@main"
with:
ignore: "brands"
category: "integration"
comment: false
3 changes: 0 additions & 3 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@
ignored:
- SC1090
- SC1091

/home/vlb/temp/HAcore/custom_vesync/.venv/local/bin
/home/vlb/temp/HAcore/custom_vesync/.venv/bin
35 changes: 7 additions & 28 deletions custom_components/vesync/humidifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
MIN_HUMIDITY = 30

MODES = [MODE_AUTO, MODE_NORMAL, MODE_SLEEP]
VESYNC_TO_HA_ATTRIBUTES = {"humidity": "current_humidity"}


async def async_setup_entry(
Expand Down Expand Up @@ -113,35 +114,13 @@ def unique_info(self):
@property
def extra_state_attributes(self):
"""Return the state attributes of the humidifier."""
attr = {}

if "water_lacks" in self.smarthumidifier.details:
attr["water_lacks"] = self.smarthumidifier.details["water_lacks"]

if "humidity_high" in self.smarthumidifier.details:
attr["humidity_high"] = self.smarthumidifier.details["humidity_high"]

if "water_tank_lifted" in self.smarthumidifier.details:
attr["water_tank_lifted"] = self.smarthumidifier.details[
"water_tank_lifted"
]

if "automatic_stop_reach_target" in self.smarthumidifier.details:
attr["automatic_stop_reach_target"] = self.smarthumidifier.details[
"automatic_stop_reach_target"
]

if "mist_level" in self.smarthumidifier.details:
attr["mist_level"] = self.smarthumidifier.details["mist_level"]

if "warm_mist_level" in self.smarthumidifier.details:
attr["warm_mist_level"] = self.smarthumidifier.details["warm_mist_level"]

if "warm_mist_enabled" in self.smarthumidifier.details:
attr["warm_mist_enabled"] = self.smarthumidifier.details[
"warm_mist_enabled"
]

attr = {}
for k, v in self.smarthumidifier.details.items():
if k in VESYNC_TO_HA_ATTRIBUTES:
attr[VESYNC_TO_HA_ATTRIBUTES[k]] = v
elif k not in self.state_attributes:
attr[k] = v
return attr

def set_humidity(self, humidity):
Expand Down

0 comments on commit 4f3c7fd

Please sign in to comment.