1 """Support for SCSGate covers."""
3 from __future__
import annotations
8 from scsgate.tasks
import (
10 LowerRollerShutterTask,
11 RaiseRollerShutterTask,
13 import voluptuous
as vol
16 PLATFORM_SCHEMA
as COVER_PLATFORM_SCHEMA,
25 from .
import CONF_SCS_ID, DOMAIN, SCSGATE_SCHEMA
27 PLATFORM_SCHEMA = COVER_PLATFORM_SCHEMA.extend(
28 {vol.Required(CONF_DEVICES): cv.schema_with_slug_keys(SCSGATE_SCHEMA)}
35 add_entities: AddEntitiesCallback,
36 discovery_info: DiscoveryInfoType |
None =
None,
38 """Set up the SCSGate cover."""
39 devices = config.get(CONF_DEVICES)
41 logger = logging.getLogger(__name__)
42 scsgate = hass.data[DOMAIN]
45 for entity_info
in devices.values():
46 if entity_info[CONF_SCS_ID]
in scsgate.devices:
49 name = entity_info[CONF_NAME]
50 scs_id = entity_info[CONF_SCS_ID]
52 logger.info(
"Adding %s scsgate.cover", name)
55 name=name, scs_id=scs_id, logger=logger, scsgate=scsgate
57 scsgate.add_device(cover)
64 """Representation of SCSGate cover."""
66 _attr_should_poll =
False
68 def __init__(self, scs_id, name, logger, scsgate):
69 """Initialize the cover."""
77 """Return the SCSGate ID."""
82 """Return the name of the cover."""
83 return self.
_name_name
87 """Return if the cover is closed."""
92 self.
_scsgate_scsgate.append_task(RaiseRollerShutterTask(target=self.
_scs_id_scs_id))
95 """Move the cover down."""
96 self.
_scsgate_scsgate.append_task(LowerRollerShutterTask(target=self.
_scs_id_scs_id))
100 self.
_scsgate_scsgate.append_task(HaltRollerShutterTask(target=self.
_scs_id_scs_id))
103 """Handle a SCSGate message related with this cover."""
104 self.
_logger_logger.debug(
"Cover %s, got message %s", self.
_scs_id_scs_id, message.toggled)
def __init__(self, scs_id, name, logger, scsgate)
None close_cover(self, **Any kwargs)
def process_event(self, message)
None open_cover(self, **Any kwargs)
None stop_cover(self, **Any kwargs)
None add_entities(AsusWrtRouter router, AddEntitiesCallback async_add_entities, set[str] tracked)
None setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback add_entities, DiscoveryInfoType|None discovery_info=None)