Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e07d6ed706 | ||
|
|
cf18cc3ecc | ||
|
|
61e6035a36 | ||
|
|
7b155aabc2 | ||
|
|
788b8f98a1 | ||
|
|
83bd158049 | ||
|
|
42a80fffe6 | ||
|
|
b121d24966 | ||
|
|
615c5d5aa9 |
No files matched your search
@@ -17,6 +17,7 @@ Your state stays on your LAN: HA talks to the appliance over a direct DTLS sessi
|
|||||||
| Type | Registry |
|
| Type | Registry |
|
||||||
|---|---|
|
|---|---|
|
||||||
| Air conditioner | `by_type/airconditioner.py` |
|
| Air conditioner | `by_type/airconditioner.py` |
|
||||||
|
| Air purifier | `by_type/air_purifier.py` |
|
||||||
| Dryer | `by_type/dryer.py` |
|
| Dryer | `by_type/dryer.py` |
|
||||||
| Oven | `by_type/oven.py` |
|
| Oven | `by_type/oven.py` |
|
||||||
| Cooktop (read-only burner status) | `by_type/cooktop.py` |
|
| Cooktop (read-only burner status) | `by_type/cooktop.py` |
|
||||||
|
|||||||
@@ -13,9 +13,10 @@ snapshot via `coordinator.resource(href)` -- the same cross-resource read that
|
|||||||
|
|
||||||
Writes go through `coordinator.async_send_command(bound, (kind, value))`: the
|
Writes go through `coordinator.async_send_command(bound, (kind, value))`: the
|
||||||
CLIMATE capability's `write_fn` maps each `(kind, value)` payload to the right
|
CLIMATE capability's `write_fn` maps each `(kind, value)` payload to the right
|
||||||
`(path_segs, body)`, and `async_send_command` POSTs to those path_segs (the
|
`(path_segs, body)`, and `async_send_command` POSTs to those path_segs and
|
||||||
bound href is only used for logging), so one descriptor drives writes to power,
|
applies the optimistic value/settle guard to that same href -- not the bound
|
||||||
mode, temperature and wind resources.
|
`/mode/vs/0` href -- so one descriptor drives writes to, and gets fresh state
|
||||||
|
back for, power, mode, temperature and wind resources alike.
|
||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|||||||
@@ -547,6 +547,22 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
return
|
return
|
||||||
path_segs, body = result
|
path_segs, body = result
|
||||||
|
|
||||||
|
# The write's actual target, not necessarily bound_entity.href. Most
|
||||||
|
# descriptors write to the same resource they're bound to, but a
|
||||||
|
# composite entity -- the AC's ClimateDesc, bound to /mode/vs/0 --
|
||||||
|
# drives writes to several sibling resources via path_segs
|
||||||
|
# (/power/0, /temperature/desired/0, /wind/strength/vs/0, ...) that
|
||||||
|
# write_fn picks per payload (see airconditioner._climate_write).
|
||||||
|
# Applying the optimistic value and settle guard below to
|
||||||
|
# bound_entity.href instead of this target protected the wrong
|
||||||
|
# resource: /mode/vs/0 got the (nonsensical, wrong-shaped) optimistic
|
||||||
|
# merge while the resource the climate entity actually displays from
|
||||||
|
# (e.g. /power/0) never got one, so HA kept showing the pre-write
|
||||||
|
# state until the next real read of that resource -- the 20-60s lag
|
||||||
|
# in issues #17/#53, which survived the earlier optimistic-apply fix
|
||||||
|
# (issue #27) because that fix applied to the wrong href too.
|
||||||
|
write_href = '/' + '/'.join(path_segs)
|
||||||
|
|
||||||
# Apply the write optimistically before starting the settle guard,
|
# Apply the write optimistically before starting the settle guard,
|
||||||
# not after -- mark_write_pending gates every source (poll, sweep,
|
# not after -- mark_write_pending gates every source (poll, sweep,
|
||||||
# observe) through the same apply(), itself included, so flipping
|
# observe) through the same apply(), itself included, so flipping
|
||||||
@@ -555,19 +571,19 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
# onto, the settle window was just delaying the real device
|
# onto, the settle window was just delaying the real device
|
||||||
# confirmation for a few seconds on every write, which read exactly
|
# confirmation for a few seconds on every write, which read exactly
|
||||||
# like the write being silently reverted (issue #27).
|
# like the write being silently reverted (issue #27).
|
||||||
self._observe.apply(href, body, source='optimistic')
|
self._observe.apply(write_href, body, source='optimistic')
|
||||||
self._observe.mark_write_pending(href)
|
self._observe.mark_write_pending(write_href)
|
||||||
|
|
||||||
def _do_put():
|
def _do_put():
|
||||||
sess = self._session
|
sess = self._session
|
||||||
if sess is None:
|
if sess is None:
|
||||||
raise RuntimeError("no session")
|
raise RuntimeError("no session")
|
||||||
code, _ = sess.post(path_segs, cbor2.dumps(body), timeout=8.0)
|
code, _ = sess.post(path_segs, cbor2.dumps(body), timeout=8.0)
|
||||||
self._log.info("PUT %s → code %#04x", href, code)
|
self._log.info("PUT %s → code %#04x", write_href, code)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.hass.async_add_executor_job(_do_put)
|
await self.hass.async_add_executor_job(_do_put)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._log.error("command failed for %s: %s", href, e)
|
self._log.error("command failed for %s: %s", write_href, e)
|
||||||
else:
|
else:
|
||||||
await self.async_request_refresh()
|
await self.async_request_refresh()
|
||||||
@@ -3,8 +3,8 @@ from typing import Optional
|
|||||||
|
|
||||||
from ._base import DeviceRegistry
|
from ._base import DeviceRegistry
|
||||||
from . import (
|
from . import (
|
||||||
airconditioner, cooktop, dishwasher, dryer, oven, range as _range,
|
air_purifier, airconditioner, cooktop, dishwasher, dryer, oven,
|
||||||
range_hood, refrigerator, washer,
|
range as _range, range_hood, refrigerator, washer,
|
||||||
)
|
)
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
@@ -14,6 +14,8 @@ __all__ = [
|
|||||||
|
|
||||||
|
|
||||||
_REGISTRY_BY_KEY: dict[str, DeviceRegistry] = {
|
_REGISTRY_BY_KEY: dict[str, DeviceRegistry] = {
|
||||||
|
'air_purifier': air_purifier.REGISTRY,
|
||||||
|
'airpurifier': air_purifier.REGISTRY,
|
||||||
'airconditioner': airconditioner.REGISTRY,
|
'airconditioner': airconditioner.REGISTRY,
|
||||||
'air_conditioner': airconditioner.REGISTRY,
|
'air_conditioner': airconditioner.REGISTRY,
|
||||||
'cooktop': cooktop.REGISTRY,
|
'cooktop': cooktop.REGISTRY,
|
||||||
@@ -111,6 +113,10 @@ def for_device_by_model(model_num: str, description: str) -> Optional[DeviceRegi
|
|||||||
# 'P' sits between the underscore and 'RAC' in that token).
|
# 'P' sits between the underscore and 'RAC' in that token).
|
||||||
if key is None and '_RAC_' in (model_num or ''):
|
if key is None and '_RAC_' in (model_num or ''):
|
||||||
key = 'airconditioner'
|
key = 'airconditioner'
|
||||||
|
# Air purifiers (e.g. ARTIK051_TVTL_18K, issue #56) report no
|
||||||
|
# oneUiVersion either, and carry the '_TVTL_' board-family token.
|
||||||
|
if key is None and '_TVTL_' in (model_num or ''):
|
||||||
|
key = 'air_purifier'
|
||||||
model_identity = f'{model_num} {description}'.upper()
|
model_identity = f'{model_num} {description}'.upper()
|
||||||
if key is None and ('_COOKTOP' in model_identity or '_GB_CT_' in model_identity):
|
if key is None and ('_COOKTOP' in model_identity or '_GB_CT_' in model_identity):
|
||||||
key = 'cooktop'
|
key = 'cooktop'
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
"""Air-purifier device registry (Samsung ARTIK051_TVTL-class, issue #56).
|
||||||
|
|
||||||
|
Reports no oneUiVersion; resolved via for_device_by_model's '_TVTL_' modelNum
|
||||||
|
token (see registry.py). Reuses dishwasher.DIAGNOSIS for /diagnosis/vs/0
|
||||||
|
(identical field/write contract).
|
||||||
|
"""
|
||||||
|
from ..capabilities import air_purifier, common, dishwasher, ignored
|
||||||
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
|
REGISTRY = DeviceRegistry(
|
||||||
|
name='air_purifier',
|
||||||
|
capabilities=_build([
|
||||||
|
*ignored.IGNORED,
|
||||||
|
*common.UNIVERSAL,
|
||||||
|
*common.POWER,
|
||||||
|
dishwasher.DIAGNOSIS,
|
||||||
|
air_purifier.AIR_QUALITY,
|
||||||
|
air_purifier.FILTER,
|
||||||
|
air_purifier.DEVICE_ACTIVE,
|
||||||
|
air_purifier.AIRFLOW_GENERIC,
|
||||||
|
air_purifier.AIRFLOW_VS_FALLBACK,
|
||||||
|
air_purifier.MODE,
|
||||||
|
*air_purifier.COVERAGE,
|
||||||
|
]),
|
||||||
|
)
|
||||||
@@ -26,5 +26,6 @@ REGISTRY = DeviceRegistry(
|
|||||||
dryer.DRYER_SETTINGS,
|
dryer.DRYER_SETTINGS,
|
||||||
dryer.DRYER_COURSE,
|
dryer.DRYER_COURSE,
|
||||||
dryer.DRYER_DIAGNOSIS,
|
dryer.DRYER_DIAGNOSIS,
|
||||||
|
dryer.AUTO_CYCLE_LINK,
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
@@ -15,5 +15,6 @@ REGISTRY = DeviceRegistry(
|
|||||||
common.WATER_METER,
|
common.WATER_METER,
|
||||||
operational.OPERATIONAL_STATE,
|
operational.OPERATIONAL_STATE,
|
||||||
dishwasher.DIAGNOSIS,
|
dishwasher.DIAGNOSIS,
|
||||||
|
washer.CYCLE_INTERFACE_IGNORED,
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
@@ -0,0 +1,164 @@
|
|||||||
|
"""Capabilities for the Samsung ARTIK051_TVTL-class air purifier family
|
||||||
|
(model AX60R5080WD/SE, issue #56 -- verified against two independent
|
||||||
|
diagnostics dumps of the same internal model).
|
||||||
|
|
||||||
|
Power, kids-lock, remote-control, alarms, and the energy meter are the shared
|
||||||
|
common.py capabilities (this family exposes the standard /power/0+/power/vs/0
|
||||||
|
pair and /alarms/vs/0, /energy/consumption/vs/0). /diagnosis/vs/0 reuses
|
||||||
|
dishwasher.DIAGNOSIS -- identical field/write contract
|
||||||
|
(x.com.samsung.da.diagnosisStart, 'Ready' on both dumps).
|
||||||
|
|
||||||
|
Two things are deliberately left as raw, unwritable diagnostic sensors rather
|
||||||
|
than modeled as real controls, per the "don't guess" rule:
|
||||||
|
|
||||||
|
/airflow/0, /airflow/vs/0 -- OCF-standard + vendor pair for fan speed/
|
||||||
|
direction, both zeroed/'Off' on every dump seen (device was off in both).
|
||||||
|
No supportedSpeed/supportedModes list is present anywhere in either dump
|
||||||
|
to confirm the valid range, so a write-capable fan/select isn't safe to
|
||||||
|
build yet -- see the issue #56 request for a running-state dump.
|
||||||
|
|
||||||
|
/mode/vs/0's x.com.samsung.da.options array packs multiple independent
|
||||||
|
'<Prefix>_<value>' flags into one list -- the same packed-list/RMW
|
||||||
|
contract laundry.py's option_value/replace_in_options already model for
|
||||||
|
/course/vs/0's options[] (reused directly below, just against this
|
||||||
|
family's own href). Of the tokens seen:
|
||||||
|
Light_On / Light_Off -- read as a plain on/off flag; MODE below
|
||||||
|
models it as a real switch, RMW-
|
||||||
|
replacing just that one list entry.
|
||||||
|
Comode_Off -- never seen non-'Off' on these dumps;
|
||||||
|
likely the fan operating mode the issue
|
||||||
|
describes (Auto/Sleep/1/2/3), but
|
||||||
|
unconfirmed -- exposed read-only.
|
||||||
|
Blooming_0 / Blooming_6 -- meaning unconfirmed; exposed read-only.
|
||||||
|
OptionCode_60282 -- opaque, unchanged across both dumps;
|
||||||
|
not modeled (same treatment as
|
||||||
|
range_hood's OptionCode_* token on the
|
||||||
|
same href).
|
||||||
|
"""
|
||||||
|
from ..capability import Capability
|
||||||
|
from ..entities import BinarySensorDesc, SensorDesc, SwitchDesc
|
||||||
|
from .common import int_or_none, sensor_item_value
|
||||||
|
from .laundry import bool_option_exists, bool_option_value, option_value, replace_in_options
|
||||||
|
|
||||||
|
_AIR_QUALITY_SENSORS = (
|
||||||
|
('dust', 'Dust', 'mdi:blur', 'Dust'),
|
||||||
|
('fine_dust', 'Fine dust', 'mdi:blur', 'FineDust'),
|
||||||
|
('super_fine_dust', 'Super fine dust', 'mdi:blur', 'SuperFineDust'),
|
||||||
|
('odor', 'Odor', 'mdi:scent', 'Odor'),
|
||||||
|
('clean_level', 'Clean level', 'mdi:air-filter', 'CleanLevel'),
|
||||||
|
)
|
||||||
|
|
||||||
|
AIR_QUALITY = Capability(
|
||||||
|
href='/sensors/vs/0',
|
||||||
|
poll_tier='warm',
|
||||||
|
entities=tuple(
|
||||||
|
SensorDesc(key=key, field='x.com.samsung.da.items', name=name, icon=icon,
|
||||||
|
value_fn=lambda items, t=sensor_type: sensor_item_value(items, t))
|
||||||
|
for key, name, icon, sensor_type in _AIR_QUALITY_SENSORS
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _consumable_state(items, name):
|
||||||
|
"""Read a `/consumable/vs/0`-style items[] entry -- {name, state} pairs,
|
||||||
|
unlike AIR_QUALITY's {type, value} shape above."""
|
||||||
|
for item in items or ():
|
||||||
|
if isinstance(item, dict) and item.get('x.com.samsung.da.name') == name:
|
||||||
|
return item.get('x.com.samsung.da.state')
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
# FilterProgress is a raw 0-100 percentage in both dumps (100 and 62); which
|
||||||
|
# end of that scale means "replace me" isn't confirmed from the dump alone,
|
||||||
|
# so the entity is named after the raw field rather than asserting a
|
||||||
|
# direction (see issue #56 follow-up questions).
|
||||||
|
FILTER = Capability(
|
||||||
|
href='/consumable/vs/0',
|
||||||
|
poll_tier='cold',
|
||||||
|
entities=(
|
||||||
|
SensorDesc(key='filter_progress', field='x.com.samsung.da.items',
|
||||||
|
name='Filter progress', unit='%', state_class='measurement',
|
||||||
|
icon='mdi:air-filter', entity_category='diagnostic',
|
||||||
|
value_fn=lambda items: int_or_none(
|
||||||
|
_consumable_state(items, 'FilterProgress'))),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
DEVICE_ACTIVE = Capability(
|
||||||
|
href='/devicespecificinfo/vs/0',
|
||||||
|
poll_tier='cold',
|
||||||
|
entities=(
|
||||||
|
BinarySensorDesc(key='device_active', field='x.com.samsung.da.deviceActive',
|
||||||
|
name='Device active', icon='mdi:check-network-outline',
|
||||||
|
entity_category='diagnostic',
|
||||||
|
value_fn=lambda v: bool(v)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
# OCF-native / vendor pair for fan speed+direction -- see module docstring for
|
||||||
|
# why these are read-only for now.
|
||||||
|
AIRFLOW_GENERIC = Capability(
|
||||||
|
href='/airflow/0',
|
||||||
|
poll_tier='warm',
|
||||||
|
entities=(
|
||||||
|
SensorDesc(key='fan_speed_level', field='speed',
|
||||||
|
name='Fan speed level', icon='mdi:fan',
|
||||||
|
state_class='measurement', entity_category='diagnostic'),
|
||||||
|
SensorDesc(key='fan_direction', field='direction',
|
||||||
|
name='Fan direction', icon='mdi:rotate-3d-variant',
|
||||||
|
entity_category='diagnostic'),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
AIRFLOW_VS_FALLBACK = Capability(
|
||||||
|
href='/airflow/vs/0',
|
||||||
|
match_fn=lambda rep, resources: '/airflow/0' not in resources,
|
||||||
|
poll_tier='warm',
|
||||||
|
entities=(
|
||||||
|
SensorDesc(key='fan_speed_level', field='x.com.samsung.da.speedLevel',
|
||||||
|
name='Fan speed level', icon='mdi:fan',
|
||||||
|
state_class='measurement', entity_category='diagnostic',
|
||||||
|
value_fn=int_or_none),
|
||||||
|
SensorDesc(key='fan_direction', field='x.com.samsung.da.direction',
|
||||||
|
name='Fan direction', icon='mdi:rotate-3d-variant',
|
||||||
|
entity_category='diagnostic'),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _light_write(payload, rep, href=None):
|
||||||
|
opts = list(rep.get('x.com.samsung.da.options') or [])
|
||||||
|
return ['mode', 'vs', '0'], {
|
||||||
|
'x.com.samsung.da.options': replace_in_options(opts, 'Light', payload),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MODE = Capability(
|
||||||
|
href='/mode/vs/0',
|
||||||
|
poll_tier='warm',
|
||||||
|
entities=(
|
||||||
|
SwitchDesc(key='display_light', name='Display light', icon='mdi:led-on',
|
||||||
|
entity_category='config',
|
||||||
|
rep_fn=bool_option_value('Light'),
|
||||||
|
exists_fn=bool_option_exists('Light'),
|
||||||
|
write_fn=_light_write),
|
||||||
|
# Read-only pending issue #56 follow-up -- see module docstring.
|
||||||
|
SensorDesc(key='operating_mode', name='Operating mode', icon='mdi:fan',
|
||||||
|
entity_category='diagnostic',
|
||||||
|
rep_fn=lambda rep: option_value(rep.get('x.com.samsung.da.options'), 'Comode'),
|
||||||
|
exists_fn=bool_option_exists('Comode')),
|
||||||
|
SensorDesc(key='blooming_level', name='Blooming level', icon='mdi:flower',
|
||||||
|
entity_category='diagnostic',
|
||||||
|
rep_fn=lambda rep: option_value(rep.get('x.com.samsung.da.options'), 'Blooming'),
|
||||||
|
exists_fn=bool_option_exists('Blooming')),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
# /humidity/0 and /humidity/vs/0 are empty {} on both dumps this family has
|
||||||
|
# been verified against -- covered here (not globally, per ignored.py's
|
||||||
|
# module docstring) since those hrefs collide with fridge/AC schemas
|
||||||
|
# elsewhere. Same two hrefs and reasoning as airconditioner.py's _AC_IGNORED.
|
||||||
|
COVERAGE = [
|
||||||
|
Capability(href='/humidity/0'),
|
||||||
|
Capability(href='/humidity/vs/0'),
|
||||||
|
]
|
||||||
@@ -23,6 +23,13 @@ def _num(v):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def int_or_none(v):
|
||||||
|
try:
|
||||||
|
return int(v)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def clamp_power(v):
|
def clamp_power(v):
|
||||||
n = _num(v)
|
n = _num(v)
|
||||||
return 0.0 if (n is not None and n < 0) else n
|
return 0.0 if (n is not None and n < 0) else n
|
||||||
@@ -58,6 +65,26 @@ def _active_alarm_codes(items):
|
|||||||
return ', '.join(codes) if codes else 'none'
|
return ', '.join(codes) if codes else 'none'
|
||||||
|
|
||||||
|
|
||||||
|
def sensor_item_value(items, sensor_type, index=0):
|
||||||
|
"""Pull one reading out of a `/sensors/vs/0`-style items[] list -- each
|
||||||
|
item is `{type, value: [...]}`; `index` picks which slot of a possibly
|
||||||
|
multi-value reading to read (index 0 is the raw measurement on every
|
||||||
|
family seen so far). Shared by range_hood.AIR_QUALITY and
|
||||||
|
air_purifier.AIR_QUALITY, which read the same resource shape."""
|
||||||
|
for item in items or ():
|
||||||
|
if not isinstance(item, dict):
|
||||||
|
continue
|
||||||
|
if item.get('x.com.samsung.da.type') != sensor_type:
|
||||||
|
continue
|
||||||
|
values = item.get('x.com.samsung.da.value') or ()
|
||||||
|
if index < len(values):
|
||||||
|
try:
|
||||||
|
return int(values[index])
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return None
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
# OCF-native / vendor '-vs' fallback pairs for power, kids-lock, remote control.
|
# OCF-native / vendor '-vs' fallback pairs for power, kids-lock, remote control.
|
||||||
#
|
#
|
||||||
# These three controls exist as both a standard OCF resource (/power/0,
|
# These three controls exist as both a standard OCF resource (/power/0,
|
||||||
|
|||||||
@@ -4,13 +4,15 @@ Dryer-specific controls only. The shared laundry surface -- power/kids-lock/
|
|||||||
remote-control fallback pairs, buzzer, energy meter, job-beginning-status, and
|
remote-control fallback pairs, buzzer, energy meter, job-beginning-status, and
|
||||||
the /course/vs/0 cycle select -- lives in laundry.py.
|
the /course/vs/0 cycle select -- lives in laundry.py.
|
||||||
|
|
||||||
/washer/vs/0 -> DRYER_SETTINGS (dryLevel, dryTime, dryerType, wrinklePrevent)
|
/washer/vs/0 -> DRYER_SETTINGS (dryLevel, dryTime, dryerType, wrinklePrevent)
|
||||||
/course/vs/0 -> DRYER_COURSE (shared cycle select; see below)
|
/course/vs/0 -> DRYER_COURSE (shared cycle select, plus the AI-pattern
|
||||||
/diagnosis/vs/0 -> DRYER_DIAGNOSIS
|
toggle read off the same options[] array; see below)
|
||||||
|
/diagnosis/vs/0 -> DRYER_DIAGNOSIS
|
||||||
|
/cycleinterface/vs/0 -> AUTO_CYCLE_LINK
|
||||||
"""
|
"""
|
||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
from ..entities import SensorDesc, SwitchDesc
|
from ..entities import SelectDesc, SensorDesc, SwitchDesc
|
||||||
from .laundry import cycle_select
|
from .laundry import bool_option_switch, cycle_select
|
||||||
|
|
||||||
|
|
||||||
def _wrinkle_write(p, rep, href=None):
|
def _wrinkle_write(p, rep, href=None):
|
||||||
@@ -23,8 +25,15 @@ DRYER_SETTINGS = Capability(
|
|||||||
href='/washer/vs/0',
|
href='/washer/vs/0',
|
||||||
poll_tier='warm',
|
poll_tier='warm',
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='dry_level', field='x.com.samsung.da.dryLevel',
|
# supportedDryLevel values (e.g. 'None'/'Less'/'Normal'/'More') are
|
||||||
name='Dry level', icon='mdi:water-percent'),
|
# already human-readable on this device, unlike the combo-unit
|
||||||
|
# numeric-minute codes washer.py's washer_dry_level select needs
|
||||||
|
# translations for -- no translation_key needed here.
|
||||||
|
SelectDesc(key='dry_level', field='x.com.samsung.da.dryLevel',
|
||||||
|
name='Dry level', icon='mdi:water-percent',
|
||||||
|
options_field='x.com.samsung.da.supportedDryLevel',
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
['washer', 'vs', '0'], {'x.com.samsung.da.dryLevel': p})),
|
||||||
SensorDesc(key='dry_time', field='x.com.samsung.da.dryTime',
|
SensorDesc(key='dry_time', field='x.com.samsung.da.dryTime',
|
||||||
name='Dry time', icon='mdi:timer'),
|
name='Dry time', icon='mdi:timer'),
|
||||||
SensorDesc(key='dryer_type', field='x.com.samsung.da.dryerType',
|
SensorDesc(key='dryer_type', field='x.com.samsung.da.dryerType',
|
||||||
@@ -40,15 +49,21 @@ DRYER_SETTINGS = Capability(
|
|||||||
# laundry.cycle_select (options read live from /wm/editcourse/vs/0, written as
|
# laundry.cycle_select (options read live from /wm/editcourse/vs/0, written as
|
||||||
# an RMW on the options array). Course display names live in translations
|
# an RMW on the options array). Course display names live in translations
|
||||||
# under entity.select.dryer_cycle (Table_03, DV5000-class, captured
|
# under entity.select.dryer_cycle (Table_03, DV5000-class, captured
|
||||||
# 2026-05-29). Codes 0x21 and 0x4C appear in the issue #14 DV90BB5245AES1
|
# 2026-05-29; codes 0x21/0x4C named from the issue #14 DV90BB5245AES1
|
||||||
# editCourseList but aren't identified yet -- they render as the raw code
|
# SmartThings course-list screenshots on 2026-07-24). The /st/dryercourse/vs/0
|
||||||
# until named. The /st/dryercourse/vs/0 resource re-encodes the same selected
|
# resource re-encodes the same selected course and is ignored (ignored.py) --
|
||||||
# course and is ignored (ignored.py) -- the mirror of how /st/washercourse/vs/0
|
# the mirror of how /st/washercourse/vs/0 is ignored for washers.
|
||||||
# is ignored for washers.
|
#
|
||||||
|
# The same options[] array also carries AiOption_On/Off -- the app's "AI
|
||||||
|
# pattern" toggle ("Get cycle recommendations based on your usage patterns"),
|
||||||
|
# confirmed against the issue #14 screenshots. Same On/Off token shape as
|
||||||
|
# washer.py's bubble-soak/pre-wash/intensive toggles; not previously bound.
|
||||||
DRYER_COURSE = Capability(
|
DRYER_COURSE = Capability(
|
||||||
href='/course/vs/0',
|
href='/course/vs/0',
|
||||||
entities=(
|
entities=(
|
||||||
cycle_select(translation_key='dryer_cycle', icon='mdi:tumble-dryer'),
|
cycle_select(translation_key='dryer_cycle', icon='mdi:tumble-dryer'),
|
||||||
|
bool_option_switch('ai_pattern', 'AI pattern', 'mdi:creation', 'AiOption',
|
||||||
|
entity_category='config', gate_on_presence=True),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -60,3 +75,26 @@ DRYER_DIAGNOSIS = Capability(
|
|||||||
name='Diagnosis', entity_category='diagnostic'),
|
name='Diagnosis', entity_category='diagnostic'),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# /cycleinterface/vs/0 -- the app's "Auto cycle link" toggle ("automatically
|
||||||
|
# set to the best drying cycle by communicating with the washer cycle"; both
|
||||||
|
# devices must stay connected). Empty ({}) on every washer dump seen so far,
|
||||||
|
# which is why it used to sit in the global ignored.IGNORED list -- the
|
||||||
|
# issue #14 dryer dump is the first to populate it. washer.py scopes its own
|
||||||
|
# ignore locally now (washer.CYCLE_INTERFACE_IGNORED) to avoid a collision.
|
||||||
|
def _auto_cycle_link_write(p, rep, href=None):
|
||||||
|
if p not in ('On', 'Off'):
|
||||||
|
return None
|
||||||
|
return ['cycleinterface', 'vs', '0'], {'x.com.samsung.da.cycleInterfaceEnabled': p}
|
||||||
|
|
||||||
|
|
||||||
|
AUTO_CYCLE_LINK = Capability(
|
||||||
|
href='/cycleinterface/vs/0',
|
||||||
|
entities=(
|
||||||
|
SwitchDesc(key='auto_cycle_link', field='x.com.samsung.da.cycleInterfaceEnabled',
|
||||||
|
name='Auto cycle link', icon='mdi:link-variant',
|
||||||
|
entity_category='config',
|
||||||
|
value_fn=lambda v: v == 'On',
|
||||||
|
write_fn=_auto_cycle_link_write),
|
||||||
|
),
|
||||||
|
)
|
||||||
@@ -117,11 +117,15 @@ IGNORED: list[Capability] = [
|
|||||||
# data -- common.ENERGY_METER on /energy/consumption/vs/0 is the only
|
# data -- common.ENERGY_METER on /energy/consumption/vs/0 is the only
|
||||||
# real source for this control.
|
# real source for this control.
|
||||||
Capability(href='/energy/consumption/0'),
|
Capability(href='/energy/consumption/0'),
|
||||||
# Empty ({}) on every washer dump seen so far -- nothing to expose.
|
|
||||||
Capability(href='/cycleinterface/vs/0'),
|
|
||||||
# OCF-native duplicate of /drlc/vs/0 above -- same utility-program
|
# OCF-native duplicate of /drlc/vs/0 above -- same utility-program
|
||||||
# dependency this integration doesn't support locally.
|
# dependency this integration doesn't support locally.
|
||||||
Capability(href='/drlc/0'),
|
Capability(href='/drlc/0'),
|
||||||
|
# NOTE: /cycleinterface/vs/0 used to be listed here as empty ({}) on
|
||||||
|
# every washer dump seen so far. The issue #14 dryer dump populates it
|
||||||
|
# (cycleInterfaceEnabled) as the app's "Auto cycle link" toggle, so it's
|
||||||
|
# now a real capability there (dryer.AUTO_CYCLE_LINK) -- washer.py scopes
|
||||||
|
# its own ignore locally (washer.CYCLE_INTERFACE_IGNORED) to avoid a
|
||||||
|
# global-ignore/real-capability href collision.
|
||||||
# OCF-native duplicate of /operational/state/vs/0, which is already
|
# OCF-native duplicate of /operational/state/vs/0, which is already
|
||||||
# modeled by operational.OPERATIONAL_STATE (a richer, write-capable
|
# modeled by operational.OPERATIONAL_STATE (a richer, write-capable
|
||||||
# capability with start/pause/stop buttons and a delay-start control)
|
# capability with start/pause/stop buttons and a delay-start control)
|
||||||
|
|||||||
@@ -17,13 +17,7 @@ from ..entities import (
|
|||||||
SensorDesc,
|
SensorDesc,
|
||||||
SwitchDesc,
|
SwitchDesc,
|
||||||
)
|
)
|
||||||
|
from .common import int_or_none, sensor_item_value
|
||||||
|
|
||||||
def _int_or_none(value):
|
|
||||||
try:
|
|
||||||
return int(value)
|
|
||||||
except (TypeError, ValueError):
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def _timestamp(value):
|
def _timestamp(value):
|
||||||
@@ -33,18 +27,6 @@ def _timestamp(value):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _item_value(items, sensor_type, index=0):
|
|
||||||
for item in items or ():
|
|
||||||
if not isinstance(item, dict):
|
|
||||||
continue
|
|
||||||
if item.get('x.com.samsung.da.type') != sensor_type:
|
|
||||||
continue
|
|
||||||
values = item.get('x.com.samsung.da.value') or ()
|
|
||||||
if index < len(values):
|
|
||||||
return _int_or_none(values[index])
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def _active_alarm_codes(items):
|
def _active_alarm_codes(items):
|
||||||
"""Discard the hood firmware's retained/deleted ``ErrorCode_OFF`` row.
|
"""Discard the hood firmware's retained/deleted ``ErrorCode_OFF`` row.
|
||||||
|
|
||||||
@@ -176,7 +158,7 @@ HOOD_FILTER = Capability(
|
|||||||
state_class='measurement',
|
state_class='measurement',
|
||||||
icon='mdi:air-filter',
|
icon='mdi:air-filter',
|
||||||
entity_category='diagnostic',
|
entity_category='diagnostic',
|
||||||
value_fn=_int_or_none,
|
value_fn=int_or_none,
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='hood_filter_status',
|
key='hood_filter_status',
|
||||||
@@ -193,7 +175,7 @@ HOOD_FILTER = Capability(
|
|||||||
icon='mdi:timer-outline',
|
icon='mdi:timer-outline',
|
||||||
entity_category='diagnostic',
|
entity_category='diagnostic',
|
||||||
enabled_default=False,
|
enabled_default=False,
|
||||||
value_fn=_int_or_none,
|
value_fn=int_or_none,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -208,25 +190,25 @@ AIR_QUALITY = Capability(
|
|||||||
field='x.com.samsung.da.items',
|
field='x.com.samsung.da.items',
|
||||||
name='Clean level',
|
name='Clean level',
|
||||||
icon='mdi:air-filter',
|
icon='mdi:air-filter',
|
||||||
value_fn=lambda items: _item_value(items, 'CleanLevel'),
|
value_fn=lambda items: sensor_item_value(items, 'CleanLevel'),
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='dust',
|
key='dust',
|
||||||
field='x.com.samsung.da.items',
|
field='x.com.samsung.da.items',
|
||||||
name='Dust',
|
name='Dust',
|
||||||
value_fn=lambda items: _item_value(items, 'Dust'),
|
value_fn=lambda items: sensor_item_value(items, 'Dust'),
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='fine_dust',
|
key='fine_dust',
|
||||||
field='x.com.samsung.da.items',
|
field='x.com.samsung.da.items',
|
||||||
name='Fine dust',
|
name='Fine dust',
|
||||||
value_fn=lambda items: _item_value(items, 'FineDust'),
|
value_fn=lambda items: sensor_item_value(items, 'FineDust'),
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='super_fine_dust',
|
key='super_fine_dust',
|
||||||
field='x.com.samsung.da.items',
|
field='x.com.samsung.da.items',
|
||||||
name='Super fine dust',
|
name='Super fine dust',
|
||||||
value_fn=lambda items: _item_value(items, 'SuperFineDust'),
|
value_fn=lambda items: sensor_item_value(items, 'SuperFineDust'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -354,3 +354,10 @@ WASHER_COURSE = Capability(
|
|||||||
'IntensiveSetting', 'IntensiveAvailableSet'),
|
'IntensiveSetting', 'IntensiveAvailableSet'),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# /cycleinterface/vs/0 -- washer-to-dryer "Auto cycle link" pairing signal
|
||||||
|
# (dryer.AUTO_CYCLE_LINK). Empty ({}) on every washer/combo dump seen so far
|
||||||
|
# (plain washers, FlexWash, and washer/dryer combos alike), so it's scoped
|
||||||
|
# out here rather than left in the global ignored.IGNORED list, which would
|
||||||
|
# collide with the real dryer-side capability.
|
||||||
|
CYCLE_INTERFACE_IGNORED = Capability(href='/cycleinterface/vs/0')
|
||||||
@@ -115,10 +115,12 @@
|
|||||||
"1e": "Outdoor",
|
"1e": "Outdoor",
|
||||||
"1f": "Mixed Load",
|
"1f": "Mixed Load",
|
||||||
"20": "Iron Dry",
|
"20": "Iron Dry",
|
||||||
|
"21": "Hygiene Care",
|
||||||
"23": "Quick Dry 35",
|
"23": "Quick Dry 35",
|
||||||
"24": "Cool Air",
|
"24": "Cool Air",
|
||||||
"25": "Warm Air",
|
"25": "Warm Air",
|
||||||
"27": "Time Dry"
|
"27": "Time Dry",
|
||||||
|
"4c": "Air Refresh"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"washer_dosing_quantity": {
|
"washer_dosing_quantity": {
|
||||||
|
|||||||
@@ -115,10 +115,12 @@
|
|||||||
"1e": "Outdoor",
|
"1e": "Outdoor",
|
||||||
"1f": "Mixed Load",
|
"1f": "Mixed Load",
|
||||||
"20": "Iron Dry",
|
"20": "Iron Dry",
|
||||||
|
"21": "Hygiene Care",
|
||||||
"23": "Quick Dry 35",
|
"23": "Quick Dry 35",
|
||||||
"24": "Cool Air",
|
"24": "Cool Air",
|
||||||
"25": "Warm Air",
|
"25": "Warm Air",
|
||||||
"27": "Time Dry"
|
"27": "Time Dry",
|
||||||
|
"4c": "Air Refresh"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"washer_dosing_quantity": {
|
"washer_dosing_quantity": {
|
||||||
|
|||||||
+200
@@ -0,0 +1,200 @@
|
|||||||
|
{
|
||||||
|
"device0": [
|
||||||
|
{
|
||||||
|
"rt": [
|
||||||
|
"x.com.samsung.devcol"
|
||||||
|
],
|
||||||
|
"if": [
|
||||||
|
"oic.if.baseline",
|
||||||
|
"oic.if.ll",
|
||||||
|
"oic.if.b"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/airflow/0",
|
||||||
|
"rep": {
|
||||||
|
"speed": 0,
|
||||||
|
"direction": "Off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/airflow/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.speedLevel": "0",
|
||||||
|
"x.com.samsung.da.direction": "Off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/alarms/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.items": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "0",
|
||||||
|
"x.com.samsung.da.description": "Alarm",
|
||||||
|
"x.com.samsung.da.alarmType": "Device",
|
||||||
|
"x.com.samsung.da.code": "ErrorCode_OFF",
|
||||||
|
"x.com.samsung.da.triggeredTime": "2026-07-23T15:56:55",
|
||||||
|
"x.com.samsung.da.state": "Deleted"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "1",
|
||||||
|
"x.com.samsung.da.description": "Alarm",
|
||||||
|
"x.com.samsung.da.alarmType": "Device",
|
||||||
|
"x.com.samsung.da.code": "FilterAlarm",
|
||||||
|
"x.com.samsung.da.triggeredTime": "2026-07-23T15:56:55",
|
||||||
|
"x.com.samsung.da.state": "Created"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/configuration/vs/0",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/consumable/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.items": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.state": "100",
|
||||||
|
"x.com.samsung.da.name": "FilterProgress"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/devicespecificinfo/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.deviceActive": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/diagnosis/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.diagnosisStart": "Ready"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/energy/consumption/0",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/energy/consumption/vs/0",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/humidity/0",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/humidity/vs/0",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/information/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.modelNum": "ARTIK051_TVTL_18K|10193941|7000023C001111C40100000000000000",
|
||||||
|
"x.com.samsung.da.description": "ARTIK051_TVTL_18K",
|
||||||
|
"x.com.samsung.da.serialNum": "**REDACTED**",
|
||||||
|
"x.com.samsung.da.otnDUID": "**REDACTED**",
|
||||||
|
"x.com.samsung.da.items": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "0",
|
||||||
|
"x.com.samsung.da.description": "Version",
|
||||||
|
"x.com.samsung.da.type": "Software",
|
||||||
|
"x.com.samsung.da.number": "02059A230513",
|
||||||
|
"x.com.samsung.da.newVersionAvailable": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "1",
|
||||||
|
"x.com.samsung.da.description": "Version",
|
||||||
|
"x.com.samsung.da.type": "Firmware",
|
||||||
|
"x.com.samsung.da.number": "19071703,19071706",
|
||||||
|
"x.com.samsung.da.newVersionAvailable": "0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/mode/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.options": [
|
||||||
|
"Comode_Off",
|
||||||
|
"Blooming_0",
|
||||||
|
"Light_On",
|
||||||
|
"OptionCode_60282"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/power/0",
|
||||||
|
"rep": {
|
||||||
|
"value": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/power/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.power": "Off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/realtimenotiforclient/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.timeforshortnoti": "0",
|
||||||
|
"x.com.samsung.da.longnotisubscription": "true",
|
||||||
|
"x.com.samsung.da.periodicnotisubscription": "false"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/sensors/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.items": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "0",
|
||||||
|
"x.com.samsung.da.description": "Sensor for Dust",
|
||||||
|
"x.com.samsung.da.type": "Dust",
|
||||||
|
"x.com.samsung.da.value": [
|
||||||
|
"11",
|
||||||
|
"0"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "1",
|
||||||
|
"x.com.samsung.da.description": "Sensor for FineDust",
|
||||||
|
"x.com.samsung.da.type": "FineDust",
|
||||||
|
"x.com.samsung.da.value": [
|
||||||
|
"9",
|
||||||
|
"0"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "2",
|
||||||
|
"x.com.samsung.da.description": "Sensor for Odor",
|
||||||
|
"x.com.samsung.da.type": "Odor",
|
||||||
|
"x.com.samsung.da.value": [
|
||||||
|
"0"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "3",
|
||||||
|
"x.com.samsung.da.description": "Sensor for CleanLevel",
|
||||||
|
"x.com.samsung.da.type": "CleanLevel",
|
||||||
|
"x.com.samsung.da.value": [
|
||||||
|
"0"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "4",
|
||||||
|
"x.com.samsung.da.description": "Sensor for SuperFineDust",
|
||||||
|
"x.com.samsung.da.type": "SuperFineDust",
|
||||||
|
"x.com.samsung.da.value": [
|
||||||
|
"5",
|
||||||
|
"0"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"state_keys": [
|
||||||
|
"alarm_code",
|
||||||
|
"blooming_level",
|
||||||
|
"clean_level",
|
||||||
|
"device_active",
|
||||||
|
"diagnosis_status",
|
||||||
|
"display_light",
|
||||||
|
"dust",
|
||||||
|
"energy_kwh",
|
||||||
|
"energy_last_month_kwh",
|
||||||
|
"energy_saved_kwh",
|
||||||
|
"energy_this_month_kwh",
|
||||||
|
"fan_direction",
|
||||||
|
"fan_speed_level",
|
||||||
|
"filter_progress",
|
||||||
|
"fine_dust",
|
||||||
|
"odor",
|
||||||
|
"operating_mode",
|
||||||
|
"power_energy_kwh",
|
||||||
|
"power_switch",
|
||||||
|
"power_watts",
|
||||||
|
"super_fine_dust"
|
||||||
|
]
|
||||||
|
}
|
||||||
Vendored
+2
@@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"state_keys": [
|
"state_keys": [
|
||||||
|
"ai_pattern",
|
||||||
"alarm_code",
|
"alarm_code",
|
||||||
|
"auto_cycle_link",
|
||||||
"buzzer_sound",
|
"buzzer_sound",
|
||||||
"child_lock",
|
"child_lock",
|
||||||
"cycle",
|
"cycle",
|
||||||
|
|||||||
@@ -643,7 +643,13 @@ async def test_write_marks_href_pending_before_post(
|
|||||||
hass: HomeAssistant, mock_entry, mock_coordinator_observe_session
|
hass: HomeAssistant, mock_entry, mock_coordinator_observe_session
|
||||||
) -> None:
|
) -> None:
|
||||||
"""async_send_command must call mark_write_pending before POSTing so a
|
"""async_send_command must call mark_write_pending before POSTing so a
|
||||||
slow-to-settle device can't immediately revert the optimistic write."""
|
slow-to-settle device can't immediately revert the optimistic write --
|
||||||
|
and it must guard the write's actual target href (write_fn's own
|
||||||
|
path_segs), not bound_entity.href. Those differ for a composite entity
|
||||||
|
like the AC's ClimateDesc (bound to /mode/vs/0, but writing power/temp/
|
||||||
|
fan/swing/preset to their own sibling hrefs) -- guarding the bound href
|
||||||
|
protected the wrong resource and left the one the entity actually
|
||||||
|
displays from unprotected (issues #17/#53)."""
|
||||||
from custom_components.localthings.registry.discovery import BoundEntity
|
from custom_components.localthings.registry.discovery import BoundEntity
|
||||||
from custom_components.localthings.registry.entities import NumberDesc
|
from custom_components.localthings.registry.entities import NumberDesc
|
||||||
|
|
||||||
@@ -662,17 +668,23 @@ async def test_write_marks_href_pending_before_post(
|
|||||||
fake.post = lambda *a, **k: (0x44, b'')
|
fake.post = lambda *a, **k: (0x44, b'')
|
||||||
await coordinator.async_send_command(bound, 5)
|
await coordinator.async_send_command(bound, 5)
|
||||||
|
|
||||||
assert coordinator._observe._settle_until.get('/test/vs/0') is not None
|
assert coordinator._observe._settle_until.get('/some/path') is not None
|
||||||
|
assert coordinator._observe._settle_until.get('/test/vs/0') is None
|
||||||
|
|
||||||
|
|
||||||
async def test_send_command_applies_write_optimistically_before_settling(
|
async def test_send_command_applies_write_optimistically_before_settling(
|
||||||
hass: HomeAssistant, mock_entry, mock_coordinator_observe_session
|
hass: HomeAssistant, mock_entry, mock_coordinator_observe_session,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""The cache must reflect a write immediately, and stay put against a
|
"""The cache must reflect a write immediately at the write's actual
|
||||||
stale echo for the rest of the settle window -- otherwise
|
target href (write_fn's path_segs) -- not bound_entity.href, which
|
||||||
mark_write_pending has nothing to protect and just delays the real
|
differs for a composite entity like the AC's ClimateDesc -- and stay put
|
||||||
device confirmation instead, which reads to a user as the write being
|
against a stale echo for the rest of the settle window there.
|
||||||
silently reverted (issue #27)."""
|
|
||||||
|
Applying the optimistic value to bound_entity.href instead is exactly
|
||||||
|
how issues #17/#53 survived the original optimistic-apply fix (issue
|
||||||
|
#27): the bound href got a harmless (if nonsensical) optimistic merge,
|
||||||
|
while the resource the entity actually reads from for its displayed
|
||||||
|
state never got one and stayed stale until the next real read of it."""
|
||||||
from custom_components.localthings.registry.discovery import BoundEntity
|
from custom_components.localthings.registry.discovery import BoundEntity
|
||||||
from custom_components.localthings.registry.entities import NumberDesc
|
from custom_components.localthings.registry.entities import NumberDesc
|
||||||
|
|
||||||
@@ -691,16 +703,50 @@ async def test_send_command_applies_write_optimistically_before_settling(
|
|||||||
fake.post = lambda *a, **k: (0x44, b'')
|
fake.post = lambda *a, **k: (0x44, b'')
|
||||||
await coordinator.async_send_command(bound, 5)
|
await coordinator.async_send_command(bound, 5)
|
||||||
|
|
||||||
# The optimistic value is visible right away, without waiting for a
|
# The optimistic value is visible right away at the write's real
|
||||||
# device response.
|
# target, not the bound href.
|
||||||
assert coordinator._cache.get('/test/vs/0') == {'value': 5}
|
assert coordinator._cache.get('/some/path') == {'value': 5}
|
||||||
|
assert coordinator._cache.get('/test/vs/0') != {'value': 5}
|
||||||
|
|
||||||
# A stale update racing in behind the write (e.g. a poll/notify that
|
# A stale update racing in behind the write (e.g. a poll/notify that
|
||||||
# was already in flight before the PUT) must not clobber it while the
|
# was already in flight before the PUT) must not clobber it while the
|
||||||
# settle window is open.
|
# settle window is open.
|
||||||
applied = coordinator._observe.apply('/test/vs/0', {'value': 0}, source='observe')
|
applied = coordinator._observe.apply('/some/path', {'value': 0}, source='observe')
|
||||||
assert applied is False
|
assert applied is False
|
||||||
assert coordinator._cache.get('/test/vs/0') == {'value': 5}
|
assert coordinator._cache.get('/some/path') == {'value': 5}
|
||||||
|
|
||||||
|
|
||||||
|
async def test_climate_power_write_applies_to_its_own_href_not_bound_href(
|
||||||
|
hass: HomeAssistant, mock_entry, mock_coordinator_observe_session
|
||||||
|
) -> None:
|
||||||
|
"""Regression for issues #17/#53, using the real AC capability. The
|
||||||
|
composite climate entity binds /mode/vs/0 (airconditioner.CLIMATE.href),
|
||||||
|
but a power command's write_fn (airconditioner._climate_write) targets
|
||||||
|
the sibling /power/0 -- the href climate.py's `_is_on()` actually reads.
|
||||||
|
The optimistic value and settle guard must land there, not on the bound
|
||||||
|
/mode/vs/0, or the entity never sees the write and shows stale state
|
||||||
|
until the next unrelated read of /power/0."""
|
||||||
|
from custom_components.localthings.registry.capabilities import airconditioner
|
||||||
|
from custom_components.localthings.registry.discovery import BoundEntity
|
||||||
|
|
||||||
|
fake = mock_coordinator_observe_session
|
||||||
|
await hass.config_entries.async_setup(mock_entry.entry_id)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
coordinator: LocalThingsCoordinator = hass.data[DOMAIN][mock_entry.entry_id]
|
||||||
|
|
||||||
|
bound = BoundEntity(
|
||||||
|
href=airconditioner.CLIMATE.href,
|
||||||
|
capability=coordinator.bound[0].capability,
|
||||||
|
desc=airconditioner.CLIMATE.entities[0],
|
||||||
|
)
|
||||||
|
|
||||||
|
with patch.object(fake, 'subscribe'):
|
||||||
|
fake.post = lambda *a, **k: (0x44, b'')
|
||||||
|
await coordinator.async_send_command(bound, ('power', True))
|
||||||
|
|
||||||
|
assert coordinator._cache.get('/power/0') == {'value': True}
|
||||||
|
assert coordinator._cache.get(airconditioner.CLIMATE.href) != {'value': True}
|
||||||
|
assert coordinator._observe._settle_until.get('/power/0') is not None
|
||||||
|
|
||||||
|
|
||||||
class TestRemoteControlEnabled:
|
class TestRemoteControlEnabled:
|
||||||
@@ -803,7 +849,7 @@ async def test_send_command_allowed_when_remote_control_enabled(
|
|||||||
fake.post = lambda *a, **k: (0x44, b'')
|
fake.post = lambda *a, **k: (0x44, b'')
|
||||||
await coordinator.async_send_command(bound, 5)
|
await coordinator.async_send_command(bound, 5)
|
||||||
|
|
||||||
assert coordinator._observe._settle_until.get('/test/vs/0') is not None
|
assert coordinator._cache.get('/some/path') == {'value': 5}
|
||||||
|
|
||||||
|
|
||||||
async def test_send_command_remote_control_check_precedes_validate_fn(
|
async def test_send_command_remote_control_check_precedes_validate_fn(
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
"""Tests for the ARTIK051_TVTL_18K air-purifier profile (issue #56)."""
|
||||||
|
from custom_components.localthings.registry.adapter import flatten
|
||||||
|
from custom_components.localthings.registry.by_type import for_device_by_model
|
||||||
|
from custom_components.localthings.registry.capabilities import air_purifier
|
||||||
|
from custom_components.localthings.registry.discovery import discover
|
||||||
|
from tests.conftest import _load_device
|
||||||
|
|
||||||
|
|
||||||
|
def _purifier():
|
||||||
|
resources = _load_device('air_purifier')
|
||||||
|
info = resources['/information/vs/0']
|
||||||
|
reg = for_device_by_model(
|
||||||
|
info['x.com.samsung.da.modelNum'], info['x.com.samsung.da.description'],
|
||||||
|
)
|
||||||
|
return reg, resources
|
||||||
|
|
||||||
|
|
||||||
|
def _state():
|
||||||
|
reg, resources = _purifier()
|
||||||
|
bound = discover(resources, reg.capabilities, reg.pattern_capabilities)
|
||||||
|
return flatten(bound, resources)
|
||||||
|
|
||||||
|
|
||||||
|
def test_model_resolves_to_air_purifier_registry():
|
||||||
|
reg, _ = _purifier()
|
||||||
|
assert reg is not None
|
||||||
|
assert reg.name == 'air_purifier'
|
||||||
|
|
||||||
|
|
||||||
|
def test_no_unbound_hrefs():
|
||||||
|
"""Every resource in the issue #56 dump binds or is ignored -- clears the
|
||||||
|
coverage-gap repair."""
|
||||||
|
reg, resources = _purifier()
|
||||||
|
unbound = []
|
||||||
|
discover(resources, reg.capabilities, reg.pattern_capabilities, log=unbound.append)
|
||||||
|
assert unbound == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_expected_entities_present():
|
||||||
|
state = _state()
|
||||||
|
for key in (
|
||||||
|
'power_switch', 'alarm_code', 'dust', 'fine_dust', 'super_fine_dust',
|
||||||
|
'odor', 'clean_level', 'filter_progress', 'device_active',
|
||||||
|
'diagnosis_status', 'fan_speed_level', 'fan_direction',
|
||||||
|
'display_light', 'operating_mode', 'blooming_level',
|
||||||
|
):
|
||||||
|
assert key in state, key
|
||||||
|
|
||||||
|
|
||||||
|
def test_air_quality_sensor_values():
|
||||||
|
"""Dust/FineDust/SuperFineDust/Odor/CleanLevel read index 0 of each
|
||||||
|
items[] entry's value list (the raw measurement, per common.sensor_item_value)."""
|
||||||
|
state = _state()
|
||||||
|
assert state['dust'] == 11
|
||||||
|
assert state['fine_dust'] == 9
|
||||||
|
assert state['super_fine_dust'] == 5
|
||||||
|
assert state['odor'] == 0
|
||||||
|
assert state['clean_level'] == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_filter_progress_reads_named_consumable_item():
|
||||||
|
assert _state()['filter_progress'] == 100
|
||||||
|
|
||||||
|
|
||||||
|
def test_diagnosis_reuses_dishwasher_capability():
|
||||||
|
"""/diagnosis/vs/0 has the identical field/write contract as
|
||||||
|
dishwasher.DIAGNOSIS, so the by_type registry reuses it directly."""
|
||||||
|
from custom_components.localthings.registry.capabilities import dishwasher
|
||||||
|
reg, _ = _purifier()
|
||||||
|
assert dishwasher.DIAGNOSIS in reg.capabilities['/diagnosis/vs/0']
|
||||||
|
|
||||||
|
|
||||||
|
def test_light_switch_write_contract():
|
||||||
|
"""The display-light switch RMW-replaces only the 'Light_*' entry in the
|
||||||
|
packed /mode/vs/0 options list (via laundry.replace_in_options), leaving
|
||||||
|
the other flags and the list order untouched."""
|
||||||
|
desc = next(e for e in air_purifier.MODE.entities if e.key == 'display_light')
|
||||||
|
rep = {'x.com.samsung.da.options': [
|
||||||
|
'Comode_Off', 'Blooming_0', 'Light_On', 'OptionCode_60282',
|
||||||
|
]}
|
||||||
|
assert desc.rep_fn(rep) is True
|
||||||
|
assert desc.write_fn('Off', rep) == (
|
||||||
|
['mode', 'vs', '0'],
|
||||||
|
{'x.com.samsung.da.options': [
|
||||||
|
'Comode_Off', 'Blooming_0', 'Light_Off', 'OptionCode_60282',
|
||||||
|
]},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_mode_tokens_are_read_only_diagnostics():
|
||||||
|
"""Comode_/Blooming_ tokens surface as raw diagnostic sensors rather than
|
||||||
|
a select/control -- their valid value ranges aren't confirmed yet (see
|
||||||
|
the air_purifier.py module docstring and the issue #56 follow-up)."""
|
||||||
|
operating_mode = next(e for e in air_purifier.MODE.entities if e.key == 'operating_mode')
|
||||||
|
blooming = next(e for e in air_purifier.MODE.entities if e.key == 'blooming_level')
|
||||||
|
rep = {'x.com.samsung.da.options': ['Comode_Off', 'Blooming_6']}
|
||||||
|
assert operating_mode.rep_fn(rep) == 'Off'
|
||||||
|
assert blooming.rep_fn(rep) == '6'
|
||||||
|
assert not hasattr(operating_mode, 'write_fn')
|
||||||
|
|
||||||
|
|
||||||
|
def test_airflow_vs_fallback_only_binds_without_generic():
|
||||||
|
"""/airflow/vs/0 is a match_fn fallback -- it must not bind when the
|
||||||
|
OCF-standard /airflow/0 is also present (both are on every dump seen)."""
|
||||||
|
assert air_purifier.AIRFLOW_VS_FALLBACK.match_fn(
|
||||||
|
{}, {'/airflow/0': {'speed': 0, 'direction': 'Off'}},
|
||||||
|
) is False
|
||||||
|
assert air_purifier.AIRFLOW_VS_FALLBACK.match_fn({}, {}) is True
|
||||||
@@ -39,10 +39,46 @@ def test_no_unbound_hrefs():
|
|||||||
def test_expected_entities_present():
|
def test_expected_entities_present():
|
||||||
state = _state()
|
state = _state()
|
||||||
for key in ('buzzer_sound', 'cycle', 'power_switch', 'child_lock',
|
for key in ('buzzer_sound', 'cycle', 'power_switch', 'child_lock',
|
||||||
'remote_control', 'dry_level', 'wrinkle_prevent', 'energy_kwh'):
|
'remote_control', 'dry_level', 'wrinkle_prevent', 'energy_kwh',
|
||||||
|
'ai_pattern', 'auto_cycle_link'):
|
||||||
assert key in state, key
|
assert key in state, key
|
||||||
|
|
||||||
|
|
||||||
|
def test_dry_level_is_a_writable_select():
|
||||||
|
"""dryLevel used to be a read-only sensor, but the app's "Dryness"
|
||||||
|
control (issue #14 screenshots) is a Level 1/2/3 picker, and the dump's
|
||||||
|
supportedDryLevel list confirms the device accepts writes -- it should
|
||||||
|
be a select, not a sensor."""
|
||||||
|
desc = next(e for e in dryer.DRYER_SETTINGS.entities if e.key == 'dry_level')
|
||||||
|
assert desc.options_field == 'x.com.samsung.da.supportedDryLevel'
|
||||||
|
assert desc.write_fn is not None
|
||||||
|
assert desc.write_fn('Less', {}) == (
|
||||||
|
['washer', 'vs', '0'], {'x.com.samsung.da.dryLevel': 'Less'})
|
||||||
|
assert _state()['dry_level'] == 'Normal'
|
||||||
|
|
||||||
|
|
||||||
|
def test_ai_pattern_reads_and_writes_options_token():
|
||||||
|
"""AiOption_On/Off on /course/vs/0's options[] array is the app's "AI
|
||||||
|
pattern" toggle (issue #14 screenshot: on)."""
|
||||||
|
assert _state()['ai_pattern'] is True
|
||||||
|
desc = next(e for e in dryer.DRYER_COURSE.entities if e.key == 'ai_pattern')
|
||||||
|
opts = ['Course_16', 'AiOption_On']
|
||||||
|
href, payload = desc.write_fn('Off', {'x.com.samsung.da.options': opts})
|
||||||
|
assert href == ['course', 'vs', '0']
|
||||||
|
assert 'AiOption_Off' in payload['x.com.samsung.da.options']
|
||||||
|
|
||||||
|
|
||||||
|
def test_auto_cycle_link_bound_to_cycleinterface():
|
||||||
|
"""cycleInterfaceEnabled on /cycleinterface/vs/0 is the app's "Auto cycle
|
||||||
|
link" toggle (issue #14 screenshot: off) -- previously globally ignored
|
||||||
|
as always-empty until this dump showed it populated on a dryer."""
|
||||||
|
assert dryer.AUTO_CYCLE_LINK.href == '/cycleinterface/vs/0'
|
||||||
|
assert _state()['auto_cycle_link'] is False
|
||||||
|
desc = next(e for e in dryer.AUTO_CYCLE_LINK.entities if e.key == 'auto_cycle_link')
|
||||||
|
assert desc.write_fn('On', {}) == (
|
||||||
|
['cycleinterface', 'vs', '0'], {'x.com.samsung.da.cycleInterfaceEnabled': 'On'})
|
||||||
|
|
||||||
|
|
||||||
def test_job_beginning_status_reads_current_status():
|
def test_job_beginning_status_reads_current_status():
|
||||||
"""The dump carries x.com.samsung.da.currentStatus (not the old
|
"""The dump carries x.com.samsung.da.currentStatus (not the old
|
||||||
jobBeginingStatus field the dryer descriptor used to read), so the sensor
|
jobBeginingStatus field the dryer descriptor used to read), so the sensor
|
||||||
|
|||||||
@@ -244,6 +244,20 @@ def test_registry_reproduces_golden_state_keys_for_range():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_registry_reproduces_golden_state_keys_for_air_purifier():
|
||||||
|
"""ARTIK051_TVTL_18K (issue #56) -- reports no oneUiVersion; resolved via
|
||||||
|
the '_TVTL_' modelNum token fallback in for_device_by_model."""
|
||||||
|
from tests.conftest import _load_device
|
||||||
|
resources = _load_device('air_purifier')
|
||||||
|
golden = json.loads((GOLDEN / 'air_purifier.json').read_text())
|
||||||
|
state_keys = _new_state_keys('air_purifier', resources)
|
||||||
|
assert set(state_keys) == set(golden['state_keys']), (
|
||||||
|
f"state_keys mismatch:\n"
|
||||||
|
f" extra: {sorted(set(state_keys) - set(golden['state_keys']))}\n"
|
||||||
|
f" missing: {sorted(set(golden['state_keys']) - set(state_keys))}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_registry_reproduces_golden_state_keys_for_oven():
|
def test_registry_reproduces_golden_state_keys_for_oven():
|
||||||
"""Wall oven (model TP1X_DA-KS-OVEN-0107X, issue #55) -- reports no
|
"""Wall oven (model TP1X_DA-KS-OVEN-0107X, issue #55) -- reports no
|
||||||
oneUiVersion; resolved via the '-OVEN-' modelNum token fallback in
|
oneUiVersion; resolved via the '-OVEN-' modelNum token fallback in
|
||||||
|
|||||||
@@ -68,8 +68,18 @@ class TestWasherIgnoredHrefs:
|
|||||||
'/wm/welcomemsg/vs/0',
|
'/wm/welcomemsg/vs/0',
|
||||||
'/wm/personalcourse/vs/0',
|
'/wm/personalcourse/vs/0',
|
||||||
'/energy/consumption/0',
|
'/energy/consumption/0',
|
||||||
'/cycleinterface/vs/0',
|
|
||||||
'/drlc/0',
|
'/drlc/0',
|
||||||
'/operational/state/0',
|
'/operational/state/0',
|
||||||
):
|
):
|
||||||
assert href in ignored_hrefs, f"{href} should be in ignored.IGNORED"
|
assert href in ignored_hrefs, f"{href} should be in ignored.IGNORED"
|
||||||
|
|
||||||
|
def test_cycleinterface_is_scoped_to_washer_registry(self):
|
||||||
|
"""/cycleinterface/vs/0 is empty on every washer dump but real on the
|
||||||
|
dryer (issue #14's AUTO_CYCLE_LINK), so it's a washer-scoped ignore
|
||||||
|
(washer.CYCLE_INTERFACE_IGNORED) rather than a global one -- a global
|
||||||
|
entry would collide with the dryer's real capability."""
|
||||||
|
from custom_components.localthings.registry.by_type import washer as washer_registry
|
||||||
|
from custom_components.localthings.registry.capabilities.ignored import IGNORED
|
||||||
|
|
||||||
|
assert '/cycleinterface/vs/0' not in {cap.href for cap in IGNORED}
|
||||||
|
assert '/cycleinterface/vs/0' in washer_registry.REGISTRY.capabilities
|
||||||
Reference in new issue
Block a user