Fixes and enhancements for the Tahoma platform (#11547)
* 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.pull/11634/head
parent
cdbf2f9293
commit
9d67d229fa
|
@ -7,7 +7,7 @@ https://home-assistant.io/components/cover.tahoma/
|
|||
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)
|
||||
|
||||
|
@ -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])
|
||||
|
@ -46,12 +41,16 @@ class TahomaCover(TahomaDevice, CoverDevice):
|
|||
|
||||
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."""
|
||||
|
|
|
@ -124,4 +124,4 @@ class TahomaDevice(Entity):
|
|||
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])
|
||||
|
|
Loading…
Reference in New Issue