Skip to content

Commit

Permalink
bump nhc2-coco to 1.2.0 to enable shutters
Browse files Browse the repository at this point in the history
  • Loading branch information
fiva authored and fiva committed Dec 1, 2020
1 parent 2a62bb0 commit ed543fa
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion custom_components/nhc2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .const import DOMAIN, KEY_GATEWAY, CONF_SWITCHES_AS_LIGHTS
from .helpers import extract_versions

REQUIREMENTS = ['nhc2-coco==1.1.3']
REQUIREMENTS = ['nhc2-coco==1.2.0']

_LOGGER = logging.getLogger(__name__)

Expand Down
5 changes: 5 additions & 0 deletions custom_components/nhc2/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@
CONF_SWITCHES_AS_LIGHTS = 'switches_as_lights'
DEFAULT_PORT = 8883
KEY_MANUAL = 'MANUAL_IP_HOST'

ROLL_DOWN_SHUTTER = 'rolldownshutter'
SUN_BLIND = 'sunblind'
GATE = 'gate'
VENETIAN_BLIND = 'venetianblind'
18 changes: 16 additions & 2 deletions custom_components/nhc2/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import logging

from homeassistant.components.cover import CoverEntity, SUPPORT_OPEN, SUPPORT_CLOSE, SUPPORT_STOP, SUPPORT_SET_POSITION, \
ATTR_POSITION
ATTR_POSITION, DEVICE_CLASS_SHUTTER, DEVICE_CLASS_BLIND, DEVICE_CLASS_GATE
from nhc2_coco import CoCo
from nhc2_coco.coco_device_class import CoCoDeviceClass
from nhc2_coco.coco_shutter import CoCoShutter

from .const import DOMAIN, KEY_GATEWAY, BRAND, COVER
from .const import DOMAIN, KEY_GATEWAY, BRAND, COVER, ROLL_DOWN_SHUTTER, SUN_BLIND, GATE, VENETIAN_BLIND
from .helpers import nhc2_entity_processor

KEY_GATEWAY = KEY_GATEWAY
Expand Down Expand Up @@ -43,6 +43,20 @@ def current_cover_position(self):
"""Return current position of cover. 0 is closed, 100 is open."""
return self._nhc2shutter.position

@property
def device_class(self):
model = self._nhc2shutter.model
if model == ROLL_DOWN_SHUTTER:
return DEVICE_CLASS_SHUTTER
if model == SUN_BLIND:
return DEVICE_CLASS_BLIND
if model == GATE:
return DEVICE_CLASS_GATE
if model == VENETIAN_BLIND:
return DEVICE_CLASS_BLIND
# If model not known, we choose 'generic' by returning None
return None

@property
def supported_features(self) -> int:
"""Flag supported features."""
Expand Down
2 changes: 1 addition & 1 deletion custom_components/nhc2/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "nhc2",
"name": "Niko Home Control II",
"requirements": ["nhc2-coco==1.1.3"],
"requirements": ["nhc2-coco==1.2.0"],
"config_flow": true,
"issue_tracker": "https://github.com/filipvh/hass-nhc2/issues",
"documentation": "https://github.com/filipvh/hass-nhc2/blob/master/README.md",
Expand Down

0 comments on commit ed543fa

Please sign in to comment.