mirror of
https://github.com/home-assistant/core.git
synced 2025-06-25 01:21:51 +02:00
Bump numato-gpio to v0.13.0 (#113182)
This commit is contained in:
@ -54,7 +54,6 @@ def setup_platform(
|
||||
for port, port_name in ports.items():
|
||||
try:
|
||||
api.setup_input(device_id, port)
|
||||
api.edge_detect(device_id, port, partial(read_gpio, device_id))
|
||||
|
||||
except NumatoGpioError as err:
|
||||
_LOGGER.error(
|
||||
@ -68,7 +67,17 @@ def setup_platform(
|
||||
err,
|
||||
)
|
||||
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(
|
||||
NumatoGpioBinarySensor(
|
||||
port_name,
|
||||
|
@ -6,5 +6,5 @@
|
||||
"integration_type": "hub",
|
||||
"iot_class": "local_push",
|
||||
"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
|
||||
|
||||
# homeassistant.components.numato
|
||||
numato-gpio==0.12.0
|
||||
numato-gpio==0.13.0
|
||||
|
||||
# homeassistant.components.compensation
|
||||
# homeassistant.components.iqvia
|
||||
|
@ -1124,7 +1124,7 @@ nsw-fuel-api-client==1.1.0
|
||||
nuheat==1.0.1
|
||||
|
||||
# homeassistant.components.numato
|
||||
numato-gpio==0.12.0
|
||||
numato-gpio==0.13.0
|
||||
|
||||
# homeassistant.components.compensation
|
||||
# homeassistant.components.iqvia
|
||||
|
@ -62,7 +62,8 @@ class NumatoModuleMock:
|
||||
|
||||
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):
|
||||
"""Mockup for the numato device cleanup."""
|
||||
|
@ -1,11 +1,17 @@
|
||||
"""Tests for the numato binary_sensor platform."""
|
||||
|
||||
import logging
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import discovery
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .common import NUMATO_CFG, mockup_raise
|
||||
from .numato_mock import NumatoGpioError, NumatoModuleMock
|
||||
|
||||
MOCKUP_ENTITY_IDS = {
|
||||
"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()
|
||||
|
||||
|
||||
async def test_setup_callbacks(
|
||||
hass: HomeAssistant, numato_fixture, monkeypatch
|
||||
) -> None:
|
||||
async def test_setup_callbacks(hass: HomeAssistant, numato_fixture) -> None:
|
||||
"""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):
|
||||
assert self == numato_fixture.devices[0]
|
||||
assert port == 1
|
||||
assert callback is callable
|
||||
assert direction == numato_fixture.BOTH
|
||||
|
||||
monkeypatch.setattr(
|
||||
numato_fixture.devices[0], "add_event_detect", mock_add_event_detect
|
||||
mock_add_event_detect.assert_called()
|
||||
assert {call.args[0] for call in mock_add_event_detect.mock_calls} == {
|
||||
int(port)
|
||||
for port in NUMATO_CFG["numato"]["devices"][0]["binary_sensors"]["ports"]
|
||||
}
|
||||
assert all(callable(call.args[1]) for call in mock_add_event_detect.mock_calls)
|
||||
assert all(
|
||||
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(
|
||||
@ -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
|
||||
for entity_id in MOCKUP_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"]
|
||||
)
|
||||
|
Reference in New Issue
Block a user