Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e07d6ed706 |
No files matched your search
@@ -12,7 +12,6 @@ from typing import Any
|
|||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.core import callback
|
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers.selector import (
|
from homeassistant.helpers.selector import (
|
||||||
TextSelector,
|
TextSelector,
|
||||||
@@ -25,7 +24,6 @@ from .const import (
|
|||||||
CONF_HOST, CONF_PORT,
|
CONF_HOST, CONF_PORT,
|
||||||
CONF_CA_CERT_PEM, CONF_CA_KEY_PEM,
|
CONF_CA_CERT_PEM, CONF_CA_KEY_PEM,
|
||||||
CONF_LEAF_CERT_PEM, CONF_LEAF_KEY_PEM,
|
CONF_LEAF_CERT_PEM, CONF_LEAF_KEY_PEM,
|
||||||
CONF_BYPASS_REMOTE_CONTROL,
|
|
||||||
PROBE_PORT_RANGE, PREFERRED_PROBE_PORTS, LIVENESS_PROBE_TIMEOUT_S,
|
PROBE_PORT_RANGE, PREFERRED_PROBE_PORTS, LIVENESS_PROBE_TIMEOUT_S,
|
||||||
PROBE_GET_TIMEOUT_S,
|
PROBE_GET_TIMEOUT_S,
|
||||||
)
|
)
|
||||||
@@ -302,13 +300,6 @@ class LocalThingsConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
self._ca_key_pem: str = ""
|
self._ca_key_pem: str = ""
|
||||||
self._pending_info: dict | None = None
|
self._pending_info: dict | None = None
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
@callback
|
|
||||||
def async_get_options_flow(
|
|
||||||
config_entry: config_entries.ConfigEntry,
|
|
||||||
) -> LocalThingsOptionsFlow:
|
|
||||||
return LocalThingsOptionsFlow()
|
|
||||||
|
|
||||||
def _create_entry(self, info: dict) -> FlowResult:
|
def _create_entry(self, info: dict) -> FlowResult:
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
title=f"Samsung Appliance ({self._host})",
|
title=f"Samsung Appliance ({self._host})",
|
||||||
@@ -393,31 +384,3 @@ class LocalThingsConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
"one_ui_version": self._pending_info["one_ui_version"] or "(none reported)",
|
"one_ui_version": self._pending_info["one_ui_version"] or "(none reported)",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class LocalThingsOptionsFlow(config_entries.OptionsFlow):
|
|
||||||
"""Per-device override of the remote-control-off write block (issue
|
|
||||||
#54). The block exists because most devices reject writes outright
|
|
||||||
while remote control is off and a clear error beats a silent
|
|
||||||
device-side rejection -- but not every model actually enforces that,
|
|
||||||
so this lets a user who's confirmed their device accepts writes anyway
|
|
||||||
turn the block off for just that device rather than it being
|
|
||||||
hardcoded on for everyone."""
|
|
||||||
|
|
||||||
async def async_step_init(
|
|
||||||
self, user_input: dict[str, Any] | None = None
|
|
||||||
) -> FlowResult:
|
|
||||||
if user_input is not None:
|
|
||||||
return self.async_create_entry(data=user_input)
|
|
||||||
|
|
||||||
return self.async_show_form(
|
|
||||||
step_id="init",
|
|
||||||
data_schema=vol.Schema({
|
|
||||||
vol.Required(
|
|
||||||
CONF_BYPASS_REMOTE_CONTROL,
|
|
||||||
default=self.config_entry.options.get(
|
|
||||||
CONF_BYPASS_REMOTE_CONTROL, False
|
|
||||||
),
|
|
||||||
): bool,
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
@@ -12,16 +12,6 @@ CONF_CA_KEY_PEM = "ca_key_pem"
|
|||||||
CONF_LEAF_CERT_PEM = "leaf_cert_pem"
|
CONF_LEAF_CERT_PEM = "leaf_cert_pem"
|
||||||
CONF_LEAF_KEY_PEM = "leaf_key_pem"
|
CONF_LEAF_KEY_PEM = "leaf_key_pem"
|
||||||
|
|
||||||
# Options-flow key (entry.options, not entry.data): lets a user override the
|
|
||||||
# device-wide remote-control-off write block for a specific device (issue
|
|
||||||
# #54). Some devices report remote control off yet still accept certain
|
|
||||||
# writes (e.g. default detergent/softener dosing on a washer, applied even
|
|
||||||
# to the built-in programs) -- the block exists to give a clear error
|
|
||||||
# instead of a silent device-side rejection, but that assumption doesn't
|
|
||||||
# hold for every model. Defaults to False (block stays on) everywhere it's
|
|
||||||
# read, so devices this doesn't apply to see no behavior change.
|
|
||||||
CONF_BYPASS_REMOTE_CONTROL = "bypass_remote_control_lock"
|
|
||||||
|
|
||||||
# The DTLS/CoAP local API binds somewhere in this ephemeral range; which port
|
# The DTLS/CoAP local API binds somewhere in this ephemeral range; which port
|
||||||
# depends on firmware. Newer builds answer on 49154/49155, but older ones have
|
# depends on firmware. Newer builds answer on 49154/49155, but older ones have
|
||||||
# been seen as low as 49153, so we sweep the whole range for a live UDP port
|
# been seen as low as 49153, so we sweep the whole range for a live UDP port
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ from .observe import ObserveManager, MODE_OBSERVE, MODE_POLL, GRACE_PERIOD_S
|
|||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
DOMAIN, CONF_HOST, CONF_PORT, CONF_LEAF_CERT_PEM, CONF_LEAF_KEY_PEM,
|
DOMAIN, CONF_HOST, CONF_PORT, CONF_LEAF_CERT_PEM, CONF_LEAF_KEY_PEM,
|
||||||
CONF_BYPASS_REMOTE_CONTROL, DEVICE_SUPPORT_ISSUE_URL, SUMMARY_INTERVAL_S,
|
DEVICE_SUPPORT_ISSUE_URL, SUMMARY_INTERVAL_S,
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@@ -77,14 +77,6 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
# fine session shouldn't tear down a working OBSERVE subscription.
|
# fine session shouldn't tear down a working OBSERVE subscription.
|
||||||
_POLL_TIMEOUT_LIMIT: int = 3
|
_POLL_TIMEOUT_LIMIT: int = 3
|
||||||
|
|
||||||
# Timeouts for the two network round trips a write triggers: the PUT
|
|
||||||
# itself (_do_put), then the confirming full /device/0 summary poll
|
|
||||||
# async_send_command requests right after (_poll_once). Named here
|
|
||||||
# (rather than left as inline literals) so the write-settle window
|
|
||||||
# below can be sized to always outlast both — see async_send_command.
|
|
||||||
_POST_TIMEOUT_S: float = 8.0
|
|
||||||
_POLL_TIMEOUT_S: float = 35.0
|
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
|
def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||||
# Per-device logger (module logger scoped to this device's host) so
|
# Per-device logger (module logger scoped to this device's host) so
|
||||||
# every log line — including the base DataUpdateCoordinator's own
|
# every log line — including the base DataUpdateCoordinator's own
|
||||||
@@ -219,7 +211,7 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
# would have succeeded, not a dead session. 35s gives a slow
|
# would have succeeded, not a dead session. 35s gives a slow
|
||||||
# blockwise transfer room to actually finish instead of
|
# blockwise transfer room to actually finish instead of
|
||||||
# generating a TimeoutError every cycle.
|
# generating a TimeoutError every cycle.
|
||||||
code, payload = sess.get(_SEED_PATH, timeout=self._POLL_TIMEOUT_S)
|
code, payload = sess.get(_SEED_PATH, timeout=35.0)
|
||||||
except TimeoutError:
|
except TimeoutError:
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -534,11 +526,7 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
user-facing message -- as opposed to write_fn's silent no-op below
|
user-facing message -- as opposed to write_fn's silent no-op below
|
||||||
-- is available to every platform for free. The remote-control
|
-- is available to every platform for free. The remote-control
|
||||||
check runs first and applies to every platform unconditionally,
|
check runs first and applies to every platform unconditionally,
|
||||||
ahead of any description-specific validate_fn -- unless the user has
|
ahead of any description-specific validate_fn."""
|
||||||
opted this device out of it via CONF_BYPASS_REMOTE_CONTROL (issue
|
|
||||||
#54: some devices accept certain writes, e.g. a washer's default
|
|
||||||
dosing levels, even while reporting remote control off, so the
|
|
||||||
block's assumption doesn't hold for every model)."""
|
|
||||||
desc = bound_entity.desc
|
desc = bound_entity.desc
|
||||||
write_fn = getattr(desc, 'write_fn', None)
|
write_fn = getattr(desc, 'write_fn', None)
|
||||||
if write_fn is None:
|
if write_fn is None:
|
||||||
@@ -546,8 +534,7 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
href = bound_entity.href
|
href = bound_entity.href
|
||||||
rep = self._cache.get(href or '') or {}
|
rep = self._cache.get(href or '') or {}
|
||||||
resources = self._cache.snapshot()
|
resources = self._cache.snapshot()
|
||||||
bypass_remote_control = self._entry.options.get(CONF_BYPASS_REMOTE_CONTROL, False)
|
if not remote_control_enabled(resources):
|
||||||
if not bypass_remote_control and not remote_control_enabled(resources):
|
|
||||||
raise ServiceValidationError(_REMOTE_CONTROL_DISABLED_MESSAGE)
|
raise ServiceValidationError(_REMOTE_CONTROL_DISABLED_MESSAGE)
|
||||||
validate_fn = getattr(desc, 'validate_fn', None)
|
validate_fn = getattr(desc, 'validate_fn', None)
|
||||||
if validate_fn is not None:
|
if validate_fn is not None:
|
||||||
@@ -584,44 +571,14 @@ 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).
|
||||||
#
|
|
||||||
# settle_s must outlast the PUT and the async_request_refresh()
|
|
||||||
# below combined, not just DEFAULT_SETTLE_S's fixed few seconds --
|
|
||||||
# that refresh is a full /device/0 summary poll, which
|
|
||||||
# _POLL_TIMEOUT_S itself admits can legitimately take tens of
|
|
||||||
# seconds on these devices (see _poll_once), and some writes settle
|
|
||||||
# on the device itself well after that: issue #9's washer packs
|
|
||||||
# cycle/detergent/softener selection into the same /course/vs/0
|
|
||||||
# options[] array, and picking a new value there visibly needs a
|
|
||||||
# few seconds of internal validation/dispenser movement before the
|
|
||||||
# device's own state agrees -- while /washer/vs/0's temperature/
|
|
||||||
# spin fields (plain flags, no device-side settling) confirm
|
|
||||||
# instantly on the same device. A short fixed window expired while
|
|
||||||
# the confirm poll was still in flight (or before the device had
|
|
||||||
# caught up internally), so that stale read landed unprotected and
|
|
||||||
# reverted the optimistic value, self-correcting again only once a
|
|
||||||
# later poll finally saw the real change -- read by the user as the
|
|
||||||
# write "reverting, then re-applying itself" a few seconds later.
|
|
||||||
#
|
|
||||||
# An earlier attempt at this also released the guard early, right
|
|
||||||
# after the confirming refresh completed, to avoid shutting out
|
|
||||||
# unrelated real updates (another automation, the physical remote)
|
|
||||||
# for the rest of settle_s. That was reverted: releasing the guard
|
|
||||||
# the moment one round trip finishes doesn't mean the device has
|
|
||||||
# actually caught up (exactly the slow-settling case above), and it
|
|
||||||
# introduced its own races around overlapping writes to the same
|
|
||||||
# href. Simpler and safer to just hold the guard for the full,
|
|
||||||
# generously-sized window and let it expire on its own.
|
|
||||||
self._observe.apply(write_href, body, source='optimistic')
|
self._observe.apply(write_href, body, source='optimistic')
|
||||||
self._observe.mark_write_pending(
|
self._observe.mark_write_pending(write_href)
|
||||||
write_href, settle_s=self._POST_TIMEOUT_S + self._POLL_TIMEOUT_S
|
|
||||||
)
|
|
||||||
|
|
||||||
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=self._POST_TIMEOUT_S)
|
code, _ = sess.post(path_segs, cbor2.dumps(body), timeout=8.0)
|
||||||
self._log.info("PUT %s → code %#04x", write_href, code)
|
self._log.info("PUT %s → code %#04x", write_href, code)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -66,30 +66,12 @@ class LocalThingsEntity(CoordinatorEntity[LocalThingsCoordinator]):
|
|||||||
self._attr_name = f"{bound.instance_name} {_derive_name(bound.desc.key)}".strip()
|
self._attr_name = f"{bound.instance_name} {_derive_name(bound.desc.key)}".strip()
|
||||||
else:
|
else:
|
||||||
self._attr_name = _derive_name(self._state_key)
|
self._attr_name = _derive_name(self._state_key)
|
||||||
|
self._attr_translation_key = bound.desc.translation_key
|
||||||
self._attr_icon = bound.desc.icon
|
self._attr_icon = bound.desc.icon
|
||||||
raw_cat = bound.desc.entity_category
|
raw_cat = bound.desc.entity_category
|
||||||
self._attr_entity_category = EntityCategory(raw_cat) if raw_cat else None
|
self._attr_entity_category = EntityCategory(raw_cat) if raw_cat else None
|
||||||
self._attr_entity_registry_enabled_default = bound.desc.enabled_default
|
self._attr_entity_registry_enabled_default = bound.desc.enabled_default
|
||||||
|
|
||||||
@property
|
|
||||||
def translation_key(self) -> str | None:
|
|
||||||
"""Override Entity.translation_key (a property upstream, not a
|
|
||||||
plain attribute) so a callable descriptor -- e.g.
|
|
||||||
laundry.cycle_select's table-id-gated resolver -- is re-evaluated
|
|
||||||
against live coordinator data on every access, not resolved once
|
|
||||||
at construction time.
|
|
||||||
|
|
||||||
Discovery runs on the first /device/0 poll, which the entity
|
|
||||||
registry already documents can hand a sibling resource an empty
|
|
||||||
stub rep before it's actually been fetched (see _is_included's
|
|
||||||
docstring) -- a static one-time resolution here would risk baking
|
|
||||||
in a permanent None (no translation) for the entity's whole
|
|
||||||
lifetime if that stub hadn't populated yet, even once the real
|
|
||||||
value arrives on a later poll.
|
|
||||||
"""
|
|
||||||
tk = self._bound.desc.translation_key
|
|
||||||
return tk(self.coordinator.last_resources) if callable(tk) else tk
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
return self.coordinator.device_info
|
return self.coordinator.device_info
|
||||||
@@ -12,5 +12,5 @@
|
|||||||
"pyOpenSSL>=23.0",
|
"pyOpenSSL>=23.0",
|
||||||
"smartthings-local>=0.1.0"
|
"smartthings-local>=0.1.0"
|
||||||
],
|
],
|
||||||
"version": "0.11.1"
|
"version": "0.10.1"
|
||||||
}
|
}
|
||||||
@@ -115,22 +115,8 @@ class ObserveManager:
|
|||||||
could each read the same prior rep and the second writer would
|
could each read the same prior rep and the second writer would
|
||||||
silently lose the first's fields, reintroducing the exact bug
|
silently lose the first's fields, reintroducing the exact bug
|
||||||
this merge fixes.
|
this merge fixes.
|
||||||
|
|
||||||
`source == 'optimistic'` always bypasses the settle gate below,
|
|
||||||
even while this href is already settling from an earlier write.
|
|
||||||
Several independent selects can share one href -- issue #9's washer
|
|
||||||
packs cycle, detergent, and softener settings onto the same
|
|
||||||
/course/vs/0 -- so a second, different write to the same href
|
|
||||||
while the first's settle window is still open (up to
|
|
||||||
_POST_TIMEOUT_S + _POLL_TIMEOUT_S, tens of seconds -- see
|
|
||||||
coordinator.async_send_command) is an expected, normal sequence,
|
|
||||||
not a stale echo of the first write. Gating it the same as a
|
|
||||||
poll/sweep/observe update would silently drop the user's own
|
|
||||||
second selection from the cache until the first write's guard
|
|
||||||
happened to expire, i.e. the exact symptom this guard exists to
|
|
||||||
prevent, just relocated to whichever write loses the race.
|
|
||||||
"""
|
"""
|
||||||
if source != 'optimistic' and self._is_settling(href):
|
if self._is_settling(href):
|
||||||
self.log.debug("dropping %s update for %s (settling)", source, href)
|
self.log.debug("dropping %s update for %s (settling)", source, href)
|
||||||
return False
|
return False
|
||||||
with self._cache_lock:
|
with self._cache_lock:
|
||||||
|
|||||||
@@ -113,15 +113,6 @@ 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'
|
||||||
# System air conditioners (multi-indoor-unit commercial installs, e.g.
|
|
||||||
# A-CAWW-TP2-20-COMMON, issue #52) report no oneUiVersion either and
|
|
||||||
# carry the '-CAWW-' board-family token instead of '_RAC_'/'_PRAC_'.
|
|
||||||
# Same TP1X/TP2X-class resource surface as the room-AC models above
|
|
||||||
# (confirmed by the issue #52 dump binding cleanly against the existing
|
|
||||||
# airconditioner registry once routed here), plus one new SAC-specific
|
|
||||||
# resource (see airconditioner.py's _AC_IGNORED).
|
|
||||||
if key is None and '-CAWW-' in (model_num or '').upper():
|
|
||||||
key = 'airconditioner'
|
|
||||||
# Air purifiers (e.g. ARTIK051_TVTL_18K, issue #56) report no
|
# Air purifiers (e.g. ARTIK051_TVTL_18K, issue #56) report no
|
||||||
# oneUiVersion either, and carry the '_TVTL_' board-family token.
|
# oneUiVersion either, and carry the '_TVTL_' board-family token.
|
||||||
if key is None and '_TVTL_' in (model_num or ''):
|
if key is None and '_TVTL_' in (model_num or ''):
|
||||||
|
|||||||
@@ -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,
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
@@ -243,11 +243,6 @@ _AC_IGNORED = [
|
|||||||
'/remotetemperature/vs/0', # external temp-sensor feed (unset on this unit)
|
'/remotetemperature/vs/0', # external temp-sensor feed (unset on this unit)
|
||||||
'/reserverulesets/vs/0', # opaque hex-encoded schedule reservation blob
|
'/reserverulesets/vs/0', # opaque hex-encoded schedule reservation blob
|
||||||
'/welcome/temperature/vs/0', # welcome-cooling plumbing
|
'/welcome/temperature/vs/0', # welcome-cooling plumbing
|
||||||
# System-AC-only (multi-indoor-unit commercial installs, e.g.
|
|
||||||
# A-CAWW-TP2-20-COMMON, issue #52): opaque hex-encoded installation
|
|
||||||
# topology -- indoor/outdoor unit pairing, per-unit serials, MCU info.
|
|
||||||
# Commissioning-time plumbing, not user-actionable appliance state.
|
|
||||||
'/sac/installationinfo/vs/0',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Built as bare no-entity caps; folded into the AC registry (not global).
|
# Built as bare no-entity caps; folded into the AC registry (not global).
|
||||||
|
|||||||
@@ -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,16 +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'),
|
||||||
table_href='/st/dryercourse/vs/0'),
|
bool_option_switch('ai_pattern', 'AI pattern', 'mdi:creation', 'AiOption',
|
||||||
|
entity_category='config', gate_on_presence=True),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -61,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)
|
||||||
|
|||||||
@@ -157,11 +157,6 @@ BUZZER_SOUND = Capability(
|
|||||||
# washer.py's course comment has the byte-level evidence for why the options[]
|
# washer.py's course comment has the byte-level evidence for why the options[]
|
||||||
# MostUsed_* entry is *not* a trustworthy second source.
|
# MostUsed_* entry is *not* a trustworthy second source.
|
||||||
#
|
#
|
||||||
# Some boards populate /wm/editcourse/vs/0 without ever filling in
|
|
||||||
# editCourseList itself (issue #1) -- cycle_options() falls back to deriving
|
|
||||||
# the same list from /course/vs/0's own supportedOptions in that case; see
|
|
||||||
# _course_codes_from_supported_options for the byte-level evidence.
|
|
||||||
#
|
|
||||||
# Shared verbatim by washer, dishwasher, and dryer -- all DA_WM_-family boards
|
# Shared verbatim by washer, dishwasher, and dryer -- all DA_WM_-family boards
|
||||||
# expose the same /course/vs/0 options contract.
|
# expose the same /course/vs/0 options contract.
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@@ -181,10 +176,7 @@ def parse_edit_course_list(raw):
|
|||||||
|
|
||||||
def cycle_options(resources):
|
def cycle_options(resources):
|
||||||
rep = resources.get('/wm/editcourse/vs/0') or {}
|
rep = resources.get('/wm/editcourse/vs/0') or {}
|
||||||
codes = parse_edit_course_list(rep.get('x.com.samsung.da.editCourseList'))
|
return parse_edit_course_list(rep.get('x.com.samsung.da.editCourseList'))
|
||||||
if codes:
|
|
||||||
return codes
|
|
||||||
return _course_codes_from_supported_options(resources.get('/course/vs/0') or {})
|
|
||||||
|
|
||||||
|
|
||||||
def option_value(options, prefix):
|
def option_value(options, prefix):
|
||||||
@@ -195,68 +187,6 @@ def option_value(options, prefix):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _course_codes_from_supported_options(course_rep):
|
|
||||||
"""Fallback for an empty/missing editCourseList: derive the selectable
|
|
||||||
course list from /course/vs/0's own x.com.samsung.da.supportedOptions
|
|
||||||
instead (issue #1: some DA_WM_TP1/TP2-class boards populate the
|
|
||||||
/wm/editcourse/vs/0 href but never fill in editCourseList itself).
|
|
||||||
|
|
||||||
supportedOptions is a 1-hex-nibble header followed by one fixed-width
|
|
||||||
record per selectable course, self-indexed rather than positional --
|
|
||||||
the first byte of every record is that course's own hex code, just in
|
|
||||||
the firmware's own internal order, not editCourseList's. Confirmed
|
|
||||||
against six independent real-world washer/dryer/dishwasher dumps: every
|
|
||||||
one divides evenly into `header + N * K bytes` with fully unique first
|
|
||||||
bytes across all N records, at the record's true byte width. (What the
|
|
||||||
rest of each record encodes is still unconfirmed -- this only uses the
|
|
||||||
course-code byte.)
|
|
||||||
|
|
||||||
Two guards, deliberately conservative rather than guessing further: the
|
|
||||||
derived codes must (a) all be distinct -- a real course table, not
|
|
||||||
noise -- and (b) include whatever course is currently selected
|
|
||||||
(x.com.samsung.da.options' Course_<code> token), which must always be a
|
|
||||||
member of its own device's valid list. If no split satisfies both, this
|
|
||||||
returns [] rather than guess.
|
|
||||||
|
|
||||||
Among splits that satisfy both, the *smallest* passing K wins, rather
|
|
||||||
than requiring a single unambiguous one -- more than one K reliably
|
|
||||||
does pass on real data (e.g. the shipped dishwasher fixture: true
|
|
||||||
K=7 passes, but so do 10, 14, and 35, none of which are multiples of
|
|
||||||
7 -- position 0 always lands on the same real course code regardless
|
|
||||||
of K, which is enough on its own to satisfy the current-course guard
|
|
||||||
for several unrelated splits). Smallest-K-wins is a heuristic, not a
|
|
||||||
proof: it matches the confirmed answer on every one of six independent
|
|
||||||
real-world dumps this was checked against, but a coincidentally
|
|
||||||
unique, current-course-inclusive *smaller* K is not mathematically
|
|
||||||
impossible on some future device, and would be picked silently. Not
|
|
||||||
guarded against further here, since course tables are typically large
|
|
||||||
enough (double digits) that colliding by chance on both checks is
|
|
||||||
unlikely, and no device seen so far actually needs it.
|
|
||||||
"""
|
|
||||||
raw = course_rep.get('x.com.samsung.da.supportedOptions')
|
|
||||||
hexstr = raw[0] if isinstance(raw, list) and raw else raw
|
|
||||||
if not isinstance(hexstr, str) or len(hexstr) < 3:
|
|
||||||
return []
|
|
||||||
body = hexstr[1:]
|
|
||||||
if len(body) % 2:
|
|
||||||
return []
|
|
||||||
total_bytes = len(body) // 2
|
|
||||||
current = option_value(course_rep.get('x.com.samsung.da.options'), 'Course')
|
|
||||||
for k in range(1, total_bytes + 1):
|
|
||||||
if total_bytes % k:
|
|
||||||
continue
|
|
||||||
n = total_bytes // k
|
|
||||||
if n < 2:
|
|
||||||
continue
|
|
||||||
firsts = [body[i * k * 2:i * k * 2 + 2] for i in range(n)]
|
|
||||||
if len(set(firsts)) != n:
|
|
||||||
continue
|
|
||||||
if current is not None and current not in firsts:
|
|
||||||
continue
|
|
||||||
return firsts
|
|
||||||
return []
|
|
||||||
|
|
||||||
|
|
||||||
def replace_in_options(options, prefix, new_value):
|
def replace_in_options(options, prefix, new_value):
|
||||||
return [f"{prefix}_{new_value}" if isinstance(o, str) and o.startswith(prefix + '_') else o
|
return [f"{prefix}_{new_value}" if isinstance(o, str) and o.startswith(prefix + '_') else o
|
||||||
for o in options]
|
for o in options]
|
||||||
@@ -271,53 +201,15 @@ def cycle_write(p, rep, href=None):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def _table_id(resources, table_href):
|
def cycle_select(*, translation_key, icon):
|
||||||
rep = resources.get(table_href) or {}
|
|
||||||
return rep.get('x.com.samsung.da.st.courseTable')
|
|
||||||
|
|
||||||
|
|
||||||
def cycle_select(*, translation_key, icon, table_href=None):
|
|
||||||
"""A 'Cycle' select over /course/vs/0, labelled from `translation_key`.
|
"""A 'Cycle' select over /course/vs/0, labelled from `translation_key`.
|
||||||
|
|
||||||
The option list, current value, and write path are all shared across
|
The caller supplies the family's translation key (washer_cycle /
|
||||||
washer/dryer/dishwasher; only the translation is family- (and, for
|
dishwasher_cycle / dryer_cycle) and icon; the option list, current value,
|
||||||
washer/dryer, board-) specific.
|
and write path are all shared.
|
||||||
|
|
||||||
table_href (washer/dryer only -- see washer.py/dryer.py's call sites)
|
|
||||||
suffixes translation_key with the device's own course-table id, read
|
|
||||||
from /st/washercourse/vs/0 or /st/dryercourse/vs/0's
|
|
||||||
x.com.samsung.da.st.courseTable (e.g. 'washer_cycle' + 'Table_02' ->
|
|
||||||
'washer_cycle_table_02'). No table id available at all -- the href
|
|
||||||
absent or empty -- gets no translation_key, i.e. the raw course code
|
|
||||||
displayed as-is.
|
|
||||||
|
|
||||||
This matters because course codes are NOT guaranteed consistent across
|
|
||||||
board generations sharing the same /course/vs/0 contract: every code in
|
|
||||||
washer_cycle_table_02 was confirmed against Table_02-reporting devices
|
|
||||||
(DA_WM_TP1/TP2 boards); FlexWash's older DA_WM_A51 board reports
|
|
||||||
Table_00 instead, so the same hex code could mean a different course
|
|
||||||
there for all we've verified. Building the key from whatever table the
|
|
||||||
device actually reports, rather than gating a single hardcoded key on
|
|
||||||
an exact match, means a table we haven't built translations for yet
|
|
||||||
(like Table_00) just falls through Home Assistant's own missing-
|
|
||||||
translation handling to the same raw-code display -- exactly what
|
|
||||||
happens today for any individual code within a table's translations
|
|
||||||
that isn't populated yet -- and adding one later needs new strings.json
|
|
||||||
entries, not a code change here.
|
|
||||||
|
|
||||||
Left at its default for dishwasher, which has no equivalent table-id
|
|
||||||
resource in any dump seen and no evidence its course codes vary by
|
|
||||||
table the way washer/dryer's do -- there's nothing to build a
|
|
||||||
table-specific key from.
|
|
||||||
"""
|
"""
|
||||||
key = translation_key
|
|
||||||
if table_href is not None:
|
|
||||||
def key(resources):
|
|
||||||
table = _table_id(resources, table_href)
|
|
||||||
return f'{translation_key}_{table.lower()}' if table else None
|
|
||||||
|
|
||||||
return SelectDesc(
|
return SelectDesc(
|
||||||
key='cycle', name='Cycle', icon=icon, translation_key=key,
|
key='cycle', name='Cycle', icon=icon, translation_key=translation_key,
|
||||||
options=cycle_options,
|
options=cycle_options,
|
||||||
exists_fn=lambda rep, resources: bool(cycle_options(resources)),
|
exists_fn=lambda rep, resources: bool(cycle_options(resources)),
|
||||||
rep_fn=lambda rep: option_value(rep.get('x.com.samsung.da.options'), 'Course'),
|
rep_fn=lambda rep: option_value(rep.get('x.com.samsung.da.options'), 'Course'),
|
||||||
|
|||||||
@@ -293,8 +293,7 @@ def _bool_option_switch(key, name, icon, prefix, availability_field):
|
|||||||
WASHER_COURSE = Capability(
|
WASHER_COURSE = Capability(
|
||||||
href='/course/vs/0',
|
href='/course/vs/0',
|
||||||
entities=(
|
entities=(
|
||||||
cycle_select(translation_key='washer_cycle', icon='mdi:washing-machine',
|
cycle_select(translation_key='washer_cycle', icon='mdi:washing-machine'),
|
||||||
table_href='/st/washercourse/vs/0'),
|
|
||||||
SensorDesc(key='drum_clean_cycles_remaining', name='Drum clean due in',
|
SensorDesc(key='drum_clean_cycles_remaining', name='Drum clean due in',
|
||||||
icon='mdi:washing-machine-alert', unit='cycles',
|
icon='mdi:washing-machine-alert', unit='cycles',
|
||||||
state_class='measurement',
|
state_class='measurement',
|
||||||
@@ -355,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')
|
||||||
@@ -28,12 +28,7 @@ class SamsungEntityDescription:
|
|||||||
key: str
|
key: str
|
||||||
field: str = ''
|
field: str = ''
|
||||||
name: Optional[str] = None
|
name: Optional[str] = None
|
||||||
translation_key: Any = None # str | Callable[[dict[str, dict]], Optional[str]]
|
translation_key: Optional[str] = None
|
||||||
# callable form receives the coordinator's full href->rep resource
|
|
||||||
# snapshot and returns the key to use (or None for no translation this
|
|
||||||
# device) -- for a descriptor shared across board generations whose
|
|
||||||
# state-code meaning isn't guaranteed consistent between them; see
|
|
||||||
# laundry.cycle_select's table-id-gated resolver.
|
|
||||||
icon: Optional[str] = None
|
icon: Optional[str] = None
|
||||||
entity_category: Optional[str] = None # 'diagnostic' | 'config' | None
|
entity_category: Optional[str] = None # 'diagnostic' | 'config' | None
|
||||||
enabled_default: bool = True
|
enabled_default: bool = True
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from homeassistant.components.select import SelectEntity
|
from homeassistant.components.select import SelectEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@@ -32,14 +31,9 @@ async def async_setup_entry(
|
|||||||
_CAMEL_BOUNDARY_RE = re.compile(r'(?<=[a-z0-9])(?=[A-Z])')
|
_CAMEL_BOUNDARY_RE = re.compile(r'(?<=[a-z0-9])(?=[A-Z])')
|
||||||
|
|
||||||
|
|
||||||
def _display(value, translation_key: Optional[str]):
|
def _display(value, desc: SelectDesc):
|
||||||
"""Turn a raw device option/state value into what's shown in the UI.
|
"""Turn a raw device option/state value into what's shown in the UI.
|
||||||
|
|
||||||
`translation_key` is the entity's already-resolved key (SelectDesc.
|
|
||||||
translation_key can itself be a callable -- see entities.py -- so
|
|
||||||
callers pass the resolved value, e.g. self.translation_key, not
|
|
||||||
the raw descriptor field).
|
|
||||||
|
|
||||||
An entity with a translation_key looks its state up in strings.json,
|
An entity with a translation_key looks its state up in strings.json,
|
||||||
and hassfest requires those keys to be lowercase -- so those values
|
and hassfest requires those keys to be lowercase -- so those values
|
||||||
must be lowercased exactly to match, and the device still expects
|
must be lowercased exactly to match, and the device still expects
|
||||||
@@ -56,7 +50,7 @@ def _display(value, translation_key: Optional[str]):
|
|||||||
"""
|
"""
|
||||||
if not isinstance(value, str):
|
if not isinstance(value, str):
|
||||||
return value
|
return value
|
||||||
if translation_key:
|
if desc.translation_key:
|
||||||
return value.lower()
|
return value.lower()
|
||||||
if value.islower():
|
if value.islower():
|
||||||
return value.replace('_', ' ').title()
|
return value.replace('_', ' ').title()
|
||||||
@@ -69,7 +63,7 @@ class LocalThingsSelect(LocalThingsEntity, SelectEntity):
|
|||||||
super().__init__(coordinator, bound)
|
super().__init__(coordinator, bound)
|
||||||
desc: SelectDesc = bound.desc
|
desc: SelectDesc = bound.desc
|
||||||
if not desc.options_field and not callable(desc.options):
|
if not desc.options_field and not callable(desc.options):
|
||||||
self._attr_options = [_display(o, self.translation_key) for o in desc.options]
|
self._attr_options = [_display(o, desc) for o in desc.options]
|
||||||
|
|
||||||
def _raw_options(self) -> list[str]:
|
def _raw_options(self) -> list[str]:
|
||||||
desc: SelectDesc = self._bound.desc
|
desc: SelectDesc = self._bound.desc
|
||||||
@@ -89,17 +83,17 @@ class LocalThingsSelect(LocalThingsEntity, SelectEntity):
|
|||||||
def options(self) -> list[str]:
|
def options(self) -> list[str]:
|
||||||
desc: SelectDesc = self._bound.desc
|
desc: SelectDesc = self._bound.desc
|
||||||
if desc.options_field or callable(desc.options):
|
if desc.options_field or callable(desc.options):
|
||||||
return [_display(o, self.translation_key) for o in self._raw_options()]
|
return [_display(o, desc) for o in self._raw_options()]
|
||||||
return self._attr_options
|
return self._attr_options
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_option(self):
|
def current_option(self):
|
||||||
raw = (self.coordinator.data or {}).get(self._state_key)
|
raw = (self.coordinator.data or {}).get(self._state_key)
|
||||||
return _display(raw, self.translation_key)
|
return _display(raw, self._bound.desc)
|
||||||
|
|
||||||
async def async_select_option(self, option: str) -> None:
|
async def async_select_option(self, option: str) -> None:
|
||||||
|
desc: SelectDesc = self._bound.desc
|
||||||
raw = next(
|
raw = next(
|
||||||
(o for o in self._raw_options() if _display(o, self.translation_key) == option),
|
(o for o in self._raw_options() if _display(o, desc) == option), option
|
||||||
option,
|
|
||||||
)
|
)
|
||||||
await self.coordinator.async_send_command(self._bound, raw)
|
await self.coordinator.async_send_command(self._bound, raw)
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
"8f": "Baby Care"
|
"8f": "Baby Care"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"washer_cycle_table_02": {
|
"washer_cycle": {
|
||||||
"state": {
|
"state": {
|
||||||
"1c": "Eco 40-60",
|
"1c": "Eco 40-60",
|
||||||
"1d": "Super Speed",
|
"1d": "Super Speed",
|
||||||
@@ -103,7 +103,7 @@
|
|||||||
"1f": "Intense Cold"
|
"1f": "Intense Cold"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dryer_cycle_table_03": {
|
"dryer_cycle": {
|
||||||
"state": {
|
"state": {
|
||||||
"16": "Cotton",
|
"16": "Cotton",
|
||||||
"18": "Synthetics",
|
"18": "Synthetics",
|
||||||
@@ -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": {
|
||||||
@@ -246,17 +248,6 @@
|
|||||||
"already_configured": "This device is already configured."
|
"already_configured": "This device is already configured."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"options": {
|
|
||||||
"step": {
|
|
||||||
"init": {
|
|
||||||
"title": "Local Things Options",
|
|
||||||
"description": "Some devices accept certain writes (e.g. default detergent/softener dosing on a washer) even while reporting remote control off. By default, LocalThings blocks every write with a clear error whenever a device reports remote control off, rather than letting the device silently reject it. Only enable this if you've confirmed writes actually work on this device with remote control off -- otherwise you'll trade that clear error for a silent failure.",
|
|
||||||
"data": {
|
|
||||||
"bypass_remote_control_lock": "Allow writes even when remote control is reported off"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"issues": {
|
"issues": {
|
||||||
"device_gap": {
|
"device_gap": {
|
||||||
"title": "Incomplete capability coverage for {device_name}",
|
"title": "Incomplete capability coverage for {device_name}",
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
"8f": "Baby Care"
|
"8f": "Baby Care"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"washer_cycle_table_02": {
|
"washer_cycle": {
|
||||||
"state": {
|
"state": {
|
||||||
"1c": "Eco 40-60",
|
"1c": "Eco 40-60",
|
||||||
"1d": "Super Speed",
|
"1d": "Super Speed",
|
||||||
@@ -103,7 +103,7 @@
|
|||||||
"1f": "Intense Cold"
|
"1f": "Intense Cold"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dryer_cycle_table_03": {
|
"dryer_cycle": {
|
||||||
"state": {
|
"state": {
|
||||||
"16": "Cotton",
|
"16": "Cotton",
|
||||||
"18": "Synthetics",
|
"18": "Synthetics",
|
||||||
@@ -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": {
|
||||||
@@ -246,17 +248,6 @@
|
|||||||
"already_configured": "This device is already configured."
|
"already_configured": "This device is already configured."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"options": {
|
|
||||||
"step": {
|
|
||||||
"init": {
|
|
||||||
"title": "Local Things Options",
|
|
||||||
"description": "Some devices accept certain writes (e.g. default detergent/softener dosing on a washer) even while reporting remote control off. By default, LocalThings blocks every write with a clear error whenever a device reports remote control off, rather than letting the device silently reject it. Only enable this if you've confirmed writes actually work on this device with remote control off -- otherwise you'll trade that clear error for a silent failure.",
|
|
||||||
"data": {
|
|
||||||
"bypass_remote_control_lock": "Allow writes even when remote control is reported off"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"issues": {
|
"issues": {
|
||||||
"device_gap": {
|
"device_gap": {
|
||||||
"title": "Incomplete capability coverage for {device_name}",
|
"title": "Incomplete capability coverage for {device_name}",
|
||||||
|
|||||||
-486
@@ -1,486 +0,0 @@
|
|||||||
{
|
|
||||||
"device0": [
|
|
||||||
{
|
|
||||||
"rt": [
|
|
||||||
"x.com.samsung.devcol",
|
|
||||||
"oic.wk.col"
|
|
||||||
],
|
|
||||||
"if": [
|
|
||||||
"oic.if.baseline",
|
|
||||||
"oic.if.ll",
|
|
||||||
"oic.if.b"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/aisleep/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.da.displayNightMode": "Off",
|
|
||||||
"x.com.samsung.da.elapsedTime": "0",
|
|
||||||
"x.com.samsung.da.requestFeedback": "Off",
|
|
||||||
"x.com.samsung.da.resultFeedback": "0",
|
|
||||||
"x.com.samsung.da.statusFeedback": "Idle",
|
|
||||||
"x.com.samsung.da.sleepTime": "14002200",
|
|
||||||
"x.com.samsung.da.sleepMode": "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-23T05:13:21",
|
|
||||||
"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_OFF",
|
|
||||||
"x.com.samsung.da.triggeredTime": "2026-07-23T05:13:21",
|
|
||||||
"x.com.samsung.da.state": "Deleted"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/availablecontrolsets/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.da.sets": "000100B4012C0000120000000000",
|
|
||||||
"x.com.samsung.da.id": "CAC",
|
|
||||||
"x.com.samsung.da.version": "1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/configuration/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.da.region": "4131000000",
|
|
||||||
"x.com.samsung.da.airconOptionList": [
|
|
||||||
"DR",
|
|
||||||
"SingleCommand_1.0",
|
|
||||||
"AI_2.0"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/diagnosis/vs/0",
|
|
||||||
"rep": {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/drlc/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.da.drlcLevel": "0",
|
|
||||||
"x.com.samsung.da.durationminutes": "0",
|
|
||||||
"x.com.samsung.da.start": "1970-01-01T00:00:00Z",
|
|
||||||
"x.com.samsung.da.override": "Off",
|
|
||||||
"x.com.samsung.da.realSaving": "Off"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/energy/consumption/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.da.instantaneousPower": "153.000000",
|
|
||||||
"x.com.samsung.da.cumulativePower": "239209",
|
|
||||||
"x.com.samsung.da.cumulativeSavedPower": "7201",
|
|
||||||
"x.com.samsung.da.cumulativeUnit": "Wh",
|
|
||||||
"x.com.samsung.da.instantaneousPowerUnit": "W",
|
|
||||||
"x.com.samsung.da.cumulativePowerType": "total",
|
|
||||||
"x.com.samsung.da.saveLocation": "/mnt/usage.db"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/file/information/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.timeoffset": "+09:00",
|
|
||||||
"x.com.samsung.supprtedtype": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/filter/airdustfilter/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.da.filterUsage": "85",
|
|
||||||
"x.com.samsung.da.filterUsageResolution": "1",
|
|
||||||
"x.com.samsung.da.filterStatus": "normal",
|
|
||||||
"x.com.samsung.da.filterCapacity": "1000",
|
|
||||||
"x.com.samsung.da.filterCapacityUnit": "Hour",
|
|
||||||
"x.com.samsung.da.filterResetType": [
|
|
||||||
"replaceable",
|
|
||||||
"washable"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/humidity/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.da.humidity": "0.000000",
|
|
||||||
"x.com.samsung.da.fivepercentHumidity": "83"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/information/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.da.modelNum": "A-CAWW-TP2-20-COMMON|10241941|600301170016110B40000F2000F2AD00",
|
|
||||||
"x.com.samsung.da.description": "A-CAWW-TP2-20-COMMON",
|
|
||||||
"x.com.samsung.da.serialNum": "**REDACTED**",
|
|
||||||
"x.com.samsung.da.otnDUID": "**REDACTED**",
|
|
||||||
"x.com.samsung.da.diagProtocolType": "WIFI_HTTPS",
|
|
||||||
"x.com.samsung.da.diagLogType": [
|
|
||||||
"errCode",
|
|
||||||
"dump"
|
|
||||||
],
|
|
||||||
"x.com.samsung.da.diagDumpType": "file",
|
|
||||||
"x.com.samsung.da.diagEndPoint": "SSM",
|
|
||||||
"x.com.samsung.da.diagMnid": "0AJT",
|
|
||||||
"x.com.samsung.da.diagSetupid": "023",
|
|
||||||
"x.com.samsung.da.diagMinVersion": "1.0",
|
|
||||||
"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": "02274A260512",
|
|
||||||
"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": "02419A25051901,FFFFFFFFFFFFFF",
|
|
||||||
"x.com.samsung.da.newVersionAvailable": "0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"x.com.samsung.da.id": "2",
|
|
||||||
"x.com.samsung.da.description": "Version",
|
|
||||||
"x.com.samsung.da.type": "Outdoor",
|
|
||||||
"x.com.samsung.da.number": "FFFFFFFFFFFFFF,FFFFFFFFFFFFFF"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/keepnormalstate/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.da.keepnormal": 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/mode/convenient/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.da.modes": "Off",
|
|
||||||
"x.com.samsung.da.supportedModes": [
|
|
||||||
"Off",
|
|
||||||
"Nano",
|
|
||||||
"LongWind",
|
|
||||||
"Speed",
|
|
||||||
"Sleep",
|
|
||||||
"NanoSleep"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/mode/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.da.workingMode": "Auto",
|
|
||||||
"x.com.samsung.da.supportedModes": [
|
|
||||||
"Auto",
|
|
||||||
"Cool",
|
|
||||||
"Dry",
|
|
||||||
"Fan",
|
|
||||||
"AIComfort"
|
|
||||||
],
|
|
||||||
"x.com.samsung.da.modes": [
|
|
||||||
"Auto"
|
|
||||||
],
|
|
||||||
"x.com.samsung.da.options": [
|
|
||||||
"Sleep_0",
|
|
||||||
"ArtificialWorking_Off",
|
|
||||||
"ComfortAICooling_Off",
|
|
||||||
"AiTempChanged_Off",
|
|
||||||
"AiTemp_240",
|
|
||||||
"OutdoorTemp_82",
|
|
||||||
"Light_Off",
|
|
||||||
"Volume_100",
|
|
||||||
"KeyInputPermit_On",
|
|
||||||
"ModePermit_NoLimit",
|
|
||||||
"UpdateAllow_NotAllowed",
|
|
||||||
"DurationOn_419",
|
|
||||||
"WelcomeCoolingState_Off"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/option/autoclean/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.da.status": "Stop",
|
|
||||||
"x.com.samsung.da.settingStatus": "On",
|
|
||||||
"x.com.samsung.da.progress": "0",
|
|
||||||
"x.com.samsung.da.supportedStatus": [
|
|
||||||
"Start",
|
|
||||||
"Stop"
|
|
||||||
],
|
|
||||||
"x.com.samsung.da.supportedSettingStatus": [
|
|
||||||
"On",
|
|
||||||
"Off"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/option/muteonce/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"muteonce": "Off"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/otninformation/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.da.target": "",
|
|
||||||
"x.com.samsung.da.newVersionAvailable": "false",
|
|
||||||
"x.com.samsung.da.newVersionNo": "00000000",
|
|
||||||
"x.com.samsung.da.currentVersionInfo": "00000000",
|
|
||||||
"otnStatus": "None",
|
|
||||||
"flashingProgress": "",
|
|
||||||
"otnTarget": "main",
|
|
||||||
"otnCompleteDate": "noHistory",
|
|
||||||
"otnList": [
|
|
||||||
{
|
|
||||||
"type": "WIFI",
|
|
||||||
"modelId": "A-CAWW-TP2-20-COMMON",
|
|
||||||
"versions": [
|
|
||||||
"14260512"
|
|
||||||
],
|
|
||||||
"visVersion": "260512"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Micom",
|
|
||||||
"modelId": "040010241941FFFFFFFF",
|
|
||||||
"versions": [
|
|
||||||
"25051901",
|
|
||||||
"FFFFFFFF"
|
|
||||||
],
|
|
||||||
"visVersion": "250519"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Micom",
|
|
||||||
"modelId": "0400FFFFFFFFFFFFFFFF",
|
|
||||||
"versions": [
|
|
||||||
"FFFFFFFF",
|
|
||||||
"FFFFFFFF"
|
|
||||||
],
|
|
||||||
"visVersion": ""
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"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": "true"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/reserverulesets/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.da.sets": "1F121E121E121E121EFFFFFFFF010001000F0001000E0000001C",
|
|
||||||
"x.com.samsung.da.id": "CAC",
|
|
||||||
"x.com.samsung.da.version": "1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/sac/installationinfo/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"installationOptions": [
|
|
||||||
{
|
|
||||||
"id": "0",
|
|
||||||
"option": "17444980C80171700010"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "1",
|
|
||||||
"option": "28010000000000000100"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "2",
|
|
||||||
"option": "50000000000000000000"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "3",
|
|
||||||
"option": "30000000000000000000"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"installationDeviceNum": [
|
|
||||||
{
|
|
||||||
"id": "0",
|
|
||||||
"number": "01"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "1",
|
|
||||||
"number": "04"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "2",
|
|
||||||
"number": "00"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"outdoorInfo": [
|
|
||||||
{
|
|
||||||
"id": "0",
|
|
||||||
"info": "01900A230418",
|
|
||||||
"serial": "**REDACTED**"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "1",
|
|
||||||
"info": "000000000000",
|
|
||||||
"serial": "**REDACTED**"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "2",
|
|
||||||
"info": "000000000000",
|
|
||||||
"serial": "**REDACTED**"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "3",
|
|
||||||
"info": "000000000000",
|
|
||||||
"serial": "**REDACTED**"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"mcuInfo": [
|
|
||||||
{
|
|
||||||
"id": "0",
|
|
||||||
"info": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "1",
|
|
||||||
"info": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "2",
|
|
||||||
"info": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "3",
|
|
||||||
"info": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "4",
|
|
||||||
"info": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "5",
|
|
||||||
"info": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "6",
|
|
||||||
"info": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "7",
|
|
||||||
"info": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "8",
|
|
||||||
"info": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "9",
|
|
||||||
"info": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "10",
|
|
||||||
"info": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "11",
|
|
||||||
"info": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "12",
|
|
||||||
"info": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "13",
|
|
||||||
"info": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "14",
|
|
||||||
"info": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "15",
|
|
||||||
"info": ""
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/temperature/control/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.da.increment": "0.5"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/temperatures/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.da.items": [
|
|
||||||
{
|
|
||||||
"x.com.samsung.da.id": "0",
|
|
||||||
"x.com.samsung.da.description": "Temperature",
|
|
||||||
"x.com.samsung.da.desired": "27.0",
|
|
||||||
"x.com.samsung.da.current": "29.0",
|
|
||||||
"x.com.samsung.da.maximum": "30",
|
|
||||||
"x.com.samsung.da.minimum": "18",
|
|
||||||
"x.com.samsung.da.increment": "0.5",
|
|
||||||
"x.com.samsung.da.unit": "Celsius"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/timezone/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"timezoneid": "Asia/Seoul",
|
|
||||||
"offset": "+09:00",
|
|
||||||
"DST": "OFF"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/wind/direction/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.da.modes": "Fix",
|
|
||||||
"x.com.samsung.da.supportedModes": [
|
|
||||||
"Up_And_Low",
|
|
||||||
"Fix",
|
|
||||||
"Left_And_Right",
|
|
||||||
"All"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"href": "/wind/strength/vs/0",
|
|
||||||
"rep": {
|
|
||||||
"x.com.samsung.da.modes": "0",
|
|
||||||
"x.com.samsung.da.supportedModes": [
|
|
||||||
"0",
|
|
||||||
"1",
|
|
||||||
"2",
|
|
||||||
"3"
|
|
||||||
],
|
|
||||||
"x.com.samsung.da.modesName": [
|
|
||||||
"Auto",
|
|
||||||
"Low",
|
|
||||||
"Mid",
|
|
||||||
"High"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"state_keys": [
|
|
||||||
"air_filter_status",
|
|
||||||
"air_filter_usage",
|
|
||||||
"alarm_code",
|
|
||||||
"auto_clean",
|
|
||||||
"climate",
|
|
||||||
"diagnosis_status",
|
|
||||||
"energy_kwh",
|
|
||||||
"energy_saved_kwh",
|
|
||||||
"firmware_update",
|
|
||||||
"mute_once",
|
|
||||||
"power_watts"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
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",
|
||||||
|
|||||||
-1
@@ -2,7 +2,6 @@
|
|||||||
"state_keys": [
|
"state_keys": [
|
||||||
"alarm_code",
|
"alarm_code",
|
||||||
"child_lock",
|
"child_lock",
|
||||||
"cycle",
|
|
||||||
"cycle_active",
|
"cycle_active",
|
||||||
"delay_start_hours",
|
"delay_start_hours",
|
||||||
"detergent_low",
|
"detergent_low",
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ from homeassistant.data_entry_flow import FlowResultType
|
|||||||
from pytest_homeassistant_custom_component.common import MockConfigEntry
|
from pytest_homeassistant_custom_component.common import MockConfigEntry
|
||||||
|
|
||||||
from custom_components.localthings.const import (
|
from custom_components.localthings.const import (
|
||||||
CONF_BYPASS_REMOTE_CONTROL, CONF_CA_CERT_PEM, CONF_CA_KEY_PEM,
|
CONF_CA_CERT_PEM, CONF_CA_KEY_PEM, CONF_HOST, CONF_PORT, DOMAIN,
|
||||||
CONF_HOST, CONF_PORT, DOMAIN,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from .conftest import (
|
from .conftest import (
|
||||||
@@ -277,45 +276,3 @@ def test_probe_marks_washer_as_recognized(monkeypatch):
|
|||||||
) is not None
|
) is not None
|
||||||
)
|
)
|
||||||
assert recognized is True
|
assert recognized is True
|
||||||
|
|
||||||
|
|
||||||
async def test_options_flow_default_is_off(hass: HomeAssistant) -> None:
|
|
||||||
"""The bypass defaults to False, so devices that never touch this
|
|
||||||
option see no change in the remote-control write block."""
|
|
||||||
entry = MockConfigEntry(domain=DOMAIN, data=ENTRY_DATA, unique_id=f'localthings_{MOCK_SERIAL}')
|
|
||||||
entry.add_to_hass(hass)
|
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
|
||||||
|
|
||||||
assert result['type'] == FlowResultType.FORM
|
|
||||||
assert result['step_id'] == 'init'
|
|
||||||
assert result['data_schema']({})[CONF_BYPASS_REMOTE_CONTROL] is False
|
|
||||||
|
|
||||||
|
|
||||||
async def test_options_flow_can_enable_bypass(hass: HomeAssistant) -> None:
|
|
||||||
"""Submitting the form with the toggle on stores it in entry.options,
|
|
||||||
where coordinator.async_send_command reads it (issue #54)."""
|
|
||||||
entry = MockConfigEntry(domain=DOMAIN, data=ENTRY_DATA, unique_id=f'localthings_{MOCK_SERIAL}')
|
|
||||||
entry.add_to_hass(hass)
|
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
|
||||||
result['flow_id'], user_input={CONF_BYPASS_REMOTE_CONTROL: True}
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result['type'] == FlowResultType.CREATE_ENTRY
|
|
||||||
assert entry.options[CONF_BYPASS_REMOTE_CONTROL] is True
|
|
||||||
|
|
||||||
|
|
||||||
async def test_options_flow_reflects_previously_saved_value(hass: HomeAssistant) -> None:
|
|
||||||
"""Reopening the form shows the currently-saved choice as the default,
|
|
||||||
not always False."""
|
|
||||||
entry = MockConfigEntry(
|
|
||||||
domain=DOMAIN, data=ENTRY_DATA, unique_id=f'localthings_{MOCK_SERIAL}',
|
|
||||||
options={CONF_BYPASS_REMOTE_CONTROL: True},
|
|
||||||
)
|
|
||||||
entry.add_to_hass(hass)
|
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
|
||||||
|
|
||||||
assert result['data_schema']({})[CONF_BYPASS_REMOTE_CONTROL] is True
|
|
||||||
@@ -11,7 +11,7 @@ from homeassistant.exceptions import ServiceValidationError
|
|||||||
from homeassistant.helpers import issue_registry as ir
|
from homeassistant.helpers import issue_registry as ir
|
||||||
|
|
||||||
from custom_components.localthings.const import (
|
from custom_components.localthings.const import (
|
||||||
CONF_BYPASS_REMOTE_CONTROL, CONF_HOST, DOMAIN, SUMMARY_INTERVAL_S,
|
CONF_HOST, DOMAIN, SUMMARY_INTERVAL_S,
|
||||||
)
|
)
|
||||||
from custom_components.localthings.coordinator import LocalThingsCoordinator
|
from custom_components.localthings.coordinator import LocalThingsCoordinator
|
||||||
from custom_components.localthings.registry.capabilities.common import (
|
from custom_components.localthings.registry.capabilities.common import (
|
||||||
@@ -749,104 +749,6 @@ async def test_climate_power_write_applies_to_its_own_href_not_bound_href(
|
|||||||
assert coordinator._observe._settle_until.get('/power/0') is not None
|
assert coordinator._observe._settle_until.get('/power/0') is not None
|
||||||
|
|
||||||
|
|
||||||
async def test_send_command_survives_stale_confirm_poll(
|
|
||||||
hass: HomeAssistant, mock_entry, mock_coordinator_observe_session, fridge_resources,
|
|
||||||
) -> None:
|
|
||||||
"""The settle window must outlast the confirm poll async_send_command
|
|
||||||
triggers via async_request_refresh(), not just DEFAULT_SETTLE_S's fixed
|
|
||||||
few seconds (issue #9). Some devices settle a write internally slower
|
|
||||||
than that refresh's own round trip -- issue #9's washer packs cycle/
|
|
||||||
detergent/softener selection into /course/vs/0's shared options[]
|
|
||||||
array, which visibly takes a few seconds of validation/dispenser
|
|
||||||
movement to catch up, unlike /washer/vs/0's plain temperature/spin
|
|
||||||
fields on the same device, which confirm instantly. A confirm poll that
|
|
||||||
lands before the device has caught up is stale, and a settle window
|
|
||||||
sized only to the fixed default (rather than the PUT+poll round trip)
|
|
||||||
expires before that poll even returns, so the stale read lands
|
|
||||||
unprotected and reverts the optimistic value -- self-correcting again
|
|
||||||
only once a later poll finally sees the real change. That reads to a
|
|
||||||
user as the write reverting, then reapplying itself, a few seconds
|
|
||||||
later."""
|
|
||||||
from custom_components.localthings.registry.discovery import BoundEntity
|
|
||||||
from custom_components.localthings.registry.entities import NumberDesc
|
|
||||||
|
|
||||||
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]
|
|
||||||
|
|
||||||
def _write_fn(payload, rep, href):
|
|
||||||
return (['test', 'vs', '0'], {'value': payload})
|
|
||||||
|
|
||||||
desc = NumberDesc(key='test', field='value', write_fn=_write_fn)
|
|
||||||
bound = BoundEntity(href='/test/vs/0', capability=coordinator.bound[0].capability, desc=desc)
|
|
||||||
|
|
||||||
def _stale_confirm_poll():
|
|
||||||
# Stand-in for the write's own confirming /device/0 poll racing
|
|
||||||
# against a stale read for the same href -- the device's internal
|
|
||||||
# state hasn't caught up to the write yet, even though it will a
|
|
||||||
# little later.
|
|
||||||
coordinator._observe.apply('/test/vs/0', {'value': 0}, source='poll')
|
|
||||||
return fridge_resources
|
|
||||||
|
|
||||||
with (
|
|
||||||
patch.object(fake, 'subscribe'),
|
|
||||||
patch.object(LocalThingsCoordinator, '_poll_once', side_effect=_stale_confirm_poll),
|
|
||||||
):
|
|
||||||
fake.post = lambda *a, **k: (0x44, b'')
|
|
||||||
await coordinator.async_send_command(bound, 5)
|
|
||||||
|
|
||||||
# The optimistic value is visible right away and survived the stale
|
|
||||||
# confirm-poll race triggered by the refresh above.
|
|
||||||
assert coordinator._cache.get('/test/vs/0') == {'value': 5}
|
|
||||||
|
|
||||||
# The settle window is still open afterward -- sized to outlast the
|
|
||||||
# whole PUT + confirm-poll round trip, not released the moment that
|
|
||||||
# round trip happens to finish.
|
|
||||||
applied = coordinator._observe.apply('/test/vs/0', {'value': 0}, source='observe')
|
|
||||||
assert applied is False
|
|
||||||
assert coordinator._cache.get('/test/vs/0') == {'value': 5}
|
|
||||||
|
|
||||||
|
|
||||||
async def test_second_write_to_same_href_lands_during_first_writes_settle_window(
|
|
||||||
hass: HomeAssistant, mock_entry, mock_coordinator_observe_session,
|
|
||||||
) -> None:
|
|
||||||
"""Regression for issue #9: /course/vs/0 backs several independent
|
|
||||||
washer selects (cycle, detergent quantity, softener quantity, ...)
|
|
||||||
sharing one href. The settle window is now sized to tens of seconds
|
|
||||||
(see test_send_command_survives_stale_confirm_poll), which makes a
|
|
||||||
second, different write to that href landing while the first write's
|
|
||||||
window is still open a routine occurrence -- e.g. a user picking a
|
|
||||||
cycle and then adjusting detergent quantity within the same minute --
|
|
||||||
not a rare edge case. The second write's own optimistic value must
|
|
||||||
still show up immediately; a guard meant to protect optimistic writes
|
|
||||||
from stale device echoes must not itself suppress a later one."""
|
|
||||||
from custom_components.localthings.registry.discovery import BoundEntity
|
|
||||||
from custom_components.localthings.registry.entities import NumberDesc
|
|
||||||
|
|
||||||
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]
|
|
||||||
|
|
||||||
desc_a = NumberDesc(key='cycle', field='cycle',
|
|
||||||
write_fn=lambda p, rep, href: (['test', 'vs', '0'], {'cycle': p}))
|
|
||||||
desc_b = NumberDesc(key='detergent', field='detergent',
|
|
||||||
write_fn=lambda p, rep, href: (['test', 'vs', '0'], {'detergent': p}))
|
|
||||||
bound_a = BoundEntity(href='/test/vs/0', capability=coordinator.bound[0].capability, desc=desc_a)
|
|
||||||
bound_b = BoundEntity(href='/test/vs/0', capability=coordinator.bound[0].capability, desc=desc_b)
|
|
||||||
|
|
||||||
with patch.object(fake, 'subscribe'):
|
|
||||||
fake.post = lambda *a, **k: (0x44, b'')
|
|
||||||
await coordinator.async_send_command(bound_a, 'Eco')
|
|
||||||
assert coordinator._cache.get('/test/vs/0') == {'cycle': 'Eco'}
|
|
||||||
|
|
||||||
# Still well within the first write's settle window.
|
|
||||||
await coordinator.async_send_command(bound_b, 'High')
|
|
||||||
|
|
||||||
assert coordinator._cache.get('/test/vs/0') == {'cycle': 'Eco', 'detergent': 'High'}
|
|
||||||
|
|
||||||
|
|
||||||
class TestRemoteControlEnabled:
|
class TestRemoteControlEnabled:
|
||||||
"""remote_control_enabled (registry/capabilities/common.py) is the
|
"""remote_control_enabled (registry/capabilities/common.py) is the
|
||||||
single source of truth for the /remotectrl on/off signal, shared by
|
single source of truth for the /remotectrl on/off signal, shared by
|
||||||
@@ -979,44 +881,3 @@ async def test_send_command_remote_control_check_precedes_validate_fn(
|
|||||||
|
|
||||||
with pytest.raises(ServiceValidationError, match="Remote control is turned off"):
|
with pytest.raises(ServiceValidationError, match="Remote control is turned off"):
|
||||||
await coordinator.async_send_command(bound, 'On')
|
await coordinator.async_send_command(bound, 'On')
|
||||||
|
|
||||||
|
|
||||||
async def test_send_command_bypasses_remote_control_when_option_enabled(
|
|
||||||
hass: HomeAssistant, mock_coordinator_observe_session
|
|
||||||
) -> None:
|
|
||||||
"""Issue #54: some devices accept certain writes even while reporting
|
|
||||||
remote control off, so a user who's confirmed that for their device can
|
|
||||||
opt it out of the block entirely via the options flow
|
|
||||||
(CONF_BYPASS_REMOTE_CONTROL, entry.options -- not entry.data)."""
|
|
||||||
from pytest_homeassistant_custom_component.common import MockConfigEntry
|
|
||||||
|
|
||||||
from custom_components.localthings.registry.discovery import BoundEntity
|
|
||||||
from custom_components.localthings.registry.entities import NumberDesc
|
|
||||||
|
|
||||||
entry = MockConfigEntry(
|
|
||||||
domain=DOMAIN, data=ENTRY_DATA, unique_id=f'localthings_{MOCK_SERIAL}',
|
|
||||||
options={CONF_BYPASS_REMOTE_CONTROL: True},
|
|
||||||
)
|
|
||||||
entry.add_to_hass(hass)
|
|
||||||
|
|
||||||
fake = mock_coordinator_observe_session
|
|
||||||
await hass.config_entries.async_setup(entry.entry_id)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
coordinator: LocalThingsCoordinator = hass.data[DOMAIN][entry.entry_id]
|
|
||||||
coordinator._cache.apply_rep(
|
|
||||||
'/remotectrl/vs/0',
|
|
||||||
{'x.com.samsung.da.remoteControlEnabled': 'false'},
|
|
||||||
source='test',
|
|
||||||
)
|
|
||||||
|
|
||||||
def _write_fn(payload, rep, href):
|
|
||||||
return (['some', 'path'], {'value': payload})
|
|
||||||
|
|
||||||
desc = NumberDesc(key='test', field='value', write_fn=_write_fn)
|
|
||||||
bound = BoundEntity(href='/test/vs/0', capability=coordinator.bound[0].capability, desc=desc)
|
|
||||||
|
|
||||||
with patch.object(fake, 'subscribe'):
|
|
||||||
fake.post = lambda *a, **k: (0x44, b'')
|
|
||||||
await coordinator.async_send_command(bound, 5)
|
|
||||||
|
|
||||||
assert coordinator._cache.get('/some/path') == {'value': 5}
|
|
||||||
@@ -67,30 +67,6 @@ def test_apply_drops_update_during_settle_window():
|
|||||||
assert mgr.cache.get('/oven/vs/0') == {'a': 1}
|
assert mgr.cache.get('/oven/vs/0') == {'a': 1}
|
||||||
|
|
||||||
|
|
||||||
def test_apply_optimistic_bypasses_an_in_progress_settle_window():
|
|
||||||
"""Regression for issue #9: /course/vs/0 backs several independent
|
|
||||||
washer selects (cycle, detergent quantity, softener quantity, ...).
|
|
||||||
Picking a second one while the first's settle window is still open
|
|
||||||
(now sized to tens of seconds -- see coordinator._POST_TIMEOUT_S/
|
|
||||||
_POLL_TIMEOUT_S) is a normal sequence, not a stale echo of the first
|
|
||||||
write, and must land in the cache immediately -- not get silently
|
|
||||||
dropped by a guard that exists to protect optimistic writes, not
|
|
||||||
suppress them."""
|
|
||||||
mgr = _manager()
|
|
||||||
mgr.cache.apply_rep('/course/vs/0', {'Course': '1C', 'Detergent': '1'}, source='seed')
|
|
||||||
mgr.mark_write_pending('/course/vs/0', settle_s=30.0)
|
|
||||||
|
|
||||||
result = mgr.apply('/course/vs/0', {'Detergent': '2'}, source='optimistic')
|
|
||||||
|
|
||||||
assert result is True
|
|
||||||
assert mgr.cache.get('/course/vs/0') == {'Course': '1C', 'Detergent': '2'}
|
|
||||||
|
|
||||||
# A poll/sweep/observe update racing in right behind it is still
|
|
||||||
# gated -- the second write's own guard (re-armed by mark_write_pending,
|
|
||||||
# not exercised directly here) is what protects it going forward.
|
|
||||||
assert mgr.apply('/course/vs/0', {'Detergent': '1'}, source='poll') is False
|
|
||||||
|
|
||||||
|
|
||||||
def test_apply_accepts_update_after_settle_window_elapses():
|
def test_apply_accepts_update_after_settle_window_elapses():
|
||||||
mgr = _manager()
|
mgr = _manager()
|
||||||
mgr.mark_write_pending('/oven/vs/0', settle_s=0.05)
|
mgr.mark_write_pending('/oven/vs/0', settle_s=0.05)
|
||||||
|
|||||||
@@ -215,30 +215,6 @@ def test_tp1x_rac_expected_state_keys_present():
|
|||||||
assert key in state, key
|
assert key in state, key
|
||||||
|
|
||||||
|
|
||||||
def test_caww_tp2_model_resolves_via_model_fallback():
|
|
||||||
"""A-CAWW-TP2-20-COMMON (issue #52, System AC) reports no oneUiVersion
|
|
||||||
and no '_RAC_'/'_PRAC_' token -- resolved via the '-CAWW-' modelNum
|
|
||||||
fallback added for this device."""
|
|
||||||
reg, _ = _resolve('airconditioner_caww_tp2')
|
|
||||||
assert reg is not None and reg.name == 'airconditioner'
|
|
||||||
|
|
||||||
|
|
||||||
def test_caww_tp2_no_unbound_hrefs():
|
|
||||||
"""Every resource in the issue #52 dump binds or is ignored -- clears
|
|
||||||
the coverage-gap repair. Only new href beyond the existing RAC/PRAC
|
|
||||||
surface is /sac/installationinfo/vs/0 (opaque SAC installation topology,
|
|
||||||
ignored)."""
|
|
||||||
reg, resources = _resolve('airconditioner_caww_tp2')
|
|
||||||
unbound = []
|
|
||||||
discover(resources, reg.capabilities, reg.pattern_capabilities, log=unbound.append)
|
|
||||||
assert unbound == []
|
|
||||||
|
|
||||||
|
|
||||||
def test_caww_tp2_sac_installationinfo_is_ignored():
|
|
||||||
ignored_hrefs = {cap.href for cap in airconditioner.COVERAGE}
|
|
||||||
assert '/sac/installationinfo/vs/0' in ignored_hrefs
|
|
||||||
|
|
||||||
|
|
||||||
def test_mute_once_write_target():
|
def test_mute_once_write_target():
|
||||||
write = airconditioner.MUTE_ONCE.entities[0].write_fn
|
write = airconditioner.MUTE_ONCE.entities[0].write_fn
|
||||||
assert write('On', {}) == (['option', 'muteonce', 'vs', '0'], {'muteonce': 'On'})
|
assert write('On', {}) == (['option', 'muteonce', 'vs', '0'], {'muteonce': 'On'})
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -59,17 +95,11 @@ def test_power_watts_gated_for_dead_sentinel():
|
|||||||
|
|
||||||
|
|
||||||
def test_course_bound_to_shared_course_vs_0():
|
def test_course_bound_to_shared_course_vs_0():
|
||||||
"""Dryer course uses the shared /course/vs/0 cycle select, with the
|
"""Dryer course uses the shared /course/vs/0 cycle select with dryer_cycle
|
||||||
translation key built from the device's own course table (see
|
translations, consistent with washer/dishwasher."""
|
||||||
laundry.cycle_select) -- confirmed dryers report Table_03, matching
|
|
||||||
the shipped dryer_cycle_table_03 translations, consistent with
|
|
||||||
washer/dishwasher."""
|
|
||||||
assert dryer.DRYER_COURSE.href == '/course/vs/0'
|
assert dryer.DRYER_COURSE.href == '/course/vs/0'
|
||||||
desc = next(e for e in dryer.DRYER_COURSE.entities if e.key == 'cycle')
|
desc = next(e for e in dryer.DRYER_COURSE.entities if e.key == 'cycle')
|
||||||
assert callable(desc.translation_key)
|
assert desc.translation_key == 'dryer_cycle'
|
||||||
table_03 = {'/st/dryercourse/vs/0': {'x.com.samsung.da.st.courseTable': 'Table_03'}}
|
|
||||||
assert desc.translation_key(table_03) == 'dryer_cycle_table_03'
|
|
||||||
assert desc.translation_key({}) is None
|
|
||||||
assert desc.options is laundry.cycle_options
|
assert desc.options is laundry.cycle_options
|
||||||
rep = {'x.com.samsung.da.options': ['Course_16', 'GMT_02']}
|
rep = {'x.com.samsung.da.options': ['Course_16', 'GMT_02']}
|
||||||
assert desc.rep_fn(rep) == '16'
|
assert desc.rep_fn(rep) == '16'
|
||||||
|
|||||||
@@ -213,24 +213,6 @@ def test_registry_reproduces_golden_state_keys_for_tp2x_rac_20k():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_registry_reproduces_golden_state_keys_for_caww_tp2():
|
|
||||||
"""A-CAWW-TP2-20-COMMON (issue #52, System AC / multi-indoor-unit
|
|
||||||
commercial install) reports no oneUiVersion and no '_RAC_'/'_PRAC_'
|
|
||||||
token; resolved via the '-CAWW-' modelNum fallback in
|
|
||||||
for_device_by_model. Otherwise binds cleanly against the existing
|
|
||||||
airconditioner registry -- same TP1X/TP2X-class resource surface, plus
|
|
||||||
one SAC-only installation-topology resource (ignored)."""
|
|
||||||
from tests.conftest import _load_device
|
|
||||||
resources = _load_device('airconditioner_caww_tp2')
|
|
||||||
golden = json.loads((GOLDEN / 'airconditioner_caww_tp2.json').read_text())
|
|
||||||
state_keys = _new_state_keys('airconditioner_caww_tp2', 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_tp1x_rac():
|
def test_registry_reproduces_golden_state_keys_for_tp1x_rac():
|
||||||
"""TP1X_DA-AC-RAC-01001_0000 (issue #38) -- fuller RAC board with display
|
"""TP1X_DA-AC-RAC-01001_0000 (issue #38) -- fuller RAC board with display
|
||||||
light, self-check, mute-once, and a current-limit setting."""
|
light, self-check, mute-once, and a current-limit setting."""
|
||||||
|
|||||||
@@ -35,103 +35,6 @@ class TestCourseHelpers:
|
|||||||
assert laundry.option_value(opts, 'Missing') is None
|
assert laundry.option_value(opts, 'Missing') is None
|
||||||
|
|
||||||
|
|
||||||
class TestCourseCodesFromSupportedOptions:
|
|
||||||
"""cycle_options()'s fallback for boards that populate
|
|
||||||
/wm/editcourse/vs/0 without ever filling in editCourseList itself
|
|
||||||
(issue #1) -- derives the course list from /course/vs/0's own
|
|
||||||
supportedOptions instead."""
|
|
||||||
|
|
||||||
# Real dump from issue #1 (DA_WM_TP1_21_COMMON, WW5000C): a 1-hex-nibble
|
|
||||||
# header followed by 14 self-indexed 7-byte-per-course records. '1C' (the
|
|
||||||
# first record) is confirmed as "Eco 40-60" both by this device's own
|
|
||||||
# currently-selected course matching the SmartThings app screenshot's
|
|
||||||
# checked item, and by six other independent devices' already-shipped
|
|
||||||
# translations agreeing on the same code -> name mapping.
|
|
||||||
_REAL_SUPPORTED_OPTIONS = (
|
|
||||||
'31C8410923FA67F1B847E923FA67F25843E933FA57F20857E943FA67F'
|
|
||||||
'088000913FA67F7485209204A5208780009000A00006841E930FA30F'
|
|
||||||
'7F841E920FA30F65841E943FA57F8F8102923FA57F96841E920FA37F'
|
|
||||||
'34841E923FA67FA0811E933FA33F'
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_derives_codes_when_edit_course_list_is_empty(self):
|
|
||||||
resources = {
|
|
||||||
'/wm/editcourse/vs/0': {'x.com.samsung.da.editCourseList': ''},
|
|
||||||
'/course/vs/0': {
|
|
||||||
'x.com.samsung.da.options': ['Course_1C'],
|
|
||||||
'x.com.samsung.da.supportedOptions': [self._REAL_SUPPORTED_OPTIONS],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
assert laundry.cycle_options(resources) == [
|
|
||||||
'1C', '1B', '25', '20', '08', '74', '87', '06',
|
|
||||||
'7F', '65', '8F', '96', '34', 'A0',
|
|
||||||
]
|
|
||||||
|
|
||||||
def test_edit_course_list_still_takes_priority(self):
|
|
||||||
"""A live editCourseList wins even with supportedOptions present --
|
|
||||||
no reason to prefer a derived list over the authoritative one."""
|
|
||||||
resources = {
|
|
||||||
'/wm/editcourse/vs/0': {'x.com.samsung.da.editCourseList': 'EditCourseList_651C'},
|
|
||||||
'/course/vs/0': {
|
|
||||||
'x.com.samsung.da.options': ['Course_1C'],
|
|
||||||
'x.com.samsung.da.supportedOptions': [self._REAL_SUPPORTED_OPTIONS],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
assert laundry.cycle_options(resources) == ['65', '1C']
|
|
||||||
|
|
||||||
def test_rejects_a_table_missing_the_current_course(self):
|
|
||||||
"""The device's own currently-selected course must be a member of
|
|
||||||
its derived list -- a mismatch means the guess is wrong, not that
|
|
||||||
the device selected something outside its own supported set."""
|
|
||||||
resources = {
|
|
||||||
'/course/vs/0': {
|
|
||||||
'x.com.samsung.da.options': ['Course_FF'],
|
|
||||||
'x.com.samsung.da.supportedOptions': [self._REAL_SUPPORTED_OPTIONS],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
assert laundry.cycle_options(resources) == []
|
|
||||||
|
|
||||||
def test_smallest_passing_split_wins_over_its_own_multiples(self):
|
|
||||||
"""K=2 and K=4 both trivially re-pass the same two checks here --
|
|
||||||
each is just a sparser sampling of the true, smaller K=1 table (its
|
|
||||||
first bytes are a subset of K=1's, so uniqueness and "contains the
|
|
||||||
current course" carry over for free) -- but K=1 is the real, most
|
|
||||||
specific table and must be the one returned."""
|
|
||||||
resources = {
|
|
||||||
'/course/vs/0': {
|
|
||||||
'x.com.samsung.da.options': ['Course_AA'],
|
|
||||||
'x.com.samsung.da.supportedOptions': ['0AABBCCDD'],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
assert laundry.cycle_options(resources) == ['AA', 'BB', 'CC', 'DD']
|
|
||||||
|
|
||||||
def test_empty_without_supported_options_or_course_href(self):
|
|
||||||
assert laundry.cycle_options({}) == []
|
|
||||||
assert laundry.cycle_options({'/course/vs/0': {}}) == []
|
|
||||||
|
|
||||||
def test_smallest_wins_even_when_a_larger_pass_is_not_a_multiple(self):
|
|
||||||
"""Real dishwasher dump (K=7, 10 courses): K=10, 14, and 35 also
|
|
||||||
pass both checks here, and none of them are multiples of 7 --
|
|
||||||
position 0 lands on the same real course code ('0e') regardless of
|
|
||||||
K, which alone satisfies the current-course guard for several
|
|
||||||
unrelated splits. Smallest-K-wins is a heuristic that matches every
|
|
||||||
real dump checked so far, not a proven guarantee -- see
|
|
||||||
_course_codes_from_supported_options's docstring."""
|
|
||||||
resources = {
|
|
||||||
'/course/vs/0': {
|
|
||||||
'x.com.samsung.da.options': ['Course_0E'],
|
|
||||||
'x.com.samsung.da.supportedOptions': [
|
|
||||||
'30E5434B102D102835034B002D002845034B002D002805034B000D000'
|
|
||||||
'865034B002D002075000B000D000905000B000D0008D5034B002D0028'
|
|
||||||
'E5034B000D0008F5034B000D000'
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
assert laundry.cycle_options(resources) == [
|
|
||||||
'0E', '83', '84', '80', '86', '07', '90', '8D', '8E', '8F',
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class TestCycleSelect:
|
class TestCycleSelect:
|
||||||
def test_builds_labelled_cycle_select(self):
|
def test_builds_labelled_cycle_select(self):
|
||||||
desc = laundry.cycle_select(translation_key='dryer_cycle', icon='mdi:tumble-dryer')
|
desc = laundry.cycle_select(translation_key='dryer_cycle', icon='mdi:tumble-dryer')
|
||||||
@@ -167,53 +70,6 @@ class TestCycleSelect:
|
|||||||
assert desc.write_fn('1D', {}) is None
|
assert desc.write_fn('1D', {}) is None
|
||||||
|
|
||||||
|
|
||||||
class TestCycleSelectTableGating:
|
|
||||||
"""translation_key becomes a resolver, not a plain string, once
|
|
||||||
table_href is given -- washer/dryer's real call sites (issue: course
|
|
||||||
codes aren't guaranteed consistent across board generations sharing
|
|
||||||
the same /course/vs/0 contract; FlexWash's older board reports a
|
|
||||||
different course table than every device the shipped translations
|
|
||||||
were confirmed against). The resolved key is built from whatever table
|
|
||||||
the device actually reports -- a table with no strings.json entries
|
|
||||||
yet just falls through Home Assistant's own missing-translation
|
|
||||||
handling to raw-code display, the same as any individual untranslated
|
|
||||||
code within an existing table."""
|
|
||||||
|
|
||||||
def _desc(self):
|
|
||||||
return laundry.cycle_select(
|
|
||||||
translation_key='washer_cycle', icon='x',
|
|
||||||
table_href='/st/washercourse/vs/0',
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_static_string_when_no_table_href_given(self):
|
|
||||||
"""dishwasher's call site -- no equivalent table-id resource in any
|
|
||||||
dump seen, no evidence of the same cross-board risk -- keeps the
|
|
||||||
plain static key unconditionally."""
|
|
||||||
desc = laundry.cycle_select(translation_key='dishwasher_cycle', icon='x')
|
|
||||||
assert desc.translation_key == 'dishwasher_cycle'
|
|
||||||
|
|
||||||
def test_resolved_key_is_built_from_the_reported_table(self):
|
|
||||||
desc = self._desc()
|
|
||||||
resources = {'/st/washercourse/vs/0': {'x.com.samsung.da.st.courseTable': 'Table_02'}}
|
|
||||||
assert callable(desc.translation_key)
|
|
||||||
assert desc.translation_key(resources) == 'washer_cycle_table_02'
|
|
||||||
|
|
||||||
def test_resolved_key_reflects_an_unbuilt_table_too(self):
|
|
||||||
"""No gating against a hardcoded 'known good' table -- a table we
|
|
||||||
haven't shipped translations for yet still gets a key built for
|
|
||||||
it, just one strings.json has nothing under (raw-code display)."""
|
|
||||||
desc = self._desc()
|
|
||||||
resources = {'/st/washercourse/vs/0': {'x.com.samsung.da.st.courseTable': 'Table_00'}}
|
|
||||||
assert desc.translation_key(resources) == 'washer_cycle_table_00'
|
|
||||||
|
|
||||||
def test_resolves_to_none_when_table_id_is_unknown(self):
|
|
||||||
"""No href, or an empty rep, gets no translation_key at all --
|
|
||||||
there's nothing to build a key from."""
|
|
||||||
desc = self._desc()
|
|
||||||
assert desc.translation_key({}) is None
|
|
||||||
assert desc.translation_key({'/st/washercourse/vs/0': {}}) is None
|
|
||||||
|
|
||||||
|
|
||||||
class TestBuzzerSound:
|
class TestBuzzerSound:
|
||||||
def test_href(self):
|
def test_href(self):
|
||||||
assert laundry.BUZZER_SOUND.href == '/buzzersound/vs/0'
|
assert laundry.BUZZER_SOUND.href == '/buzzersound/vs/0'
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
"""Tests for select-option display casing (custom_components/localthings/select.py)."""
|
"""Tests for select-option display casing (custom_components/localthings/select.py)."""
|
||||||
|
from custom_components.localthings.registry.entities import SelectDesc
|
||||||
from custom_components.localthings.select import _display
|
from custom_components.localthings.select import _display
|
||||||
|
|
||||||
_UNTRANSLATED = None
|
_UNTRANSLATED = SelectDesc(key='x', options=())
|
||||||
_TRANSLATED = 'door_alert'
|
_TRANSLATED = SelectDesc(key='y', options=(), translation_key='door_alert')
|
||||||
|
|
||||||
|
|
||||||
def test_display_titlecases_a_fully_lowercase_device_native_token():
|
def test_display_titlecases_a_fully_lowercase_device_native_token():
|
||||||
|
|||||||
@@ -57,20 +57,3 @@ def test_callable_options_empty_result():
|
|||||||
desc = SelectDesc(key='cycle', options=lambda resources: [])
|
desc = SelectDesc(key='cycle', options=lambda resources: [])
|
||||||
entity = _make_select(desc, '/x/vs/0', {})
|
entity = _make_select(desc, '/x/vs/0', {})
|
||||||
assert entity.options == []
|
assert entity.options == []
|
||||||
|
|
||||||
|
|
||||||
def test_callable_translation_key_reresolves_live_not_once_at_construction():
|
|
||||||
"""A callable translation_key (laundry.cycle_select's table-id-gated
|
|
||||||
resolver) must be re-evaluated against current coordinator data on
|
|
||||||
every access, not baked in once at __init__ -- discovery can run while
|
|
||||||
a sibling resource (e.g. /st/washercourse/vs/0) is still an empty stub
|
|
||||||
(see entity.py's _is_included docstring), and a one-time resolution
|
|
||||||
would permanently show untranslated codes even after a later poll
|
|
||||||
populates the real value."""
|
|
||||||
desc = SelectDesc(key='cycle', translation_key=lambda resources: resources.get('key'))
|
|
||||||
resources = {'key': None}
|
|
||||||
entity = _make_select(desc, '/x/vs/0', resources)
|
|
||||||
assert entity.translation_key is None
|
|
||||||
|
|
||||||
resources['key'] = 'washer_cycle_table_02'
|
|
||||||
assert entity.translation_key == 'washer_cycle_table_02'
|
|
||||||
@@ -61,19 +61,8 @@ class TestWasherCourse:
|
|||||||
assert washer.WASHER_COURSE.href == '/course/vs/0'
|
assert washer.WASHER_COURSE.href == '/course/vs/0'
|
||||||
|
|
||||||
def test_translation_key(self):
|
def test_translation_key(self):
|
||||||
"""Table-scoped (issue: course codes aren't guaranteed consistent
|
|
||||||
across board generations sharing /course/vs/0 -- FlexWash's older
|
|
||||||
board reports Table_00, not the Table_02 every washer_cycle_table_02
|
|
||||||
name was confirmed against) -- see laundry.cycle_select. The key is
|
|
||||||
built from whatever table the device reports, not gated against a
|
|
||||||
hardcoded 'known good' value."""
|
|
||||||
desc = next(e for e in washer.WASHER_COURSE.entities if e.key == 'cycle')
|
desc = next(e for e in washer.WASHER_COURSE.entities if e.key == 'cycle')
|
||||||
assert callable(desc.translation_key)
|
assert desc.translation_key == 'washer_cycle'
|
||||||
table_02 = {'/st/washercourse/vs/0': {'x.com.samsung.da.st.courseTable': 'Table_02'}}
|
|
||||||
assert desc.translation_key(table_02) == 'washer_cycle_table_02'
|
|
||||||
table_00 = {'/st/washercourse/vs/0': {'x.com.samsung.da.st.courseTable': 'Table_00'}}
|
|
||||||
assert desc.translation_key(table_00) == 'washer_cycle_table_00'
|
|
||||||
assert desc.translation_key({}) is None
|
|
||||||
|
|
||||||
def test_reads_raw_course_code_from_options_array(self):
|
def test_reads_raw_course_code_from_options_array(self):
|
||||||
"""rep_fn returns the raw device code; display names come from
|
"""rep_fn returns the raw device code; display names come from
|
||||||
|
|||||||
Reference in new issue
Block a user