Add binary sensor to SmartTub for online status (#46889)
This commit is contained in:
parent
603191702f
commit
81d011efc5
6 changed files with 72 additions and 16 deletions
|
@ -3,7 +3,7 @@ from enum import Enum
|
|||
import logging
|
||||
|
||||
from .const import DOMAIN, SMARTTUB_CONTROLLER
|
||||
from .entity import SmartTubEntity
|
||||
from .entity import SmartTubSensorBase
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -42,18 +42,8 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
|||
async_add_entities(entities)
|
||||
|
||||
|
||||
class SmartTubSensor(SmartTubEntity):
|
||||
"""Generic and base class for SmartTub sensors."""
|
||||
|
||||
def __init__(self, coordinator, spa, sensor_name, attr_name):
|
||||
"""Initialize the entity."""
|
||||
super().__init__(coordinator, spa, sensor_name)
|
||||
self._attr_name = attr_name
|
||||
|
||||
@property
|
||||
def _state(self):
|
||||
"""Retrieve the underlying state from the spa."""
|
||||
return getattr(self.spa_status, self._attr_name)
|
||||
class SmartTubSensor(SmartTubSensorBase):
|
||||
"""Generic class for SmartTub status sensors."""
|
||||
|
||||
@property
|
||||
def state(self) -> str:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue