Skip to content

Commit

Permalink
Fixes and enhancements for the Tahoma platform (#11547)
Browse files Browse the repository at this point in the history
* Strip off the RTS/IO ID from the entity ID

* Ignore exception thrown when the device does not provide an active state

* Send actions with a label for easier identification in the Tahoma log

* Linting

* Strip off the RTS/IO ID from the entity ID, take 2

As per suggestions, let HA do the standard initialization and assign
an appropriate entity_id, instead of overriding it with the lengthy
unique_id coming from the TaHoma devices.
  • Loading branch information
glpatcern authored and pvizeli committed Jan 13, 2018
1 parent cdbf2f9 commit 9d67d22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
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 @@ -124,4 +124,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])

0 comments on commit 9d67d22

Please sign in to comment.