Nx584 maint (#5149)
* Update nx584 requirement to 0.4 There have been a few bug fixes to nx584 since 0.2, so this just updates our requirement to pull in the newer version. * Fix nx584 if no partitions are found If we succeed in our connection to the panel but find no configured partitions, then we will fall through to the bypass probe and fail because 'zones' is never initialized. This fixes both exception paths and adds a test that would poke it.
This commit is contained in:
parent
c864ea60c9
commit
f71027a9c7
4 changed files with 11 additions and 3 deletions
|
@ -16,7 +16,7 @@ from homeassistant.const import (
|
|||
STATE_UNKNOWN, CONF_NAME, CONF_HOST, CONF_PORT)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
REQUIREMENTS = ['pynx584==0.2']
|
||||
REQUIREMENTS = ['pynx584==0.4']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -86,9 +86,11 @@ class NX584Alarm(alarm.AlarmControlPanel):
|
|||
_LOGGER.error('Unable to connect to %(host)s: %(reason)s',
|
||||
dict(host=self._url, reason=ex))
|
||||
self._state = STATE_UNKNOWN
|
||||
zones = []
|
||||
except IndexError:
|
||||
_LOGGER.error('nx584 reports no partitions')
|
||||
self._state = STATE_UNKNOWN
|
||||
zones = []
|
||||
|
||||
bypassed = False
|
||||
for zone in zones:
|
||||
|
|
|
@ -16,7 +16,7 @@ from homeassistant.components.binary_sensor import (
|
|||
from homeassistant.const import (CONF_HOST, CONF_PORT)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
REQUIREMENTS = ['pynx584==0.2']
|
||||
REQUIREMENTS = ['pynx584==0.4']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -442,7 +442,7 @@ pynut2==2.1.2
|
|||
|
||||
# homeassistant.components.alarm_control_panel.nx584
|
||||
# homeassistant.components.binary_sensor.nx584
|
||||
pynx584==0.2
|
||||
pynx584==0.4
|
||||
|
||||
# homeassistant.components.sensor.openweathermap
|
||||
# homeassistant.components.weather.openweathermap
|
||||
|
|
|
@ -106,6 +106,12 @@ class TestNX584SensorSetup(unittest.TestCase):
|
|||
requests.exceptions.ConnectionError
|
||||
self._test_assert_graceful_fail({})
|
||||
|
||||
def test_setup_no_partitions(self):
|
||||
"""Test the setup with connection failure."""
|
||||
nx584_client.Client.return_value.list_zones.side_effect = \
|
||||
IndexError
|
||||
self._test_assert_graceful_fail({})
|
||||
|
||||
def test_setup_version_too_old(self):
|
||||
""""Test if version is too old."""
|
||||
nx584_client.Client.return_value.get_version.return_value = '1.0'
|
||||
|
|
Loading…
Add table
Reference in a new issue