mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Cache shelly coordinator properties that never change (#124756)
This commit is contained in:
parent
4108b7ada6
commit
a63c5e6725
@ -6,6 +6,7 @@ import asyncio
|
||||
from collections.abc import Callable, Coroutine
|
||||
from dataclasses import dataclass
|
||||
from datetime import timedelta
|
||||
from functools import cached_property
|
||||
from typing import Any, cast
|
||||
|
||||
from aioshelly.ble import async_ensure_ble_enabled, async_stop_scanner
|
||||
@ -120,12 +121,12 @@ class ShellyCoordinatorBase[_DeviceT: BlockDevice | RpcDevice](
|
||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self._handle_ha_stop)
|
||||
)
|
||||
|
||||
@property
|
||||
@cached_property
|
||||
def model(self) -> str:
|
||||
"""Model of the device."""
|
||||
return cast(str, self.entry.data["model"])
|
||||
|
||||
@property
|
||||
@cached_property
|
||||
def mac(self) -> str:
|
||||
"""Mac address of the device."""
|
||||
return cast(str, self.entry.unique_id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user