mirror of
https://github.com/home-assistant/core.git
synced 2025-07-07 21:37:07 +00:00
Type Z-Wave JS config entry (#147456)
* Type Z-Wave JS config entry * Migrate to data class
This commit is contained in:
parent
a6e3da43ca
commit
c7b2f236be
@ -29,7 +29,7 @@ from zwave_js_server.model.value import Value, ValueNotification
|
|||||||
|
|
||||||
from homeassistant.components.hassio import AddonError, AddonManager, AddonState
|
from homeassistant.components.hassio import AddonError, AddonManager, AddonState
|
||||||
from homeassistant.components.persistent_notification import async_create
|
from homeassistant.components.persistent_notification import async_create
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigEntryState
|
from homeassistant.config_entries import ConfigEntryState
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_DEVICE_ID,
|
ATTR_DEVICE_ID,
|
||||||
ATTR_DOMAIN,
|
ATTR_DOMAIN,
|
||||||
@ -104,7 +104,6 @@ from .const import (
|
|||||||
CONF_S2_UNAUTHENTICATED_KEY,
|
CONF_S2_UNAUTHENTICATED_KEY,
|
||||||
CONF_USB_PATH,
|
CONF_USB_PATH,
|
||||||
CONF_USE_ADDON,
|
CONF_USE_ADDON,
|
||||||
DATA_CLIENT,
|
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
DRIVER_READY_TIMEOUT,
|
DRIVER_READY_TIMEOUT,
|
||||||
EVENT_DEVICE_ADDED_TO_REGISTRY,
|
EVENT_DEVICE_ADDED_TO_REGISTRY,
|
||||||
@ -133,10 +132,10 @@ from .helpers import (
|
|||||||
get_valueless_base_unique_id,
|
get_valueless_base_unique_id,
|
||||||
)
|
)
|
||||||
from .migrate import async_migrate_discovered_value
|
from .migrate import async_migrate_discovered_value
|
||||||
|
from .models import ZwaveJSConfigEntry, ZwaveJSData
|
||||||
from .services import async_setup_services
|
from .services import async_setup_services
|
||||||
|
|
||||||
CONNECT_TIMEOUT = 10
|
CONNECT_TIMEOUT = 10
|
||||||
DATA_DRIVER_EVENTS = "driver_events"
|
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
@ -182,7 +181,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ZwaveJSConfigEntry) -> bool:
|
||||||
"""Set up Z-Wave JS from a config entry."""
|
"""Set up Z-Wave JS from a config entry."""
|
||||||
if use_addon := entry.data.get(CONF_USE_ADDON):
|
if use_addon := entry.data.get(CONF_USE_ADDON):
|
||||||
await async_ensure_addon_running(hass, entry)
|
await async_ensure_addon_running(hass, entry)
|
||||||
@ -260,10 +259,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
LOGGER.debug("Connection to Zwave JS Server initialized")
|
LOGGER.debug("Connection to Zwave JS Server initialized")
|
||||||
|
|
||||||
entry_runtime_data = entry.runtime_data = {
|
driver_events = DriverEvents(hass, entry)
|
||||||
DATA_CLIENT: client,
|
entry_runtime_data = ZwaveJSData(
|
||||||
}
|
client=client,
|
||||||
entry_runtime_data[DATA_DRIVER_EVENTS] = driver_events = DriverEvents(hass, entry)
|
driver_events=driver_events,
|
||||||
|
)
|
||||||
|
entry.runtime_data = entry_runtime_data
|
||||||
|
|
||||||
driver = client.driver
|
driver = client.driver
|
||||||
# When the driver is ready we know it's set on the client.
|
# When the driver is ready we know it's set on the client.
|
||||||
@ -348,7 +349,7 @@ class DriverEvents:
|
|||||||
|
|
||||||
driver: Driver
|
driver: Driver
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
|
def __init__(self, hass: HomeAssistant, entry: ZwaveJSConfigEntry) -> None:
|
||||||
"""Set up the driver events instance."""
|
"""Set up the driver events instance."""
|
||||||
self.config_entry = entry
|
self.config_entry = entry
|
||||||
self.dev_reg = dr.async_get(hass)
|
self.dev_reg = dr.async_get(hass)
|
||||||
@ -1045,7 +1046,7 @@ class NodeEvents:
|
|||||||
|
|
||||||
async def client_listen(
|
async def client_listen(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: ZwaveClient,
|
client: ZwaveClient,
|
||||||
driver_ready: asyncio.Event,
|
driver_ready: asyncio.Event,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -1072,12 +1073,12 @@ async def client_listen(
|
|||||||
hass.config_entries.async_schedule_reload(entry.entry_id)
|
hass.config_entries.async_schedule_reload(entry.entry_id)
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: ZwaveJSConfigEntry) -> bool:
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
|
|
||||||
entry_runtime_data = entry.runtime_data
|
entry_runtime_data = entry.runtime_data
|
||||||
client: ZwaveClient = entry_runtime_data[DATA_CLIENT]
|
client = entry_runtime_data.client
|
||||||
|
|
||||||
if client.connected and (driver := client.driver):
|
if client.connected and (driver := client.driver):
|
||||||
await async_disable_server_logging_if_needed(hass, entry, driver)
|
await async_disable_server_logging_if_needed(hass, entry, driver)
|
||||||
@ -1094,7 +1095,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
async def async_remove_entry(hass: HomeAssistant, entry: ZwaveJSConfigEntry) -> None:
|
||||||
"""Remove a config entry."""
|
"""Remove a config entry."""
|
||||||
if not entry.data.get(CONF_INTEGRATION_CREATED_ADDON):
|
if not entry.data.get(CONF_INTEGRATION_CREATED_ADDON):
|
||||||
return
|
return
|
||||||
@ -1116,7 +1117,9 @@ async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
|||||||
LOGGER.error(err)
|
LOGGER.error(err)
|
||||||
|
|
||||||
|
|
||||||
async def async_ensure_addon_running(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
async def async_ensure_addon_running(
|
||||||
|
hass: HomeAssistant, entry: ZwaveJSConfigEntry
|
||||||
|
) -> None:
|
||||||
"""Ensure that Z-Wave JS add-on is installed and running."""
|
"""Ensure that Z-Wave JS add-on is installed and running."""
|
||||||
addon_manager = _get_addon_manager(hass)
|
addon_manager = _get_addon_manager(hass)
|
||||||
try:
|
try:
|
||||||
|
@ -7,7 +7,7 @@ from collections.abc import Callable, Coroutine
|
|||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
import dataclasses
|
import dataclasses
|
||||||
from functools import partial, wraps
|
from functools import partial, wraps
|
||||||
from typing import Any, Concatenate, Literal, cast
|
from typing import TYPE_CHECKING, Any, Concatenate, Literal, cast
|
||||||
|
|
||||||
from aiohttp import web, web_exceptions, web_request
|
from aiohttp import web, web_exceptions, web_request
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -70,7 +70,7 @@ from homeassistant.components.websocket_api import (
|
|||||||
ERR_UNKNOWN_ERROR,
|
ERR_UNKNOWN_ERROR,
|
||||||
ActiveConnection,
|
ActiveConnection,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigEntryState
|
from homeassistant.config_entries import ConfigEntryState
|
||||||
from homeassistant.const import CONF_URL
|
from homeassistant.const import CONF_URL
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
||||||
@ -86,7 +86,6 @@ from .const import (
|
|||||||
ATTR_WAIT_FOR_RESULT,
|
ATTR_WAIT_FOR_RESULT,
|
||||||
CONF_DATA_COLLECTION_OPTED_IN,
|
CONF_DATA_COLLECTION_OPTED_IN,
|
||||||
CONF_INSTALLER_MODE,
|
CONF_INSTALLER_MODE,
|
||||||
DATA_CLIENT,
|
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
DRIVER_READY_TIMEOUT,
|
DRIVER_READY_TIMEOUT,
|
||||||
EVENT_DEVICE_ADDED_TO_REGISTRY,
|
EVENT_DEVICE_ADDED_TO_REGISTRY,
|
||||||
@ -102,6 +101,10 @@ from .helpers import (
|
|||||||
get_device_id,
|
get_device_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
|
|
||||||
DATA_UNSUBSCRIBE = "unsubs"
|
DATA_UNSUBSCRIBE = "unsubs"
|
||||||
|
|
||||||
# general API constants
|
# general API constants
|
||||||
@ -254,7 +257,7 @@ async def _async_get_entry(
|
|||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry_id: str,
|
entry_id: str,
|
||||||
) -> tuple[ConfigEntry, Client, Driver] | tuple[None, None, None]:
|
) -> tuple[ZwaveJSConfigEntry, Client, Driver] | tuple[None, None, None]:
|
||||||
"""Get config entry and client from message data."""
|
"""Get config entry and client from message data."""
|
||||||
entry = hass.config_entries.async_get_entry(entry_id)
|
entry = hass.config_entries.async_get_entry(entry_id)
|
||||||
if entry is None:
|
if entry is None:
|
||||||
@ -269,7 +272,7 @@ async def _async_get_entry(
|
|||||||
)
|
)
|
||||||
return None, None, None
|
return None, None, None
|
||||||
|
|
||||||
client: Client = entry.runtime_data[DATA_CLIENT]
|
client = entry.runtime_data.client
|
||||||
|
|
||||||
if client.driver is None:
|
if client.driver is None:
|
||||||
connection.send_error(
|
connection.send_error(
|
||||||
@ -284,7 +287,14 @@ async def _async_get_entry(
|
|||||||
|
|
||||||
def async_get_entry(
|
def async_get_entry(
|
||||||
orig_func: Callable[
|
orig_func: Callable[
|
||||||
[HomeAssistant, ActiveConnection, dict[str, Any], ConfigEntry, Client, Driver],
|
[
|
||||||
|
HomeAssistant,
|
||||||
|
ActiveConnection,
|
||||||
|
dict[str, Any],
|
||||||
|
ZwaveJSConfigEntry,
|
||||||
|
Client,
|
||||||
|
Driver,
|
||||||
|
],
|
||||||
Coroutine[Any, Any, None],
|
Coroutine[Any, Any, None],
|
||||||
],
|
],
|
||||||
) -> Callable[
|
) -> Callable[
|
||||||
@ -726,7 +736,7 @@ async def websocket_add_node(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -903,7 +913,7 @@ async def websocket_cancel_secure_bootstrap_s2(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -926,7 +936,7 @@ async def websocket_subscribe_s2_inclusion(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -979,7 +989,7 @@ async def websocket_grant_security_classes(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -1007,7 +1017,7 @@ async def websocket_validate_dsk_and_enter_pin(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -1077,7 +1087,7 @@ async def websocket_provision_smart_start_node(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -1162,7 +1172,7 @@ async def websocket_unprovision_smart_start_node(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -1212,7 +1222,7 @@ async def websocket_get_provisioning_entries(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -1236,7 +1246,7 @@ async def websocket_parse_qr_code_string(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -1262,7 +1272,7 @@ async def websocket_try_parse_dsk_from_qr_code_string(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -1291,7 +1301,7 @@ async def websocket_lookup_device(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -1323,7 +1333,7 @@ async def websocket_supports_feature(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -1349,7 +1359,7 @@ async def websocket_stop_inclusion(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -1376,7 +1386,7 @@ async def websocket_stop_exclusion(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -1404,7 +1414,7 @@ async def websocket_remove_node(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -1692,7 +1702,7 @@ async def websocket_begin_rebuilding_routes(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -1719,7 +1729,7 @@ async def websocket_subscribe_rebuild_routes_progress(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -1772,7 +1782,7 @@ async def websocket_stop_rebuilding_routes(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -2100,7 +2110,7 @@ async def websocket_subscribe_log_updates(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -2187,7 +2197,7 @@ async def websocket_update_log_config(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -2211,7 +2221,7 @@ async def websocket_get_log_config(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -2238,7 +2248,7 @@ async def websocket_update_data_collection_preference(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -2273,7 +2283,7 @@ async def websocket_data_collection_status(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -2507,7 +2517,7 @@ async def websocket_is_any_ota_firmware_update_in_progress(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -2602,7 +2612,7 @@ async def websocket_check_for_config_updates(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -2631,7 +2641,7 @@ async def websocket_install_config_update(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -2670,7 +2680,7 @@ async def websocket_subscribe_controller_statistics(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -2823,7 +2833,7 @@ async def websocket_hard_reset_controller(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -3000,7 +3010,7 @@ async def websocket_backup_nvm(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -3062,7 +3072,7 @@ async def websocket_restore_nvm(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
connection: ActiveConnection,
|
connection: ActiveConnection,
|
||||||
msg: dict[str, Any],
|
msg: dict[str, Any],
|
||||||
entry: ConfigEntry,
|
entry: ZwaveJSConfigEntry,
|
||||||
client: Client,
|
client: Client,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -4,7 +4,6 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
|
||||||
from zwave_js_server.const import CommandClass
|
from zwave_js_server.const import CommandClass
|
||||||
from zwave_js_server.const.command_class.lock import DOOR_STATUS_PROPERTY
|
from zwave_js_server.const.command_class.lock import DOOR_STATUS_PROPERTY
|
||||||
from zwave_js_server.const.command_class.notification import (
|
from zwave_js_server.const.command_class.notification import (
|
||||||
@ -18,15 +17,15 @@ from homeassistant.components.binary_sensor import (
|
|||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
BinarySensorEntityDescription,
|
BinarySensorEntityDescription,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import EntityCategory
|
from homeassistant.const import EntityCategory
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import DATA_CLIENT, DOMAIN
|
from .const import DOMAIN
|
||||||
from .discovery import ZwaveDiscoveryInfo
|
from .discovery import ZwaveDiscoveryInfo
|
||||||
from .entity import ZWaveBaseEntity
|
from .entity import ZWaveBaseEntity
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
@ -364,11 +363,11 @@ def is_valid_notification_binary_sensor(
|
|||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Z-Wave binary sensor from config entry."""
|
"""Set up Z-Wave binary sensor from config entry."""
|
||||||
client: ZwaveClient = config_entry.runtime_data[DATA_CLIENT]
|
client = config_entry.runtime_data.client
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_add_binary_sensor(info: ZwaveDiscoveryInfo) -> None:
|
def async_add_binary_sensor(info: ZwaveDiscoveryInfo) -> None:
|
||||||
@ -448,7 +447,7 @@ class ZWaveBooleanBinarySensor(ZWaveBaseEntity, BinarySensorEntity):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
info: ZwaveDiscoveryInfo,
|
info: ZwaveDiscoveryInfo,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -476,7 +475,7 @@ class ZWaveNotificationBinarySensor(ZWaveBaseEntity, BinarySensorEntity):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
info: ZwaveDiscoveryInfo,
|
info: ZwaveDiscoveryInfo,
|
||||||
state_key: str,
|
state_key: str,
|
||||||
@ -509,7 +508,7 @@ class ZWavePropertyBinarySensor(ZWaveBaseEntity, BinarySensorEntity):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
info: ZwaveDiscoveryInfo,
|
info: ZwaveDiscoveryInfo,
|
||||||
description: PropertyZWaveJSEntityDescription,
|
description: PropertyZWaveJSEntityDescription,
|
||||||
@ -533,7 +532,7 @@ class ZWaveConfigParameterBinarySensor(ZWaveBooleanBinarySensor):
|
|||||||
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize a ZWaveConfigParameterBinarySensor entity."""
|
"""Initialize a ZWaveConfigParameterBinarySensor entity."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
|
@ -2,32 +2,31 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
|
||||||
from zwave_js_server.model.driver import Driver
|
from zwave_js_server.model.driver import Driver
|
||||||
from zwave_js_server.model.node import Node as ZwaveNode
|
from zwave_js_server.model.node import Node as ZwaveNode
|
||||||
|
|
||||||
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, ButtonEntity
|
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, ButtonEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import EntityCategory
|
from homeassistant.const import EntityCategory
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import DATA_CLIENT, DOMAIN, LOGGER
|
from .const import DOMAIN, LOGGER
|
||||||
from .discovery import ZwaveDiscoveryInfo
|
from .discovery import ZwaveDiscoveryInfo
|
||||||
from .entity import ZWaveBaseEntity
|
from .entity import ZWaveBaseEntity
|
||||||
from .helpers import get_device_info, get_valueless_base_unique_id
|
from .helpers import get_device_info, get_valueless_base_unique_id
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Z-Wave button from config entry."""
|
"""Set up Z-Wave button from config entry."""
|
||||||
client: ZwaveClient = config_entry.runtime_data[DATA_CLIENT]
|
client = config_entry.runtime_data.client
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_add_button(info: ZwaveDiscoveryInfo) -> None:
|
def async_add_button(info: ZwaveDiscoveryInfo) -> None:
|
||||||
@ -70,7 +69,7 @@ class ZwaveBooleanNodeButton(ZWaveBaseEntity, ButtonEntity):
|
|||||||
"""Representation of a ZWave button entity for a boolean value."""
|
"""Representation of a ZWave button entity for a boolean value."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize entity."""
|
"""Initialize entity."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
@ -141,7 +140,7 @@ class ZWaveNotificationIdleButton(ZWaveBaseEntity, ButtonEntity):
|
|||||||
_attr_entity_category = EntityCategory.CONFIG
|
_attr_entity_category = EntityCategory.CONFIG
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize a ZWaveNotificationIdleButton entity."""
|
"""Initialize a ZWaveNotificationIdleButton entity."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
|
@ -4,7 +4,6 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
|
||||||
from zwave_js_server.const import CommandClass
|
from zwave_js_server.const import CommandClass
|
||||||
from zwave_js_server.const.command_class.thermostat import (
|
from zwave_js_server.const.command_class.thermostat import (
|
||||||
THERMOSTAT_CURRENT_TEMP_PROPERTY,
|
THERMOSTAT_CURRENT_TEMP_PROPERTY,
|
||||||
@ -31,18 +30,18 @@ from homeassistant.components.climate import (
|
|||||||
HVACAction,
|
HVACAction,
|
||||||
HVACMode,
|
HVACMode,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import ATTR_TEMPERATURE, PRECISION_TENTHS, UnitOfTemperature
|
from homeassistant.const import ATTR_TEMPERATURE, PRECISION_TENTHS, UnitOfTemperature
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
from homeassistant.util.unit_conversion import TemperatureConverter
|
from homeassistant.util.unit_conversion import TemperatureConverter
|
||||||
|
|
||||||
from .const import DATA_CLIENT, DOMAIN
|
from .const import DOMAIN
|
||||||
from .discovery import ZwaveDiscoveryInfo
|
from .discovery import ZwaveDiscoveryInfo
|
||||||
from .discovery_data_template import DynamicCurrentTempClimateDataTemplate
|
from .discovery_data_template import DynamicCurrentTempClimateDataTemplate
|
||||||
from .entity import ZWaveBaseEntity
|
from .entity import ZWaveBaseEntity
|
||||||
from .helpers import get_value_of_zwave_value
|
from .helpers import get_value_of_zwave_value
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
@ -96,11 +95,11 @@ ATTR_FAN_STATE = "fan_state"
|
|||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Z-Wave climate from config entry."""
|
"""Set up Z-Wave climate from config entry."""
|
||||||
client: ZwaveClient = config_entry.runtime_data[DATA_CLIENT]
|
client = config_entry.runtime_data.client
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_add_climate(info: ZwaveDiscoveryInfo) -> None:
|
def async_add_climate(info: ZwaveDiscoveryInfo) -> None:
|
||||||
@ -130,7 +129,7 @@ class ZWaveClimate(ZWaveBaseEntity, ClimateEntity):
|
|||||||
_attr_precision = PRECISION_TENTHS
|
_attr_precision = PRECISION_TENTHS
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize thermostat."""
|
"""Initialize thermostat."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
@ -563,7 +562,7 @@ class DynamicCurrentTempClimate(ZWaveClimate):
|
|||||||
"""Representation of a thermostat that can dynamically use a different Zwave Value for current temp."""
|
"""Representation of a thermostat that can dynamically use a different Zwave Value for current temp."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize thermostat."""
|
"""Initialize thermostat."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
|
@ -27,7 +27,6 @@ from homeassistant.components.hassio import (
|
|||||||
)
|
)
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
SOURCE_USB,
|
SOURCE_USB,
|
||||||
ConfigEntry,
|
|
||||||
ConfigEntryState,
|
ConfigEntryState,
|
||||||
ConfigFlow,
|
ConfigFlow,
|
||||||
ConfigFlowResult,
|
ConfigFlowResult,
|
||||||
@ -62,11 +61,11 @@ from .const import (
|
|||||||
CONF_S2_UNAUTHENTICATED_KEY,
|
CONF_S2_UNAUTHENTICATED_KEY,
|
||||||
CONF_USB_PATH,
|
CONF_USB_PATH,
|
||||||
CONF_USE_ADDON,
|
CONF_USE_ADDON,
|
||||||
DATA_CLIENT,
|
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
DRIVER_READY_TIMEOUT,
|
DRIVER_READY_TIMEOUT,
|
||||||
)
|
)
|
||||||
from .helpers import CannotConnect, async_get_version_info
|
from .helpers import CannotConnect, async_get_version_info
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -185,7 +184,7 @@ class ZWaveJSConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self.backup_filepath: Path | None = None
|
self.backup_filepath: Path | None = None
|
||||||
self.use_addon = False
|
self.use_addon = False
|
||||||
self._migrating = False
|
self._migrating = False
|
||||||
self._reconfigure_config_entry: ConfigEntry | None = None
|
self._reconfigure_config_entry: ZwaveJSConfigEntry | None = None
|
||||||
self._usb_discovery = False
|
self._usb_discovery = False
|
||||||
self._recommended_install = False
|
self._recommended_install = False
|
||||||
|
|
||||||
@ -1443,7 +1442,7 @@ class ZWaveJSConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
assert config_entry is not None
|
assert config_entry is not None
|
||||||
if config_entry.state != ConfigEntryState.LOADED:
|
if config_entry.state != ConfigEntryState.LOADED:
|
||||||
raise AbortFlow("Configuration entry is not loaded")
|
raise AbortFlow("Configuration entry is not loaded")
|
||||||
client: Client = config_entry.runtime_data[DATA_CLIENT]
|
client: Client = config_entry.runtime_data.client
|
||||||
assert client.driver is not None
|
assert client.driver is not None
|
||||||
return client.driver
|
return client.driver
|
||||||
|
|
||||||
|
@ -38,8 +38,6 @@ CONF_USE_ADDON = "use_addon"
|
|||||||
CONF_DATA_COLLECTION_OPTED_IN = "data_collection_opted_in"
|
CONF_DATA_COLLECTION_OPTED_IN = "data_collection_opted_in"
|
||||||
DOMAIN = "zwave_js"
|
DOMAIN = "zwave_js"
|
||||||
|
|
||||||
DATA_CLIENT = "client"
|
|
||||||
DATA_OLD_SERVER_LOG_LEVEL = "old_server_log_level"
|
|
||||||
|
|
||||||
EVENT_DEVICE_ADDED_TO_REGISTRY = f"{DOMAIN}_device_added_to_registry"
|
EVENT_DEVICE_ADDED_TO_REGISTRY = f"{DOMAIN}_device_added_to_registry"
|
||||||
EVENT_VALUE_UPDATED = "value updated"
|
EVENT_VALUE_UPDATED = "value updated"
|
||||||
|
@ -4,7 +4,6 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
|
||||||
from zwave_js_server.const import (
|
from zwave_js_server.const import (
|
||||||
CURRENT_VALUE_PROPERTY,
|
CURRENT_VALUE_PROPERTY,
|
||||||
TARGET_STATE_PROPERTY,
|
TARGET_STATE_PROPERTY,
|
||||||
@ -34,31 +33,26 @@ from homeassistant.components.cover import (
|
|||||||
CoverEntity,
|
CoverEntity,
|
||||||
CoverEntityFeature,
|
CoverEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import (
|
from .const import COVER_POSITION_PROPERTY_KEYS, COVER_TILT_PROPERTY_KEYS, DOMAIN
|
||||||
COVER_POSITION_PROPERTY_KEYS,
|
|
||||||
COVER_TILT_PROPERTY_KEYS,
|
|
||||||
DATA_CLIENT,
|
|
||||||
DOMAIN,
|
|
||||||
)
|
|
||||||
from .discovery import ZwaveDiscoveryInfo
|
from .discovery import ZwaveDiscoveryInfo
|
||||||
from .discovery_data_template import CoverTiltDataTemplate
|
from .discovery_data_template import CoverTiltDataTemplate
|
||||||
from .entity import ZWaveBaseEntity
|
from .entity import ZWaveBaseEntity
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Z-Wave Cover from Config Entry."""
|
"""Set up Z-Wave Cover from Config Entry."""
|
||||||
client: ZwaveClient = config_entry.runtime_data[DATA_CLIENT]
|
client = config_entry.runtime_data.client
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_add_cover(info: ZwaveDiscoveryInfo) -> None:
|
def async_add_cover(info: ZwaveDiscoveryInfo) -> None:
|
||||||
@ -288,7 +282,7 @@ class ZWaveMultilevelSwitchCover(CoverPositionMixin):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
info: ZwaveDiscoveryInfo,
|
info: ZwaveDiscoveryInfo,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -318,7 +312,7 @@ class ZWaveTiltCover(ZWaveMultilevelSwitchCover, CoverTiltMixin):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
info: ZwaveDiscoveryInfo,
|
info: ZwaveDiscoveryInfo,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -336,7 +330,7 @@ class ZWaveWindowCovering(CoverPositionMixin, CoverTiltMixin):
|
|||||||
"""Representation of a Z-Wave Window Covering cover device."""
|
"""Representation of a Z-Wave Window Covering cover device."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
@ -438,7 +432,7 @@ class ZwaveMotorizedBarrier(ZWaveBaseEntity, CoverEntity):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
info: ZwaveDiscoveryInfo,
|
info: ZwaveDiscoveryInfo,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -2,14 +2,13 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
|
||||||
from zwave_js_server.model.value import ConfigurationValue
|
from zwave_js_server.model.value import ConfigurationValue
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntryState
|
from homeassistant.config_entries import ConfigEntryState
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import device_registry as dr
|
from homeassistant.helpers import device_registry as dr
|
||||||
|
|
||||||
from .const import DATA_CLIENT, DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
NODE_STATUSES = ["asleep", "awake", "dead", "alive"]
|
NODE_STATUSES = ["asleep", "awake", "dead", "alive"]
|
||||||
|
|
||||||
@ -55,5 +54,5 @@ def async_bypass_dynamic_config_validation(hass: HomeAssistant, device_id: str)
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
# The driver may not be ready when the config entry is loaded.
|
# The driver may not be ready when the config entry is loaded.
|
||||||
client: ZwaveClient = entry.runtime_data[DATA_CLIENT]
|
client = entry.runtime_data.client
|
||||||
return client.driver is None
|
return client.driver is None
|
||||||
|
@ -13,13 +13,12 @@ from zwave_js_server.model.value import ValueDataType
|
|||||||
from zwave_js_server.util.node import dump_node_state
|
from zwave_js_server.util.node import dump_node_state
|
||||||
|
|
||||||
from homeassistant.components.diagnostics import REDACTED, async_redact_data
|
from homeassistant.components.diagnostics import REDACTED, async_redact_data
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import CONF_URL
|
from homeassistant.const import CONF_URL
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import DATA_CLIENT, USER_AGENT
|
from .const import USER_AGENT
|
||||||
from .helpers import (
|
from .helpers import (
|
||||||
ZwaveValueMatcher,
|
ZwaveValueMatcher,
|
||||||
get_home_and_node_id_from_device_entry,
|
get_home_and_node_id_from_device_entry,
|
||||||
@ -27,6 +26,7 @@ from .helpers import (
|
|||||||
get_value_id_from_unique_id,
|
get_value_id_from_unique_id,
|
||||||
value_matches_matcher,
|
value_matches_matcher,
|
||||||
)
|
)
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
KEYS_TO_REDACT = {"homeId", "location"}
|
KEYS_TO_REDACT = {"homeId", "location"}
|
||||||
|
|
||||||
@ -73,7 +73,10 @@ def redact_node_state(node_state: dict) -> dict:
|
|||||||
|
|
||||||
|
|
||||||
def get_device_entities(
|
def get_device_entities(
|
||||||
hass: HomeAssistant, node: Node, config_entry: ConfigEntry, device: dr.DeviceEntry
|
hass: HomeAssistant,
|
||||||
|
node: Node,
|
||||||
|
config_entry: ZwaveJSConfigEntry,
|
||||||
|
device: dr.DeviceEntry,
|
||||||
) -> list[dict[str, Any]]:
|
) -> list[dict[str, Any]]:
|
||||||
"""Get entities for a device."""
|
"""Get entities for a device."""
|
||||||
entity_entries = er.async_entries_for_device(
|
entity_entries = er.async_entries_for_device(
|
||||||
@ -125,7 +128,7 @@ def get_device_entities(
|
|||||||
|
|
||||||
|
|
||||||
async def async_get_config_entry_diagnostics(
|
async def async_get_config_entry_diagnostics(
|
||||||
hass: HomeAssistant, config_entry: ConfigEntry
|
hass: HomeAssistant, config_entry: ZwaveJSConfigEntry
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Return diagnostics for a config entry."""
|
"""Return diagnostics for a config entry."""
|
||||||
msgs: list[dict] = async_redact_data(
|
msgs: list[dict] = async_redact_data(
|
||||||
@ -144,10 +147,10 @@ async def async_get_config_entry_diagnostics(
|
|||||||
|
|
||||||
|
|
||||||
async def async_get_device_diagnostics(
|
async def async_get_device_diagnostics(
|
||||||
hass: HomeAssistant, config_entry: ConfigEntry, device: dr.DeviceEntry
|
hass: HomeAssistant, config_entry: ZwaveJSConfigEntry, device: dr.DeviceEntry
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Return diagnostics for a device."""
|
"""Return diagnostics for a device."""
|
||||||
client: Client = config_entry.runtime_data[DATA_CLIENT]
|
client: Client = config_entry.runtime_data.client
|
||||||
identifiers = get_home_and_node_id_from_device_entry(device)
|
identifiers = get_home_and_node_id_from_device_entry(device)
|
||||||
node_id = identifiers[1] if identifiers else None
|
node_id = identifiers[1] if identifiers else None
|
||||||
driver = client.driver
|
driver = client.driver
|
||||||
|
@ -2,30 +2,29 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
|
||||||
from zwave_js_server.model.driver import Driver
|
from zwave_js_server.model.driver import Driver
|
||||||
from zwave_js_server.model.value import Value, ValueNotification
|
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
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import ATTR_VALUE, DATA_CLIENT, DOMAIN
|
from .const import ATTR_VALUE, DOMAIN
|
||||||
from .discovery import ZwaveDiscoveryInfo
|
from .discovery import ZwaveDiscoveryInfo
|
||||||
from .entity import ZWaveBaseEntity
|
from .entity import ZWaveBaseEntity
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Z-Wave Event entity from Config Entry."""
|
"""Set up Z-Wave Event entity from Config Entry."""
|
||||||
client: ZwaveClient = config_entry.runtime_data[DATA_CLIENT]
|
client = config_entry.runtime_data.client
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_add_event(info: ZwaveDiscoveryInfo) -> None:
|
def async_add_event(info: ZwaveDiscoveryInfo) -> None:
|
||||||
@ -56,7 +55,7 @@ class ZwaveEventEntity(ZWaveBaseEntity, EventEntity):
|
|||||||
"""Representation of a Z-Wave event entity."""
|
"""Representation of a Z-Wave event entity."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize a ZwaveEventEntity entity."""
|
"""Initialize a ZwaveEventEntity entity."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
|
@ -5,7 +5,6 @@ from __future__ import annotations
|
|||||||
import math
|
import math
|
||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
|
||||||
from zwave_js_server.const import TARGET_VALUE_PROPERTY, CommandClass
|
from zwave_js_server.const import TARGET_VALUE_PROPERTY, CommandClass
|
||||||
from zwave_js_server.const.command_class.multilevel_switch import SET_TO_PREVIOUS_VALUE
|
from zwave_js_server.const.command_class.multilevel_switch import SET_TO_PREVIOUS_VALUE
|
||||||
from zwave_js_server.const.command_class.thermostat import (
|
from zwave_js_server.const.command_class.thermostat import (
|
||||||
@ -20,7 +19,6 @@ from homeassistant.components.fan import (
|
|||||||
FanEntity,
|
FanEntity,
|
||||||
FanEntityFeature,
|
FanEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
@ -30,11 +28,12 @@ from homeassistant.util.percentage import (
|
|||||||
ranged_value_to_percentage,
|
ranged_value_to_percentage,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .const import DATA_CLIENT, DOMAIN
|
from .const import DOMAIN
|
||||||
from .discovery import ZwaveDiscoveryInfo
|
from .discovery import ZwaveDiscoveryInfo
|
||||||
from .discovery_data_template import FanValueMapping, FanValueMappingDataTemplate
|
from .discovery_data_template import FanValueMapping, FanValueMappingDataTemplate
|
||||||
from .entity import ZWaveBaseEntity
|
from .entity import ZWaveBaseEntity
|
||||||
from .helpers import get_value_of_zwave_value
|
from .helpers import get_value_of_zwave_value
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
@ -45,11 +44,11 @@ ATTR_FAN_STATE = "fan_state"
|
|||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Z-Wave Fan from Config Entry."""
|
"""Set up Z-Wave Fan from Config Entry."""
|
||||||
client: ZwaveClient = config_entry.runtime_data[DATA_CLIENT]
|
client = config_entry.runtime_data.client
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_add_fan(info: ZwaveDiscoveryInfo) -> None:
|
def async_add_fan(info: ZwaveDiscoveryInfo) -> None:
|
||||||
@ -85,7 +84,7 @@ class ZwaveFan(ZWaveBaseEntity, FanEntity):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the fan."""
|
"""Initialize the fan."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
@ -165,7 +164,7 @@ class ValueMappingZwaveFan(ZwaveFan):
|
|||||||
"""A Zwave fan with a value mapping data (e.g., 1-24 is low)."""
|
"""A Zwave fan with a value mapping data (e.g., 1-24 is low)."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the fan."""
|
"""Initialize the fan."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
@ -316,7 +315,7 @@ class ZwaveThermostatFan(ZWaveBaseEntity, FanEntity):
|
|||||||
_fan_state: ZwaveValue | None = None
|
_fan_state: ZwaveValue | None = None
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the thermostat fan."""
|
"""Initialize the thermostat fan."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
|
@ -10,7 +10,6 @@ from typing import Any, cast
|
|||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
|
||||||
from zwave_js_server.const import (
|
from zwave_js_server.const import (
|
||||||
LOG_LEVEL_MAP,
|
LOG_LEVEL_MAP,
|
||||||
CommandClass,
|
CommandClass,
|
||||||
@ -30,7 +29,7 @@ from zwave_js_server.model.value import (
|
|||||||
from zwave_js_server.version import VersionInfo, get_server_version
|
from zwave_js_server.version import VersionInfo, get_server_version
|
||||||
|
|
||||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigEntryState
|
from homeassistant.config_entries import ConfigEntryState
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_AREA_ID,
|
ATTR_AREA_ID,
|
||||||
ATTR_DEVICE_ID,
|
ATTR_DEVICE_ID,
|
||||||
@ -51,12 +50,11 @@ from .const import (
|
|||||||
ATTR_ENDPOINT,
|
ATTR_ENDPOINT,
|
||||||
ATTR_PROPERTY,
|
ATTR_PROPERTY,
|
||||||
ATTR_PROPERTY_KEY,
|
ATTR_PROPERTY_KEY,
|
||||||
DATA_CLIENT,
|
|
||||||
DATA_OLD_SERVER_LOG_LEVEL,
|
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
LIB_LOGGER,
|
LIB_LOGGER,
|
||||||
LOGGER,
|
LOGGER,
|
||||||
)
|
)
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
SERVER_VERSION_TIMEOUT = 10
|
SERVER_VERSION_TIMEOUT = 10
|
||||||
|
|
||||||
@ -143,7 +141,7 @@ async def async_enable_statistics(driver: Driver) -> None:
|
|||||||
|
|
||||||
|
|
||||||
async def async_enable_server_logging_if_needed(
|
async def async_enable_server_logging_if_needed(
|
||||||
hass: HomeAssistant, entry: ConfigEntry, driver: Driver
|
hass: HomeAssistant, entry: ZwaveJSConfigEntry, driver: Driver
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Enable logging of zwave-js-server in the lib."""
|
"""Enable logging of zwave-js-server in the lib."""
|
||||||
# If lib log level is set to debug, we want to enable server logging. First we
|
# If lib log level is set to debug, we want to enable server logging. First we
|
||||||
@ -161,15 +159,14 @@ async def async_enable_server_logging_if_needed(
|
|||||||
if (curr_server_log_level := driver.log_config.level) and (
|
if (curr_server_log_level := driver.log_config.level) and (
|
||||||
LOG_LEVEL_MAP[curr_server_log_level]
|
LOG_LEVEL_MAP[curr_server_log_level]
|
||||||
) > LIB_LOGGER.getEffectiveLevel():
|
) > LIB_LOGGER.getEffectiveLevel():
|
||||||
entry_data = entry.runtime_data
|
entry.runtime_data.old_server_log_level = curr_server_log_level
|
||||||
entry_data[DATA_OLD_SERVER_LOG_LEVEL] = curr_server_log_level
|
|
||||||
await driver.async_update_log_config(LogConfig(level=LogLevel.DEBUG))
|
await driver.async_update_log_config(LogConfig(level=LogLevel.DEBUG))
|
||||||
await driver.client.enable_server_logging()
|
await driver.client.enable_server_logging()
|
||||||
LOGGER.info("Zwave-js-server logging is enabled")
|
LOGGER.info("Zwave-js-server logging is enabled")
|
||||||
|
|
||||||
|
|
||||||
async def async_disable_server_logging_if_needed(
|
async def async_disable_server_logging_if_needed(
|
||||||
hass: HomeAssistant, entry: ConfigEntry, driver: Driver
|
hass: HomeAssistant, entry: ZwaveJSConfigEntry, driver: Driver
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Disable logging of zwave-js-server in the lib if still connected to server."""
|
"""Disable logging of zwave-js-server in the lib if still connected to server."""
|
||||||
if (
|
if (
|
||||||
@ -180,10 +177,8 @@ async def async_disable_server_logging_if_needed(
|
|||||||
return
|
return
|
||||||
LOGGER.info("Disabling zwave_js server logging")
|
LOGGER.info("Disabling zwave_js server logging")
|
||||||
if (
|
if (
|
||||||
DATA_OLD_SERVER_LOG_LEVEL in entry.runtime_data
|
old_server_log_level := entry.runtime_data.old_server_log_level
|
||||||
and (old_server_log_level := entry.runtime_data.pop(DATA_OLD_SERVER_LOG_LEVEL))
|
) is not None and old_server_log_level != driver.log_config.level:
|
||||||
!= driver.log_config.level
|
|
||||||
):
|
|
||||||
LOGGER.info(
|
LOGGER.info(
|
||||||
(
|
(
|
||||||
"Server logging is currently set to %s as a result of server logging "
|
"Server logging is currently set to %s as a result of server logging "
|
||||||
@ -193,6 +188,7 @@ async def async_disable_server_logging_if_needed(
|
|||||||
old_server_log_level,
|
old_server_log_level,
|
||||||
)
|
)
|
||||||
await driver.async_update_log_config(LogConfig(level=old_server_log_level))
|
await driver.async_update_log_config(LogConfig(level=old_server_log_level))
|
||||||
|
entry.runtime_data.old_server_log_level = None
|
||||||
driver.client.disable_server_logging()
|
driver.client.disable_server_logging()
|
||||||
LOGGER.info("Zwave-js-server logging is enabled")
|
LOGGER.info("Zwave-js-server logging is enabled")
|
||||||
|
|
||||||
@ -262,7 +258,7 @@ def async_get_node_from_device_id(
|
|||||||
# Use device config entry ID's to validate that this is a valid zwave_js device
|
# Use device config entry ID's to validate that this is a valid zwave_js device
|
||||||
# and to get the client
|
# and to get the client
|
||||||
config_entry_ids = device_entry.config_entries
|
config_entry_ids = device_entry.config_entries
|
||||||
entry = next(
|
entry: ZwaveJSConfigEntry | None = next(
|
||||||
(
|
(
|
||||||
entry
|
entry
|
||||||
for entry in hass.config_entries.async_entries(DOMAIN)
|
for entry in hass.config_entries.async_entries(DOMAIN)
|
||||||
@ -277,7 +273,7 @@ def async_get_node_from_device_id(
|
|||||||
if entry.state != ConfigEntryState.LOADED:
|
if entry.state != ConfigEntryState.LOADED:
|
||||||
raise ValueError(f"Device {device_id} config entry is not loaded")
|
raise ValueError(f"Device {device_id} config entry is not loaded")
|
||||||
|
|
||||||
client: ZwaveClient = entry.runtime_data[DATA_CLIENT]
|
client = entry.runtime_data.client
|
||||||
driver = client.driver
|
driver = client.driver
|
||||||
|
|
||||||
if driver is None:
|
if driver is None:
|
||||||
@ -310,7 +306,7 @@ async def async_get_provisioning_entry_from_device_id(
|
|||||||
# Use device config entry ID's to validate that this is a valid zwave_js device
|
# Use device config entry ID's to validate that this is a valid zwave_js device
|
||||||
# and to get the client
|
# and to get the client
|
||||||
config_entry_ids = device_entry.config_entries
|
config_entry_ids = device_entry.config_entries
|
||||||
entry = next(
|
entry: ZwaveJSConfigEntry | None = next(
|
||||||
(
|
(
|
||||||
entry
|
entry
|
||||||
for entry in hass.config_entries.async_entries(DOMAIN)
|
for entry in hass.config_entries.async_entries(DOMAIN)
|
||||||
@ -325,7 +321,7 @@ async def async_get_provisioning_entry_from_device_id(
|
|||||||
if entry.state != ConfigEntryState.LOADED:
|
if entry.state != ConfigEntryState.LOADED:
|
||||||
raise ValueError(f"Device {device_id} config entry is not loaded")
|
raise ValueError(f"Device {device_id} config entry is not loaded")
|
||||||
|
|
||||||
client: ZwaveClient = entry.runtime_data[DATA_CLIENT]
|
client = entry.runtime_data.client
|
||||||
driver = client.driver
|
driver = client.driver
|
||||||
|
|
||||||
if driver is None:
|
if driver is None:
|
||||||
@ -393,7 +389,7 @@ def async_get_nodes_from_area_id(
|
|||||||
for device in dr.async_entries_for_area(dev_reg, area_id)
|
for device in dr.async_entries_for_area(dev_reg, area_id)
|
||||||
if any(
|
if any(
|
||||||
cast(
|
cast(
|
||||||
ConfigEntry,
|
ZwaveJSConfigEntry,
|
||||||
hass.config_entries.async_get_entry(config_entry_id),
|
hass.config_entries.async_get_entry(config_entry_id),
|
||||||
).domain
|
).domain
|
||||||
== DOMAIN
|
== DOMAIN
|
||||||
@ -487,7 +483,7 @@ def async_get_node_status_sensor_entity_id(
|
|||||||
|
|
||||||
entry = hass.config_entries.async_get_entry(entry_id)
|
entry = hass.config_entries.async_get_entry(entry_id)
|
||||||
assert entry
|
assert entry
|
||||||
client = entry.runtime_data[DATA_CLIENT]
|
client = entry.runtime_data.client
|
||||||
node = async_get_node_from_device_id(hass, device_id, dev_reg)
|
node = async_get_node_from_device_id(hass, device_id, dev_reg)
|
||||||
return ent_reg.async_get_entity_id(
|
return ent_reg.async_get_entity_id(
|
||||||
SENSOR_DOMAIN,
|
SENSOR_DOMAIN,
|
||||||
@ -565,7 +561,7 @@ def get_device_info(driver: Driver, node: ZwaveNode) -> DeviceInfo:
|
|||||||
|
|
||||||
|
|
||||||
def get_network_identifier_for_notification(
|
def get_network_identifier_for_notification(
|
||||||
hass: HomeAssistant, config_entry: ConfigEntry, controller: Controller
|
hass: HomeAssistant, config_entry: ZwaveJSConfigEntry, controller: Controller
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Return the network identifier string for persistent notifications."""
|
"""Return the network identifier string for persistent notifications."""
|
||||||
home_id = str(controller.home_id)
|
home_id = str(controller.home_id)
|
||||||
|
@ -5,7 +5,6 @@ from __future__ import annotations
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
|
||||||
from zwave_js_server.const import CommandClass
|
from zwave_js_server.const import CommandClass
|
||||||
from zwave_js_server.const.command_class.humidity_control import (
|
from zwave_js_server.const.command_class.humidity_control import (
|
||||||
HUMIDITY_CONTROL_SETPOINT_PROPERTY,
|
HUMIDITY_CONTROL_SETPOINT_PROPERTY,
|
||||||
@ -23,14 +22,14 @@ from homeassistant.components.humidifier import (
|
|||||||
HumidifierEntity,
|
HumidifierEntity,
|
||||||
HumidifierEntityDescription,
|
HumidifierEntityDescription,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import DATA_CLIENT, DOMAIN
|
from .const import DOMAIN
|
||||||
from .discovery import ZwaveDiscoveryInfo
|
from .discovery import ZwaveDiscoveryInfo
|
||||||
from .entity import ZWaveBaseEntity
|
from .entity import ZWaveBaseEntity
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
@ -69,11 +68,11 @@ DEHUMIDIFIER_ENTITY_DESCRIPTION = ZwaveHumidifierEntityDescription(
|
|||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Z-Wave humidifier from config entry."""
|
"""Set up Z-Wave humidifier from config entry."""
|
||||||
client: ZwaveClient = config_entry.runtime_data[DATA_CLIENT]
|
client = config_entry.runtime_data.client
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_add_humidifier(info: ZwaveDiscoveryInfo) -> None:
|
def async_add_humidifier(info: ZwaveDiscoveryInfo) -> None:
|
||||||
@ -122,7 +121,7 @@ class ZWaveHumidifier(ZWaveBaseEntity, HumidifierEntity):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
info: ZwaveDiscoveryInfo,
|
info: ZwaveDiscoveryInfo,
|
||||||
description: ZwaveHumidifierEntityDescription,
|
description: ZwaveHumidifierEntityDescription,
|
||||||
|
@ -4,7 +4,6 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import TYPE_CHECKING, Any, cast
|
from typing import TYPE_CHECKING, Any, cast
|
||||||
|
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
|
||||||
from zwave_js_server.const import (
|
from zwave_js_server.const import (
|
||||||
TARGET_VALUE_PROPERTY,
|
TARGET_VALUE_PROPERTY,
|
||||||
TRANSITION_DURATION_OPTION,
|
TRANSITION_DURATION_OPTION,
|
||||||
@ -38,15 +37,15 @@ from homeassistant.components.light import (
|
|||||||
LightEntity,
|
LightEntity,
|
||||||
LightEntityFeature,
|
LightEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
from homeassistant.util import color as color_util
|
from homeassistant.util import color as color_util
|
||||||
|
|
||||||
from .const import DATA_CLIENT, DOMAIN
|
from .const import DOMAIN
|
||||||
from .discovery import ZwaveDiscoveryInfo
|
from .discovery import ZwaveDiscoveryInfo
|
||||||
from .entity import ZWaveBaseEntity
|
from .entity import ZWaveBaseEntity
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
@ -66,11 +65,11 @@ MAX_MIREDS = 370 # 2700K as a safe default
|
|||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Z-Wave Light from Config Entry."""
|
"""Set up Z-Wave Light from Config Entry."""
|
||||||
client: ZwaveClient = config_entry.runtime_data[DATA_CLIENT]
|
client = config_entry.runtime_data.client
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_add_light(info: ZwaveDiscoveryInfo) -> None:
|
def async_add_light(info: ZwaveDiscoveryInfo) -> None:
|
||||||
@ -109,7 +108,7 @@ class ZwaveLight(ZWaveBaseEntity, LightEntity):
|
|||||||
_attr_max_color_temp_kelvin = 6500 # 153 mireds as a safe default
|
_attr_max_color_temp_kelvin = 6500 # 153 mireds as a safe default
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the light."""
|
"""Initialize the light."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
@ -539,7 +538,7 @@ class ZwaveColorOnOffLight(ZwaveLight):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the light."""
|
"""Initialize the light."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
|
@ -5,7 +5,6 @@ from __future__ import annotations
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
|
||||||
from zwave_js_server.const import CommandClass
|
from zwave_js_server.const import CommandClass
|
||||||
from zwave_js_server.const.command_class.lock import (
|
from zwave_js_server.const.command_class.lock import (
|
||||||
ATTR_CODE_SLOT,
|
ATTR_CODE_SLOT,
|
||||||
@ -20,7 +19,6 @@ from zwave_js_server.exceptions import BaseZwaveJSServerError
|
|||||||
from zwave_js_server.util.lock import clear_usercode, set_configuration, set_usercode
|
from zwave_js_server.util.lock import clear_usercode, set_configuration, set_usercode
|
||||||
|
|
||||||
from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN, LockEntity, LockState
|
from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN, LockEntity, LockState
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import config_validation as cv, entity_platform
|
from homeassistant.helpers import config_validation as cv, entity_platform
|
||||||
@ -34,7 +32,6 @@ from .const import (
|
|||||||
ATTR_LOCK_TIMEOUT,
|
ATTR_LOCK_TIMEOUT,
|
||||||
ATTR_OPERATION_TYPE,
|
ATTR_OPERATION_TYPE,
|
||||||
ATTR_TWIST_ASSIST,
|
ATTR_TWIST_ASSIST,
|
||||||
DATA_CLIENT,
|
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
LOGGER,
|
LOGGER,
|
||||||
SERVICE_CLEAR_LOCK_USERCODE,
|
SERVICE_CLEAR_LOCK_USERCODE,
|
||||||
@ -43,6 +40,7 @@ from .const import (
|
|||||||
)
|
)
|
||||||
from .discovery import ZwaveDiscoveryInfo
|
from .discovery import ZwaveDiscoveryInfo
|
||||||
from .entity import ZWaveBaseEntity
|
from .entity import ZWaveBaseEntity
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
@ -61,11 +59,11 @@ UNIT16_SCHEMA = vol.All(vol.Coerce(int), vol.Range(min=0, max=65535))
|
|||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Z-Wave lock from config entry."""
|
"""Set up Z-Wave lock from config entry."""
|
||||||
client: ZwaveClient = config_entry.runtime_data[DATA_CLIENT]
|
client = config_entry.runtime_data.client
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_add_lock(info: ZwaveDiscoveryInfo) -> None:
|
def async_add_lock(info: ZwaveDiscoveryInfo) -> None:
|
||||||
|
27
homeassistant/components/zwave_js/models.py
Normal file
27
homeassistant/components/zwave_js/models.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
"""Type definitions for Z-Wave JS integration."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
from zwave_js_server.const import LogLevel
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from zwave_js_server.client import Client as ZwaveClient
|
||||||
|
|
||||||
|
from . import DriverEvents
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class ZwaveJSData:
|
||||||
|
"""Data for zwave_js runtime data."""
|
||||||
|
|
||||||
|
client: ZwaveClient
|
||||||
|
driver_events: DriverEvents
|
||||||
|
old_server_log_level: LogLevel | None = None
|
||||||
|
|
||||||
|
|
||||||
|
type ZwaveJSConfigEntry = ConfigEntry[ZwaveJSData]
|
@ -5,33 +5,32 @@ from __future__ import annotations
|
|||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
|
||||||
from zwave_js_server.const import TARGET_VALUE_PROPERTY
|
from zwave_js_server.const import TARGET_VALUE_PROPERTY
|
||||||
from zwave_js_server.model.driver import Driver
|
from zwave_js_server.model.driver import Driver
|
||||||
from zwave_js_server.model.value import Value
|
from zwave_js_server.model.value import Value
|
||||||
|
|
||||||
from homeassistant.components.number import DOMAIN as NUMBER_DOMAIN, NumberEntity
|
from homeassistant.components.number import DOMAIN as NUMBER_DOMAIN, NumberEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import EntityCategory
|
from homeassistant.const import EntityCategory
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import ATTR_RESERVED_VALUES, DATA_CLIENT, DOMAIN
|
from .const import ATTR_RESERVED_VALUES, DOMAIN
|
||||||
from .discovery import ZwaveDiscoveryInfo
|
from .discovery import ZwaveDiscoveryInfo
|
||||||
from .entity import ZWaveBaseEntity
|
from .entity import ZWaveBaseEntity
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Z-Wave Number entity from Config Entry."""
|
"""Set up Z-Wave Number entity from Config Entry."""
|
||||||
client: ZwaveClient = config_entry.runtime_data[DATA_CLIENT]
|
client = config_entry.runtime_data.client
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_add_number(info: ZwaveDiscoveryInfo) -> None:
|
def async_add_number(info: ZwaveDiscoveryInfo) -> None:
|
||||||
@ -62,7 +61,7 @@ class ZwaveNumberEntity(ZWaveBaseEntity, NumberEntity):
|
|||||||
"""Representation of a Z-Wave number entity."""
|
"""Representation of a Z-Wave number entity."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize a ZwaveNumberEntity entity."""
|
"""Initialize a ZwaveNumberEntity entity."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
@ -114,7 +113,7 @@ class ZWaveConfigParameterNumberEntity(ZwaveNumberEntity):
|
|||||||
_attr_entity_category = EntityCategory.CONFIG
|
_attr_entity_category = EntityCategory.CONFIG
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize a ZWaveConfigParameterNumber entity."""
|
"""Initialize a ZWaveConfigParameterNumber entity."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
@ -142,7 +141,7 @@ class ZwaveVolumeNumberEntity(ZWaveBaseEntity, NumberEntity):
|
|||||||
"""Representation of a volume number entity."""
|
"""Representation of a volume number entity."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize a ZwaveVolumeNumberEntity entity."""
|
"""Initialize a ZwaveVolumeNumberEntity entity."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
|
@ -4,33 +4,32 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import cast
|
from typing import cast
|
||||||
|
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
|
||||||
from zwave_js_server.const import TARGET_VALUE_PROPERTY, CommandClass
|
from zwave_js_server.const import TARGET_VALUE_PROPERTY, CommandClass
|
||||||
from zwave_js_server.const.command_class.lock import TARGET_MODE_PROPERTY
|
from zwave_js_server.const.command_class.lock import TARGET_MODE_PROPERTY
|
||||||
from zwave_js_server.const.command_class.sound_switch import TONE_ID_PROPERTY, ToneID
|
from zwave_js_server.const.command_class.sound_switch import TONE_ID_PROPERTY, ToneID
|
||||||
from zwave_js_server.model.driver import Driver
|
from zwave_js_server.model.driver import Driver
|
||||||
|
|
||||||
from homeassistant.components.select import DOMAIN as SELECT_DOMAIN, SelectEntity
|
from homeassistant.components.select import DOMAIN as SELECT_DOMAIN, SelectEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import EntityCategory
|
from homeassistant.const import EntityCategory
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import DATA_CLIENT, DOMAIN
|
from .const import DOMAIN
|
||||||
from .discovery import ZwaveDiscoveryInfo
|
from .discovery import ZwaveDiscoveryInfo
|
||||||
from .entity import ZWaveBaseEntity
|
from .entity import ZWaveBaseEntity
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Z-Wave Select entity from Config Entry."""
|
"""Set up Z-Wave Select entity from Config Entry."""
|
||||||
client: ZwaveClient = config_entry.runtime_data[DATA_CLIENT]
|
client = config_entry.runtime_data.client
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_add_select(info: ZwaveDiscoveryInfo) -> None:
|
def async_add_select(info: ZwaveDiscoveryInfo) -> None:
|
||||||
@ -69,7 +68,7 @@ class ZwaveSelectEntity(ZWaveBaseEntity, SelectEntity):
|
|||||||
_attr_entity_category = EntityCategory.CONFIG
|
_attr_entity_category = EntityCategory.CONFIG
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize a ZwaveSelectEntity entity."""
|
"""Initialize a ZwaveSelectEntity entity."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
@ -103,7 +102,7 @@ class ZWaveDoorLockSelectEntity(ZwaveSelectEntity):
|
|||||||
"""Representation of a Z-Wave door lock CC mode select entity."""
|
"""Representation of a Z-Wave door lock CC mode select entity."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize a ZWaveDoorLockSelectEntity entity."""
|
"""Initialize a ZWaveDoorLockSelectEntity entity."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
@ -126,7 +125,7 @@ class ZWaveConfigParameterSelectEntity(ZwaveSelectEntity):
|
|||||||
_attr_entity_category = EntityCategory.CONFIG
|
_attr_entity_category = EntityCategory.CONFIG
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize a ZWaveConfigParameterSelect entity."""
|
"""Initialize a ZWaveConfigParameterSelect entity."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
@ -145,7 +144,7 @@ class ZwaveDefaultToneSelectEntity(ZWaveBaseEntity, SelectEntity):
|
|||||||
_attr_entity_category = EntityCategory.CONFIG
|
_attr_entity_category = EntityCategory.CONFIG
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize a ZwaveDefaultToneSelectEntity entity."""
|
"""Initialize a ZwaveDefaultToneSelectEntity entity."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
@ -194,7 +193,7 @@ class ZwaveMultilevelSwitchSelectEntity(ZWaveBaseEntity, SelectEntity):
|
|||||||
"""Representation of a Z-Wave Multilevel Switch CC select entity."""
|
"""Representation of a Z-Wave Multilevel Switch CC select entity."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize a ZwaveSelectEntity entity."""
|
"""Initialize a ZwaveSelectEntity entity."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
|
@ -7,7 +7,6 @@ from dataclasses import dataclass
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
|
||||||
from zwave_js_server.const import CommandClass
|
from zwave_js_server.const import CommandClass
|
||||||
from zwave_js_server.const.command_class.meter import (
|
from zwave_js_server.const.command_class.meter import (
|
||||||
RESET_METER_OPTION_TARGET_VALUE,
|
RESET_METER_OPTION_TARGET_VALUE,
|
||||||
@ -28,7 +27,6 @@ from homeassistant.components.sensor import (
|
|||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONCENTRATION_PARTS_PER_MILLION,
|
CONCENTRATION_PARTS_PER_MILLION,
|
||||||
LIGHT_LUX,
|
LIGHT_LUX,
|
||||||
@ -56,7 +54,6 @@ from .const import (
|
|||||||
ATTR_METER_TYPE,
|
ATTR_METER_TYPE,
|
||||||
ATTR_METER_TYPE_NAME,
|
ATTR_METER_TYPE_NAME,
|
||||||
ATTR_VALUE,
|
ATTR_VALUE,
|
||||||
DATA_CLIENT,
|
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
ENTITY_DESC_KEY_BATTERY_LEVEL,
|
ENTITY_DESC_KEY_BATTERY_LEVEL,
|
||||||
ENTITY_DESC_KEY_BATTERY_LIST_STATE,
|
ENTITY_DESC_KEY_BATTERY_LIST_STATE,
|
||||||
@ -94,6 +91,7 @@ from .discovery_data_template import (
|
|||||||
from .entity import ZWaveBaseEntity
|
from .entity import ZWaveBaseEntity
|
||||||
from .helpers import get_device_info, get_valueless_base_unique_id
|
from .helpers import get_device_info, get_valueless_base_unique_id
|
||||||
from .migrate import async_migrate_statistics_sensors
|
from .migrate import async_migrate_statistics_sensors
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
@ -576,11 +574,11 @@ def get_entity_description(
|
|||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Z-Wave sensor from config entry."""
|
"""Set up Z-Wave sensor from config entry."""
|
||||||
client: ZwaveClient = config_entry.runtime_data[DATA_CLIENT]
|
client = config_entry.runtime_data.client
|
||||||
driver = client.driver
|
driver = client.driver
|
||||||
assert driver is not None # Driver is ready before platforms are loaded.
|
assert driver is not None # Driver is ready before platforms are loaded.
|
||||||
|
|
||||||
@ -717,7 +715,7 @@ class ZwaveSensor(ZWaveBaseEntity, SensorEntity):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
info: ZwaveDiscoveryInfo,
|
info: ZwaveDiscoveryInfo,
|
||||||
entity_description: SensorEntityDescription,
|
entity_description: SensorEntityDescription,
|
||||||
@ -756,7 +754,7 @@ class ZWaveNumericSensor(ZwaveSensor):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
info: ZwaveDiscoveryInfo,
|
info: ZwaveDiscoveryInfo,
|
||||||
entity_description: SensorEntityDescription,
|
entity_description: SensorEntityDescription,
|
||||||
@ -831,7 +829,7 @@ class ZWaveListSensor(ZwaveSensor):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
info: ZwaveDiscoveryInfo,
|
info: ZwaveDiscoveryInfo,
|
||||||
entity_description: SensorEntityDescription,
|
entity_description: SensorEntityDescription,
|
||||||
@ -870,7 +868,7 @@ class ZWaveConfigParameterSensor(ZWaveListSensor):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
info: ZwaveDiscoveryInfo,
|
info: ZwaveDiscoveryInfo,
|
||||||
entity_description: SensorEntityDescription,
|
entity_description: SensorEntityDescription,
|
||||||
@ -906,7 +904,7 @@ class ZWaveNodeStatusSensor(SensorEntity):
|
|||||||
_attr_translation_key = "node_status"
|
_attr_translation_key = "node_status"
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, node: ZwaveNode
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, node: ZwaveNode
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize a generic Z-Wave device entity."""
|
"""Initialize a generic Z-Wave device entity."""
|
||||||
self.config_entry = config_entry
|
self.config_entry = config_entry
|
||||||
@ -968,7 +966,7 @@ class ZWaveControllerStatusSensor(SensorEntity):
|
|||||||
_attr_has_entity_name = True
|
_attr_has_entity_name = True
|
||||||
_attr_translation_key = "controller_status"
|
_attr_translation_key = "controller_status"
|
||||||
|
|
||||||
def __init__(self, config_entry: ConfigEntry, driver: Driver) -> None:
|
def __init__(self, config_entry: ZwaveJSConfigEntry, driver: Driver) -> None:
|
||||||
"""Initialize a generic Z-Wave device entity."""
|
"""Initialize a generic Z-Wave device entity."""
|
||||||
self.config_entry = config_entry
|
self.config_entry = config_entry
|
||||||
self.controller = driver.controller
|
self.controller = driver.controller
|
||||||
@ -1030,7 +1028,7 @@ class ZWaveStatisticsSensor(SensorEntity):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
statistics_src: ZwaveNode | Controller,
|
statistics_src: ZwaveNode | Controller,
|
||||||
description: ZWaveJSStatisticsSensorEntityDescription,
|
description: ZWaveJSStatisticsSensorEntityDescription,
|
||||||
|
@ -704,7 +704,7 @@ class ZWaveServices:
|
|||||||
client = first_node.client
|
client = first_node.client
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
data = self._hass.config_entries.async_entries(const.DOMAIN)[0].runtime_data
|
data = self._hass.config_entries.async_entries(const.DOMAIN)[0].runtime_data
|
||||||
client = data[const.DATA_CLIENT]
|
client = data.client
|
||||||
assert client.driver
|
assert client.driver
|
||||||
first_node = next(
|
first_node = next(
|
||||||
node
|
node
|
||||||
|
@ -4,7 +4,6 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
|
||||||
from zwave_js_server.const.command_class.sound_switch import ToneID
|
from zwave_js_server.const.command_class.sound_switch import ToneID
|
||||||
from zwave_js_server.model.driver import Driver
|
from zwave_js_server.model.driver import Driver
|
||||||
|
|
||||||
@ -15,25 +14,25 @@ from homeassistant.components.siren import (
|
|||||||
SirenEntity,
|
SirenEntity,
|
||||||
SirenEntityFeature,
|
SirenEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import DATA_CLIENT, DOMAIN
|
from .const import DOMAIN
|
||||||
from .discovery import ZwaveDiscoveryInfo
|
from .discovery import ZwaveDiscoveryInfo
|
||||||
from .entity import ZWaveBaseEntity
|
from .entity import ZWaveBaseEntity
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Z-Wave Siren entity from Config Entry."""
|
"""Set up Z-Wave Siren entity from Config Entry."""
|
||||||
client: ZwaveClient = config_entry.runtime_data[DATA_CLIENT]
|
client = config_entry.runtime_data.client
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_add_siren(info: ZwaveDiscoveryInfo) -> None:
|
def async_add_siren(info: ZwaveDiscoveryInfo) -> None:
|
||||||
@ -57,7 +56,7 @@ class ZwaveSirenEntity(ZWaveBaseEntity, SirenEntity):
|
|||||||
"""Representation of a Z-Wave siren entity."""
|
"""Representation of a Z-Wave siren entity."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize a ZwaveSirenEntity entity."""
|
"""Initialize a ZwaveSirenEntity entity."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
|
@ -4,7 +4,6 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
|
||||||
from zwave_js_server.const import TARGET_VALUE_PROPERTY
|
from zwave_js_server.const import TARGET_VALUE_PROPERTY
|
||||||
from zwave_js_server.const.command_class.barrier_operator import (
|
from zwave_js_server.const.command_class.barrier_operator import (
|
||||||
BarrierEventSignalingSubsystemState,
|
BarrierEventSignalingSubsystemState,
|
||||||
@ -12,26 +11,26 @@ from zwave_js_server.const.command_class.barrier_operator import (
|
|||||||
from zwave_js_server.model.driver import Driver
|
from zwave_js_server.model.driver import Driver
|
||||||
|
|
||||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN, SwitchEntity
|
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN, SwitchEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import EntityCategory
|
from homeassistant.const import EntityCategory
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import DATA_CLIENT, DOMAIN
|
from .const import DOMAIN
|
||||||
from .discovery import ZwaveDiscoveryInfo
|
from .discovery import ZwaveDiscoveryInfo
|
||||||
from .entity import ZWaveBaseEntity
|
from .entity import ZWaveBaseEntity
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Z-Wave sensor from config entry."""
|
"""Set up Z-Wave sensor from config entry."""
|
||||||
client: ZwaveClient = config_entry.runtime_data[DATA_CLIENT]
|
client = config_entry.runtime_data.client
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_add_switch(info: ZwaveDiscoveryInfo) -> None:
|
def async_add_switch(info: ZwaveDiscoveryInfo) -> None:
|
||||||
@ -65,7 +64,7 @@ class ZWaveSwitch(ZWaveBaseEntity, SwitchEntity):
|
|||||||
"""Representation of a Z-Wave switch."""
|
"""Representation of a Z-Wave switch."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the switch."""
|
"""Initialize the switch."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
@ -95,7 +94,7 @@ class ZWaveIndicatorSwitch(ZWaveSwitch):
|
|||||||
"""Representation of a Z-Wave Indicator CC switch."""
|
"""Representation of a Z-Wave Indicator CC switch."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the switch."""
|
"""Initialize the switch."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
@ -108,7 +107,7 @@ class ZWaveBarrierEventSignalingSwitch(ZWaveBaseEntity, SwitchEntity):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
driver: Driver,
|
driver: Driver,
|
||||||
info: ZwaveDiscoveryInfo,
|
info: ZwaveDiscoveryInfo,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -164,7 +163,7 @@ class ZWaveConfigParameterSwitch(ZWaveSwitch):
|
|||||||
_attr_entity_category = EntityCategory.CONFIG
|
_attr_entity_category = EntityCategory.CONFIG
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize a ZWaveConfigParameterSwitch entity."""
|
"""Initialize a ZWaveConfigParameterSwitch entity."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
|
@ -7,7 +7,6 @@ import functools
|
|||||||
|
|
||||||
from pydantic.v1 import ValidationError
|
from pydantic.v1 import ValidationError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from zwave_js_server.client import Client
|
|
||||||
from zwave_js_server.model.controller import CONTROLLER_EVENT_MODEL_MAP
|
from zwave_js_server.model.controller import CONTROLLER_EVENT_MODEL_MAP
|
||||||
from zwave_js_server.model.driver import DRIVER_EVENT_MODEL_MAP, Driver
|
from zwave_js_server.model.driver import DRIVER_EVENT_MODEL_MAP, Driver
|
||||||
from zwave_js_server.model.node import NODE_EVENT_MODEL_MAP
|
from zwave_js_server.model.node import NODE_EVENT_MODEL_MAP
|
||||||
@ -26,7 +25,6 @@ from ..const import (
|
|||||||
ATTR_EVENT_SOURCE,
|
ATTR_EVENT_SOURCE,
|
||||||
ATTR_NODE_ID,
|
ATTR_NODE_ID,
|
||||||
ATTR_PARTIAL_DICT_MATCH,
|
ATTR_PARTIAL_DICT_MATCH,
|
||||||
DATA_CLIENT,
|
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
)
|
)
|
||||||
from ..helpers import (
|
from ..helpers import (
|
||||||
@ -219,7 +217,7 @@ async def async_attach_trigger(
|
|||||||
entry_id = config[ATTR_CONFIG_ENTRY_ID]
|
entry_id = config[ATTR_CONFIG_ENTRY_ID]
|
||||||
entry = hass.config_entries.async_get_entry(entry_id)
|
entry = hass.config_entries.async_get_entry(entry_id)
|
||||||
assert entry
|
assert entry
|
||||||
client: Client = entry.runtime_data[DATA_CLIENT]
|
client = entry.runtime_data.client
|
||||||
driver = client.driver
|
driver = client.driver
|
||||||
assert driver
|
assert driver
|
||||||
drivers.add(driver)
|
drivers.add(driver)
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
"""Helpers for Z-Wave JS custom triggers."""
|
"""Helpers for Z-Wave JS custom triggers."""
|
||||||
|
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntryState
|
from homeassistant.config_entries import ConfigEntryState
|
||||||
from homeassistant.const import ATTR_DEVICE_ID, ATTR_ENTITY_ID
|
from homeassistant.const import ATTR_DEVICE_ID, ATTR_ENTITY_ID
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from ..const import ATTR_CONFIG_ENTRY_ID, DATA_CLIENT, DOMAIN
|
from ..const import ATTR_CONFIG_ENTRY_ID, DOMAIN
|
||||||
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
@ -37,7 +35,7 @@ def async_bypass_dynamic_config_validation(
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
# The driver may not be ready when the config entry is loaded.
|
# The driver may not be ready when the config entry is loaded.
|
||||||
client: ZwaveClient = entry.runtime_data[DATA_CLIENT]
|
client = entry.runtime_data.client
|
||||||
if client.driver is None:
|
if client.driver is None:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ from datetime import datetime, timedelta
|
|||||||
from typing import Any, Final
|
from typing import Any, Final
|
||||||
|
|
||||||
from awesomeversion import AwesomeVersion
|
from awesomeversion import AwesomeVersion
|
||||||
from zwave_js_server.client import Client as ZwaveClient
|
|
||||||
from zwave_js_server.const import NodeStatus
|
from zwave_js_server.const import NodeStatus
|
||||||
from zwave_js_server.exceptions import BaseZwaveJSServerError, FailedZWaveCommand
|
from zwave_js_server.exceptions import BaseZwaveJSServerError, FailedZWaveCommand
|
||||||
from zwave_js_server.model.driver import Driver
|
from zwave_js_server.model.driver import Driver
|
||||||
@ -27,7 +26,6 @@ from homeassistant.components.update import (
|
|||||||
UpdateEntity,
|
UpdateEntity,
|
||||||
UpdateEntityFeature,
|
UpdateEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import EntityCategory
|
from homeassistant.const import EntityCategory
|
||||||
from homeassistant.core import CoreState, HomeAssistant, callback
|
from homeassistant.core import CoreState, HomeAssistant, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
@ -36,8 +34,9 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
|||||||
from homeassistant.helpers.event import async_call_later
|
from homeassistant.helpers.event import async_call_later
|
||||||
from homeassistant.helpers.restore_state import ExtraStoredData
|
from homeassistant.helpers.restore_state import ExtraStoredData
|
||||||
|
|
||||||
from .const import API_KEY_FIRMWARE_UPDATE_SERVICE, DATA_CLIENT, DOMAIN, LOGGER
|
from .const import API_KEY_FIRMWARE_UPDATE_SERVICE, DOMAIN, LOGGER
|
||||||
from .helpers import get_device_info, get_valueless_base_unique_id
|
from .helpers import get_device_info, get_valueless_base_unique_id
|
||||||
|
from .models import ZwaveJSConfigEntry
|
||||||
|
|
||||||
PARALLEL_UPDATES = 1
|
PARALLEL_UPDATES = 1
|
||||||
|
|
||||||
@ -76,11 +75,11 @@ class ZWaveNodeFirmwareUpdateExtraStoredData(ExtraStoredData):
|
|||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ZwaveJSConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Z-Wave update entity from config entry."""
|
"""Set up Z-Wave update entity from config entry."""
|
||||||
client: ZwaveClient = config_entry.runtime_data[DATA_CLIENT]
|
client = config_entry.runtime_data.client
|
||||||
cnt: Counter = Counter()
|
cnt: Counter = Counter()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
Loading…
x
Reference in New Issue
Block a user