Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion homeassistant/components/apcupsd/quality_scale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ rules:
Consider looking into making a `mock_setup_entry` fixture that just automatically do this.
`test_config_flow_cannot_connect`: Needs to end in CREATE_ENTRY to test that its able to recover.
`test_config_flow_duplicate`: this test should be split in 2, one for testing duplicate host/port and one for duplicate serial number.
`test_flow_works`: Should also test unique id.
config-flow: done
dependency-transparency: done
docs-actions:
Expand Down
14 changes: 8 additions & 6 deletions homeassistant/components/bluetooth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,21 +388,23 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
mode = BluetoothScanningMode.PASSIVE if passive else BluetoothScanningMode.ACTIVE
scanner = HaScanner(mode, adapter, address)
scanner.async_setup()
try:
await scanner.async_start()
except (RuntimeError, ScannerStartError) as err:
raise ConfigEntryNotReady(
f"{adapter_human_name(adapter, address)}: {err}"
) from err
adapters = await manager.async_get_bluetooth_adapters()
details = adapters[adapter]
if entry.title == address:
hass.config_entries.async_update_entry(
entry, title=adapter_title(adapter, details)
)
slots: int = details.get(ADAPTER_CONNECTION_SLOTS) or DEFAULT_CONNECTION_SLOTS
# Register the scanner before starting so
# any raw advertisement data can be processed
entry.async_on_unload(async_register_scanner(hass, scanner, connection_slots=slots))
await async_update_device(hass, entry, adapter, details)
try:
await scanner.async_start()
except (RuntimeError, ScannerStartError) as err:
raise ConfigEntryNotReady(
f"{adapter_human_name(adapter, address)}: {err}"
) from err
entry.async_on_unload(entry.add_update_listener(async_update_listener))
entry.async_on_unload(scanner.async_stop)
return True
Expand Down
12 changes: 5 additions & 7 deletions homeassistant/components/bluetooth/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,9 @@ def _async_save_scanner_histories(self) -> None:

def _async_save_scanner_history(self, scanner: BaseHaScanner) -> None:
"""Save the scanner history."""
if isinstance(scanner, BaseHaRemoteScanner):
self.storage.async_set_advertisement_history(
scanner.source, scanner.serialize_discovered_devices()
)
self.storage.async_set_advertisement_history(
scanner.source, scanner.serialize_discovered_devices()
)

def _async_unregister_scanner(
self, scanner: BaseHaScanner, unregister: CALLBACK_TYPE
Expand Down Expand Up @@ -285,9 +284,8 @@ def async_register_scanner(
connection_slots: int | None = None,
) -> CALLBACK_TYPE:
"""Register a scanner."""
if isinstance(scanner, BaseHaRemoteScanner):
if history := self.storage.async_get_advertisement_history(scanner.source):
scanner.restore_discovered_devices(history)
if history := self.storage.async_get_advertisement_history(scanner.source):
scanner.restore_discovered_devices(history)

unregister = super().async_register_scanner(scanner, connection_slots)
return partial(self._async_unregister_scanner, scanner, unregister)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/bluetooth/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"bluetooth-auto-recovery==1.5.2",
"bluetooth-data-tools==1.28.2",
"dbus-fast==2.44.3",
"habluetooth==4.0.2"
"habluetooth==5.0.1"
]
}
9 changes: 8 additions & 1 deletion homeassistant/components/bluetooth/websocket_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ def async_setup(hass: HomeAssistant) -> None:
def serialize_service_info(
service_info: BluetoothServiceInfoBleak, time_diff: float
) -> dict[str, Any]:
"""Serialize a BluetoothServiceInfoBleak object."""
"""Serialize a BluetoothServiceInfoBleak object.

The raw field is included for:
1. Debugging - to see the actual advertisement packet
2. Data freshness - manufacturer_data and service_data are aggregated
across multiple advertisements, raw shows the latest packet only
"""
return {
"name": service_info.name,
"address": service_info.address,
Expand All @@ -57,6 +63,7 @@ def serialize_service_info(
"connectable": service_info.connectable,
"time": service_info.time + time_diff,
"tx_power": service_info.tx_power,
"raw": service_info.raw.hex() if service_info.raw else None,
}


Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/emoncms/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import logging

CONF_EXCLUDE_FEEDID = "exclude_feed_id"
CONF_ONLY_INCLUDE_FEEDID = "include_only_feed_id"
CONF_MESSAGE = "message"
CONF_SUCCESS = "success"
Expand Down
11 changes: 2 additions & 9 deletions homeassistant/components/emoncms/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@
from homeassistant.helpers.update_coordinator import CoordinatorEntity

from .config_flow import sensor_name
from .const import (
CONF_EXCLUDE_FEEDID,
CONF_ONLY_INCLUDE_FEEDID,
FEED_ID,
FEED_NAME,
FEED_TAG,
)
from .const import CONF_ONLY_INCLUDE_FEEDID, FEED_ID, FEED_NAME, FEED_TAG
from .coordinator import EmonCMSConfigEntry, EmoncmsCoordinator

SENSORS: dict[str | None, SensorEntityDescription] = {
Expand Down Expand Up @@ -200,12 +194,11 @@ async def async_setup_entry(
) -> None:
"""Set up the emoncms sensors."""
name = sensor_name(entry.data[CONF_URL])
exclude_feeds = entry.data.get(CONF_EXCLUDE_FEEDID)
include_only_feeds = entry.options.get(
CONF_ONLY_INCLUDE_FEEDID, entry.data.get(CONF_ONLY_INCLUDE_FEEDID)
)

if exclude_feeds is None and include_only_feeds is None:
if include_only_feeds is None:
return

coordinator = entry.runtime_data
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/mercury_nz/__init__.py

This file was deleted.

6 changes: 0 additions & 6 deletions homeassistant/components/mercury_nz/manifest.json

This file was deleted.

1 change: 1 addition & 0 deletions homeassistant/components/modbus/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
CONF_WRITE_TYPE = "write_type"
CONF_ZERO_SUPPRESS = "zero_suppress"

DEVICE_ID = "device_id"
RTUOVERTCP = "rtuovertcp"
SERIAL = "serial"
TCP = "tcp"
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/modbus/modbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
CONF_PARITY,
CONF_STOPBITS,
DEFAULT_HUB,
DEVICE_ID,
MODBUS_DOMAIN as DOMAIN,
PLATFORMS,
RTUOVERTCP,
Expand Down Expand Up @@ -380,7 +381,7 @@ async def low_level_pb_call(
) -> ModbusPDU | None:
"""Call sync. pymodbus."""
kwargs: dict[str, Any] = (
{ATTR_SLAVE: slave} if slave is not None else {ATTR_SLAVE: 1}
{DEVICE_ID: slave} if slave is not None else {DEVICE_ID: 1}
)
entry = self._pb_request[use_call]

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/open_router/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"integration_type": "service",
"iot_class": "cloud_polling",
"quality_scale": "bronze",
"requirements": ["openai==1.99.3", "python-open-router==0.3.1"]
"requirements": ["openai==1.99.5", "python-open-router==0.3.1"]
}
2 changes: 1 addition & 1 deletion homeassistant/components/openai_conversation/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"documentation": "https://www.home-assistant.io/integrations/openai_conversation",
"integration_type": "service",
"iot_class": "cloud_polling",
"requirements": ["openai==1.99.3"]
"requirements": ["openai==1.99.5"]
}
5 changes: 0 additions & 5 deletions homeassistant/generated/integrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -3833,11 +3833,6 @@
"config_flow": false,
"iot_class": "cloud_polling"
},
"mercury_nz": {
"name": "Mercury NZ Limited",
"integration_type": "virtual",
"supported_by": "opower"
},
"message_bird": {
"name": "MessageBird",
"integration_type": "hub",
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/package_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dbus-fast==2.44.3
fnv-hash-fast==1.5.0
go2rtc-client==0.2.1
ha-ffmpeg==3.2.2
habluetooth==4.0.2
habluetooth==5.0.1
hass-nabucasa==0.111.2
hassil==2.2.3
home-assistant-bluetooth==1.13.1
Expand Down
4 changes: 2 additions & 2 deletions requirements_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions requirements_test_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/components/apcupsd/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ async def test_flow_works(hass: HomeAssistant) -> None:
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_STATUS["UPSNAME"]
assert result["data"] == CONF_DATA
assert result["result"].unique_id == MOCK_STATUS["SERIALNO"]

mock_setup.assert_called_once()

Expand Down
2 changes: 2 additions & 0 deletions tests/components/bluetooth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def inject_advertisement_with_time_and_source_connectable(
time: float,
source: str,
connectable: bool,
raw: bytes | None = None,
) -> None:
"""Inject an advertisement into the manager from a specific source at a time and connectable status."""
async_get_advertisement_callback(hass)(
Expand All @@ -161,6 +162,7 @@ def inject_advertisement_with_time_and_source_connectable(
connectable=connectable,
time=time,
tx_power=adv.tx_power,
raw=raw,
)
)

Expand Down
14 changes: 12 additions & 2 deletions tests/components/bluetooth/test_websocket_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
generate_advertisement_data,
generate_ble_device,
inject_advertisement_with_source,
inject_advertisement_with_time_and_source_connectable,
)

from tests.common import MockConfigEntry, async_fire_time_changed
Expand Down Expand Up @@ -72,6 +73,7 @@ async def test_subscribe_advertisements(
"source": HCI0_SOURCE_ADDRESS,
"time": ANY,
"tx_power": -127,
"raw": None,
}
]
}
Expand All @@ -83,8 +85,15 @@ async def test_subscribe_advertisements(
service_uuids=[],
rssi=-80,
)
inject_advertisement_with_source(
hass, switchbot_device_signal_100, switchbot_adv_signal_100, HCI1_SOURCE_ADDRESS
# Inject with raw bytes data
inject_advertisement_with_time_and_source_connectable(
hass,
switchbot_device_signal_100,
switchbot_adv_signal_100,
time.monotonic(),
HCI1_SOURCE_ADDRESS,
True,
raw=b"\x02\x01\x06\x03\x03\x0f\x18",
)
async with asyncio.timeout(1):
response = await client.receive_json()
Expand All @@ -101,6 +110,7 @@ async def test_subscribe_advertisements(
"source": HCI1_SOURCE_ADDRESS,
"time": ANY,
"tx_power": -127,
"raw": "02010603030f18",
}
]
}
Expand Down
8 changes: 4 additions & 4 deletions tests/components/modbus/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ async def test_hvac_onoff_values(hass: HomeAssistant, mock_modbus) -> None:
)
await hass.async_block_till_done()

mock_modbus.write_register.assert_called_with(11, value=0xAA, slave=10)
mock_modbus.write_register.assert_called_with(11, value=0xAA, device_id=10)

await hass.services.async_call(
CLIMATE_DOMAIN,
Expand All @@ -477,7 +477,7 @@ async def test_hvac_onoff_values(hass: HomeAssistant, mock_modbus) -> None:
)
await hass.async_block_till_done()

mock_modbus.write_register.assert_called_with(11, value=0xFF, slave=10)
mock_modbus.write_register.assert_called_with(11, value=0xFF, device_id=10)


@pytest.mark.parametrize(
Expand Down Expand Up @@ -506,7 +506,7 @@ async def test_hvac_onoff_coil(hass: HomeAssistant, mock_modbus) -> None:
)
await hass.async_block_till_done()

mock_modbus.write_coil.assert_called_with(11, value=1, slave=10)
mock_modbus.write_coil.assert_called_with(11, value=1, device_id=10)

await hass.services.async_call(
CLIMATE_DOMAIN,
Expand All @@ -516,7 +516,7 @@ async def test_hvac_onoff_coil(hass: HomeAssistant, mock_modbus) -> None:
)
await hass.async_block_till_done()

mock_modbus.write_coil.assert_called_with(11, value=0, slave=10)
mock_modbus.write_coil.assert_called_with(11, value=0, device_id=10)


@pytest.mark.parametrize(
Expand Down
7 changes: 4 additions & 3 deletions tests/components/modbus/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
CONF_SWING_MODE_VALUES,
CONF_VIRTUAL_COUNT,
DEFAULT_SCAN_INTERVAL,
DEVICE_ID,
MODBUS_DOMAIN as DOMAIN,
RTUOVERTCP,
SERIAL,
Expand Down Expand Up @@ -867,7 +868,7 @@ async def test_pb_service_write(
assert func_name[do_write[FUNC]].called
assert func_name[do_write[FUNC]].call_args.args == (data[ATTR_ADDRESS],)
assert func_name[do_write[FUNC]].call_args.kwargs == {
"slave": 17,
DEVICE_ID: 17,
value_arg_name[do_write[FUNC]]: data[do_write[DATA]],
}

Expand Down Expand Up @@ -1326,7 +1327,7 @@ async def test_check_default_slave(
"""Test default slave."""
assert mock_modbus.read_holding_registers.mock_calls
first_call = mock_modbus.read_holding_registers.mock_calls[0]
assert first_call.kwargs["slave"] == expected_slave_value
assert first_call.kwargs[DEVICE_ID] == expected_slave_value


@pytest.mark.parametrize(
Expand Down Expand Up @@ -1407,7 +1408,7 @@ async def test_pb_service_write_no_slave(
assert func_name[do_write[FUNC]].called
assert func_name[do_write[FUNC]].call_args.args == (data[ATTR_ADDRESS],)
assert func_name[do_write[FUNC]].call_args.kwargs == {
"slave": 1,
DEVICE_ID: 1,
value_arg_name[do_write[FUNC]]: data[do_write[DATA]],
}

Expand Down
Loading