Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated ISY994 Insteon and variable sensor entities #92255

Merged
merged 1 commit into from
Apr 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 2 additions & 9 deletions homeassistant/components/isy994/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@
CONF_NETWORK,
CONF_SENSOR_STRING,
CONF_TLS_VER,
CONF_VAR_SENSOR_STRING,
DEFAULT_IGNORE_STRING,
DEFAULT_SENSOR_STRING,
DEFAULT_VAR_SENSOR_STRING,
DOMAIN,
ISY_CONF_FIRMWARE,
ISY_CONF_MODEL,
Expand All @@ -45,7 +43,7 @@
SCHEME_HTTP,
SCHEME_HTTPS,
)
from .helpers import _categorize_nodes, _categorize_programs, _categorize_variables
from .helpers import _categorize_nodes, _categorize_programs
from .models import IsyData
from .services import async_setup_services, async_unload_services
from .util import _async_cleanup_registry_entries
Expand Down Expand Up @@ -75,9 +73,6 @@ async def async_setup_entry(
tls_version = isy_config.get(CONF_TLS_VER)
ignore_identifier = isy_options.get(CONF_IGNORE_STRING, DEFAULT_IGNORE_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:
https = False
Expand Down Expand Up @@ -132,9 +127,7 @@ async def async_setup_entry(

_categorize_nodes(isy_data, isy.nodes, ignore_identifier, sensor_identifier)
_categorize_programs(isy_data, isy.programs)
# Categorize variables call to be removed with variable sensors in 2023.5.0
_categorize_variables(isy_data, isy.variables, variable_identifier)
# Gather ISY Variables to be added. Identifier used to enable by default.
# Gather ISY Variables to be added.
if isy.variables.children:
isy_data.devices[CONF_VARIABLES] = _create_service_device_info(
isy, name=CONF_VARIABLES.title(), unique_id=CONF_VARIABLES
Expand Down
17 changes: 0 additions & 17 deletions homeassistant/components/isy994/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
)
from pyisy.nodes import Group, Node, Nodes
from pyisy.programs import Programs
from pyisy.variables import Variables

from homeassistant.const import ATTR_MANUFACTURER, ATTR_MODEL, Platform
from homeassistant.helpers.entity import DeviceInfo
Expand Down Expand Up @@ -349,8 +348,6 @@ def _categorize_nodes(
if getattr(node, "is_dimmable", False):
aux_controls = ROOT_AUX_CONTROLS.intersection(node.aux_properties)
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]
isy_data.aux_properties[platform].append((node, control))
if hasattr(node, TAG_ENABLED):
Expand Down Expand Up @@ -432,20 +429,6 @@ def _categorize_programs(isy_data: IsyData, programs: Programs) -> None:
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(
value: int | float | None,
uom: str | None,
Expand Down
40 changes: 2 additions & 38 deletions homeassistant/components/isy994/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
)
from pyisy.helpers import EventListener, NodeProperty
from pyisy.nodes import Node, NodeChangedEvent
from pyisy.variables import Variable

from homeassistant.components.sensor import (
SensorDeviceClass,
Expand All @@ -44,7 +43,7 @@
UOM_ON_OFF,
UOM_TO_STATES,
)
from .entity import ISYEntity, ISYNodeEntity
from .entity import ISYNodeEntity
from .helpers import convert_isy_value_to_hass

# Disable general purpose and redundant sensors by default
Expand Down Expand Up @@ -111,7 +110,7 @@ async def async_setup_entry(
) -> None:
"""Set up the ISY sensor platform."""
isy_data = hass.data[DOMAIN][entry.entry_id]
entities: list[ISYSensorEntity | ISYSensorVariableEntity] = []
entities: list[ISYSensorEntity] = []
devices: dict[str, DeviceInfo] = isy_data.devices

for node in isy_data.nodes[Platform.SENSOR]:
Expand All @@ -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)


Expand Down Expand Up @@ -292,35 +288,3 @@ def async_on_update(self, event: NodeProperty | NodeChangedEvent) -> None:
def available(self) -> bool:
"""Return entity availability."""
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"