Compare commits

...

3 Commits

Author SHA1 Message Date
Paul Bottein
df06a5878c Add windows 98 labs feature 2026-03-10 09:41:49 +01:00
Panda-NZ
a36733c4dc Add ambient temperature range controls to ToGrill integration (#165235) 2026-03-09 23:40:30 +01:00
Bram Kragten
bf846e0756 Validate reorder is only used when multiple is true (#165216) 2026-03-09 22:32:02 +01:00
11 changed files with 1917 additions and 35 deletions

View File

@@ -19,7 +19,7 @@
],
"documentation": "https://www.home-assistant.io/integrations/frontend",
"integration_type": "system",
"preview_features": { "winter_mode": {} },
"preview_features": { "windows_98": {}, "winter_mode": {} },
"quality_scale": "internal",
"requirements": ["home-assistant-frontend==20260304.0"]
}

View File

@@ -1,5 +1,11 @@
{
"preview_features": {
"windows_98": {
"description": "Transforms your dashboard with a nostalgic Windows 98 look.",
"disable_confirmation": "Your dashboard will return to its normal look. You can re-enable this at any time in Labs settings.",
"enable_confirmation": "Your dashboard will be transformed with a Windows 98 theme. You can turn this off at any time in Labs settings.",
"name": "Windows 98"
},
"winter_mode": {
"description": "Adds falling snowflakes on your screen. Get your home ready for winter! ❄️\n\nIf you have animations disabled in your device accessibility settings, this feature will not work.",
"disable_confirmation": "Snowflakes will no longer fall on your screen. You can re-enable this at any time in Labs settings.",

View File

@@ -790,7 +790,6 @@ edit_message:
filter:
domain: notify
integration: telegram_bot
reorder: true
message_id:
required: true
example: "{{ trigger.event.data.message.message_id }}"
@@ -843,7 +842,6 @@ edit_message_media:
filter:
domain: notify
integration: telegram_bot
reorder: true
message_id:
required: true
example: "{{ trigger.event.data.message.message_id }}"
@@ -922,7 +920,6 @@ edit_caption:
filter:
domain: notify
integration: telegram_bot
reorder: true
message_id:
required: true
example: "{{ trigger.event.data.message.message_id }}"
@@ -960,7 +957,6 @@ edit_replymarkup:
filter:
domain: notify
integration: telegram_bot
reorder: true
message_id:
required: true
example: "{{ trigger.event.data.message.message_id }}"
@@ -1015,7 +1011,6 @@ delete_message:
filter:
domain: notify
integration: telegram_bot
reorder: true
message_id:
required: true
example: "{{ trigger.event.data.message.message_id }}"
@@ -1042,7 +1037,6 @@ leave_chat:
filter:
domain: notify
integration: telegram_bot
reorder: true
advanced:
collapsed: true
fields:
@@ -1064,7 +1058,6 @@ set_message_reaction:
filter:
domain: notify
integration: telegram_bot
reorder: true
message_id:
required: true
example: 54321

View File

@@ -32,7 +32,7 @@ from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.device_registry import CONNECTION_BLUETOOTH, DeviceInfo
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from .const import CONF_PROBE_COUNT, DOMAIN
from .const import CONF_HAS_AMBIENT, CONF_PROBE_COUNT, DOMAIN
type ToGrillConfigEntry = ConfigEntry[ToGrillCoordinator]
@@ -213,6 +213,8 @@ class ToGrillCoordinator(DataUpdateCoordinator[dict[tuple[int, int | None], Pack
await client.request(PacketA1Notify)
for probe in range(1, self.config_entry.data[CONF_PROBE_COUNT] + 1):
await client.write(PacketA8Write(probe=probe))
if self.config_entry.data.get(CONF_HAS_AMBIENT):
await client.write(PacketA8Write(probe=0))
except BleakError as exc:
raise DeviceFailed(f"Device failed {exc}") from exc
return self.data

View File

@@ -27,7 +27,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from . import ToGrillConfigEntry
from .const import CONF_PROBE_COUNT, MAX_PROBE_COUNT
from .const import CONF_HAS_AMBIENT, CONF_PROBE_COUNT, MAX_PROBE_COUNT
from .coordinator import ToGrillCoordinator
from .entity import ToGrillEntity
@@ -123,12 +123,64 @@ def _get_temperature_descriptions(
)
def _get_ambient_temperatures(
coordinator: ToGrillCoordinator, alarm_type: AlarmType
) -> tuple[float | None, float | None]:
if not (packet := coordinator.get_packet(PacketA8Notify, 0)):
return None, None
if packet.alarm_type != alarm_type:
return None, None
return packet.temperature_1, packet.temperature_2
ENTITY_DESCRIPTIONS = (
*[
description
for probe_number in range(1, MAX_PROBE_COUNT + 1)
for description in _get_temperature_descriptions(probe_number)
],
ToGrillNumberEntityDescription(
key="ambient_temperature_minimum",
translation_key="ambient_temperature_minimum",
device_class=NumberDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
native_min_value=0,
native_max_value=400,
mode=NumberMode.BOX,
icon="mdi:thermometer-chevron-down",
set_packet=lambda coordinator, value: PacketA300Write(
probe=0,
minimum=None if value == 0.0 else value,
maximum=_get_ambient_temperatures(coordinator, AlarmType.TEMPERATURE_RANGE)[
1
],
),
get_value=lambda x: _get_ambient_temperatures(x, AlarmType.TEMPERATURE_RANGE)[
0
],
entity_supported=lambda x: x.get(CONF_HAS_AMBIENT, False),
),
ToGrillNumberEntityDescription(
key="ambient_temperature_maximum",
translation_key="ambient_temperature_maximum",
device_class=NumberDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
native_min_value=0,
native_max_value=400,
mode=NumberMode.BOX,
icon="mdi:thermometer-chevron-up",
set_packet=lambda coordinator, value: PacketA300Write(
probe=0,
minimum=_get_ambient_temperatures(coordinator, AlarmType.TEMPERATURE_RANGE)[
0
],
maximum=None if value == 0.0 else value,
),
get_value=lambda x: _get_ambient_temperatures(x, AlarmType.TEMPERATURE_RANGE)[
1
],
entity_supported=lambda x: x.get(CONF_HAS_AMBIENT, False),
),
ToGrillNumberEntityDescription(
key="alarm_interval",
translation_key="alarm_interval",

View File

@@ -55,6 +55,12 @@
"alarm_interval": {
"name": "Alarm interval"
},
"ambient_temperature_maximum": {
"name": "Ambient maximum temperature"
},
"ambient_temperature_minimum": {
"name": "Ambient minimum temperature"
},
"temperature_maximum": {
"name": "Maximum temperature"
},

View File

@@ -19,6 +19,11 @@ LABS_PREVIEW_FEATURES = {
},
},
"frontend": {
"windows_98": {
"feedback_url": "",
"learn_more_url": "",
"report_issue_url": "",
},
"winter_mode": {
"feedback_url": "",
"learn_more_url": "",

View File

@@ -119,6 +119,13 @@ def _validate_supported_features(supported_features: list[str]) -> int:
return feature_mask
def _validate_selector_reorder_config(config: Any) -> Any:
"""Validate selectors with reorder option."""
if config.get("reorder") and not config.get("multiple"):
raise vol.Invalid("reorder can only be used when multiple is true")
return config
def make_selector_config_schema(schema_dict: dict | None = None) -> vol.Schema:
"""Make selector config schema."""
if schema_dict is None:
@@ -310,19 +317,22 @@ class AreaSelector(Selector[AreaSelectorConfig]):
selector_type = "area"
CONFIG_SCHEMA = make_selector_config_schema(
{
vol.Optional("entity"): vol.All(
cv.ensure_list,
[ENTITY_FILTER_SELECTOR_CONFIG_SCHEMA],
),
vol.Optional("device"): vol.All(
cv.ensure_list,
[DEVICE_FILTER_SELECTOR_CONFIG_SCHEMA],
),
vol.Optional("multiple", default=False): cv.boolean,
vol.Optional("reorder", default=False): cv.boolean,
}
CONFIG_SCHEMA = vol.All(
make_selector_config_schema(
{
vol.Optional("entity"): vol.All(
cv.ensure_list,
[ENTITY_FILTER_SELECTOR_CONFIG_SCHEMA],
),
vol.Optional("device"): vol.All(
cv.ensure_list,
[DEVICE_FILTER_SELECTOR_CONFIG_SCHEMA],
),
vol.Optional("multiple", default=False): cv.boolean,
vol.Optional("reorder", default=False): cv.boolean,
}
),
_validate_selector_reorder_config,
)
def __init__(self, config: AreaSelectorConfig | None = None) -> None:
@@ -894,18 +904,21 @@ class EntitySelector(Selector[EntitySelectorConfig]):
selector_type = "entity"
CONFIG_SCHEMA = make_selector_config_schema(
{
**_LEGACY_ENTITY_SELECTOR_CONFIG_SCHEMA_DICT,
vol.Optional("exclude_entities"): [str],
vol.Optional("include_entities"): [str],
vol.Optional("multiple", default=False): cv.boolean,
vol.Optional("reorder", default=False): cv.boolean,
vol.Optional("filter"): vol.All(
cv.ensure_list,
[ENTITY_FILTER_SELECTOR_CONFIG_SCHEMA],
),
}
CONFIG_SCHEMA = vol.All(
make_selector_config_schema(
{
**_LEGACY_ENTITY_SELECTOR_CONFIG_SCHEMA_DICT,
vol.Optional("exclude_entities"): [str],
vol.Optional("include_entities"): [str],
vol.Optional("multiple", default=False): cv.boolean,
vol.Optional("reorder", default=False): cv.boolean,
vol.Optional("filter"): vol.All(
cv.ensure_list,
[ENTITY_FILTER_SELECTOR_CONFIG_SCHEMA],
),
}
),
_validate_selector_reorder_config,
)
def __init__(self, config: EntitySelectorConfig | None = None) -> None:

File diff suppressed because it is too large Load Diff

View File

@@ -77,6 +77,150 @@ async def test_setup(
await snapshot_platform(hass, entity_registry, snapshot, mock_entry.entry_id)
@pytest.mark.parametrize(
"packets",
[
pytest.param([], id="no_data"),
pytest.param(
[
PacketA8Notify(
probe=0,
alarm_type=PacketA8Notify.AlarmType.TEMPERATURE_RANGE,
temperature_1=5.0,
temperature_2=300.0,
),
],
id="ambient_with_range",
),
pytest.param(
[
PacketA8Notify(
probe=0,
alarm_type=None,
temperature_1=5.0,
temperature_2=300.0,
),
],
id="ambient_wrong_alarm_type",
),
],
)
async def test_setup_with_ambient(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
mock_entry_with_ambient: MockConfigEntry,
mock_client: Mock,
packets,
) -> None:
"""Test the numbers with ambient sensor enabled."""
inject_bluetooth_service_info(hass, TOGRILL_SERVICE_INFO)
await setup_entry(hass, mock_entry_with_ambient, [Platform.NUMBER])
for packet in packets:
mock_client.mocked_notify(packet)
await snapshot_platform(
hass, entity_registry, snapshot, mock_entry_with_ambient.entry_id
)
@pytest.mark.parametrize(
("packets", "entity_id", "value", "write_packet"),
[
pytest.param(
[
PacketA8Notify(
probe=0,
alarm_type=PacketA8Notify.AlarmType.TEMPERATURE_RANGE,
temperature_1=5.0,
temperature_2=300.0,
),
],
"number.pro_05_ambient_minimum_temperature",
10.0,
PacketA300Write(probe=0, minimum=10.0, maximum=300.0),
id="ambient_minimum",
),
pytest.param(
[
PacketA8Notify(
probe=0,
alarm_type=PacketA8Notify.AlarmType.TEMPERATURE_RANGE,
temperature_1=5.0,
temperature_2=300.0,
),
],
"number.pro_05_ambient_minimum_temperature",
0.0,
PacketA300Write(probe=0, minimum=None, maximum=300.0),
id="ambient_minimum_clear",
),
pytest.param(
[
PacketA8Notify(
probe=0,
alarm_type=PacketA8Notify.AlarmType.TEMPERATURE_RANGE,
temperature_1=5.0,
temperature_2=300.0,
),
],
"number.pro_05_ambient_maximum_temperature",
350.0,
PacketA300Write(probe=0, minimum=5.0, maximum=350.0),
id="ambient_maximum",
),
pytest.param(
[
PacketA8Notify(
probe=0,
alarm_type=PacketA8Notify.AlarmType.TEMPERATURE_RANGE,
temperature_1=5.0,
temperature_2=300.0,
),
],
"number.pro_05_ambient_maximum_temperature",
0.0,
PacketA300Write(probe=0, minimum=5.0, maximum=None),
id="ambient_maximum_clear",
),
],
)
async def test_set_ambient_number(
hass: HomeAssistant,
mock_entry_with_ambient: MockConfigEntry,
mock_client: Mock,
packets,
entity_id,
value,
write_packet,
) -> None:
"""Test setting ambient temperature numbers."""
inject_bluetooth_service_info(hass, TOGRILL_SERVICE_INFO)
await setup_entry(hass, mock_entry_with_ambient, [Platform.NUMBER])
for packet in packets:
mock_client.mocked_notify(packet)
await hass.services.async_call(
NUMBER_DOMAIN,
SERVICE_SET_VALUE,
service_data={
ATTR_VALUE: value,
},
target={
ATTR_ENTITY_ID: entity_id,
},
blocking=True,
)
mock_client.write.assert_any_call(write_packet)
@pytest.mark.parametrize(
("packets", "entity_id", "value", "write_packet"),
[

View File

@@ -319,6 +319,9 @@ def test_entity_selector_schema(schema, valid_selections, invalid_selections) ->
{"filter": [{"supported_features": ["light.LightEntityFeature.blah"]}]},
# supported_features should be used under the filter key
{"supported_features": ["light.LightEntityFeature.EFFECT"]},
# reorder can only be used when multiple is true
{"reorder": True},
{"reorder": True, "multiple": False},
],
)
def test_entity_selector_schema_error(schema) -> None:
@@ -394,6 +397,20 @@ def test_area_selector_schema(schema, valid_selections, invalid_selections) -> N
_test_selector("area", schema, valid_selections, invalid_selections)
@pytest.mark.parametrize(
"schema",
[
# reorder can only be used when multiple is true
{"reorder": True},
{"reorder": True, "multiple": False},
],
)
def test_area_selector_schema_error(schema) -> None:
"""Test area selector."""
with pytest.raises(vol.Invalid):
selector.validate_selector({"area": schema})
@pytest.mark.parametrize(
("schema", "valid_selections", "invalid_selections"),
[