Skip to content

Commit

Permalink
Merge pull request #6 from quielb/enable-timer
Browse files Browse the repository at this point in the history
Add timer service and cleanup docs
  • Loading branch information
quielb authored Apr 11, 2021
2 parents df464fe + 2e0a118 commit 92f4ee1
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 7 deletions.
1 change: 1 addition & 0 deletions custom_components/airscape/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""The Airscape component."""

DOMAIN = "airscape"
AIRSCAPE_DOMAIN = "airscape"
3 changes: 2 additions & 1 deletion custom_components/airscape/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"power": "Power",
"inside": "Inside Temperature",
"attic": "Attic Temperature",
"oa": "Ouside Temperature",
"oa": "Outside Temperature",
"interlock1": "InterLock1",
"interlock2": "InterLock2",
"timeremaining": "Shutoff Timer"
}
27 changes: 24 additions & 3 deletions custom_components/airscape/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
CONF_MINIMUM
)

from . import AIRSCAPE_DOMAIN
from .const import fan_to_hass_attr

DEFAULT_TIMEOUT = 5
Expand Down Expand Up @@ -75,8 +76,17 @@ def service_slow_down(call):
entity = hass.data[DOMAIN].get_entity(entity_id)
entity.slow_down()

hass.services.register(DOMAIN, "airscape_speed_up", service_speed_up)
hass.services.register(DOMAIN, "airscape_slow_down", service_slow_down)
def service_add_time(call):
"""Handle slow_down service call."""
entity_id = call.data.get("entity_id")
_LOGGER.debug("Calling add_time for %s", entity_id)

entity = hass.data[DOMAIN].get_entity(entity_id)
entity.add_time()

hass.services.register(AIRSCAPE_DOMAIN, "speed_up", service_speed_up)
hass.services.register(AIRSCAPE_DOMAIN, "slow_down", service_slow_down)
hass.services.register(AIRSCAPE_DOMAIN, "add_time", service_add_time)

return True

Expand Down Expand Up @@ -156,7 +166,7 @@ def speed_up(self):
airscape.exceptions.Timeout
):
self._available = False

def slow_down(self):
"""Instruct fan to increment speed down by 1."""
try:
Expand All @@ -167,6 +177,17 @@ def slow_down(self):
airscape.exceptions.Timeout
):
self._available = False

def add_time(self):
"""Add an hour to the shutoff timer."""
try:
self._fan.add_time()
except (
airscape.exceptions.ConnectionError,
airscape.exceptions.Timeout
):
self._available = False


@property
def speed_list(self):
Expand Down
5 changes: 3 additions & 2 deletions custom_components/airscape/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"domain": "airscape",
"name": "Airscape Whole House Fan",
"documentation": "https://www.home-assistant.io/components/fan.airscape",
"version": "0.1.1",
"requirements": [
"airscape==0.1.8"
"airscape==0.1.8.1"
],
"dependencies": [],
"codeowners": [
"@quielb"
]
}
}
25 changes: 24 additions & 1 deletion custom_components/airscape/services.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@

speed_up:
name: Speed Up
description: Bump the WHF speed up by 1.
fields:
entity_id:
name: Entity ID
description: Entity ID of the fan to change.
required: true
slow_down:
name: Slow Down
description: Bump the WHF speed down by 1.
fields:
entity_id:
name: Entity ID
description: Entity ID of the fan to change.
required: true
add_time:
name: Add Time
description: Add an hour to the automatic shutoff timer of the WHF.
fields:
entity_id:
name: Entity ID
description: Entity ID of the fan to change.
required: true

0 comments on commit 92f4ee1

Please sign in to comment.