mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Bump numato-gpio to v0.13.0 (#113182)
This commit is contained in:
parent
42873cacf5
commit
25be71e05b
@ -54,7 +54,6 @@ def setup_platform(
|
|||||||
for port, port_name in ports.items():
|
for port, port_name in ports.items():
|
||||||
try:
|
try:
|
||||||
api.setup_input(device_id, port)
|
api.setup_input(device_id, port)
|
||||||
api.edge_detect(device_id, port, partial(read_gpio, device_id))
|
|
||||||
|
|
||||||
except NumatoGpioError as err:
|
except NumatoGpioError as err:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
@ -68,7 +67,17 @@ def setup_platform(
|
|||||||
err,
|
err,
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
try:
|
||||||
|
api.edge_detect(device_id, port, partial(read_gpio, device_id))
|
||||||
|
|
||||||
|
except NumatoGpioError as err:
|
||||||
|
_LOGGER.info(
|
||||||
|
"Notification setup failed on device %s, "
|
||||||
|
"updates on binary sensor %s only in polling mode: %s",
|
||||||
|
device_id,
|
||||||
|
port_name,
|
||||||
|
err,
|
||||||
|
)
|
||||||
binary_sensors.append(
|
binary_sensors.append(
|
||||||
NumatoGpioBinarySensor(
|
NumatoGpioBinarySensor(
|
||||||
port_name,
|
port_name,
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
"integration_type": "hub",
|
"integration_type": "hub",
|
||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"loggers": ["numato_gpio"],
|
"loggers": ["numato_gpio"],
|
||||||
"requirements": ["numato-gpio==0.12.0"]
|
"requirements": ["numato-gpio==0.13.0"]
|
||||||
}
|
}
|
||||||
|
@ -1406,7 +1406,7 @@ nsw-fuel-api-client==1.1.0
|
|||||||
nuheat==1.0.1
|
nuheat==1.0.1
|
||||||
|
|
||||||
# homeassistant.components.numato
|
# homeassistant.components.numato
|
||||||
numato-gpio==0.12.0
|
numato-gpio==0.13.0
|
||||||
|
|
||||||
# homeassistant.components.compensation
|
# homeassistant.components.compensation
|
||||||
# homeassistant.components.iqvia
|
# homeassistant.components.iqvia
|
||||||
|
@ -1124,7 +1124,7 @@ nsw-fuel-api-client==1.1.0
|
|||||||
nuheat==1.0.1
|
nuheat==1.0.1
|
||||||
|
|
||||||
# homeassistant.components.numato
|
# homeassistant.components.numato
|
||||||
numato-gpio==0.12.0
|
numato-gpio==0.13.0
|
||||||
|
|
||||||
# homeassistant.components.compensation
|
# homeassistant.components.compensation
|
||||||
# homeassistant.components.iqvia
|
# homeassistant.components.iqvia
|
||||||
|
@ -62,7 +62,8 @@ class NumatoModuleMock:
|
|||||||
|
|
||||||
Ignore the device list argument, mock discovers /dev/ttyACM0.
|
Ignore the device list argument, mock discovers /dev/ttyACM0.
|
||||||
"""
|
"""
|
||||||
self.devices[0] = NumatoModuleMock.NumatoDeviceMock("/dev/ttyACM0")
|
if not self.devices:
|
||||||
|
self.devices[0] = NumatoModuleMock.NumatoDeviceMock("/dev/ttyACM0")
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
"""Mockup for the numato device cleanup."""
|
"""Mockup for the numato device cleanup."""
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
"""Tests for the numato binary_sensor platform."""
|
"""Tests for the numato binary_sensor platform."""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from .common import NUMATO_CFG, mockup_raise
|
from .common import NUMATO_CFG, mockup_raise
|
||||||
|
from .numato_mock import NumatoGpioError, NumatoModuleMock
|
||||||
|
|
||||||
MOCKUP_ENTITY_IDS = {
|
MOCKUP_ENTITY_IDS = {
|
||||||
"binary_sensor.numato_binary_sensor_mock_port2",
|
"binary_sensor.numato_binary_sensor_mock_port2",
|
||||||
@ -25,23 +31,25 @@ async def test_failing_setups_no_entities(
|
|||||||
assert entity_id not in hass.states.async_entity_ids()
|
assert entity_id not in hass.states.async_entity_ids()
|
||||||
|
|
||||||
|
|
||||||
async def test_setup_callbacks(
|
async def test_setup_callbacks(hass: HomeAssistant, numato_fixture) -> None:
|
||||||
hass: HomeAssistant, numato_fixture, monkeypatch
|
|
||||||
) -> None:
|
|
||||||
"""During setup a callback shall be registered."""
|
"""During setup a callback shall be registered."""
|
||||||
|
|
||||||
numato_fixture.discover()
|
with patch.object(
|
||||||
|
NumatoModuleMock.NumatoDeviceMock, "add_event_detect"
|
||||||
|
) as mock_add_event_detect:
|
||||||
|
numato_fixture.discover()
|
||||||
|
assert await async_setup_component(hass, "numato", NUMATO_CFG)
|
||||||
|
await hass.async_block_till_done() # wait until services are registered
|
||||||
|
|
||||||
def mock_add_event_detect(self, port, callback, direction):
|
mock_add_event_detect.assert_called()
|
||||||
assert self == numato_fixture.devices[0]
|
assert {call.args[0] for call in mock_add_event_detect.mock_calls} == {
|
||||||
assert port == 1
|
int(port)
|
||||||
assert callback is callable
|
for port in NUMATO_CFG["numato"]["devices"][0]["binary_sensors"]["ports"]
|
||||||
assert direction == numato_fixture.BOTH
|
}
|
||||||
|
assert all(callable(call.args[1]) for call in mock_add_event_detect.mock_calls)
|
||||||
monkeypatch.setattr(
|
assert all(
|
||||||
numato_fixture.devices[0], "add_event_detect", mock_add_event_detect
|
call.args[2] == numato_fixture.BOTH for call in mock_add_event_detect.mock_calls
|
||||||
)
|
)
|
||||||
assert await async_setup_component(hass, "numato", NUMATO_CFG)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_hass_binary_sensor_notification(
|
async def test_hass_binary_sensor_notification(
|
||||||
@ -73,3 +81,32 @@ async def test_binary_sensor_setup_without_discovery_info(
|
|||||||
await hass.async_block_till_done() # wait for numato platform to be loaded
|
await hass.async_block_till_done() # wait for numato platform to be loaded
|
||||||
for entity_id in MOCKUP_ENTITY_IDS:
|
for entity_id in MOCKUP_ENTITY_IDS:
|
||||||
assert entity_id in hass.states.async_entity_ids()
|
assert entity_id in hass.states.async_entity_ids()
|
||||||
|
|
||||||
|
|
||||||
|
async def test_binary_sensor_setup_no_notify(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
numato_fixture,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
) -> None:
|
||||||
|
"""Setup of a device without notification capability shall print an info message."""
|
||||||
|
caplog.set_level(logging.INFO)
|
||||||
|
|
||||||
|
def raise_notification_error(self, port, callback, direction):
|
||||||
|
raise NumatoGpioError(
|
||||||
|
f"{repr(self)} Mockup device doesn't support notifications."
|
||||||
|
)
|
||||||
|
|
||||||
|
with patch.object(
|
||||||
|
NumatoModuleMock.NumatoDeviceMock,
|
||||||
|
"add_event_detect",
|
||||||
|
raise_notification_error,
|
||||||
|
):
|
||||||
|
numato_fixture.discover()
|
||||||
|
assert await async_setup_component(hass, "numato", NUMATO_CFG)
|
||||||
|
await hass.async_block_till_done() # wait until services are registered
|
||||||
|
|
||||||
|
assert all(
|
||||||
|
f"updates on binary sensor numato_binary_sensor_mock_port{port} only in polling mode"
|
||||||
|
in caplog.text
|
||||||
|
for port in NUMATO_CFG["numato"]["devices"][0]["binary_sensors"]["ports"]
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user