Use EntityFeature in modbus
parent
e9126dd9bd
commit
56cf9d900d
|
@ -5,11 +5,8 @@ from datetime import datetime
|
|||
import struct
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.climate import ClimateEntity
|
||||
from homeassistant.components.climate.const import (
|
||||
HVAC_MODE_AUTO,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
|
||||
from homeassistant.components.climate.const import HVAC_MODE_AUTO
|
||||
from homeassistant.const import (
|
||||
ATTR_TEMPERATURE,
|
||||
CONF_NAME,
|
||||
|
@ -63,6 +60,8 @@ async def async_setup_platform(
|
|||
class ModbusThermostat(BaseStructPlatform, RestoreEntity, ClimateEntity):
|
||||
"""Representation of a Modbus Thermostat."""
|
||||
|
||||
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hub: ModbusHub,
|
||||
|
@ -73,7 +72,6 @@ class ModbusThermostat(BaseStructPlatform, RestoreEntity, ClimateEntity):
|
|||
self._target_temperature_register = config[CONF_TARGET_TEMP]
|
||||
self._unit = config[CONF_TEMPERATURE_UNIT]
|
||||
|
||||
self._attr_supported_features = SUPPORT_TARGET_TEMPERATURE
|
||||
self._attr_hvac_mode = HVAC_MODE_AUTO
|
||||
self._attr_hvac_modes = [HVAC_MODE_AUTO]
|
||||
self._attr_current_temperature = None
|
||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.cover import SUPPORT_CLOSE, SUPPORT_OPEN, CoverEntity
|
||||
from homeassistant.components.cover import CoverEntity, CoverEntityFeature
|
||||
from homeassistant.const import (
|
||||
CONF_COVERS,
|
||||
CONF_NAME,
|
||||
|
@ -59,6 +59,8 @@ async def async_setup_platform(
|
|||
class ModbusCover(BasePlatform, CoverEntity, RestoreEntity):
|
||||
"""Representation of a Modbus cover."""
|
||||
|
||||
_attr_supported_features = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hub: ModbusHub,
|
||||
|
@ -73,7 +75,6 @@ class ModbusCover(BasePlatform, CoverEntity, RestoreEntity):
|
|||
self._status_register = config.get(CONF_STATUS_REGISTER)
|
||||
self._status_register_type = config[CONF_STATUS_REGISTER_TYPE]
|
||||
|
||||
self._attr_supported_features = SUPPORT_OPEN | SUPPORT_CLOSE
|
||||
self._attr_is_closed = False
|
||||
|
||||
# If we read cover status from coil, and not from optional status register,
|
||||
|
|
Loading…
Reference in New Issue