Add support for oralb IO Series 4 (#81110)

pull/81341/head
J. Nick Koston 2022-10-27 14:38:42 -05:00 committed by Paulus Schoutsen
parent 8751eaaf3e
commit 4927f4206a
6 changed files with 60 additions and 5 deletions

View File

@ -8,7 +8,7 @@
"manufacturer_id": 220
}
],
"requirements": ["oralb-ble==0.5.0"],
"requirements": ["oralb-ble==0.6.0"],
"dependencies": ["bluetooth"],
"codeowners": ["@bdraco"],
"iot_class": "local_push"

View File

@ -1238,7 +1238,7 @@ openwrt-luci-rpc==1.1.11
openwrt-ubus-rpc==0.0.2
# homeassistant.components.oralb
oralb-ble==0.5.0
oralb-ble==0.6.0
# homeassistant.components.oru
oru==0.1.11

View File

@ -883,7 +883,7 @@ open-meteo==0.2.1
openerz-api==0.1.0
# homeassistant.components.oralb
oralb-ble==0.5.0
oralb-ble==0.6.0
# homeassistant.components.ovo_energy
ovoenergy==1.2.0

View File

@ -22,3 +22,14 @@ ORALB_SERVICE_INFO = BluetoothServiceInfo(
service_data={},
source="local",
)
ORALB_IO_SERIES_4_SERVICE_INFO = BluetoothServiceInfo(
name="GXB772CD\x00\x00\x00\x00\x00\x00\x00\x00\x00",
address="78:DB:2F:C2:48:BE",
rssi=-63,
manufacturer_data={220: b"\x074\x0c\x038\x00\x00\x02\x01\x00\x04"},
service_uuids=[],
service_data={},
source="local",
)

View File

@ -6,7 +6,7 @@ from homeassistant import config_entries
from homeassistant.components.oralb.const import DOMAIN
from homeassistant.data_entry_flow import FlowResultType
from . import NOT_ORALB_SERVICE_INFO, ORALB_SERVICE_INFO
from . import NOT_ORALB_SERVICE_INFO, ORALB_IO_SERIES_4_SERVICE_INFO, ORALB_SERVICE_INFO
from tests.common import MockConfigEntry
@ -30,6 +30,25 @@ async def test_async_step_bluetooth_valid_device(hass):
assert result2["result"].unique_id == "78:DB:2F:C2:48:BE"
async def test_async_step_bluetooth_valid_io_series4_device(hass):
"""Test discovery via bluetooth with a valid device."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_BLUETOOTH},
data=ORALB_IO_SERIES_4_SERVICE_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm"
with patch("homeassistant.components.oralb.async_setup_entry", return_value=True):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["title"] == "IO Series 4 48BE"
assert result2["data"] == {}
assert result2["result"].unique_id == "78:DB:2F:C2:48:BE"
async def test_async_step_bluetooth_not_oralb(hass):
"""Test discovery via bluetooth not oralb."""
result = await hass.config_entries.flow.async_init(

View File

@ -4,7 +4,7 @@
from homeassistant.components.oralb.const import DOMAIN
from homeassistant.const import ATTR_FRIENDLY_NAME
from . import ORALB_SERVICE_INFO
from . import ORALB_IO_SERIES_4_SERVICE_INFO, ORALB_SERVICE_INFO
from tests.common import MockConfigEntry
from tests.components.bluetooth import inject_bluetooth_service_info
@ -38,3 +38,28 @@ async def test_sensors(hass, entity_registry_enabled_by_default):
assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done()
async def test_sensors_io_series_4(hass, entity_registry_enabled_by_default):
"""Test setting up creates the sensors with an io series 4."""
entry = MockConfigEntry(
domain=DOMAIN,
unique_id=ORALB_IO_SERIES_4_SERVICE_INFO.address,
)
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, ORALB_IO_SERIES_4_SERVICE_INFO)
await hass.async_block_till_done()
assert len(hass.states.async_all("sensor")) == 8
toothbrush_sensor = hass.states.get("sensor.io_series_4_48be_mode")
toothbrush_sensor_attrs = toothbrush_sensor.attributes
assert toothbrush_sensor.state == "gum care"
assert toothbrush_sensor_attrs[ATTR_FRIENDLY_NAME] == "IO Series 4 48BE Mode"
assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done()