Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions homeassistant/components/cover/tahoma.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import logging
from datetime import timedelta

from homeassistant.components.cover import CoverDevice, ENTITY_ID_FORMAT
from homeassistant.components.cover import CoverDevice
from homeassistant.components.tahoma import (
DOMAIN as TAHOMA_DOMAIN, TahomaDevice)

Expand All @@ -30,11 +30,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class TahomaCover(TahomaDevice, CoverDevice):
"""Representation a Tahoma Cover."""

def __init__(self, tahoma_device, controller):
"""Initialize the Tahoma device."""
super().__init__(tahoma_device, controller)
self.entity_id = ENTITY_ID_FORMAT.format(self.unique_id)

def update(self):
"""Update method."""
self.controller.get_states([self.tahoma_device])
Expand All @@ -46,12 +41,16 @@ def current_cover_position(self):

0 is closed, 100 is fully open.
"""
position = 100 - self.tahoma_device.active_states['core:ClosureState']
if position <= 5:
return 0
if position >= 95:
return 100
return position
try:
position = 100 - \
self.tahoma_device.active_states['core:ClosureState']
if position <= 5:
return 0
if position >= 95:
return 100
return position
except KeyError:
return None

def set_cover_position(self, position, **kwargs):
"""Move the cover to a specific position."""
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/tahoma.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ def apply_action(self, cmd_name, *args):
from tahoma_api import Action
action = Action(self.tahoma_device.url)
action.add_command(cmd_name, *args)
self.controller.apply_actions('', [action])
self.controller.apply_actions('HomeAssistant', [action])