"""A Capability binds one OCF resource href to the entities it produces.""" from __future__ import annotations from dataclasses import dataclass from typing import Callable, Optional from .entities import SamsungEntityDescription @dataclass(frozen=True, kw_only=True) class Capability: href: Optional[str] = None entities: tuple[SamsungEntityDescription, ...] = () poll_tier: str = 'warm' # 'hot' | 'warm' | 'cold' rt_filter: Optional[str] = None # bind only if rt_filter in rep.get('rt', ()) match_fn: Optional[Callable[[dict, dict], bool]] = None # match_fn(rep, resources) -> bool key_fn: Optional[Callable[[str], str]] = None # href -> entity key (pattern caps) # Rare optional hooks — only operational-state-style resources use these. active_when: Optional[Callable[[dict], bool]] = None on_observation: Optional[Callable[[dict, dict], None]] = None project: Optional[Callable[[dict, dict], dict]] = None