Ignore central confic in instanciate entities
This commit is contained in:
@@ -20,6 +20,8 @@ from .const import (
|
|||||||
CONF_USE_PRESENCE_FEATURE,
|
CONF_USE_PRESENCE_FEATURE,
|
||||||
CONF_USE_MOTION_FEATURE,
|
CONF_USE_MOTION_FEATURE,
|
||||||
CONF_USE_WINDOW_FEATURE,
|
CONF_USE_WINDOW_FEATURE,
|
||||||
|
CONF_THERMOSTAT_TYPE,
|
||||||
|
CONF_THERMOSTAT_CENTRAL_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@@ -37,8 +39,15 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
unique_id = entry.entry_id
|
unique_id = entry.entry_id
|
||||||
name = entry.data.get(CONF_NAME)
|
name = entry.data.get(CONF_NAME)
|
||||||
|
vt_type = entry.data.get(CONF_THERMOSTAT_TYPE)
|
||||||
|
|
||||||
entities = [SecurityBinarySensor(hass, unique_id, name, entry.data),WindowByPassBinarySensor(hass, unique_id, name, entry.data)]
|
if vt_type == CONF_THERMOSTAT_CENTRAL_CONFIG:
|
||||||
|
return
|
||||||
|
|
||||||
|
entities = [
|
||||||
|
SecurityBinarySensor(hass, unique_id, name, entry.data),
|
||||||
|
WindowByPassBinarySensor(hass, unique_id, name, entry.data),
|
||||||
|
]
|
||||||
if entry.data.get(CONF_USE_MOTION_FEATURE):
|
if entry.data.get(CONF_USE_MOTION_FEATURE):
|
||||||
entities.append(MotionBinarySensor(hass, unique_id, name, entry.data))
|
entities.append(MotionBinarySensor(hass, unique_id, name, entry.data))
|
||||||
if entry.data.get(CONF_USE_WINDOW_FEATURE):
|
if entry.data.get(CONF_USE_WINDOW_FEATURE):
|
||||||
@@ -55,8 +64,12 @@ class SecurityBinarySensor(VersatileThermostatBaseEntity, BinarySensorEntity):
|
|||||||
"""Representation of a BinarySensor which exposes the security state"""
|
"""Representation of a BinarySensor which exposes the security state"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, hass: HomeAssistant, unique_id, name, entry_infos
|
self,
|
||||||
) -> None: # pylint: disable=unused-argument
|
hass: HomeAssistant,
|
||||||
|
unique_id,
|
||||||
|
name, # pylint: disable=unused-argument
|
||||||
|
entry_infos,
|
||||||
|
) -> None:
|
||||||
"""Initialize the SecurityState Binary sensor"""
|
"""Initialize the SecurityState Binary sensor"""
|
||||||
super().__init__(hass, unique_id, entry_infos.get(CONF_NAME))
|
super().__init__(hass, unique_id, entry_infos.get(CONF_NAME))
|
||||||
self._attr_name = "Security state"
|
self._attr_name = "Security state"
|
||||||
@@ -90,8 +103,12 @@ class OverpoweringBinarySensor(VersatileThermostatBaseEntity, BinarySensorEntity
|
|||||||
"""Representation of a BinarySensor which exposes the overpowering state"""
|
"""Representation of a BinarySensor which exposes the overpowering state"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, hass: HomeAssistant, unique_id, name, entry_infos
|
self,
|
||||||
) -> None: # pylint: disable=unused-argument
|
hass: HomeAssistant,
|
||||||
|
unique_id,
|
||||||
|
name, # pylint: disable=unused-argument
|
||||||
|
entry_infos,
|
||||||
|
) -> None:
|
||||||
"""Initialize the OverpoweringState Binary sensor"""
|
"""Initialize the OverpoweringState Binary sensor"""
|
||||||
super().__init__(hass, unique_id, entry_infos.get(CONF_NAME))
|
super().__init__(hass, unique_id, entry_infos.get(CONF_NAME))
|
||||||
self._attr_name = "Overpowering state"
|
self._attr_name = "Overpowering state"
|
||||||
@@ -125,8 +142,12 @@ class WindowBinarySensor(VersatileThermostatBaseEntity, BinarySensorEntity):
|
|||||||
"""Representation of a BinarySensor which exposes the window state"""
|
"""Representation of a BinarySensor which exposes the window state"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, hass: HomeAssistant, unique_id, name, entry_infos
|
self,
|
||||||
) -> None: # pylint: disable=unused-argument
|
hass: HomeAssistant,
|
||||||
|
unique_id,
|
||||||
|
name, # pylint: disable=unused-argument
|
||||||
|
entry_infos,
|
||||||
|
) -> None:
|
||||||
"""Initialize the WindowState Binary sensor"""
|
"""Initialize the WindowState Binary sensor"""
|
||||||
super().__init__(hass, unique_id, entry_infos.get(CONF_NAME))
|
super().__init__(hass, unique_id, entry_infos.get(CONF_NAME))
|
||||||
self._attr_name = "Window state"
|
self._attr_name = "Window state"
|
||||||
@@ -171,8 +192,12 @@ class MotionBinarySensor(VersatileThermostatBaseEntity, BinarySensorEntity):
|
|||||||
"""Representation of a BinarySensor which exposes the motion state"""
|
"""Representation of a BinarySensor which exposes the motion state"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, hass: HomeAssistant, unique_id, name, entry_infos
|
self,
|
||||||
) -> None: # pylint: disable=unused-argument
|
hass: HomeAssistant,
|
||||||
|
unique_id,
|
||||||
|
name, # pylint: disable=unused-argument
|
||||||
|
entry_infos,
|
||||||
|
) -> None:
|
||||||
"""Initialize the MotionState Binary sensor"""
|
"""Initialize the MotionState Binary sensor"""
|
||||||
super().__init__(hass, unique_id, entry_infos.get(CONF_NAME))
|
super().__init__(hass, unique_id, entry_infos.get(CONF_NAME))
|
||||||
self._attr_name = "Motion state"
|
self._attr_name = "Motion state"
|
||||||
@@ -207,8 +232,12 @@ class PresenceBinarySensor(VersatileThermostatBaseEntity, BinarySensorEntity):
|
|||||||
"""Representation of a BinarySensor which exposes the presence state"""
|
"""Representation of a BinarySensor which exposes the presence state"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, hass: HomeAssistant, unique_id, name, entry_infos
|
self,
|
||||||
) -> None: # pylint: disable=unused-argument
|
hass: HomeAssistant,
|
||||||
|
unique_id,
|
||||||
|
name, # pylint: disable=unused-argument
|
||||||
|
entry_infos,
|
||||||
|
) -> None:
|
||||||
"""Initialize the PresenceState Binary sensor"""
|
"""Initialize the PresenceState Binary sensor"""
|
||||||
super().__init__(hass, unique_id, entry_infos.get(CONF_NAME))
|
super().__init__(hass, unique_id, entry_infos.get(CONF_NAME))
|
||||||
self._attr_name = "Presence state"
|
self._attr_name = "Presence state"
|
||||||
@@ -239,13 +268,18 @@ class PresenceBinarySensor(VersatileThermostatBaseEntity, BinarySensorEntity):
|
|||||||
else:
|
else:
|
||||||
return "mdi:nature-people"
|
return "mdi:nature-people"
|
||||||
|
|
||||||
#PR - Adding Window ByPass
|
|
||||||
|
# PR - Adding Window ByPass
|
||||||
class WindowByPassBinarySensor(VersatileThermostatBaseEntity, BinarySensorEntity):
|
class WindowByPassBinarySensor(VersatileThermostatBaseEntity, BinarySensorEntity):
|
||||||
"""Representation of a BinarySensor which exposes the Window ByPass state"""
|
"""Representation of a BinarySensor which exposes the Window ByPass state"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, hass: HomeAssistant, unique_id, name, entry_infos
|
self,
|
||||||
) -> None: # pylint: disable=unused-argument
|
hass: HomeAssistant,
|
||||||
|
unique_id,
|
||||||
|
name, # pylint: disable=unused-argument
|
||||||
|
entry_infos,
|
||||||
|
) -> None:
|
||||||
"""Initialize the WindowByPass Binary sensor"""
|
"""Initialize the WindowByPass Binary sensor"""
|
||||||
super().__init__(hass, unique_id, entry_infos.get(CONF_NAME))
|
super().__init__(hass, unique_id, entry_infos.get(CONF_NAME))
|
||||||
self._attr_name = "Window bypass"
|
self._attr_name = "Window bypass"
|
||||||
@@ -272,4 +306,4 @@ class WindowByPassBinarySensor(VersatileThermostatBaseEntity, BinarySensorEntity
|
|||||||
if self._attr_is_on:
|
if self._attr_is_on:
|
||||||
return "mdi:window-shutter-cog"
|
return "mdi:window-shutter-cog"
|
||||||
else:
|
else:
|
||||||
return "mdi:window-shutter-auto"
|
return "mdi:window-shutter-auto"
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ from .const import (
|
|||||||
CONF_THERMOSTAT_SWITCH,
|
CONF_THERMOSTAT_SWITCH,
|
||||||
CONF_THERMOSTAT_CLIMATE,
|
CONF_THERMOSTAT_CLIMATE,
|
||||||
CONF_THERMOSTAT_VALVE,
|
CONF_THERMOSTAT_VALVE,
|
||||||
|
CONF_THERMOSTAT_CENTRAL_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .thermostat_switch import ThermostatOverSwitch
|
from .thermostat_switch import ThermostatOverSwitch
|
||||||
@@ -64,7 +65,11 @@ async def async_setup_entry(
|
|||||||
name = entry.data.get(CONF_NAME)
|
name = entry.data.get(CONF_NAME)
|
||||||
vt_type = entry.data.get(CONF_THERMOSTAT_TYPE)
|
vt_type = entry.data.get(CONF_THERMOSTAT_TYPE)
|
||||||
|
|
||||||
|
if vt_type == CONF_THERMOSTAT_CENTRAL_CONFIG:
|
||||||
|
return
|
||||||
|
|
||||||
# Instantiate the right base class
|
# Instantiate the right base class
|
||||||
|
entity = None
|
||||||
if vt_type == CONF_THERMOSTAT_SWITCH:
|
if vt_type == CONF_THERMOSTAT_SWITCH:
|
||||||
entity = ThermostatOverSwitch(hass, unique_id, name, entry.data)
|
entity = ThermostatOverSwitch(hass, unique_id, name, entry.data)
|
||||||
elif vt_type == CONF_THERMOSTAT_CLIMATE:
|
elif vt_type == CONF_THERMOSTAT_CLIMATE:
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ from .const import (
|
|||||||
CONF_THERMOSTAT_VALVE,
|
CONF_THERMOSTAT_VALVE,
|
||||||
CONF_THERMOSTAT_CLIMATE,
|
CONF_THERMOSTAT_CLIMATE,
|
||||||
CONF_THERMOSTAT_TYPE,
|
CONF_THERMOSTAT_TYPE,
|
||||||
|
CONF_THERMOSTAT_CENTRAL_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
THRESHOLD_WATT_KILO = 100
|
THRESHOLD_WATT_KILO = 100
|
||||||
@@ -46,6 +47,10 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
unique_id = entry.entry_id
|
unique_id = entry.entry_id
|
||||||
name = entry.data.get(CONF_NAME)
|
name = entry.data.get(CONF_NAME)
|
||||||
|
vt_type = entry.data.get(CONF_THERMOSTAT_TYPE)
|
||||||
|
|
||||||
|
if vt_type == CONF_THERMOSTAT_CENTRAL_CONFIG:
|
||||||
|
return
|
||||||
|
|
||||||
entities = [
|
entities = [
|
||||||
LastTemperatureSensor(hass, unique_id, name, entry.data),
|
LastTemperatureSensor(hass, unique_id, name, entry.data),
|
||||||
|
|||||||
Reference in New Issue
Block a user