Skip to content

Commit

Permalink
Manual speed support
Browse files Browse the repository at this point in the history
  • Loading branch information
dingusdk committed Dec 22, 2020
1 parent ef112e2 commit 2499140
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 21 deletions.
26 changes: 13 additions & 13 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
{
"name": "DukaOne",
"image": "ludeeus/devcontainer:integration",
"image": "ludeeus/container:integration",
"context": "..",
"postCreateCommand": "",
"runArgs": [],
"appPort": [
"4000:4000/udp",
"4001:4001/udp",
"8123:8123"
],
"postCreateCommand": "dc install",
"settings": {
"files.eol": "\n",
"editor.tabSize": 2,
Expand All @@ -24,16 +23,17 @@
},
"extensions": [
"ms-python.python",
"visualstudioexptteam.vscodeintellicode",
"github.vscode-pull-request-github",
"eamodio.gitlens",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"bierner.lit-html",
"runem.lit-plugin",
"auchenberg.vscode-browser-preview",
"davidanson.vscode-markdownlint",
"redhat.vscode-yaml",
"oderwat.indent-rainbow"
"ryanluker.vscode-coverage-gutters",
"ms-python.vscode-pylance"
// "eamodio.gitlens",
// "dbaeumer.vscode-eslint",
// "esbenp.prettier-vscode",
// "bierner.lit-html",
// "runem.lit-plugin",
// "auchenberg.vscode-browser-preview",
// "davidanson.vscode-markdownlint",
// "redhat.vscode-yaml",
// "oderwat.indent-rainbow"
],
}
3 changes: 3 additions & 0 deletions custom_components/dukaone/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
CONF_STATICIP = "static_ip"

ATTR_MODE = "mode"
ATTR_MANUAL_SPEED = "manual_speed"

MODE_IN = "in"
MODE_OUT = "out"
MODE_INOUT = "inout"

SPEED_MANUAL = "manual"
31 changes: 26 additions & 5 deletions custom_components/dukaone/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
SPEED_MEDIUM,
SPEED_OFF,
SUPPORT_SET_SPEED,
SUPPORT_OSCILLATE,
SUPPORT_DIRECTION,
FanEntity,
)
from homeassistant.config_entries import ConfigEntry
Expand All @@ -36,7 +34,14 @@
from dukaonesdk.dukaclient import DukaClient

from . import DukaEntityComponent
from .const import ATTR_MODE, DOMAIN, MODE_IN, MODE_INOUT, MODE_OUT
from .const import (
ATTR_MANUAL_SPEED,
ATTR_MODE,
DOMAIN,
MODE_IN,
MODE_INOUT,
MODE_OUT,SPEED_MANUAL
)

_LOGGER = logging.getLogger(__name__)

Expand All @@ -60,6 +65,10 @@
RESET_FILTER_TIMER_SCHEMA = vol.Schema({
vol.Required(ATTR_ENTITY_ID): cv.entity_ids
})
SET_MANUAL_SPEED_SCHEMA = vol.Schema({
vol.Required(ATTR_ENTITY_ID): cv.entity_ids,
vol.Required(ATTR_MANUAL_SPEED): int
})



Expand Down Expand Up @@ -97,6 +106,9 @@ async def async_setup_entry(
platform.async_register_entity_service(
"reset_filter_timer", RESET_FILTER_TIMER_SCHEMA,"reset_filter_timer"
)
platform.async_register_entity_service(
"set_manual_speed", SET_MANUAL_SPEED_SCHEMA,"set_manual_speed"
)


class DukaOneFan(FanEntity):
Expand Down Expand Up @@ -132,6 +144,8 @@ def OnChange(self, device: Device):
self._speed = SPEED_MEDIUM
elif device.speed == Speed.HIGH:
self._speed = SPEED_HIGH
elif device.speed == Speed.MANUAL:
self._speed = SPEED_MANUAL
else:
self._speed = SPEED_OFF
self._state = ((int)(device.speed)) != 0
Expand Down Expand Up @@ -182,7 +196,7 @@ def is_on(self):
@property
def speed_list(self) -> list:
"""Get the list of available speeds."""
return [SPEED_OFF, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]
return [SPEED_OFF, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH, SPEED_MANUAL]

@property
def supported_features(self) -> int:
Expand Down Expand Up @@ -216,6 +230,8 @@ def set_speed(self, speed: str) -> None:
self.the_client.set_speed(self._device, Speed.LOW)
elif speed == SPEED_OFF:
self.the_client.set_speed(self._device, Speed.OFF)
elif speed == SPEED_MANUAL:
self.the_client.set_speed(self._device, Speed.MANUAL)

@property
def mode(self):
Expand Down Expand Up @@ -250,10 +266,15 @@ def turn_off(self, **kwargs) -> None:
return

def reset_filter_timer(self):
"""REset the filter timer to 90 days"""
"""Reset the filter timer to 90 days"""
self.the_client.reset_filter_alarm(self._device)
return

def set_manual_speed(self, manual_speed: int):
"""Set the manual fan speed"""
self.the_client.set_manual_speed(self._device, manual_speed)
return

@property
def device_info(self):
"""Return device information."""
Expand Down
2 changes: 1 addition & 1 deletion custom_components/dukaone/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"homekit": {},
"documentation": "https://www.dingus.dk",
"requirements": [
"dukaonesdk==0.9.8"
"dukaonesdk==1.0.0"
]
}
13 changes: 11 additions & 2 deletions custom_components/dukaone/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set_mode:
fields:
entity_id:
description: Name of the entity to set
example: "fan.dukeone"
example: "fan.dukaone"
mode:
description: Mode in,out,inout
example: "inout"
Expand All @@ -12,4 +12,13 @@ reset_filter_timer:
fields:
entity_id:
description: Name of the entity to reset
example: "fan.dukeone"
example: "fan.dukaone"
set_manual_speed:
description: Set the fan speed manaually
fields:
entity_id:
description: Name of the entity to reset
example: "fan.dukaone"
manual_speed:
description: Manual speed 0-255
example: 100

0 comments on commit 2499140

Please sign in to comment.