Add binary sensor to SmartTub for online status (#46889)

This commit is contained in:
Matt Zimmerman 2021-02-22 06:10:00 -08:00 committed by GitHub
parent 603191702f
commit 81d011efc5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 72 additions and 16 deletions

View file

@ -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: