Bump mopeka_iot_ble to 0.4.1 (#88680)

* Bump mopeka_iot_ble to 0.4.1

closes #88232

* adjust tests
This commit is contained in:
J. Nick Koston 2023-02-23 19:52:31 -06:00 committed by Paulus Schoutsen
parent 74696a3fac
commit 64ad5326dd
5 changed files with 55 additions and 7 deletions

View File

@ -21,5 +21,5 @@
"documentation": "https://www.home-assistant.io/integrations/mopeka", "documentation": "https://www.home-assistant.io/integrations/mopeka",
"integration_type": "device", "integration_type": "device",
"iot_class": "local_push", "iot_class": "local_push",
"requirements": ["mopeka_iot_ble==0.4.0"] "requirements": ["mopeka_iot_ble==0.4.1"]
} }

View File

@ -1144,7 +1144,7 @@ moat-ble==0.1.1
moehlenhoff-alpha2==1.3.0 moehlenhoff-alpha2==1.3.0
# homeassistant.components.mopeka # homeassistant.components.mopeka
mopeka_iot_ble==0.4.0 mopeka_iot_ble==0.4.1
# homeassistant.components.motion_blinds # homeassistant.components.motion_blinds
motionblinds==0.6.17 motionblinds==0.6.17

View File

@ -849,7 +849,7 @@ moat-ble==0.1.1
moehlenhoff-alpha2==1.3.0 moehlenhoff-alpha2==1.3.0
# homeassistant.components.mopeka # homeassistant.components.mopeka
mopeka_iot_ble==0.4.0 mopeka_iot_ble==0.4.1
# homeassistant.components.motion_blinds # homeassistant.components.motion_blinds
motionblinds==0.6.17 motionblinds==0.6.17

View File

@ -23,6 +23,16 @@ PRO_SERVICE_INFO = BluetoothServiceInfo(
source="local", source="local",
) )
PRO_UNUSABLE_SIGNAL_SERVICE_INFO = BluetoothServiceInfo(
name="",
address="aa:bb:cc:dd:ee:ff",
rssi=-60,
manufacturer_data={89: b"\x08rF\x00\x00\xe0\xf5\t\xf0\xd8"},
service_data={},
service_uuids=["0000fee5-0000-1000-8000-00805f9b34fb"],
source="local",
)
PRO_GOOD_SIGNAL_SERVICE_INFO = BluetoothServiceInfo( PRO_GOOD_SIGNAL_SERVICE_INFO = BluetoothServiceInfo(
name="", name="",

View File

@ -10,14 +10,52 @@ from homeassistant.const import (
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from . import PRO_GOOD_SIGNAL_SERVICE_INFO, PRO_SERVICE_INFO from . import (
PRO_GOOD_SIGNAL_SERVICE_INFO,
PRO_SERVICE_INFO,
PRO_UNUSABLE_SIGNAL_SERVICE_INFO,
)
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
from tests.components.bluetooth import inject_bluetooth_service_info from tests.components.bluetooth import inject_bluetooth_service_info
async def test_sensors_bad_signal(hass: HomeAssistant) -> None: async def test_sensors_unusable_signal(hass: HomeAssistant) -> None:
"""Test setting up creates the sensors when there is bad signal.""" """Test setting up creates the sensors when there is unusable signal."""
entry = MockConfigEntry(
domain=DOMAIN,
unique_id="aa:bb:cc:dd:ee:ff",
)
entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
assert len(hass.states.async_all("sensor")) == 0
inject_bluetooth_service_info(hass, PRO_UNUSABLE_SIGNAL_SERVICE_INFO)
await hass.async_block_till_done()
assert len(hass.states.async_all("sensor")) == 4
temp_sensor = hass.states.get("sensor.pro_plus_eeff_temperature")
temp_sensor_attrs = temp_sensor.attributes
assert temp_sensor.state == "30"
assert temp_sensor_attrs[ATTR_FRIENDLY_NAME] == "Pro Plus EEFF Temperature"
assert temp_sensor_attrs[ATTR_UNIT_OF_MEASUREMENT] == UnitOfTemperature.CELSIUS
assert temp_sensor_attrs[ATTR_STATE_CLASS] == "measurement"
tank_sensor = hass.states.get("sensor.pro_plus_eeff_tank_level")
tank_sensor_attrs = tank_sensor.attributes
assert tank_sensor.state == STATE_UNKNOWN
assert tank_sensor_attrs[ATTR_FRIENDLY_NAME] == "Pro Plus EEFF Tank Level"
assert tank_sensor_attrs[ATTR_UNIT_OF_MEASUREMENT] == UnitOfLength.MILLIMETERS
assert tank_sensor_attrs[ATTR_STATE_CLASS] == "measurement"
assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done()
async def test_sensors_poor_signal(hass: HomeAssistant) -> None:
"""Test setting up creates the sensors when there is poor signal."""
entry = MockConfigEntry( entry = MockConfigEntry(
domain=DOMAIN, domain=DOMAIN,
unique_id="aa:bb:cc:dd:ee:ff", unique_id="aa:bb:cc:dd:ee:ff",
@ -41,7 +79,7 @@ async def test_sensors_bad_signal(hass: HomeAssistant) -> None:
tank_sensor = hass.states.get("sensor.pro_plus_eeff_tank_level") tank_sensor = hass.states.get("sensor.pro_plus_eeff_tank_level")
tank_sensor_attrs = tank_sensor.attributes tank_sensor_attrs = tank_sensor.attributes
assert tank_sensor.state == STATE_UNKNOWN assert tank_sensor.state == "0"
assert tank_sensor_attrs[ATTR_FRIENDLY_NAME] == "Pro Plus EEFF Tank Level" assert tank_sensor_attrs[ATTR_FRIENDLY_NAME] == "Pro Plus EEFF Tank Level"
assert tank_sensor_attrs[ATTR_UNIT_OF_MEASUREMENT] == UnitOfLength.MILLIMETERS assert tank_sensor_attrs[ATTR_UNIT_OF_MEASUREMENT] == UnitOfLength.MILLIMETERS
assert tank_sensor_attrs[ATTR_STATE_CLASS] == "measurement" assert tank_sensor_attrs[ATTR_STATE_CLASS] == "measurement"