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
2 changes: 1 addition & 1 deletion homeassistant/components/google/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"documentation": "https://www.home-assistant.io/integrations/google",
"iot_class": "cloud_polling",
"loggers": ["googleapiclient"],
"requirements": ["gcal-sync==8.0.0", "oauth2client==4.1.3", "ical==11.0.0"]
"requirements": ["gcal-sync==8.0.0", "oauth2client==4.1.3", "ical==11.1.0"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
"dependencies": ["hardware", "usb", "homeassistant_hardware"],
"documentation": "https://www.home-assistant.io/integrations/homeassistant_connect_zbt2",
"integration_type": "hardware",
"loggers": [
"bellows",
"universal_silabs_flasher",
"zigpy.serial",
"serial_asyncio_fast"
],
"quality_scale": "bronze",
"usb": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
"dependencies": ["hardware", "usb", "homeassistant_hardware"],
"documentation": "https://www.home-assistant.io/integrations/homeassistant_sky_connect",
"integration_type": "hardware",
"loggers": [
"bellows",
"universal_silabs_flasher",
"zigpy.serial",
"serial_asyncio_fast"
],
"usb": [
{
"description": "*skyconnect v1.0*",
Expand Down
6 changes: 6 additions & 0 deletions homeassistant/components/homeassistant_yellow/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@
"dependencies": ["hardware", "homeassistant_hardware"],
"documentation": "https://www.home-assistant.io/integrations/homeassistant_yellow",
"integration_type": "hardware",
"loggers": [
"bellows",
"universal_silabs_flasher",
"zigpy.serial",
"serial_asyncio_fast"
],
"single_config_entry": true
}
2 changes: 1 addition & 1 deletion homeassistant/components/local_calendar/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"documentation": "https://www.home-assistant.io/integrations/local_calendar",
"iot_class": "local_polling",
"loggers": ["ical"],
"requirements": ["ical==11.0.0"]
"requirements": ["ical==11.1.0"]
}
2 changes: 1 addition & 1 deletion homeassistant/components/local_todo/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/local_todo",
"iot_class": "local_polling",
"requirements": ["ical==11.0.0"]
"requirements": ["ical==11.1.0"]
}
2 changes: 1 addition & 1 deletion homeassistant/components/remote_calendar/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"iot_class": "cloud_polling",
"loggers": ["ical"],
"quality_scale": "silver",
"requirements": ["ical==11.0.0"]
"requirements": ["ical==11.1.0"]
}
11 changes: 2 additions & 9 deletions homeassistant/components/zwave_js/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
NumericSensorDataTemplate,
)
from .entity import NewZwaveDiscoveryInfo
from .event import DISCOVERY_SCHEMAS as EVENT_SCHEMAS
from .models import (
FirmwareVersionRange,
NewZWaveDiscoverySchema,
Expand All @@ -77,6 +78,7 @@

NEW_DISCOVERY_SCHEMAS: dict[Platform, list[NewZWaveDiscoverySchema]] = {
Platform.BINARY_SENSOR: BINARY_SENSOR_SCHEMAS,
Platform.EVENT: EVENT_SCHEMAS,
}
SUPPORTED_PLATFORMS = tuple(NEW_DISCOVERY_SCHEMAS)

Expand Down Expand Up @@ -1164,15 +1166,6 @@ class ZWaveDiscoverySchema:
allow_multi=True,
entity_registry_enabled_default=False,
),
# event
# stateful = False
ZWaveDiscoverySchema(
platform=Platform.EVENT,
hint="stateless",
primary_value=ZWaveValueDiscoverySchema(
stateful=False,
),
),
# button
# Meter CC idle
ZWaveDiscoverySchema(
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/zwave_js/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ def __init__(
)

# Entity class attributes
self._attr_name = self.generate_name()
self._attr_unique_id = get_unique_id(driver, self.info.primary_value.value_id)
if isinstance(info, NewZwaveDiscoveryInfo):
self.entity_description = info.entity_description
else:
if (enabled_default := info.entity_registry_enabled_default) is False:
self._attr_entity_registry_enabled_default = enabled_default
if (entity_category := info.entity_category) is not None:
self._attr_entity_category = entity_category
self._attr_name = self.generate_name()
self._attr_unique_id = get_unique_id(driver, self.info.primary_value.value_id)
self._attr_assumed_state = self.info.assumed_state
# device is precreated in main handler
self._attr_device_info = DeviceInfo(
Expand Down
48 changes: 41 additions & 7 deletions homeassistant/components/zwave_js/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,37 @@

from __future__ import annotations

from dataclasses import dataclass

from zwave_js_server.model.driver import Driver
from zwave_js_server.model.value import Value, ValueNotification

from homeassistant.components.event import DOMAIN as EVENT_DOMAIN, EventEntity
from homeassistant.components.event import (
DOMAIN as EVENT_DOMAIN,
EventEntity,
EventEntityDescription,
)
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback

from .const import ATTR_VALUE, DOMAIN
from .discovery import ZwaveDiscoveryInfo
from .entity import ZWaveBaseEntity
from .models import ZwaveJSConfigEntry
from .entity import NewZwaveDiscoveryInfo, ZWaveBaseEntity
from .models import (
NewZWaveDiscoverySchema,
ZwaveJSConfigEntry,
ZWaveValueDiscoverySchema,
)

PARALLEL_UPDATES = 0


@dataclass(frozen=True, kw_only=True)
class ValueNotificationZWaveJSEntityDescription(EventEntityDescription):
"""Represent a Z-Wave JS event entity description."""


async def async_setup_entry(
hass: HomeAssistant,
config_entry: ZwaveJSConfigEntry,
Expand All @@ -27,11 +42,13 @@ async def async_setup_entry(
client = config_entry.runtime_data.client

@callback
def async_add_event(info: ZwaveDiscoveryInfo) -> None:
def async_add_event(info: NewZwaveDiscoveryInfo) -> None:
"""Add Z-Wave event entity."""
driver = client.driver
assert driver is not None # Driver is ready before platforms are loaded.
entities: list[ZWaveBaseEntity] = [ZwaveEventEntity(config_entry, driver, info)]
entities: list[ZWaveBaseEntity] = [
info.entity_class(config_entry, driver, info)
]
async_add_entities(entities)

config_entry.async_on_unload(
Expand All @@ -55,7 +72,10 @@ class ZwaveEventEntity(ZWaveBaseEntity, EventEntity):
"""Representation of a Z-Wave event entity."""

def __init__(
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
self,
config_entry: ZwaveJSConfigEntry,
driver: Driver,
info: NewZwaveDiscoveryInfo,
) -> None:
"""Initialize a ZwaveEventEntity entity."""
super().__init__(config_entry, driver, info)
Expand Down Expand Up @@ -96,3 +116,17 @@ async def async_added_to_hass(self) -> None:
lambda event: self._async_handle_event(event["value_notification"]),
)
)


DISCOVERY_SCHEMAS: list[NewZWaveDiscoverySchema] = [
NewZWaveDiscoverySchema(
platform=Platform.EVENT,
primary_value=ZWaveValueDiscoverySchema(
stateful=False,
),
entity_description=ValueNotificationZWaveJSEntityDescription(
key="value_notification",
),
entity_class=ZwaveEventEntity,
),
]
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.

12 changes: 11 additions & 1 deletion tests/components/lg_netcast/test_device_trigger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
"""The tests for LG NEtcast device triggers."""
"""The tests for LG Netcast device triggers."""

from collections.abc import Generator
from unittest.mock import patch

import pytest

Expand All @@ -19,6 +22,13 @@
from tests.common import MockConfigEntry, async_get_device_automations


@pytest.fixture(autouse=True)
def mock_lg_netcast() -> Generator[None]:
"""Mock LG Netcast library."""
with patch("homeassistant.components.lg_netcast.LgNetCastClient"):
yield


async def test_get_triggers(
hass: HomeAssistant, device_registry: dr.DeviceRegistry
) -> None:
Expand Down
8 changes: 8 additions & 0 deletions tests/components/lg_netcast/test_trigger.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""The tests for LG Netcast device triggers."""

from collections.abc import Generator
from unittest.mock import patch

import pytest
Expand All @@ -17,6 +18,13 @@
from tests.common import MockEntity, MockEntityPlatform


@pytest.fixture(autouse=True)
def mock_lg_netcast() -> Generator[None]:
"""Mock LG Netcast library."""
with patch("homeassistant.components.lg_netcast.LgNetCastClient"):
yield


async def test_lg_netcast_turn_on_trigger_device_id(
hass: HomeAssistant,
service_calls: list[ServiceCall],
Expand Down
45 changes: 34 additions & 11 deletions tests/components/zwave_js/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import pytest
from zwave_js_server.event import Event

from homeassistant.components.event import ATTR_EVENT_TYPE
from homeassistant.components.zwave_js.const import ATTR_VALUE
from homeassistant.const import STATE_UNKNOWN, Platform
from homeassistant.core import HomeAssistant
from homeassistant.util import dt as dt_util
Expand Down Expand Up @@ -66,9 +64,12 @@ async def test_basic(

assert state
assert state.state == dt_util.as_utc(fut).isoformat(timespec="milliseconds")
attributes = state.attributes
assert attributes[ATTR_EVENT_TYPE] == "Basic event value"
assert attributes[ATTR_VALUE] == 255
assert state.attributes == {
"friendly_name": "honeywell_in_wall_smart_fan_control Event value",
"event_type": "Basic event value",
"event_types": ["Basic event value"],
"value": 255,
}


async def test_central_scene(
Expand Down Expand Up @@ -128,9 +129,20 @@ async def test_central_scene(

assert state
assert state.state == dt_util.as_utc(fut).isoformat(timespec="milliseconds")
attributes = state.attributes
assert attributes[ATTR_EVENT_TYPE] == "KeyReleased"
assert attributes[ATTR_VALUE] == 1
assert state.attributes == {
"friendly_name": "Node 51 Scene 002",
"event_type": "KeyReleased",
"event_types": [
"KeyHeldDown",
"KeyPressed",
"KeyPressed2x",
"KeyPressed3x",
"KeyPressed4x",
"KeyPressed5x",
"KeyReleased",
],
"value": 1,
}

# Try invalid value
event = Event(
Expand Down Expand Up @@ -178,6 +190,17 @@ async def test_central_scene(

assert state
assert state.state == dt_util.as_utc(fut).isoformat(timespec="milliseconds")
attributes = state.attributes
assert attributes[ATTR_EVENT_TYPE] == "KeyReleased"
assert attributes[ATTR_VALUE] == 1
assert state.attributes == {
"friendly_name": "Node 51 Scene 002",
"event_type": "KeyReleased",
"event_types": [
"KeyHeldDown",
"KeyPressed",
"KeyPressed2x",
"KeyPressed3x",
"KeyPressed4x",
"KeyPressed5x",
"KeyReleased",
],
"value": 1,
}
Loading