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
7 changes: 7 additions & 0 deletions homeassistant/components/alexa_devices/icons.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
"entity": {
"sensor": {
"voc_index": {
"default": "mdi:molecule"
}
}
},
"services": {
"send_info_skill": {
"service": "mdi:information"
Expand Down
43 changes: 42 additions & 1 deletion homeassistant/components/alexa_devices/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.const import LIGHT_LUX, UnitOfTemperature
from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_MILLION,
LIGHT_LUX,
PERCENTAGE,
UnitOfTemperature,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from homeassistant.helpers.typing import StateType
Expand Down Expand Up @@ -77,6 +83,41 @@ class AmazonNotificationEntityDescription(SensorEntityDescription):
native_unit_of_measurement=LIGHT_LUX,
state_class=SensorStateClass.MEASUREMENT,
),
AmazonSensorEntityDescription(
key="Humidity",
device_class=SensorDeviceClass.HUMIDITY,
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
),
AmazonSensorEntityDescription(
key="PM10",
device_class=SensorDeviceClass.PM10,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
),
AmazonSensorEntityDescription(
key="PM25",
device_class=SensorDeviceClass.PM25,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
),
AmazonSensorEntityDescription(
key="CO",
device_class=SensorDeviceClass.CO,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
state_class=SensorStateClass.MEASUREMENT,
),
AmazonSensorEntityDescription(
key="VOC",
# No device class as this is an index not a concentration
state_class=SensorStateClass.MEASUREMENT,
translation_key="voc_index",
),
AmazonSensorEntityDescription(
key="Air Quality",
device_class=SensorDeviceClass.AQI,
state_class=SensorStateClass.MEASUREMENT,
),
)
NOTIFICATIONS: Final = (
AmazonNotificationEntityDescription(
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/alexa_devices/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
},
"timer": {
"name": "Next timer"
},
"voc_index": {
"name": "Volatile organic compounds index"
}
},
"switch": {
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/cloud/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"integration_type": "system",
"iot_class": "cloud_push",
"loggers": ["acme", "hass_nabucasa", "snitun"],
"requirements": ["hass-nabucasa==1.13.0", "openai==2.15.0"],
"requirements": ["hass-nabucasa==1.13.0", "openai==2.21.0"],
"single_config_entry": true
}
3 changes: 3 additions & 0 deletions homeassistant/components/nintendo_parental_controls/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
BEDTIME_ALARM_MAX = "23:00"
BEDTIME_ALARM_DISABLE = "00:00"

BEDTIME_END_TIME_MIN = "05:00"
BEDTIME_END_TIME_MAX = "09:00"

APP_SETUP_URL = (
"https://www.nintendo.com/my/support/switch/parentalcontrols/app/setup.html"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
"time": {
"bedtime_alarm": {
"name": "Bedtime alarm"
},
"bedtime_end_time": {
"name": "Bedtime end time"
}
}
},
Expand All @@ -75,6 +78,9 @@
"bedtime_alarm_out_of_range": {
"message": "{value} not accepted. Bedtime Alarm must be between {bedtime_alarm_min} and {bedtime_alarm_max}. To disable, set to {bedtime_alarm_disable}."
},
"bedtime_end_time_out_of_range": {
"message": "{value} not accepted. Bedtime End Time must be between {bedtime_end_time_min} and {bedtime_end_time_max}. To disable, set to {bedtime_alarm_disable}."
},
"config_entry_not_found": {
"message": "Config entry not found."
},
Expand Down
30 changes: 29 additions & 1 deletion homeassistant/components/nintendo_parental_controls/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
from homeassistant.exceptions import ServiceValidationError
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback

from .const import BEDTIME_ALARM_DISABLE, BEDTIME_ALARM_MAX, BEDTIME_ALARM_MIN, DOMAIN
from .const import (
BEDTIME_ALARM_DISABLE,
BEDTIME_ALARM_MAX,
BEDTIME_ALARM_MIN,
BEDTIME_END_TIME_MAX,
BEDTIME_END_TIME_MIN,
DOMAIN,
)
from .coordinator import NintendoParentalControlsConfigEntry, NintendoUpdateCoordinator
from .entity import Device, NintendoDevice

Expand All @@ -30,6 +37,7 @@ class NintendoParentalControlsTime(StrEnum):
"""Store keys for Nintendo Parental time."""

BEDTIME_ALARM = "bedtime_alarm"
BEDTIME_END_TIME = "bedtime_end_time"


@dataclass(kw_only=True, frozen=True)
Expand All @@ -47,6 +55,12 @@ class NintendoParentalControlsTimeEntityDescription(TimeEntityDescription):
value_fn=lambda device: device.bedtime_alarm,
set_value_fn=lambda device, value: device.set_bedtime_alarm(value=value),
),
NintendoParentalControlsTimeEntityDescription(
key=NintendoParentalControlsTime.BEDTIME_END_TIME,
translation_key=NintendoParentalControlsTime.BEDTIME_END_TIME,
value_fn=lambda device: device.bedtime_end,
set_value_fn=lambda device, value: device.set_bedtime_end_time(value=value),
),
)


Expand Down Expand Up @@ -88,6 +102,20 @@ async def async_set_value(self, value: time) -> None:
try:
await self.entity_description.set_value_fn(self._device, value)
except BedtimeOutOfRangeError as exc:
if (
self.entity_description.key
== NintendoParentalControlsTime.BEDTIME_END_TIME
):
raise ServiceValidationError(
translation_domain=DOMAIN,
translation_key="bedtime_end_time_out_of_range",
translation_placeholders={
"value": value.strftime("%H:%M"),
"bedtime_end_time_max": BEDTIME_END_TIME_MAX,
"bedtime_end_time_min": BEDTIME_END_TIME_MIN,
"bedtime_alarm_disable": BEDTIME_ALARM_DISABLE,
},
) from exc
raise ServiceValidationError(
translation_domain=DOMAIN,
translation_key="bedtime_alarm_out_of_range",
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==2.15.0", "python-open-router==0.3.3"]
"requirements": ["openai==2.21.0", "python-open-router==0.3.3"]
}
2 changes: 1 addition & 1 deletion homeassistant/components/openai_conversation/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==2.15.0"]
"requirements": ["openai==2.21.0"]
}
2 changes: 1 addition & 1 deletion homeassistant/package_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ifaddr==0.2.0
Jinja2==3.1.6
lru-dict==1.3.0
mutagen==1.47.0
openai==2.15.0
openai==2.21.0
orjson==3.11.5
packaging>=23.1
paho-mqtt==2.1.0
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt

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

2 changes: 1 addition & 1 deletion requirements_test_all.txt

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

2 changes: 2 additions & 0 deletions tests/components/nintendo_parental_controls/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ def mock_nintendo_device() -> Device:
mock.limit_time = 120
mock.today_playing_time = 110
mock.today_time_remaining = 10
mock.bedtime_end = time(hour=7)
mock.bedtime_alarm = time(hour=19)
mock.timer_mode = DeviceTimerMode.DAILY
mock.extra_playing_time = 30
mock.add_extra_time.return_value = None
mock.set_bedtime_alarm.return_value = None
mock.set_bedtime_end_time.return_value = None
mock.update_max_daily_playtime.return_value = None
mock.set_timer_mode.return_value = None
mock.forced_termination_mode = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,52 @@
'state': '19:00:00',
})
# ---
# name: test_time[time.home_assistant_test_bedtime_end_time-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'time',
'entity_category': None,
'entity_id': 'time.home_assistant_test_bedtime_end_time',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Bedtime end time',
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Bedtime end time',
'platform': 'nintendo_parental_controls',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': <NintendoParentalControlsTime.BEDTIME_END_TIME: 'bedtime_end_time'>,
'unique_id': 'testdevid_bedtime_end_time',
'unit_of_measurement': None,
})
# ---
# name: test_time[time.home_assistant_test_bedtime_end_time-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Home Assistant Test Bedtime end time',
}),
'context': <ANY>,
'entity_id': 'time.home_assistant_test_bedtime_end_time',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '07:00:00',
})
# ---
53 changes: 45 additions & 8 deletions tests/components/nintendo_parental_controls/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,25 @@ async def test_time(
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)


@pytest.mark.parametrize(
("entity_id", "new_value", "called_function_name"),
[
("time.home_assistant_test_bedtime_alarm", "20:00:00", "set_bedtime_alarm"),
(
"time.home_assistant_test_bedtime_end_time",
"06:30:00",
"set_bedtime_end_time",
),
],
)
async def test_set_time(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_nintendo_client: AsyncMock,
mock_nintendo_device: AsyncMock,
entity_id: str,
new_value: str,
called_function_name: str,
) -> None:
"""Test time platform service validation errors."""
with patch(
Expand All @@ -53,21 +67,44 @@ async def test_set_time(
await hass.services.async_call(
TIME_DOMAIN,
SERVICE_SET_VALUE,
service_data={ATTR_TIME: "20:00:00"},
target={ATTR_ENTITY_ID: "time.home_assistant_test_bedtime_alarm"},
service_data={ATTR_TIME: new_value},
target={ATTR_ENTITY_ID: entity_id},
blocking=True,
)
assert len(mock_nintendo_device.set_bedtime_alarm.mock_calls) == 1
assert len(getattr(mock_nintendo_device, called_function_name).mock_calls) == 1


@pytest.mark.parametrize(
("entity_id", "new_value", "translation_key", "called_function_name"),
[
(
"time.home_assistant_test_bedtime_alarm",
"03:00:00",
"bedtime_alarm_out_of_range",
"set_bedtime_alarm",
),
(
"time.home_assistant_test_bedtime_end_time",
"10:00:00",
"bedtime_end_time_out_of_range",
"set_bedtime_end_time",
),
],
)
async def test_set_time_service_exceptions(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_nintendo_client: AsyncMock,
mock_nintendo_device: AsyncMock,
entity_id: str,
new_value: str,
translation_key: str,
called_function_name: str,
) -> None:
"""Test time platform service validation errors."""
mock_nintendo_device.set_bedtime_alarm.side_effect = BedtimeOutOfRangeError(None)
getattr(
mock_nintendo_device, called_function_name
).side_effect = BedtimeOutOfRangeError(None)
with patch(
"homeassistant.components.nintendo_parental_controls._PLATFORMS",
[Platform.TIME],
Expand All @@ -77,9 +114,9 @@ async def test_set_time_service_exceptions(
await hass.services.async_call(
TIME_DOMAIN,
SERVICE_SET_VALUE,
service_data={ATTR_TIME: "01:00:00"},
target={ATTR_ENTITY_ID: "time.home_assistant_test_bedtime_alarm"},
service_data={ATTR_TIME: new_value},
target={ATTR_ENTITY_ID: entity_id},
blocking=True,
)
assert len(mock_nintendo_device.set_bedtime_alarm.mock_calls) == 1
assert err.value.translation_key == "bedtime_alarm_out_of_range"
assert len(getattr(mock_nintendo_device, called_function_name).mock_calls) == 1
assert err.value.translation_key == translation_key
Loading