Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion homeassistant/components/cover/isy994.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ def is_closed(self) -> bool:
@property
def state(self) -> str:
"""Get the state of the ISY994 cover device."""
return VALUE_TO_STATE.get(self.value, STATE_OPEN)
if self.is_unknown():
return None
else:
return VALUE_TO_STATE.get(self.value, STATE_OPEN)

def open_cover(self, **kwargs) -> None:
"""Send the open cover command to the ISY994 cover device."""
Expand Down
37 changes: 35 additions & 2 deletions homeassistant/components/isy994.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
For configuration details please visit the documentation for this component at
https://home-assistant.io/components/isy994/
"""
import asyncio
from collections import namedtuple
import logging
from urllib.parse import urlparse
Expand All @@ -17,7 +18,7 @@
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import ConfigType, Dict # noqa

REQUIREMENTS = ['PyISY==1.0.8']
REQUIREMENTS = ['PyISY==1.1.0']

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -106,7 +107,8 @@ def _categorize_nodes(hidden_identifier: str, sensor_identifier: str) -> None:
hidden = hidden_identifier in path or hidden_identifier in node.name
if hidden:
node.name += hidden_identifier
if sensor_identifier in path or sensor_identifier in node.name:
if (sensor_identifier in path or sensor_identifier in node.name) \
and isinstance(node, PYISY.Nodes.Node):
SENSOR_NODES.append(node)
elif isinstance(node, PYISY.Nodes.Node):
NODES.append(node)
Expand Down Expand Up @@ -227,15 +229,31 @@ class ISYDevice(Entity):
def __init__(self, node) -> None:
"""Initialize the insteon device."""
self._node = node
self._change_handler = None
self._control_handler = None

@asyncio.coroutine
def async_added_to_hass(self) -> None:
"""Subscribe to the node change events."""
self._change_handler = self._node.status.subscribe(
'changed', self.on_update)

if hasattr(self._node, 'controlEvents'):
self._control_handler = self._node.controlEvents.subscribe(
self.on_control)

# pylint: disable=unused-argument
def on_update(self, event: object) -> None:
"""Handle the update event from the ISY994 Node."""
self.schedule_update_ha_state()

def on_control(self, event: object) -> None:
"""Handle a control event from the ISY994 Node."""
self.hass.bus.fire('isy994_control', {
'entity_id': self.entity_id,
'control': event
})

@property
def domain(self) -> str:
"""Get the domain of the device."""
Expand Down Expand Up @@ -270,6 +288,21 @@ def value(self) -> object:
# pylint: disable=protected-access
return self._node.status._val

def is_unknown(self) -> bool:
"""Get whether or not the value of this Entity's node is unknown.

PyISY reports unknown values as -inf
"""
return self.value == -1 * float('inf')

@property
def state(self):
"""Return the state of the ISY device."""
if self.is_unknown():
return None
else:
return super().state

@property
def device_state_attributes(self) -> Dict:
"""Get the state attributes for the device."""
Expand Down
5 changes: 4 additions & 1 deletion homeassistant/components/lock/isy994.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ def is_locked(self) -> bool:
@property
def state(self) -> str:
"""Get the state of the lock."""
return VALUE_TO_STATE.get(self.value, STATE_UNKNOWN)
if self.is_unknown():
return None
else:
return VALUE_TO_STATE.get(self.value, STATE_UNKNOWN)

def lock(self, **kwargs) -> None:
"""Send the lock command to the ISY994 device."""
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/sensor/isy994.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ def raw_unit_of_measurement(self) -> str:
@property
def state(self) -> str:
"""Get the state of the ISY994 sensor device."""
if self.is_unknown():
return None

if len(self._node.uom) == 1:
if self._node.uom[0] in UOM_TO_STATES:
states = UOM_TO_STATES.get(self._node.uom[0])
Expand Down
5 changes: 4 additions & 1 deletion homeassistant/components/switch/isy994.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ def is_on(self) -> bool:
@property
def state(self) -> str:
"""Get the state of the ISY994 device."""
return VALUE_TO_STATE.get(bool(self.value), STATE_UNKNOWN)
if self.is_unknown():
return None
else:
return VALUE_TO_STATE.get(bool(self.value), STATE_UNKNOWN)

def turn_off(self, **kwargs) -> None:
"""Send the turn on command to the ISY994 switch."""
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ certifi>=2017.4.17
DoorBirdPy==0.1.0

# homeassistant.components.isy994
PyISY==1.0.8
PyISY==1.1.0

# homeassistant.components.notify.html5
PyJWT==1.5.3
Expand Down