Remove deprecated ISY994 Insteon and variable sensor entities (#92255)
This commit is contained in:
parent
b0b4134ded
commit
d9e0681123
3 changed files with 4 additions and 64 deletions
|
@ -32,10 +32,8 @@ from .const import (
|
||||||
CONF_NETWORK,
|
CONF_NETWORK,
|
||||||
CONF_SENSOR_STRING,
|
CONF_SENSOR_STRING,
|
||||||
CONF_TLS_VER,
|
CONF_TLS_VER,
|
||||||
CONF_VAR_SENSOR_STRING,
|
|
||||||
DEFAULT_IGNORE_STRING,
|
DEFAULT_IGNORE_STRING,
|
||||||
DEFAULT_SENSOR_STRING,
|
DEFAULT_SENSOR_STRING,
|
||||||
DEFAULT_VAR_SENSOR_STRING,
|
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
ISY_CONF_FIRMWARE,
|
ISY_CONF_FIRMWARE,
|
||||||
ISY_CONF_MODEL,
|
ISY_CONF_MODEL,
|
||||||
|
@ -45,7 +43,7 @@ from .const import (
|
||||||
SCHEME_HTTP,
|
SCHEME_HTTP,
|
||||||
SCHEME_HTTPS,
|
SCHEME_HTTPS,
|
||||||
)
|
)
|
||||||
from .helpers import _categorize_nodes, _categorize_programs, _categorize_variables
|
from .helpers import _categorize_nodes, _categorize_programs
|
||||||
from .models import IsyData
|
from .models import IsyData
|
||||||
from .services import async_setup_services, async_unload_services
|
from .services import async_setup_services, async_unload_services
|
||||||
from .util import _async_cleanup_registry_entries
|
from .util import _async_cleanup_registry_entries
|
||||||
|
@ -75,9 +73,6 @@ async def async_setup_entry(
|
||||||
tls_version = isy_config.get(CONF_TLS_VER)
|
tls_version = isy_config.get(CONF_TLS_VER)
|
||||||
ignore_identifier = isy_options.get(CONF_IGNORE_STRING, DEFAULT_IGNORE_STRING)
|
ignore_identifier = isy_options.get(CONF_IGNORE_STRING, DEFAULT_IGNORE_STRING)
|
||||||
sensor_identifier = isy_options.get(CONF_SENSOR_STRING, DEFAULT_SENSOR_STRING)
|
sensor_identifier = isy_options.get(CONF_SENSOR_STRING, DEFAULT_SENSOR_STRING)
|
||||||
variable_identifier = isy_options.get(
|
|
||||||
CONF_VAR_SENSOR_STRING, DEFAULT_VAR_SENSOR_STRING
|
|
||||||
)
|
|
||||||
|
|
||||||
if host.scheme == SCHEME_HTTP:
|
if host.scheme == SCHEME_HTTP:
|
||||||
https = False
|
https = False
|
||||||
|
@ -132,9 +127,7 @@ async def async_setup_entry(
|
||||||
|
|
||||||
_categorize_nodes(isy_data, isy.nodes, ignore_identifier, sensor_identifier)
|
_categorize_nodes(isy_data, isy.nodes, ignore_identifier, sensor_identifier)
|
||||||
_categorize_programs(isy_data, isy.programs)
|
_categorize_programs(isy_data, isy.programs)
|
||||||
# Categorize variables call to be removed with variable sensors in 2023.5.0
|
# Gather ISY Variables to be added.
|
||||||
_categorize_variables(isy_data, isy.variables, variable_identifier)
|
|
||||||
# Gather ISY Variables to be added. Identifier used to enable by default.
|
|
||||||
if isy.variables.children:
|
if isy.variables.children:
|
||||||
isy_data.devices[CONF_VARIABLES] = _create_service_device_info(
|
isy_data.devices[CONF_VARIABLES] = _create_service_device_info(
|
||||||
isy, name=CONF_VARIABLES.title(), unique_id=CONF_VARIABLES
|
isy, name=CONF_VARIABLES.title(), unique_id=CONF_VARIABLES
|
||||||
|
|
|
@ -22,7 +22,6 @@ from pyisy.constants import (
|
||||||
)
|
)
|
||||||
from pyisy.nodes import Group, Node, Nodes
|
from pyisy.nodes import Group, Node, Nodes
|
||||||
from pyisy.programs import Programs
|
from pyisy.programs import Programs
|
||||||
from pyisy.variables import Variables
|
|
||||||
|
|
||||||
from homeassistant.const import ATTR_MANUFACTURER, ATTR_MODEL, Platform
|
from homeassistant.const import ATTR_MANUFACTURER, ATTR_MODEL, Platform
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
|
@ -349,8 +348,6 @@ def _categorize_nodes(
|
||||||
if getattr(node, "is_dimmable", False):
|
if getattr(node, "is_dimmable", False):
|
||||||
aux_controls = ROOT_AUX_CONTROLS.intersection(node.aux_properties)
|
aux_controls = ROOT_AUX_CONTROLS.intersection(node.aux_properties)
|
||||||
for control in aux_controls:
|
for control in aux_controls:
|
||||||
# Deprecated all aux properties as sensors. Update in 2023.5.0 to remove extras.
|
|
||||||
isy_data.aux_properties[Platform.SENSOR].append((node, control))
|
|
||||||
platform = NODE_AUX_FILTERS[control]
|
platform = NODE_AUX_FILTERS[control]
|
||||||
isy_data.aux_properties[platform].append((node, control))
|
isy_data.aux_properties[platform].append((node, control))
|
||||||
if hasattr(node, TAG_ENABLED):
|
if hasattr(node, TAG_ENABLED):
|
||||||
|
@ -432,20 +429,6 @@ def _categorize_programs(isy_data: IsyData, programs: Programs) -> None:
|
||||||
isy_data.programs[platform].append(entity)
|
isy_data.programs[platform].append(entity)
|
||||||
|
|
||||||
|
|
||||||
def _categorize_variables(
|
|
||||||
isy_data: IsyData, variables: Variables, identifier: str
|
|
||||||
) -> None:
|
|
||||||
"""Gather the ISY Variables to be added as sensors."""
|
|
||||||
try:
|
|
||||||
isy_data.variables[Platform.SENSOR] = [
|
|
||||||
variables[vtype][vid]
|
|
||||||
for (vtype, vname, vid) in variables.children
|
|
||||||
if identifier in vname
|
|
||||||
]
|
|
||||||
except KeyError as err:
|
|
||||||
_LOGGER.error("Error adding ISY Variables: %s", err)
|
|
||||||
|
|
||||||
|
|
||||||
def convert_isy_value_to_hass(
|
def convert_isy_value_to_hass(
|
||||||
value: int | float | None,
|
value: int | float | None,
|
||||||
uom: str | None,
|
uom: str | None,
|
||||||
|
|
|
@ -22,7 +22,6 @@ from pyisy.constants import (
|
||||||
)
|
)
|
||||||
from pyisy.helpers import EventListener, NodeProperty
|
from pyisy.helpers import EventListener, NodeProperty
|
||||||
from pyisy.nodes import Node, NodeChangedEvent
|
from pyisy.nodes import Node, NodeChangedEvent
|
||||||
from pyisy.variables import Variable
|
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
|
@ -44,7 +43,7 @@ from .const import (
|
||||||
UOM_ON_OFF,
|
UOM_ON_OFF,
|
||||||
UOM_TO_STATES,
|
UOM_TO_STATES,
|
||||||
)
|
)
|
||||||
from .entity import ISYEntity, ISYNodeEntity
|
from .entity import ISYNodeEntity
|
||||||
from .helpers import convert_isy_value_to_hass
|
from .helpers import convert_isy_value_to_hass
|
||||||
|
|
||||||
# Disable general purpose and redundant sensors by default
|
# Disable general purpose and redundant sensors by default
|
||||||
|
@ -111,7 +110,7 @@ async def async_setup_entry(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the ISY sensor platform."""
|
"""Set up the ISY sensor platform."""
|
||||||
isy_data = hass.data[DOMAIN][entry.entry_id]
|
isy_data = hass.data[DOMAIN][entry.entry_id]
|
||||||
entities: list[ISYSensorEntity | ISYSensorVariableEntity] = []
|
entities: list[ISYSensorEntity] = []
|
||||||
devices: dict[str, DeviceInfo] = isy_data.devices
|
devices: dict[str, DeviceInfo] = isy_data.devices
|
||||||
|
|
||||||
for node in isy_data.nodes[Platform.SENSOR]:
|
for node in isy_data.nodes[Platform.SENSOR]:
|
||||||
|
@ -134,9 +133,6 @@ async def async_setup_entry(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
for variable in isy_data.variables[Platform.SENSOR]:
|
|
||||||
entities.append(ISYSensorVariableEntity(variable))
|
|
||||||
|
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
|
||||||
|
@ -292,35 +288,3 @@ class ISYAuxSensorEntity(ISYSensorEntity):
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Return entity availability."""
|
"""Return entity availability."""
|
||||||
return cast(bool, self._node.enabled)
|
return cast(bool, self._node.enabled)
|
||||||
|
|
||||||
|
|
||||||
class ISYSensorVariableEntity(ISYEntity, SensorEntity):
|
|
||||||
"""Representation of an ISY variable as a sensor device."""
|
|
||||||
|
|
||||||
# Deprecated sensors, will be removed in 2023.5.0
|
|
||||||
_attr_entity_registry_enabled_default = False
|
|
||||||
|
|
||||||
def __init__(self, variable_node: Variable) -> None:
|
|
||||||
"""Initialize the ISY binary sensor program."""
|
|
||||||
super().__init__(variable_node)
|
|
||||||
self._name = variable_node.name
|
|
||||||
|
|
||||||
@property
|
|
||||||
def native_value(self) -> float | int | None:
|
|
||||||
"""Return the state of the variable."""
|
|
||||||
return convert_isy_value_to_hass(self._node.status, "", self._node.prec)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def extra_state_attributes(self) -> dict[str, Any]:
|
|
||||||
"""Get the state attributes for the device."""
|
|
||||||
return {
|
|
||||||
"init_value": convert_isy_value_to_hass(
|
|
||||||
self._node.init, "", self._node.prec
|
|
||||||
),
|
|
||||||
"last_edited": self._node.last_edited,
|
|
||||||
}
|
|
||||||
|
|
||||||
@property
|
|
||||||
def icon(self) -> str:
|
|
||||||
"""Return the icon."""
|
|
||||||
return "mdi:counter"
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue