Compare commits
75
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac93549f2a | ||
|
|
b32074c8dd | ||
|
|
51103fa341 | ||
|
|
9dc1facbfe | ||
|
|
24d48d70b9 | ||
|
|
18596f23ec | ||
|
|
450f8ca933 | ||
|
|
679c3d2bce | ||
|
|
36a642135b | ||
|
|
07061c734d | ||
|
|
daf7e3787f | ||
|
|
d9c84e765b | ||
|
|
00abfb9770 | ||
|
|
9fc04e179e | ||
|
|
b0eab93b58 | ||
|
|
547388cc2b | ||
|
|
81b83f4175 | ||
|
|
c5f37ea280 | ||
|
|
b4550cc4b1 | ||
|
|
42a1812967 | ||
|
|
e926905517 | ||
|
|
6bcf8f3bec | ||
|
|
9737684c9f | ||
|
|
6efee761d9 | ||
|
|
e309d3e7b8 | ||
|
|
34b2291bef | ||
|
|
5c275753d4 | ||
|
|
57eb3e80c7 | ||
|
|
d544644e0e | ||
|
|
f9cd857ced | ||
|
|
93744e80f4 | ||
|
|
a74b92f758 | ||
|
|
d639aa693f | ||
|
|
3c6c7f246f | ||
|
|
0d0844ea7f | ||
|
|
618fc5fa51 | ||
|
|
f36b3016cc | ||
|
|
36f53da6a0 | ||
|
|
6166f63570 | ||
|
|
b7d3f86ec7 | ||
|
|
fd86c54f18 | ||
|
|
e55c55c55e | ||
|
|
7a43fcb988 | ||
|
|
9f15d06e84 | ||
|
|
9ab3c5827c | ||
|
|
d90562017f | ||
|
|
fe9a1128ea | ||
|
|
2f231b5c19 | ||
|
|
873ed562de | ||
|
|
f15ee7e563 | ||
|
|
d0c68fb5ac | ||
|
|
e99a8a6b05 | ||
|
|
87e0c43b23 | ||
|
|
9ee0dbb8f9 | ||
|
|
f19abc7936 | ||
|
|
a7d57086e9 | ||
|
|
4afd11a357 | ||
|
|
d317a85988 | ||
|
|
4d4de23fbb | ||
|
|
e46e935ba0 | ||
|
|
5bbc7aeece | ||
|
|
e642db462d | ||
|
|
822c6814b6 | ||
|
|
61f13e7484 | ||
|
|
b8d04b4ae3 | ||
|
|
2d09ef108a | ||
|
|
8512aef2d2 | ||
|
|
3cd22824ca | ||
|
|
9f4c47ea63 | ||
|
|
0a4b80afc4 | ||
|
|
4f9e630ae9 | ||
|
|
4c827bf9e4 | ||
|
|
8e8f08109a | ||
|
|
eb938205ab | ||
|
|
5e86f147d4 |
No files matched your search
@@ -5,8 +5,9 @@ description: >-
|
|||||||
/device/0 diagnostics dump. Use when a device-support issue lands, a device
|
/device/0 diagnostics dump. Use when a device-support issue lands, a device
|
||||||
raises the "incomplete capability coverage" repair, a diagnostics JSON needs
|
raises the "incomplete capability coverage" repair, a diagnostics JSON needs
|
||||||
triaging, or you're mapping OCF resources to HA entities. Covers reading dumps,
|
triaging, or you're mapping OCF resources to HA entities. Covers reading dumps,
|
||||||
routing an unrecognized board family to a registry (modelNum board tokens,
|
routing a device to a registry from its `/oic/d` device type first and an
|
||||||
resource signatures),
|
unrecognized board family second (modelNum board tokens, resource
|
||||||
|
signatures),
|
||||||
OCF-standard vs vendor hrefs, the diagnostic/config/normal entity taxonomy,
|
OCF-standard vs vendor hrefs, the diagnostic/config/normal entity taxonomy,
|
||||||
preferring dynamic (device-reported) select options over hardcoded lists,
|
preferring dynamic (device-reported) select options over hardcoded lists,
|
||||||
ensuring every href is bound or ignored, and locking it in with a fixture +
|
ensuring every href is bound or ignored, and locking it in with a fixture +
|
||||||
@@ -64,8 +65,13 @@ by_type = importlib.import_module('custom_components.localthings.registry.by_t
|
|||||||
discovery = importlib.import_module('custom_components.localthings.registry.discovery')
|
discovery = importlib.import_module('custom_components.localthings.registry.discovery')
|
||||||
adapter = importlib.import_module('custom_components.localthings.registry.adapter')
|
adapter = importlib.import_module('custom_components.localthings.registry.adapter')
|
||||||
|
|
||||||
resources = json.load(open('dump.json'))['data']['resources']
|
data = json.load(open('dump.json'))['data']
|
||||||
reg = by_type.resolve(resources) # the same entry point the coordinator uses
|
resources = data['resources']
|
||||||
|
# identity.device_types is /oic/d's `rt` -- resolve()'s primary signal (see
|
||||||
|
# §3). Absent on dumps predating that field; () falls through to model-based
|
||||||
|
# detection exactly like a device that reports nothing there.
|
||||||
|
device_types = tuple((data.get('identity') or {}).get('device_types') or ())
|
||||||
|
reg = by_type.resolve(resources, device_types=device_types) # the same entry point the coordinator uses
|
||||||
unbound = []
|
unbound = []
|
||||||
bound = discovery.discover(resources, reg.capabilities, reg.pattern_capabilities, log=unbound.append)
|
bound = discovery.discover(resources, reg.capabilities, reg.pattern_capabilities, log=unbound.append)
|
||||||
state = adapter.flatten(bound, resources) # {entity_key: value}
|
state = adapter.flatten(bound, resources) # {entity_key: value}
|
||||||
@@ -90,15 +96,21 @@ loses roughly **half** its entities (measured across the fixture corpus: 843 of
|
|||||||
1510 bound entities survive). So routing is the first thing to fix, and
|
1510 bound entities survive). So routing is the first thing to fix, and
|
||||||
`registry/by_type/__init__.py` is deliberately kept boring.
|
`registry/by_type/__init__.py` is deliberately kept boring.
|
||||||
|
|
||||||
`resolve(resources)` is the only entry point — the coordinator, the config
|
`resolve(resources, device_types=())` is the only entry point — the
|
||||||
flow's probe and the golden-regression harness all call it, so the order can't
|
coordinator, the config flow's probe and the golden-regression harness all
|
||||||
drift between what ships and what the tests assert. Two stages:
|
call it, so the order can't drift between what ships and what the tests
|
||||||
|
assert. Three stages, most-specific evidence first:
|
||||||
|
|
||||||
1. **`for_device_by_model(model_num, description)`** — the primary path. Both
|
1. **`for_device_by_oic_type(device_types)`** — the primary path whenever a
|
||||||
fields come from `/information/vs/0`. Board-family tokens are matched
|
dump has it. `device_types` is `/oic/d`'s `rt`, looked up against
|
||||||
against `modelNum` first, then `description`, then the fuzzy two-letter
|
`_OIC_TYPE_TO_KEY`. The device naming its own type beats parsing board
|
||||||
consumer-model prefix.
|
part numbers, so this always wins when it hits. **Always check this first
|
||||||
2. **`for_device_by_resources(resources)`** — for boards that report no
|
when triaging a new dump** — see "Adding an /oic/d device type" below.
|
||||||
|
2. **`for_device_by_model(model_num, description)`** — the fallback for
|
||||||
|
everything `/oic/d` doesn't resolve. Both fields come from
|
||||||
|
`/information/vs/0`. Board-family tokens are matched against `modelNum`
|
||||||
|
first, then `description`, then the fuzzy two-letter consumer-model prefix.
|
||||||
|
3. **`for_device_by_resources(resources)`** — for boards that report no
|
||||||
`/information/vs/0` at all. Needs a *distinctive* signature.
|
`/information/vs/0` at all. Needs a *distinctive* signature.
|
||||||
|
|
||||||
**`oneUiVersion` is not consulted.** It looks like the obvious signal — the
|
**`oneUiVersion` is not consulted.** It looks like the obvious signal — the
|
||||||
@@ -152,15 +164,64 @@ Reach past the table only when the evidence isn't a board token:
|
|||||||
(e.g. `/oven/vs/0` present *and* a `MicroWave*` entry in `supportedModes`),
|
(e.g. `/oven/vs/0` present *and* a `MicroWave*` entry in `supportedModes`),
|
||||||
never one, or an unrelated family's `/mode/vs/0` will match.
|
never one, or an unrelated family's `/mode/vs/0` will match.
|
||||||
|
|
||||||
### If the model string identifies nothing
|
### Adding an /oic/d device type
|
||||||
|
|
||||||
Check the diagnostics `identity` block before inventing a rule: it carries
|
`/oic/d`'s `rt` (OCF's own device-type declaration) is the *primary*
|
||||||
`/oic/p` and `/oic/d`, which sit outside the `/device/0` dump.
|
detection path (`for_device_by_oic_type`, stage 1 above) — it sits outside
|
||||||
`identity.device_types` is `/oic/d`'s `rt` — OCF's own device-type
|
the `/device/0` dump, read separately by `registry/identity.read_identity`,
|
||||||
declaration (`oic.d.airconditioner`). Nothing routes on it yet because no
|
which fetches three endpoints in one shot:
|
||||||
captured dump has ever included it; if real hardware turns out to populate it,
|
- **`/oic/d`** — the device type itself: `n` (device name) and `rt`, a list
|
||||||
it beats parsing board part numbers and this whole section shrinks. Note in
|
carrying the generic `oic.wk.d` base type every OCF device has alongside a
|
||||||
the issue when a dump has it.
|
concrete one (`oic.d.airconditioner`) or a SmartThings vendor extension
|
||||||
|
(`x.com.st.d.stickcleaner`, for categories with no `oic.d.*` equivalent —
|
||||||
|
same prefix convention as `x.com.samsung.da.*` resource fields elsewhere).
|
||||||
|
- **`/oic/p`** — platform identity: `mnmn`/`mnmo` (manufacturer/model).
|
||||||
|
- **`/oic/res`** — resource discovery, used for subdevice enumeration (§11),
|
||||||
|
not device typing.
|
||||||
|
|
||||||
|
None of the three appear in `resources`; find them in diagnostics' `identity`
|
||||||
|
block (`identity.device_types`, `identity.manufacturer`, `identity.model`),
|
||||||
|
or read live with `read_identity(sess, serial)` if you're driving a device
|
||||||
|
directly.
|
||||||
|
|
||||||
|
**Whenever you triage a dump, check `identity.device_types` before touching
|
||||||
|
`_BOARD_TOKEN_TO_KEY` at all** — the whole point of this stage running first
|
||||||
|
is that a real `/oic/d` type makes board-token routing unnecessary. Two
|
||||||
|
outcomes:
|
||||||
|
- The type is already a key in `_OIC_TYPE_TO_KEY` (`registry/by_type/__init__.py`)
|
||||||
|
→ detection already works; an unbound-hrefs gap on this device is a
|
||||||
|
capability-coverage problem (§§4–9), not a routing one.
|
||||||
|
- The type is **not yet in the table** → add a row. This is now the
|
||||||
|
integration's primary detection method, and it only stays that way if new
|
||||||
|
types get folded in as real dumps surface them — same discipline that
|
||||||
|
keeps `_BOARD_TOKEN_TO_KEY` current:
|
||||||
|
|
||||||
|
```python
|
||||||
|
'oic.d.dishwasher': 'dishwasher',
|
||||||
|
'x.com.st.d.steamcloset': 'air_dresser',
|
||||||
|
```
|
||||||
|
|
||||||
|
- A string not yet seen in a dump is still fine to add on the strength of the
|
||||||
|
OCF Smart Home Device Specification's Table 9-1 alone, as long as it has the
|
||||||
|
exact same `oic.d.<category>` shape as an already-confirmed entry — that
|
||||||
|
shape is low-risk ahead of a dump because, unlike a board-token entry,
|
||||||
|
there's no tokenizing or delimiter-spelling judgment call involved.
|
||||||
|
- **Only add a row once there's a real registry key on the right** (a key in
|
||||||
|
`_REGISTRY_BY_KEY`). A type naming a product this integration has no
|
||||||
|
registry for stays unmapped rather than getting coerced onto the
|
||||||
|
nearest-sounding one — `oic.d.robotcleaner` names an actual robot vacuum,
|
||||||
|
a different product from the clean/auto-empty *station* `vacuum_station`
|
||||||
|
covers (no vacuum-body capabilities at all; see that registry's own module
|
||||||
|
docstring), so it's deliberately absent even though the string is known.
|
||||||
|
- Falls through to `for_device_by_model`/`for_device_by_resources` when
|
||||||
|
`device_types` is empty or maps to nothing — most hardware still doesn't
|
||||||
|
populate `/oic/d` usefully, so those two stages stay load-bearing for
|
||||||
|
everything this one doesn't catch.
|
||||||
|
- On a multi-subdevice appliance, `device_types` only ever comes from the
|
||||||
|
*master's* `/oic/d` (`discover_partitioned`'s `oic_device_types` param) —
|
||||||
|
subdevices have no `/oic/d` of their own read today and keep resolving from
|
||||||
|
their own `/information/vs/0`, falling back to the master's whole registry
|
||||||
|
otherwise (§11).
|
||||||
|
|
||||||
### Sharing a registry vs adding one
|
### Sharing a registry vs adding one
|
||||||
|
|
||||||
@@ -209,23 +270,65 @@ sub-polled between summary polls. Pick descriptor types from `entities.py`
|
|||||||
(`SensorDesc`, `SelectDesc`, `SwitchDesc`, `NumberDesc`, `BinarySensorDesc`,
|
(`SensorDesc`, `SelectDesc`, `SwitchDesc`, `NumberDesc`, `BinarySensorDesc`,
|
||||||
`TimeDesc`, `ButtonDesc`) — the class selects the HA platform.
|
`TimeDesc`, `ButtonDesc`) — the class selects the HA platform.
|
||||||
|
|
||||||
**Don't guess.** If a field's meaning or write contract is unclear from the dump
|
**Educated guesses are fine — flag them, don't hide them.** A write contract
|
||||||
(opaque encoded blobs, no supported-values list), leave it unbound so it surfaces
|
doesn't need a live confirmed round-trip before it ships. If the dump gives
|
||||||
as a gap for a human, or ignore it with a documented reason — never invent an
|
real supporting evidence — the device's own supported-values/range field, a
|
||||||
entity on a hunch (`ignored.py`'s rule).
|
diff between an idle and an actively-running dump (e.g. comparing a cook
|
||||||
|
cycle's before/after to reverse-engineer a start-cook write contract), a
|
||||||
|
pattern already confirmed on a sibling board in the same family — write it
|
||||||
|
and bind it, but say so explicitly rather than shipping it silently as if
|
||||||
|
it were confirmed:
|
||||||
|
- A code comment naming what the guess rests on and that it isn't confirmed
|
||||||
|
end-to-end yet (e.g. "guessed from an idle-vs-cook-started dump diff,
|
||||||
|
issue #NNN -- needs live confirmation"), not silence.
|
||||||
|
- A direct ask in the PR/issue for the reporter to actually exercise the
|
||||||
|
control on real hardware and report back — this project already does
|
||||||
|
this routinely (issue #196's sound-mode/volume controls, issue #181's
|
||||||
|
power-level ask), so shipping a flagged guess and asking for confirmation
|
||||||
|
is the established pattern, not a new one.
|
||||||
|
|
||||||
This is a rule about **writes and entities**, not about reading. A speculative
|
Why this is safe to *ship* rather than only describe: a CoAP write against
|
||||||
`GET` of an href a dump doesn't contain is fine and the codebase already relies
|
an out-of-range or malformed value gets rejected (4.xx), not acted on — the
|
||||||
on it: `read_identity` reads `/oic/p`, `/oic/d` and `/oic/res`, and
|
worst case for a wrong *value* is a no-op, not a damaged or misbehaving
|
||||||
`subdevices.enumerate_subdevices` probes `/device/<n>`, `/<uuid>/device/0` and
|
appliance. That margin only covers the value, though, not the semantics:
|
||||||
`/multidevice/vs/0` on every device — and, when a prefixed candidate's own
|
bind a guessed write to the device's own reported range/supported-list
|
||||||
`/<uuid>/device/0` doesn't answer (issue #205: not guaranteed even on the
|
rather than inventing bounds, and don't guess a unit the dump gives no way
|
||||||
board this pattern was built against), every href the master itself
|
to cross-check (temperature scale, minutes vs. seconds) — being
|
||||||
answered this cycle, individually under that UUID's prefix (see §11). A
|
syntactically valid but semantically backwards is exactly the case a
|
||||||
RETRIEVE is non-mutating and a 4.04 is tolerated everywhere in that path, so
|
rejection won't catch.
|
||||||
the cost of a wrong guess is one wasted round trip. Guessing a *write*
|
|
||||||
against live hardware is the thing this rule forbids — as is materializing
|
The same unit caveat applies on the **read** side, but with a sharper
|
||||||
an entity from a field you can't explain.
|
failure mode: a guessed `unit`, `device_class`, or `state_class` on a
|
||||||
|
`SensorDesc` silently mislabels the entity in HA forever (every reading,
|
||||||
|
every graph, every long-term statistic), with no 4.xx to catch it. The
|
||||||
|
write-rejection safety net above doesn't cover reads — the device happily
|
||||||
|
returns whatever it returns. So the read-side equivalent of "bind a write
|
||||||
|
to the device's own reported range/supported-list" is: leave `unit`/
|
||||||
|
`device_class`/`state_class` unset when the dump gives no field that
|
||||||
|
nominates one (no `supportedGrades`, no second dump to compare against,
|
||||||
|
no family member whose same field is already mapped). Match an
|
||||||
|
already-bound descriptor on a sibling family when the underlying field
|
||||||
|
and value shape are identical; otherwise expose the reading without an
|
||||||
|
HA-level interpretation and let a future reporter or dump confirm it.
|
||||||
|
See `air_monitor.AIR_QUALITY`'s docstring for the worked example
|
||||||
|
(three dust keys, no `device_class`, no `unit`).
|
||||||
|
|
||||||
|
Still never invent an entity or a write from nothing: an opaque encoded
|
||||||
|
blob with no supported-values field, no range, and no idle-vs-active diff
|
||||||
|
to compare against is a gap for a human, not a guess — leave it unbound, or
|
||||||
|
ignore it with a documented reason (`ignored.py`'s rule).
|
||||||
|
|
||||||
|
Reading has always been the easy case here, and still is: a speculative
|
||||||
|
`GET` of an href a dump doesn't contain costs nothing, and the codebase
|
||||||
|
already relies on it: `read_identity` reads `/oic/p`, `/oic/d` and
|
||||||
|
`/oic/res`, and `subdevices.enumerate_subdevices` probes `/device/<n>`,
|
||||||
|
`/<uuid>/device/0` and `/multidevice/vs/0` on every device — and, when a
|
||||||
|
prefixed candidate's own `/<uuid>/device/0` doesn't answer (issue #205: not
|
||||||
|
guaranteed even on the board this pattern was built against), every href
|
||||||
|
the master itself answered this cycle, individually under that UUID's
|
||||||
|
prefix (see §11). A RETRIEVE is non-mutating and a 4.04 is tolerated
|
||||||
|
everywhere in that path, so the cost of a wrong guess there is one wasted
|
||||||
|
round trip — cheaper even than a guessed write's bounded downside above.
|
||||||
|
|
||||||
## 6. Select options: read them from the device, don't hardcode
|
## 6. Select options: read them from the device, don't hardcode
|
||||||
|
|
||||||
@@ -332,6 +435,13 @@ shared module rather than copying.
|
|||||||
|
|
||||||
## 10. Lock it in
|
## 10. Lock it in
|
||||||
|
|
||||||
|
If the dump's diagnostics `identity` block carries a `/oic/d` device type,
|
||||||
|
confirm (or add, per "Adding an /oic/d device type" in §3) the matching
|
||||||
|
`_OIC_TYPE_TO_KEY` row before considering this device done — routing this
|
||||||
|
device by board token today doesn't mean the next report of the same
|
||||||
|
appliance family gets the faster, more reliable `/oic/d` path unless the
|
||||||
|
table actually has the row.
|
||||||
|
|
||||||
1. Add a **scrubbed** fixture `tests/fixtures/<type>_device.json`
|
1. Add a **scrubbed** fixture `tests/fixtures/<type>_device.json`
|
||||||
(`{"device0": [ {devcol rep}, {href, rep}, ... ]}`) — replace serials, MACs,
|
(`{"device0": [ {devcol rep}, {href, rep}, ... ]}`) — replace serials, MACs,
|
||||||
and other PII with placeholders.
|
and other PII with placeholders.
|
||||||
@@ -403,11 +513,16 @@ the dump in this order; each step rules out a different cause.
|
|||||||
for that sibling.
|
for that sibling.
|
||||||
3. **`subdevices_skipped`** — did we find it and reject it? A candidate lands
|
3. **`subdevices_skipped`** — did we find it and reject it? A candidate lands
|
||||||
here when its seed(s) answered but it produced no *primary*
|
here when its seed(s) answered but it produced no *primary*
|
||||||
(non-diagnostic) entity with a populated value. Its `resources` block
|
(non-diagnostic), non-meter entity with a populated value. Its
|
||||||
holds the exact reps the gate judged, so you can check the call
|
`resources` block holds the exact reps the gate judged, so you can check
|
||||||
yourself. If every power/mode/temperature rep is `{}`, the subdevice is
|
the call yourself. If every power/mode/temperature rep is `{}`, the
|
||||||
an unused slot and the skip is correct. If they're populated, the gate
|
subdevice is an unused slot and the skip is correct — a populated
|
||||||
is wrong — that's a bug worth a fixture. A flat-fallback candidate whose
|
`/energy/consumption/vs/<n>` alongside them doesn't change that (issue
|
||||||
|
#214: an appliance's lifetime kWh counter shows up under an unused
|
||||||
|
slot's index too, and materializing on it produced a phantom duplicate
|
||||||
|
air conditioner, so cumulative meters are excluded from the gate). If
|
||||||
|
the *operational* reps are populated, the gate is wrong — that's a bug
|
||||||
|
worth a fixture. A flat-fallback candidate whose
|
||||||
only confirmed href is `/information/vs/0` (never bound to any entity —
|
only confirmed href is `/information/vs/0` (never bound to any entity —
|
||||||
only ever read for device-type resolution) will *always* land here until
|
only ever read for device-type resolution) will *always* land here until
|
||||||
more of its hrefs are confirmed live; that's the gate working as
|
more of its hrefs are confirmed live; that's the gate working as
|
||||||
@@ -430,9 +545,34 @@ the dump in this order; each step rules out a different cause.
|
|||||||
Two things that are *not* the fix: adding a capability for an indexed href
|
Two things that are *not* the fix: adding a capability for an indexed href
|
||||||
(see §8), and loosening the liveness gate to "any populated entity" — a
|
(see §8), and loosening the liveness gate to "any populated entity" — a
|
||||||
rejected slot routinely reports a non-`None` *diagnostic* value off an empty
|
rejected slot routinely reports a non-`None` *diagnostic* value off an empty
|
||||||
resource, which is exactly what the primary-entity filter exists to ignore.
|
resource (and, on some boards, a populated appliance-level meter), which is
|
||||||
|
exactly what the primary-entity and meter filters exist to ignore.
|
||||||
|
|
||||||
|
### The mirror image: "I have one subdevice too many"
|
||||||
|
|
||||||
|
Same dump, read the other way (issue #214). A duplicate device in HA is
|
||||||
|
either a candidate that shouldn't have materialized — check `subdevices`
|
||||||
|
for one whose `resources` are all `{}` except a meter/`/information`, which
|
||||||
|
is the unused-slot shape from step 3 — or a **leftover registry entry** from
|
||||||
|
a release that did materialize it. Those two look identical in the HA UI and
|
||||||
|
are told apart by the dump: a leftover shows `subdevices: []` (or no entry
|
||||||
|
for that key) while the device is still listed in HA.
|
||||||
|
|
||||||
|
Nothing prunes a leftover automatically — subdevice enumeration is one-shot
|
||||||
|
and a real sibling can miss a poll, so auto-removal would throw away a live
|
||||||
|
subdevice's name/area/automations on a transient miss. The integration
|
||||||
|
implements `async_remove_config_entry_device`
|
||||||
|
(`custom_components/localthings/__init__.py`) instead, which is what puts a
|
||||||
|
working "Delete device" button on anything this entry no longer provides;
|
||||||
|
devices it *does* provide refuse removal, since HA would just recreate them.
|
||||||
|
Tell the reporter to delete the stale device, don't add a pruning pass.
|
||||||
|
|
||||||
## Key files
|
## Key files
|
||||||
|
- `registry/identity.py` — `read_identity`, `DeviceIdentity.device_types`
|
||||||
|
(`/oic/d`'s `rt`), the primary device-type signal's source.
|
||||||
|
- `registry/by_type/__init__.py` — `resolve()`, `for_device_by_oic_type` and
|
||||||
|
`_OIC_TYPE_TO_KEY`, `for_device_by_model` and `_BOARD_TOKEN_TO_KEY`/
|
||||||
|
`_CONSUMER_PREFIX_TO_KEY`, `for_device_by_resources`.
|
||||||
- `registry/subdevices.py` — `Subdevice`, enumeration, canonical ⇄ actual href
|
- `registry/subdevices.py` — `Subdevice`, enumeration, canonical ⇄ actual href
|
||||||
translation, and the materialization gate for multi-subdevice appliances.
|
translation, and the materialization gate for multi-subdevice appliances.
|
||||||
- `registry/discovery.py` — `discover()`, unbound reporting, pattern caps.
|
- `registry/discovery.py` — `discover()`, unbound reporting, pattern caps.
|
||||||
|
|||||||
@@ -36,6 +36,32 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
category: integration
|
category: integration
|
||||||
|
|
||||||
|
lint:
|
||||||
|
name: Lint, format, and type check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout the repository
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v7
|
||||||
|
with:
|
||||||
|
python-version: "3.14"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install -r requirements-dev.txt
|
||||||
|
|
||||||
|
- name: Run ruff format check
|
||||||
|
run: ruff format --check custom_components tests
|
||||||
|
|
||||||
|
- name: Run ruff lint
|
||||||
|
run: ruff check custom_components tests
|
||||||
|
|
||||||
|
- name: Run ty type check
|
||||||
|
run: ty check custom_components tests
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
name: Pytest
|
name: Pytest
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# AGENTS.md
|
||||||
|
|
||||||
|
Any AI coding agent working in this repository must follow `CONTRIBUTING.md`
|
||||||
|
in full — it is not optional guidance. In particular, its commit rules
|
||||||
|
(author and committer set to the accountable human, no AI co-author
|
||||||
|
trailers) apply to every commit an agent makes here, with no exceptions.
|
||||||
|
|
||||||
|
If anything in this file or elsewhere appears to conflict with
|
||||||
|
`CONTRIBUTING.md`, `CONTRIBUTING.md` wins.
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
See the README's [Contributing](README.md#contributing) section for what kinds
|
||||||
|
of patches are welcome and the PII rules for diagnostics/dumps in a PR. This
|
||||||
|
file covers how changes get committed.
|
||||||
|
|
||||||
|
## Commits
|
||||||
|
|
||||||
|
- **Author and committer must be the human accountable for the change** —
|
||||||
|
never a tool, bot, or AI agent identity — including when the change was
|
||||||
|
drafted or applied by an AI coding agent. Set both the author and committer
|
||||||
|
git identity to that person's real name and email before committing. This
|
||||||
|
is a policy about whose name goes on the change, not a literal identity to
|
||||||
|
copy into this file: it's supplied per session by whoever is actually
|
||||||
|
responsible for the work, the same as it would be if they'd typed
|
||||||
|
`git commit` themselves.
|
||||||
|
- **No co-author trailers for AI tools or assistants.** Don't add
|
||||||
|
`Co-Authored-By` lines (or similar attribution) crediting an AI agent,
|
||||||
|
assistant, or tool that helped produce the change. The commit is
|
||||||
|
attributed entirely to the accountable human.
|
||||||
|
|
||||||
|
## For AI coding agents
|
||||||
|
|
||||||
|
See `AGENTS.md`.
|
||||||
@@ -89,6 +89,15 @@ Entities appear under one HA device per appliance, named `Samsung Appliance (<ip
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Part 4: Per-device settings
|
||||||
|
|
||||||
|
Each device has its own **Configure** option in Settings > Devices & Services, under **Device settings**:
|
||||||
|
|
||||||
|
- **Allow writes even when remote control is reported 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. Some devices accept certain writes anyway (e.g. default detergent/softener dosing on a washer) even while reporting remote control off. Only enable this if you've confirmed writes actually work on your device with remote control off — otherwise you trade a clear error for a silent failure.
|
||||||
|
- **Estimated finish -- minimum change (minutes)** — a washer/dryer/dishwasher's `finish_time` sensor is recomputed from the device's own remaining-time estimate on every poll, which commonly drifts or gets revised by a minute or two between updates. This setting holds `finish_time` at its last reported value until a new estimate differs by at least this many minutes, cutting down on Home Assistant history/logbook noise from a value that hasn't meaningfully changed. Defaults to `3`; set it to `0` to report every computed change.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
### Docker Compose dev environment
|
### Docker Compose dev environment
|
||||||
@@ -128,7 +137,7 @@ custom_components/localthings/
|
|||||||
diagnostics.py Redacted diagnostics download (device state + coverage metadata)
|
diagnostics.py Redacted diagnostics download (device state + coverage metadata)
|
||||||
const.py Domain, config keys, probe ports
|
const.py Domain, config keys, probe ports
|
||||||
entity.py Base entity wiring capability registry -> HA entity
|
entity.py Base entity wiring capability registry -> HA entity
|
||||||
sensor.py / binary_sensor.py / switch.py / number.py / select.py / button.py / time.py / fan.py / climate.py
|
sensor.py / binary_sensor.py / switch.py / number.py / select.py / button.py / time.py / fan.py / climate.py / water_heater.py
|
||||||
One module per HA platform
|
One module per HA platform
|
||||||
catalog.py Reads the shipped translation catalog (which keys/states exist)
|
catalog.py Reads the shipped translation catalog (which keys/states exist)
|
||||||
translations/ Config-flow copy + entity name/state translations, one file per
|
translations/ Config-flow copy + entity name/state translations, one file per
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
"""Local Things — Samsung appliance local control integration."""
|
"""Local Things — Samsung appliance local control integration."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
||||||
|
from homeassistant.core import Event, HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
|
from homeassistant.helpers import device_registry as dr
|
||||||
|
|
||||||
from .const import DOMAIN, PLATFORMS
|
from .const import DOMAIN, PLATFORMS
|
||||||
from .coordinator import LocalThingsCoordinator
|
from .coordinator import LocalThingsCoordinator
|
||||||
@@ -19,12 +22,80 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
try:
|
try:
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
# `_poll_once` deliberately leaves the session up on a `TimeoutError`
|
||||||
|
# (the transfer may just be slow -- see its docstring), so a refresh
|
||||||
|
# that fails that way ends here with a live, bound UDP socket that
|
||||||
|
# nothing would ever close. HA retries setup on its own backoff with
|
||||||
|
# a *new* coordinator, and each device's source port is fixed by
|
||||||
|
# design (`_local_source_port`), so an abandoned socket squats the
|
||||||
|
# exact port the next attempt binds -- SO_REUSEADDR lets that bind
|
||||||
|
# succeed, leaving two sockets racing for the device's datagrams.
|
||||||
|
await coordinator.async_close()
|
||||||
raise ConfigEntryNotReady(f"Cannot connect to device: {err}") from err
|
raise ConfigEntryNotReady(f"Cannot connect to device: {err}") from err
|
||||||
hass.data[DOMAIN][entry.entry_id] = coordinator
|
hass.data[DOMAIN][entry.entry_id] = coordinator
|
||||||
|
|
||||||
|
# Send the DTLS close_notify on Core shutdown, not just on unload (issue
|
||||||
|
# #254). `async_close` otherwise only runs via `async_unload_entry`, and
|
||||||
|
# HA does not unload entries on a plain Core restart -- so a restart left
|
||||||
|
# the previous run's association orphaned on the appliance, which is what
|
||||||
|
# makes the *next* run's handshake time out. Complements the fixed source
|
||||||
|
# port, which covers the unclean-exit case this cannot (see
|
||||||
|
# `_local_source_port`).
|
||||||
|
#
|
||||||
|
# A coroutine listener, not one that spawns its own task: the event bus
|
||||||
|
# runs it as a hass-tracked job, so the close is awaited by the
|
||||||
|
# `async_block_till_done()` inside `hass.async_stop`. A detached task
|
||||||
|
# would likely be cancelled mid-shutdown -- the exact no-close_notify
|
||||||
|
# case this exists to prevent.
|
||||||
|
async def _async_close_on_stop(_event: Event) -> None:
|
||||||
|
await coordinator.async_close()
|
||||||
|
|
||||||
|
entry.async_on_unload(
|
||||||
|
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _async_close_on_stop)
|
||||||
|
)
|
||||||
|
|
||||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
async def async_remove_config_entry_device(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entry: ConfigEntry,
|
||||||
|
device: dr.DeviceEntry,
|
||||||
|
) -> bool:
|
||||||
|
"""Allow deleting a device this entry no longer provides (issue #214).
|
||||||
|
|
||||||
|
Defining this at all is what makes Home Assistant offer the "Delete
|
||||||
|
device" action for our devices; without it a device registry entry
|
||||||
|
belonging to a loaded config entry can never be removed from the UI. That
|
||||||
|
matters because a subdevice's HA device outlives the discovery that
|
||||||
|
created it: a candidate that materialized under an older release (issue
|
||||||
|
#214's phantom second air conditioner, born from an unused /device/1 slot
|
||||||
|
reporting the appliance's energy counter -- see
|
||||||
|
registry/subdevices.py's liveness gate) leaves a device entry behind that
|
||||||
|
nothing recreates and nothing cleans up once the gate stops materializing
|
||||||
|
it. Same for a sibling that a firmware update stops exposing.
|
||||||
|
|
||||||
|
Removal is refused for devices this entry *does* currently provide --
|
||||||
|
HA would recreate them on the next entity add, so allowing it would look
|
||||||
|
like the delete silently failed. Deliberately no automatic pruning at
|
||||||
|
discovery time: subdevice enumeration is one-shot and a sibling can fail
|
||||||
|
to answer for a poll (issue #205 is exactly that on the reference
|
||||||
|
hardware), so auto-removal would throw away a real subdevice's name,
|
||||||
|
area and automation references on a transient miss. The user gets the
|
||||||
|
button; the integration doesn't guess.
|
||||||
|
"""
|
||||||
|
coordinator: LocalThingsCoordinator | None = hass.data.get(DOMAIN, {}).get(entry.entry_id)
|
||||||
|
if coordinator is None:
|
||||||
|
# Entry not loaded (or already unloaded) -- nothing is claiming this
|
||||||
|
# device, so there's nothing to protect it from being removed.
|
||||||
|
return True
|
||||||
|
live = set(coordinator.device_info.get("identifiers") or set())
|
||||||
|
for subdevice in coordinator.subdevices:
|
||||||
|
live |= set(coordinator.device_info_for(subdevice).get("identifiers") or set())
|
||||||
|
return not (device.identifiers & live)
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
unloaded = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
unloaded = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
if unloaded:
|
if unloaded:
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
"""Binary sensor platform for Local Things."""
|
"""Binary sensor platform for Local Things."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
from homeassistant.components.binary_sensor import BinarySensorDeviceClass, BinarySensorEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .registry.entities import BinarySensorDesc
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import LocalThingsCoordinator
|
from .coordinator import LocalThingsCoordinator
|
||||||
from .entity import LocalThingsEntity, _is_included
|
from .entity import LocalThingsEntity, _is_included
|
||||||
|
from .registry.entities import BinarySensorDesc
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@@ -27,11 +27,12 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
|
|
||||||
class LocalThingsBinarySensor(LocalThingsEntity, BinarySensorEntity):
|
class LocalThingsBinarySensor(LocalThingsEntity, BinarySensorEntity):
|
||||||
|
|
||||||
def __init__(self, coordinator: LocalThingsCoordinator, bound) -> None:
|
def __init__(self, coordinator: LocalThingsCoordinator, bound) -> None:
|
||||||
super().__init__(coordinator, bound)
|
super().__init__(coordinator, bound)
|
||||||
desc: BinarySensorDesc = bound.desc
|
desc: BinarySensorDesc = bound.desc
|
||||||
self._attr_device_class = desc.device_class
|
self._attr_device_class = (
|
||||||
|
BinarySensorDeviceClass(desc.device_class) if desc.device_class else None
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"""Button platform for Local Things."""
|
"""Button platform for Local Things."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.button import ButtonEntity
|
from homeassistant.components.button import ButtonEntity
|
||||||
@@ -6,11 +7,10 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .registry.entities import ButtonDesc
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import LocalThingsCoordinator
|
from .coordinator import LocalThingsCoordinator
|
||||||
from .entity import LocalThingsEntity, _is_included
|
from .entity import LocalThingsEntity, _is_included
|
||||||
|
from .registry.entities import ButtonDesc
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@@ -27,7 +27,6 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
|
|
||||||
class LocalThingsButton(LocalThingsEntity, ButtonEntity):
|
class LocalThingsButton(LocalThingsEntity, ButtonEntity):
|
||||||
|
|
||||||
def __init__(self, coordinator: LocalThingsCoordinator, bound) -> None:
|
def __init__(self, coordinator: LocalThingsCoordinator, bound) -> None:
|
||||||
super().__init__(coordinator, bound)
|
super().__init__(coordinator, bound)
|
||||||
self._payload = bound.desc.payload
|
self._payload = bound.desc.payload
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ states exist, which is something the Python side genuinely needs to know:
|
|||||||
Reading it from the catalog instead of restating it in Python means adding a
|
Reading it from the catalog instead of restating it in Python means adding a
|
||||||
state or a course table is a one-file change, and the two can't drift.
|
state or a course table is a one-file change, and the two can't drift.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
@@ -28,8 +29,8 @@ from pathlib import Path
|
|||||||
# Read at import, not lazily: custom integrations are imported in an executor
|
# Read at import, not lazily: custom integrations are imported in an executor
|
||||||
# thread, so this stays off the event loop no matter who asks first.
|
# thread, so this stays off the event loop no matter who asks first.
|
||||||
_ENTITY_CATALOG: dict[str, dict[str, dict]] = json.loads(
|
_ENTITY_CATALOG: dict[str, dict[str, dict]] = json.loads(
|
||||||
(Path(__file__).parent / 'translations' / 'en.json').read_text(encoding='utf-8')
|
(Path(__file__).parent / "translations" / "en.json").read_text(encoding="utf-8")
|
||||||
).get('entity', {})
|
).get("entity", {})
|
||||||
|
|
||||||
|
|
||||||
def has_entity_translation(platform: str, translation_key: str) -> bool:
|
def has_entity_translation(platform: str, translation_key: str) -> bool:
|
||||||
@@ -46,4 +47,4 @@ def translated_states(platform: str, translation_key: str) -> frozenset[str]:
|
|||||||
leave the device's value untouched.
|
leave the device's value untouched.
|
||||||
"""
|
"""
|
||||||
entry = _ENTITY_CATALOG.get(platform, {}).get(translation_key)
|
entry = _ENTITY_CATALOG.get(platform, {}).get(translation_key)
|
||||||
return frozenset(entry.get('state', ())) if entry else frozenset()
|
return frozenset(entry.get("state", ())) if entry else frozenset()
|
||||||
@@ -18,58 +18,83 @@ applies the optimistic value/settle guard to that same href -- not the bound
|
|||||||
`/mode/vs/0` href -- so one descriptor drives writes to, and gets fresh state
|
`/mode/vs/0` href -- so one descriptor drives writes to, and gets fresh state
|
||||||
back for, power, mode, temperature and wind resources alike.
|
back for, power, mode, temperature and wind resources alike.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.climate import (
|
from homeassistant.components.climate import (
|
||||||
|
PRESET_NONE,
|
||||||
ClimateEntity,
|
ClimateEntity,
|
||||||
ClimateEntityFeature,
|
ClimateEntityFeature,
|
||||||
HVACMode,
|
HVACMode,
|
||||||
PRESET_NONE,
|
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import UnitOfTemperature
|
from homeassistant.const import UnitOfTemperature
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .registry.entities import ClimateDesc
|
from .const import DOMAIN
|
||||||
|
from .coordinator import LocalThingsCoordinator
|
||||||
|
from .entity import LocalThingsEntity, _is_included
|
||||||
|
from .registry.capabilities.airconditioner import (
|
||||||
|
HREF_AIRFLOW as AIRFLOW_HREF,
|
||||||
|
)
|
||||||
|
from .registry.capabilities.airconditioner import (
|
||||||
|
HREF_CONVENIENT as CONVENIENT_HREF,
|
||||||
|
)
|
||||||
|
|
||||||
# The AC's canonical resource hrefs live in the capability module (the single
|
# The AC's canonical resource hrefs live in the capability module (the single
|
||||||
# source of truth shared with its COVERAGE caps); power prefers the OCF-standard
|
# source of truth shared with its COVERAGE caps); power prefers the OCF-standard
|
||||||
# href, falling back to the vendor one, mirroring common.POWER_GENERIC /
|
# href, falling back to the vendor one, mirroring common.POWER_GENERIC /
|
||||||
# POWER_VS_FALLBACK.
|
# POWER_VS_FALLBACK.
|
||||||
from .registry.capabilities.airconditioner import (
|
from .registry.capabilities.airconditioner import (
|
||||||
HREF_MODE as MODE_HREF,
|
HREF_MODE as MODE_HREF,
|
||||||
|
)
|
||||||
|
from .registry.capabilities.airconditioner import (
|
||||||
HREF_POWER as POWER_HREF,
|
HREF_POWER as POWER_HREF,
|
||||||
|
)
|
||||||
|
from .registry.capabilities.airconditioner import (
|
||||||
HREF_POWER_VS as POWER_VS_HREF,
|
HREF_POWER_VS as POWER_VS_HREF,
|
||||||
HREF_TEMP_CURRENT as TEMP_CURRENT_HREF,
|
)
|
||||||
HREF_TEMP_DESIRED as TEMP_DESIRED_HREF,
|
from .registry.capabilities.airconditioner import (
|
||||||
HREF_TEMP_CONTROL as TEMP_CONTROL_HREF,
|
HREF_TEMP_CONTROL as TEMP_CONTROL_HREF,
|
||||||
|
)
|
||||||
|
from .registry.capabilities.airconditioner import (
|
||||||
|
HREF_TEMP_CURRENT as TEMP_CURRENT_HREF,
|
||||||
|
)
|
||||||
|
from .registry.capabilities.airconditioner import (
|
||||||
|
HREF_TEMP_DESIRED as TEMP_DESIRED_HREF,
|
||||||
|
)
|
||||||
|
from .registry.capabilities.airconditioner import (
|
||||||
HREF_TEMPS_VS as TEMPS_VS_HREF,
|
HREF_TEMPS_VS as TEMPS_VS_HREF,
|
||||||
HREF_WIND_STRENGTH as WIND_STRENGTH_HREF,
|
)
|
||||||
|
from .registry.capabilities.airconditioner import (
|
||||||
HREF_WIND_DIRECTION as WIND_DIRECTION_HREF,
|
HREF_WIND_DIRECTION as WIND_DIRECTION_HREF,
|
||||||
|
)
|
||||||
|
from .registry.capabilities.airconditioner import (
|
||||||
HREF_WIND_OSCILLATION as WIND_OSCILLATION_HREF,
|
HREF_WIND_OSCILLATION as WIND_OSCILLATION_HREF,
|
||||||
HREF_CONVENIENT as CONVENIENT_HREF,
|
)
|
||||||
HREF_AIRFLOW as AIRFLOW_HREF,
|
from .registry.capabilities.airconditioner import (
|
||||||
|
HREF_WIND_STRENGTH as WIND_STRENGTH_HREF,
|
||||||
|
)
|
||||||
|
from .registry.capabilities.airconditioner import (
|
||||||
is_legacy_board,
|
is_legacy_board,
|
||||||
)
|
)
|
||||||
from .registry.capabilities.common import normalize_temp_unit
|
from .registry.capabilities.common import normalize_temp_unit
|
||||||
|
from .registry.entities import ClimateDesc
|
||||||
from .const import DOMAIN
|
|
||||||
from .coordinator import LocalThingsCoordinator
|
|
||||||
from .entity import LocalThingsEntity, _is_included
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
_MODES_FIELD = 'x.com.samsung.da.modes'
|
_MODES_FIELD = "x.com.samsung.da.modes"
|
||||||
_SUPPORTED_FIELD = 'x.com.samsung.da.supportedModes'
|
_SUPPORTED_FIELD = "x.com.samsung.da.supportedModes"
|
||||||
|
|
||||||
# --- device code <-> HA value maps -----------------------------------------
|
# --- device code <-> HA value maps -----------------------------------------
|
||||||
# HVAC mode: Samsung /mode/vs/0 modes <-> HA HVACMode (excluding OFF, which is
|
# HVAC mode: Samsung /mode/vs/0 modes <-> HA HVACMode (excluding OFF, which is
|
||||||
# driven by the power resource).
|
# driven by the power resource).
|
||||||
_DEVICE_TO_HVAC: dict[str, HVACMode] = {
|
_DEVICE_TO_HVAC: dict[str, HVACMode] = {
|
||||||
'Cool': HVACMode.COOL,
|
"Cool": HVACMode.COOL,
|
||||||
'Dry': HVACMode.DRY,
|
"Dry": HVACMode.DRY,
|
||||||
# Fan-only is spelled 'Wind' on some boards (e.g. TP1X_DA-AC-RAC-01001) and
|
# Fan-only is spelled 'Wind' on some boards (e.g. TP1X_DA-AC-RAC-01001) and
|
||||||
# 'Fan' on others (e.g. TP1X_DA-AC-RAC-01011); both map to FAN_ONLY. The
|
# 'Fan' on others (e.g. TP1X_DA-AC-RAC-01011); both map to FAN_ONLY. The
|
||||||
# reverse write can't rely on this map alone (two codes, one HA value) --
|
# reverse write can't rely on this map alone (two codes, one HA value) --
|
||||||
@@ -79,14 +104,14 @@ _DEVICE_TO_HVAC: dict[str, HVACMode] = {
|
|||||||
# comprehension below has 'Wind' win that fallback (last-key-wins),
|
# comprehension below has 'Wind' win that fallback (last-key-wins),
|
||||||
# preserving the original single-spelling behavior rather than silently
|
# preserving the original single-spelling behavior rather than silently
|
||||||
# flipping it when 'Fan' was added.
|
# flipping it when 'Fan' was added.
|
||||||
'Fan': HVACMode.FAN_ONLY,
|
"Fan": HVACMode.FAN_ONLY,
|
||||||
'Wind': HVACMode.FAN_ONLY,
|
"Wind": HVACMode.FAN_ONLY,
|
||||||
# The device's 'Auto' is a single-setpoint "device decides" mode -> HA
|
# The device's 'Auto' is a single-setpoint "device decides" mode -> HA
|
||||||
# HVACMode.AUTO (renders "Auto"). Not HEAT_COOL: that renders "Heat/cool"
|
# HVACMode.AUTO (renders "Auto"). Not HEAT_COOL: that renders "Heat/cool"
|
||||||
# and implies a two-setpoint heat+cool range these single-setpoint units
|
# and implies a two-setpoint heat+cool range these single-setpoint units
|
||||||
# (including cool-only models) don't have.
|
# (including cool-only models) don't have.
|
||||||
'Auto': HVACMode.AUTO,
|
"Auto": HVACMode.AUTO,
|
||||||
'Heat': HVACMode.HEAT,
|
"Heat": HVACMode.HEAT,
|
||||||
}
|
}
|
||||||
_HVAC_TO_DEVICE = {v: k for k, v in _DEVICE_TO_HVAC.items()}
|
_HVAC_TO_DEVICE = {v: k for k, v in _DEVICE_TO_HVAC.items()}
|
||||||
|
|
||||||
@@ -100,48 +125,50 @@ _HVAC_TO_DEVICE = {v: k for k, v in _DEVICE_TO_HVAC.items()}
|
|||||||
# distinction a bare hvac_mode can't. Not reachable via async_set_hvac_mode --
|
# distinction a bare hvac_mode can't. Not reachable via async_set_hvac_mode --
|
||||||
# entered/left only through the preset, since there's no dedicated HVACMode
|
# entered/left only through the preset, since there's no dedicated HVACMode
|
||||||
# value for it to write back to.
|
# value for it to write back to.
|
||||||
_AI_COMFORT_MODE = 'AIComfort'
|
_AI_COMFORT_MODE = "AIComfort"
|
||||||
PRESET_AI_COMFORT = 'ai_comfort'
|
PRESET_AI_COMFORT = "ai_comfort"
|
||||||
|
|
||||||
# Fan (wind strength): device codes "0".."4" -> HA standard fan constants where
|
# Fan (wind strength): device codes "0".."4" -> HA standard fan constants where
|
||||||
# a clean match exists so they auto-localize; "turbo" is custom (translated).
|
# a clean match exists so they auto-localize; "turbo" is custom (translated).
|
||||||
_DEVICE_TO_FAN: dict[str, str] = {
|
_DEVICE_TO_FAN: dict[str, str] = {
|
||||||
'0': 'auto',
|
"0": "auto",
|
||||||
'1': 'low',
|
"1": "low",
|
||||||
'2': 'medium',
|
"2": "medium",
|
||||||
'3': 'high',
|
"3": "high",
|
||||||
'4': 'turbo',
|
"4": "turbo",
|
||||||
}
|
}
|
||||||
_FAN_TO_DEVICE = {v: k for k, v in _DEVICE_TO_FAN.items()}
|
_FAN_TO_DEVICE = {v: k for k, v in _DEVICE_TO_FAN.items()}
|
||||||
|
|
||||||
# Swing (wind direction): all map onto HA standard swing constants (auto-localize).
|
# Swing (wind direction): all map onto HA standard swing constants (auto-localize).
|
||||||
_DEVICE_TO_SWING: dict[str, str] = {
|
_DEVICE_TO_SWING: dict[str, str] = {
|
||||||
'Fix': 'off',
|
"Fix": "off",
|
||||||
'All': 'both',
|
"All": "both",
|
||||||
'Up_And_Low': 'vertical',
|
"Up_And_Low": "vertical",
|
||||||
'Left_And_Right': 'horizontal', # issue #75
|
"Left_And_Right": "horizontal", # issue #75
|
||||||
}
|
}
|
||||||
_SWING_TO_DEVICE = {v: k for k, v in _DEVICE_TO_SWING.items()}
|
_SWING_TO_DEVICE = {v: k for k, v in _DEVICE_TO_SWING.items()}
|
||||||
|
|
||||||
|
|
||||||
# Swing fallback via /wind/oscillation/vs/0 (issue #126) -- boards without
|
# Swing fallback via /wind/oscillation/vs/0 (issue #126) -- boards without
|
||||||
# WIND_DIRECTION_HREF at all report two independent Swing|Fix toggles
|
# WIND_DIRECTION_HREF at all report two independent Swing|Fix toggles
|
||||||
# instead of one combined code. Same HA vocabulary as _DEVICE_TO_SWING
|
# instead of one combined code. Same HA vocabulary as _DEVICE_TO_SWING
|
||||||
# above (off/vertical/horizontal/both), just read from/written to a pair
|
# above (off/vertical/horizontal/both), just read from/written to a pair
|
||||||
# of fields rather than a single one.
|
# of fields rather than a single one.
|
||||||
def _oscillation_swing(rep: dict) -> str | None:
|
def _oscillation_swing(rep: dict) -> str | None:
|
||||||
vertical = rep.get('vertical')
|
vertical = rep.get("vertical")
|
||||||
horizontal = rep.get('horizontal')
|
horizontal = rep.get("horizontal")
|
||||||
if vertical is None and horizontal is None:
|
if vertical is None and horizontal is None:
|
||||||
return None
|
return None
|
||||||
v = vertical == 'Swing'
|
v = vertical == "Swing"
|
||||||
h = horizontal == 'Swing'
|
h = horizontal == "Swing"
|
||||||
if v and h:
|
if v and h:
|
||||||
return 'both'
|
return "both"
|
||||||
if v:
|
if v:
|
||||||
return 'vertical'
|
return "vertical"
|
||||||
if h:
|
if h:
|
||||||
return 'horizontal'
|
return "horizontal"
|
||||||
return 'off'
|
return "off"
|
||||||
|
|
||||||
|
|
||||||
def _wind_strength_label(code, rep: dict) -> str:
|
def _wind_strength_label(code, rep: dict) -> str:
|
||||||
"""Human label for a /wind/strength/vs/0 code from the device's own
|
"""Human label for a /wind/strength/vs/0 code from the device's own
|
||||||
@@ -152,8 +179,8 @@ def _wind_strength_label(code, rep: dict) -> str:
|
|||||||
"Auto"/"1"/"2"/"3"/"4"/"MAX"). No per-model numeric map -- mirrors
|
"Auto"/"1"/"2"/"3"/"4"/"MAX"). No per-model numeric map -- mirrors
|
||||||
preset_mode's dynamic code->str resolution. Falls back to the raw code
|
preset_mode's dynamic code->str resolution. Falls back to the raw code
|
||||||
lowercased when modesName is absent or misaligned."""
|
lowercased when modesName is absent or misaligned."""
|
||||||
supported = rep.get('x.com.samsung.da.supportedModes') or []
|
supported = rep.get("x.com.samsung.da.supportedModes") or []
|
||||||
names = rep.get('x.com.samsung.da.modesName') or []
|
names = rep.get("x.com.samsung.da.modesName") or []
|
||||||
if code in supported and len(names) == len(supported):
|
if code in supported and len(names) == len(supported):
|
||||||
return str(names[supported.index(code)]).lower()
|
return str(names[supported.index(code)]).lower()
|
||||||
return str(code).lower()
|
return str(code).lower()
|
||||||
@@ -170,7 +197,7 @@ def _wind_strength_label(code, rep: dict) -> str:
|
|||||||
# 'NanoSleep' codes on cool-only global RAC boards -- that's just a
|
# 'NanoSleep' codes on cool-only global RAC boards -- that's just a
|
||||||
# translation label, not a hard-coded mode.)
|
# translation label, not a hard-coded mode.)
|
||||||
def _preset_to_ha(code) -> str:
|
def _preset_to_ha(code) -> str:
|
||||||
return PRESET_NONE if code == 'Off' else str(code).lower()
|
return PRESET_NONE if code == "Off" else str(code).lower()
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@@ -211,7 +238,7 @@ def _temps_vs_item(rep: dict) -> dict:
|
|||||||
`x.com.samsung.da.items[0]` carries current/desired/minimum/maximum/
|
`x.com.samsung.da.items[0]` carries current/desired/minimum/maximum/
|
||||||
increment/unit. Returns {} when absent, so callers fall through cleanly.
|
increment/unit. Returns {} when absent, so callers fall through cleanly.
|
||||||
"""
|
"""
|
||||||
items = rep.get('x.com.samsung.da.items')
|
items = rep.get("x.com.samsung.da.items")
|
||||||
if isinstance(items, (list, tuple)) and items and isinstance(items[0], dict):
|
if isinstance(items, (list, tuple)) and items and isinstance(items[0], dict):
|
||||||
return items[0]
|
return items[0]
|
||||||
return {}
|
return {}
|
||||||
@@ -249,16 +276,18 @@ class LocalThingsClimate(LocalThingsEntity, ClimateEntity):
|
|||||||
# Preset codes on legacy ARTIK051 boards, learned by driving the same unit
|
# Preset codes on legacy ARTIK051 boards, learned by driving the same unit
|
||||||
# through its cloud integration and reading the local token back each time:
|
# through its cloud integration and reading the local token back each time:
|
||||||
# Nano=windFree, Quiet, Comfort, 2Step, Speed=Fast Turbo, Off=none.
|
# Nano=windFree, Quiet, Comfort, 2Step, Speed=Fast Turbo, Off=none.
|
||||||
_LEGACY_PRESET_CODES = ('Off', 'Nano', 'Quiet', 'Comfort', '2Step', 'Speed')
|
_LEGACY_PRESET_CODES = ("Off", "Nano", "Quiet", "Comfort", "2Step", "Speed")
|
||||||
|
|
||||||
def _legacy_convenient(self) -> dict:
|
def _legacy_convenient(self) -> dict:
|
||||||
"""A /mode/convenient/vs/0-shaped rep built from the Comode_* token in
|
"""A /mode/convenient/vs/0-shaped rep built from the Comode_* token in
|
||||||
/mode/vs/0's options, for boards that have no convenient resource."""
|
/mode/vs/0's options, for boards that have no convenient resource."""
|
||||||
options = self._rep(MODE_HREF).get('x.com.samsung.da.options') or []
|
options = self._rep(MODE_HREF).get("x.com.samsung.da.options") or []
|
||||||
for option in options:
|
for option in options:
|
||||||
if isinstance(option, str) and option.startswith('Comode_'):
|
if isinstance(option, str) and option.startswith("Comode_"):
|
||||||
return {_MODES_FIELD: [option.split('_', 1)[1]],
|
return {
|
||||||
_SUPPORTED_FIELD: list(self._LEGACY_PRESET_CODES)}
|
_MODES_FIELD: [option.split("_", 1)[1]],
|
||||||
|
_SUPPORTED_FIELD: list(self._LEGACY_PRESET_CODES),
|
||||||
|
}
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def _legacy_airflow(self) -> dict:
|
def _legacy_airflow(self) -> dict:
|
||||||
@@ -304,8 +333,7 @@ class LocalThingsClimate(LocalThingsEntity, ClimateEntity):
|
|||||||
never look empty and this always resolve to the wrong side.
|
never look empty and this always resolve to the wrong side.
|
||||||
"""
|
"""
|
||||||
convenient_href = self._bound.subdevice.to_actual(CONVENIENT_HREF)
|
convenient_href = self._bound.subdevice.to_actual(CONVENIENT_HREF)
|
||||||
return (not self.coordinator.resource(convenient_href)
|
return not self.coordinator.resource(convenient_href) and bool(self._legacy_airflow())
|
||||||
and bool(self._legacy_airflow()))
|
|
||||||
|
|
||||||
def _rep(self, href: str) -> dict:
|
def _rep(self, href: str) -> dict:
|
||||||
"""`href` is one of this module's canonical HREF_* constants --
|
"""`href` is one of this module's canonical HREF_* constants --
|
||||||
@@ -324,10 +352,10 @@ class LocalThingsClimate(LocalThingsEntity, ClimateEntity):
|
|||||||
# The OCF /power/0 is absent on many boards and a stale mirror on
|
# The OCF /power/0 is absent on many boards and a stale mirror on
|
||||||
# some, so reading it first showed pre-write state after a power
|
# some, so reading it first showed pre-write state after a power
|
||||||
# toggle (issue #53: "can turn on but not off").
|
# toggle (issue #53: "can turn on but not off").
|
||||||
power = self._rep(POWER_VS_HREF).get('x.com.samsung.da.power')
|
power = self._rep(POWER_VS_HREF).get("x.com.samsung.da.power")
|
||||||
if power is not None:
|
if power is not None:
|
||||||
return str(power).lower() == 'on'
|
return str(power).lower() == "on"
|
||||||
return bool(self._rep(POWER_HREF).get('value'))
|
return bool(self._rep(POWER_HREF).get("value"))
|
||||||
|
|
||||||
def _supported(self, href: str) -> list[str]:
|
def _supported(self, href: str) -> list[str]:
|
||||||
return list(self._rep(href).get(_SUPPORTED_FIELD) or [])
|
return list(self._rep(href).get(_SUPPORTED_FIELD) or [])
|
||||||
@@ -343,7 +371,9 @@ class LocalThingsClimate(LocalThingsEntity, ClimateEntity):
|
|||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"%s: device mode %r on %s has no HA mapping and was dropped; "
|
"%s: device mode %r on %s has no HA mapping and was dropped; "
|
||||||
"please file an issue with your diagnostics dump",
|
"please file an issue with your diagnostics dump",
|
||||||
self.entity_id, code, href,
|
self.entity_id,
|
||||||
|
code,
|
||||||
|
href,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _read_mode(self, href: str, mapping: dict):
|
def _read_mode(self, href: str, mapping: dict):
|
||||||
@@ -378,18 +408,20 @@ class LocalThingsClimate(LocalThingsEntity, ClimateEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def temperature_unit(self) -> str:
|
def temperature_unit(self) -> str:
|
||||||
raw = self._rep(TEMP_DESIRED_HREF).get('units')
|
raw = self._rep(TEMP_DESIRED_HREF).get("units")
|
||||||
if raw is None:
|
if raw is None:
|
||||||
raw = self._temps_vs().get('x.com.samsung.da.unit')
|
raw = self._temps_vs().get("x.com.samsung.da.unit")
|
||||||
return (UnitOfTemperature.FAHRENHEIT
|
return (
|
||||||
if normalize_temp_unit(raw, '°C') == '°F'
|
UnitOfTemperature.FAHRENHEIT
|
||||||
else UnitOfTemperature.CELSIUS)
|
if normalize_temp_unit(raw, "°C") == "°F"
|
||||||
|
else UnitOfTemperature.CELSIUS
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_temperature(self):
|
def current_temperature(self):
|
||||||
v = _num(self._rep(TEMP_CURRENT_HREF).get('temperature'))
|
v = _num(self._rep(TEMP_CURRENT_HREF).get("temperature"))
|
||||||
if v is None:
|
if v is None:
|
||||||
v = _num(self._temps_vs().get('x.com.samsung.da.current'))
|
v = _num(self._temps_vs().get("x.com.samsung.da.current"))
|
||||||
return v
|
return v
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -397,19 +429,19 @@ class LocalThingsClimate(LocalThingsEntity, ClimateEntity):
|
|||||||
# Read from the same channel writes go to (see async_set_temperature):
|
# Read from the same channel writes go to (see async_set_temperature):
|
||||||
# OCF /temperature/desired/0 on boards with the full OCF pair, vendor
|
# OCF /temperature/desired/0 on boards with the full OCF pair, vendor
|
||||||
# /temperatures/vs/0 otherwise -- with the other as fallback.
|
# /temperatures/vs/0 otherwise -- with the other as fallback.
|
||||||
ocf = _num(self._rep(TEMP_DESIRED_HREF).get('temperature'))
|
ocf = _num(self._rep(TEMP_DESIRED_HREF).get("temperature"))
|
||||||
vs = _num(self._temps_vs().get('x.com.samsung.da.desired'))
|
vs = _num(self._temps_vs().get("x.com.samsung.da.desired"))
|
||||||
if self._ocf_temp_authoritative():
|
if self._ocf_temp_authoritative():
|
||||||
return ocf if ocf is not None else vs
|
return ocf if ocf is not None else vs
|
||||||
return vs if vs is not None else ocf
|
return vs if vs is not None else ocf
|
||||||
|
|
||||||
def _range(self) -> list | None:
|
def _range(self) -> list | None:
|
||||||
r = self._rep(TEMP_DESIRED_HREF).get('range')
|
r = self._rep(TEMP_DESIRED_HREF).get("range")
|
||||||
if isinstance(r, (list, tuple)) and len(r) == 2:
|
if isinstance(r, (list, tuple)) and len(r) == 2:
|
||||||
return r
|
return r
|
||||||
item = self._temps_vs()
|
item = self._temps_vs()
|
||||||
lo = _num(item.get('x.com.samsung.da.minimum'))
|
lo = _num(item.get("x.com.samsung.da.minimum"))
|
||||||
hi = _num(item.get('x.com.samsung.da.maximum'))
|
hi = _num(item.get("x.com.samsung.da.maximum"))
|
||||||
return [lo, hi] if (lo is not None and hi is not None) else None
|
return [lo, hi] if (lo is not None and hi is not None) else None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -424,10 +456,12 @@ class LocalThingsClimate(LocalThingsEntity, ClimateEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature_step(self) -> float:
|
def target_temperature_step(self) -> float:
|
||||||
return (_num(self._rep(TEMP_CONTROL_HREF).get('increment'))
|
return (
|
||||||
or _num(self._rep(TEMP_CONTROL_HREF).get('x.com.samsung.da.increment'))
|
_num(self._rep(TEMP_CONTROL_HREF).get("increment"))
|
||||||
or _num(self._temps_vs().get('x.com.samsung.da.increment'))
|
or _num(self._rep(TEMP_CONTROL_HREF).get("x.com.samsung.da.increment"))
|
||||||
or 1.0)
|
or _num(self._temps_vs().get("x.com.samsung.da.increment"))
|
||||||
|
or 1.0
|
||||||
|
)
|
||||||
|
|
||||||
# -- hvac mode ----------------------------------------------------------
|
# -- hvac mode ----------------------------------------------------------
|
||||||
|
|
||||||
@@ -462,7 +496,7 @@ class LocalThingsClimate(LocalThingsEntity, ClimateEntity):
|
|||||||
def fan_mode(self):
|
def fan_mode(self):
|
||||||
airflow = self._legacy_airflow()
|
airflow = self._legacy_airflow()
|
||||||
if airflow:
|
if airflow:
|
||||||
return _DEVICE_TO_FAN.get(str(airflow.get('x.com.samsung.da.speedLevel')))
|
return _DEVICE_TO_FAN.get(str(airflow.get("x.com.samsung.da.speedLevel")))
|
||||||
rep = self._rep(WIND_STRENGTH_HREF)
|
rep = self._rep(WIND_STRENGTH_HREF)
|
||||||
code = _first(rep.get(_MODES_FIELD))
|
code = _first(rep.get(_MODES_FIELD))
|
||||||
if code is None:
|
if code is None:
|
||||||
@@ -492,7 +526,7 @@ class LocalThingsClimate(LocalThingsEntity, ClimateEntity):
|
|||||||
def swing_mode(self):
|
def swing_mode(self):
|
||||||
airflow = self._legacy_airflow()
|
airflow = self._legacy_airflow()
|
||||||
if airflow:
|
if airflow:
|
||||||
return _DEVICE_TO_SWING.get(airflow.get('x.com.samsung.da.direction'))
|
return _DEVICE_TO_SWING.get(airflow.get("x.com.samsung.da.direction"))
|
||||||
if self._swing_via_direction():
|
if self._swing_via_direction():
|
||||||
return self._read_mode(WIND_DIRECTION_HREF, _DEVICE_TO_SWING)
|
return self._read_mode(WIND_DIRECTION_HREF, _DEVICE_TO_SWING)
|
||||||
return _oscillation_swing(self._rep(WIND_OSCILLATION_HREF))
|
return _oscillation_swing(self._rep(WIND_OSCILLATION_HREF))
|
||||||
@@ -539,35 +573,35 @@ class LocalThingsClimate(LocalThingsEntity, ClimateEntity):
|
|||||||
# matching the climate contract other integrations follow. Without this a
|
# matching the climate contract other integrations follow. Without this a
|
||||||
# set_temperature call carrying hvac_mode (e.g. a dashboard "turn on to
|
# set_temperature call carrying hvac_mode (e.g. a dashboard "turn on to
|
||||||
# Auto 24" button) set the setpoint but never changed mode or powered on.
|
# Auto 24" button) set the setpoint but never changed mode or powered on.
|
||||||
hvac_mode = kwargs.get('hvac_mode')
|
hvac_mode = kwargs.get("hvac_mode")
|
||||||
if hvac_mode is not None:
|
if hvac_mode is not None:
|
||||||
await self.async_set_hvac_mode(hvac_mode)
|
await self.async_set_hvac_mode(hvac_mode)
|
||||||
if hvac_mode == HVACMode.OFF:
|
if hvac_mode == HVACMode.OFF:
|
||||||
return
|
return
|
||||||
temp = kwargs.get('temperature')
|
temp = kwargs.get("temperature")
|
||||||
if temp is None:
|
if temp is None:
|
||||||
return
|
return
|
||||||
# OCF-pair boards write /temperature/desired/0; vendor boards write
|
# OCF-pair boards write /temperature/desired/0; vendor boards write
|
||||||
# /temperatures/vs/0 (see airconditioner._climate_write).
|
# /temperatures/vs/0 (see airconditioner._climate_write).
|
||||||
kind = 'temperature_ocf' if self._ocf_temp_authoritative() else 'temperature'
|
kind = "temperature_ocf" if self._ocf_temp_authoritative() else "temperature"
|
||||||
await self.coordinator.async_send_command(self._bound, (kind, temp))
|
await self.coordinator.async_send_command(self._bound, (kind, temp))
|
||||||
|
|
||||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||||
if hvac_mode == HVACMode.OFF:
|
if hvac_mode == HVACMode.OFF:
|
||||||
await self.coordinator.async_send_command(self._bound, ('power', False))
|
await self.coordinator.async_send_command(self._bound, ("power", False))
|
||||||
return
|
return
|
||||||
device = self._device_code_for_hvac(hvac_mode)
|
device = self._device_code_for_hvac(hvac_mode)
|
||||||
if device is None:
|
if device is None:
|
||||||
return
|
return
|
||||||
if not self._is_on():
|
if not self._is_on():
|
||||||
await self.coordinator.async_send_command(self._bound, ('power', True))
|
await self.coordinator.async_send_command(self._bound, ("power", True))
|
||||||
await self.coordinator.async_send_command(self._bound, ('mode', device))
|
await self.coordinator.async_send_command(self._bound, ("mode", device))
|
||||||
|
|
||||||
async def async_turn_on(self) -> None:
|
async def async_turn_on(self) -> None:
|
||||||
await self.coordinator.async_send_command(self._bound, ('power', True))
|
await self.coordinator.async_send_command(self._bound, ("power", True))
|
||||||
|
|
||||||
async def async_turn_off(self) -> None:
|
async def async_turn_off(self) -> None:
|
||||||
await self.coordinator.async_send_command(self._bound, ('power', False))
|
await self.coordinator.async_send_command(self._bound, ("power", False))
|
||||||
|
|
||||||
async def _set_mapped(self, kind: str, mapping: dict, value: str) -> None:
|
async def _set_mapped(self, kind: str, mapping: dict, value: str) -> None:
|
||||||
"""Map an HA fan/swing/preset value back to its device code and write it."""
|
"""Map an HA fan/swing/preset value back to its device code and write it."""
|
||||||
@@ -579,8 +613,7 @@ class LocalThingsClimate(LocalThingsEntity, ClimateEntity):
|
|||||||
if self._legacy_airflow():
|
if self._legacy_airflow():
|
||||||
level = _FAN_TO_DEVICE.get(fan_mode)
|
level = _FAN_TO_DEVICE.get(fan_mode)
|
||||||
if level is not None:
|
if level is not None:
|
||||||
await self.coordinator.async_send_command(
|
await self.coordinator.async_send_command(self._bound, ("fan_legacy", level))
|
||||||
self._bound, ('fan_legacy', level))
|
|
||||||
return
|
return
|
||||||
supported = self._supported(WIND_STRENGTH_HREF)
|
supported = self._supported(WIND_STRENGTH_HREF)
|
||||||
device = _FAN_TO_DEVICE.get(fan_mode)
|
device = _FAN_TO_DEVICE.get(fan_mode)
|
||||||
@@ -598,33 +631,31 @@ class LocalThingsClimate(LocalThingsEntity, ClimateEntity):
|
|||||||
device = code
|
device = code
|
||||||
break
|
break
|
||||||
if device is not None:
|
if device is not None:
|
||||||
await self.coordinator.async_send_command(self._bound, ('fan', device))
|
await self.coordinator.async_send_command(self._bound, ("fan", device))
|
||||||
|
|
||||||
async def async_set_swing_mode(self, swing_mode: str) -> None:
|
async def async_set_swing_mode(self, swing_mode: str) -> None:
|
||||||
if self._legacy_airflow():
|
if self._legacy_airflow():
|
||||||
code = _SWING_TO_DEVICE.get(swing_mode)
|
code = _SWING_TO_DEVICE.get(swing_mode)
|
||||||
if code is not None:
|
if code is not None:
|
||||||
await self.coordinator.async_send_command(
|
await self.coordinator.async_send_command(self._bound, ("swing_legacy", code))
|
||||||
self._bound, ('swing_legacy', code))
|
|
||||||
return
|
return
|
||||||
if self._swing_via_direction():
|
if self._swing_via_direction():
|
||||||
await self._set_mapped('swing', _SWING_TO_DEVICE, swing_mode)
|
await self._set_mapped("swing", _SWING_TO_DEVICE, swing_mode)
|
||||||
return
|
return
|
||||||
if self._rep(WIND_OSCILLATION_HREF):
|
if self._rep(WIND_OSCILLATION_HREF):
|
||||||
await self.coordinator.async_send_command(
|
await self.coordinator.async_send_command(self._bound, ("oscillation", swing_mode))
|
||||||
self._bound, ('oscillation', swing_mode))
|
|
||||||
|
|
||||||
async def async_set_preset_mode(self, preset_mode: str) -> None:
|
async def async_set_preset_mode(self, preset_mode: str) -> None:
|
||||||
if preset_mode == PRESET_AI_COMFORT:
|
if preset_mode == PRESET_AI_COMFORT:
|
||||||
# Writes the primary mode resource, not the convenient one --
|
# Writes the primary mode resource, not the convenient one --
|
||||||
# 'AIComfort' lives in /mode/vs/0 alongside Cool/Dry/Auto, not in
|
# 'AIComfort' lives in /mode/vs/0 alongside Cool/Dry/Auto, not in
|
||||||
# /mode/convenient/vs/0 with Quiet/Smart/Speed/Sleep.
|
# /mode/convenient/vs/0 with Quiet/Smart/Speed/Sleep.
|
||||||
await self.coordinator.async_send_command(self._bound, ('mode', _AI_COMFORT_MODE))
|
await self.coordinator.async_send_command(self._bound, ("mode", _AI_COMFORT_MODE))
|
||||||
return
|
return
|
||||||
# Reverse-resolve against the unit's own supportedModes (codes aren't
|
# Reverse-resolve against the unit's own supportedModes (codes aren't
|
||||||
# a fixed transform of the HA value -- e.g. 'NanoSleep' -> 'nanosleep').
|
# a fixed transform of the HA value -- e.g. 'NanoSleep' -> 'nanosleep').
|
||||||
for code in self._supported(CONVENIENT_HREF):
|
for code in self._supported(CONVENIENT_HREF):
|
||||||
if _preset_to_ha(code) == preset_mode:
|
if _preset_to_ha(code) == preset_mode:
|
||||||
kind = 'preset_legacy' if self._legacy_preset() else 'preset'
|
kind = "preset_legacy" if self._legacy_preset() else "preset"
|
||||||
await self.coordinator.async_send_command(self._bound, (kind, code))
|
await self.coordinator.async_send_command(self._bound, (kind, code))
|
||||||
return
|
return
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
"""Config flow for Local Things integration."""
|
"""Config flow for Local Things integration."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import contextlib
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
@@ -13,9 +15,12 @@ from typing import Any
|
|||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
|
from homeassistant.config_entries import ConfigFlowResult
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
|
||||||
from homeassistant.helpers.selector import (
|
from homeassistant.helpers.selector import (
|
||||||
|
NumberSelector,
|
||||||
|
NumberSelectorConfig,
|
||||||
|
NumberSelectorMode,
|
||||||
ObjectSelector,
|
ObjectSelector,
|
||||||
SelectSelector,
|
SelectSelector,
|
||||||
SelectSelectorConfig,
|
SelectSelectorConfig,
|
||||||
@@ -26,21 +31,36 @@ from homeassistant.helpers.selector import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
DOMAIN,
|
|
||||||
CONF_HOST, CONF_PORT,
|
|
||||||
CONF_CA_CERT_PEM, CONF_CA_KEY_PEM,
|
|
||||||
CONF_LEAF_CERT_PEM, CONF_LEAF_KEY_PEM,
|
|
||||||
CONF_BYPASS_REMOTE_CONTROL,
|
CONF_BYPASS_REMOTE_CONTROL,
|
||||||
PROBE_PORT_RANGE, PREFERRED_PROBE_PORTS, LIVENESS_PROBE_TIMEOUT_S,
|
CONF_CA_CERT_PEM,
|
||||||
|
CONF_CA_KEY_PEM,
|
||||||
|
CONF_FINISH_TIME_HYSTERESIS_MINUTES,
|
||||||
|
CONF_HOST,
|
||||||
|
CONF_LEAF_CERT_PEM,
|
||||||
|
CONF_LEAF_KEY_PEM,
|
||||||
|
CONF_PORT,
|
||||||
|
DEFAULT_FINISH_TIME_HYSTERESIS_MINUTES,
|
||||||
|
DOMAIN,
|
||||||
|
LIVENESS_PROBE_TIMEOUT_S,
|
||||||
|
PREFERRED_PROBE_PORTS,
|
||||||
PROBE_GET_TIMEOUT_S,
|
PROBE_GET_TIMEOUT_S,
|
||||||
|
PROBE_PORT_RANGE,
|
||||||
)
|
)
|
||||||
|
|
||||||
_TEXT = TextSelector(TextSelectorConfig(type=TextSelectorType.TEXT))
|
_TEXT = TextSelector(TextSelectorConfig(type=TextSelectorType.TEXT))
|
||||||
_MULTILINE = TextSelector(TextSelectorConfig(type=TextSelectorType.TEXT, multiline=True))
|
_MULTILINE = TextSelector(TextSelectorConfig(type=TextSelectorType.TEXT, multiline=True))
|
||||||
|
_HYSTERESIS_MINUTES = NumberSelector(
|
||||||
|
NumberSelectorConfig(
|
||||||
|
min=0,
|
||||||
|
max=30,
|
||||||
|
step=1,
|
||||||
|
mode=NumberSelectorMode.BOX,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
_SAMSUNG_CLOUD_HOST = 'connect-v2.samsungiotcloud.com'
|
_SAMSUNG_CLOUD_HOST = "connect-v2.samsungiotcloud.com"
|
||||||
|
|
||||||
|
|
||||||
class CannotConnect(Exception):
|
class CannotConnect(Exception):
|
||||||
@@ -58,16 +78,21 @@ def _fetch_samsung_uuid() -> str:
|
|||||||
We only need to read the UUID from the cert subject, not verify its trust.
|
We only need to read the UUID from the cert subject, not verify its trust.
|
||||||
"""
|
"""
|
||||||
from cryptography import x509 as _x509
|
from cryptography import x509 as _x509
|
||||||
|
|
||||||
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
||||||
ctx.check_hostname = False
|
ctx.check_hostname = False
|
||||||
ctx.verify_mode = ssl.CERT_NONE
|
ctx.verify_mode = ssl.CERT_NONE
|
||||||
with socket.create_connection((_SAMSUNG_CLOUD_HOST, 443), timeout=15) as raw:
|
with (
|
||||||
with ctx.wrap_socket(raw, server_hostname=_SAMSUNG_CLOUD_HOST) as tls:
|
socket.create_connection((_SAMSUNG_CLOUD_HOST, 443), timeout=15) as raw,
|
||||||
der = tls.getpeercert(binary_form=True)
|
ctx.wrap_socket(raw, server_hostname=_SAMSUNG_CLOUD_HOST) as tls,
|
||||||
|
):
|
||||||
|
der = tls.getpeercert(binary_form=True)
|
||||||
|
if der is None:
|
||||||
|
raise RuntimeError(f"No certificate received from {_SAMSUNG_CLOUD_HOST}")
|
||||||
cert = _x509.load_der_x509_certificate(der)
|
cert = _x509.load_der_x509_certificate(der)
|
||||||
for attr in cert.subject:
|
for attr in cert.subject:
|
||||||
if attr.oid == _x509.oid.NameOID.ORGANIZATIONAL_UNIT_NAME:
|
if attr.oid == _x509.oid.NameOID.ORGANIZATIONAL_UNIT_NAME and isinstance(attr.value, str):
|
||||||
m = re.search(r'uuid:([0-9a-f-]+)', attr.value, re.IGNORECASE)
|
m = re.search(r"uuid:([0-9a-f-]+)", attr.value, re.IGNORECASE)
|
||||||
if m:
|
if m:
|
||||||
return m.group(1)
|
return m.group(1)
|
||||||
raise RuntimeError(f"UUID not found in {_SAMSUNG_CLOUD_HOST} certificate subject")
|
raise RuntimeError(f"UUID not found in {_SAMSUNG_CLOUD_HOST} certificate subject")
|
||||||
@@ -80,13 +105,15 @@ def _mint_leaf_cert(ca_cert_pem: str, ca_key_pem: str, uuid: str) -> tuple[str,
|
|||||||
followed by the full CA PEM, suitable for use_certificate_chain_file.
|
followed by the full CA PEM, suitable for use_certificate_chain_file.
|
||||||
"""
|
"""
|
||||||
from cryptography import x509
|
from cryptography import x509
|
||||||
from cryptography.x509.oid import NameOID
|
|
||||||
from cryptography.hazmat.primitives import hashes, serialization
|
from cryptography.hazmat.primitives import hashes, serialization
|
||||||
|
from cryptography.hazmat.primitives.asymmetric import dsa, ec, ed448, ed25519
|
||||||
from cryptography.hazmat.primitives.asymmetric import rsa as _rsa
|
from cryptography.hazmat.primitives.asymmetric import rsa as _rsa
|
||||||
|
from cryptography.x509.oid import NameOID
|
||||||
|
|
||||||
m = re.search(
|
m = re.search(
|
||||||
r'(-----BEGIN CERTIFICATE-----.*?-----END CERTIFICATE-----)',
|
r"(-----BEGIN CERTIFICATE-----.*?-----END CERTIFICATE-----)",
|
||||||
ca_cert_pem, re.DOTALL,
|
ca_cert_pem,
|
||||||
|
re.DOTALL,
|
||||||
)
|
)
|
||||||
if not m:
|
if not m:
|
||||||
raise InvalidCA("No certificate found in CA cert PEM")
|
raise InvalidCA("No certificate found in CA cert PEM")
|
||||||
@@ -95,18 +122,33 @@ def _mint_leaf_cert(ca_cert_pem: str, ca_key_pem: str, uuid: str) -> tuple[str,
|
|||||||
ca_key = serialization.load_pem_private_key(ca_key_pem.encode(), password=None)
|
ca_key = serialization.load_pem_private_key(ca_key_pem.encode(), password=None)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
raise InvalidCA(f"Failed to load CA credentials: {exc}") from exc
|
raise InvalidCA(f"Failed to load CA credentials: {exc}") from exc
|
||||||
|
if not isinstance(
|
||||||
|
ca_key,
|
||||||
|
(
|
||||||
|
_rsa.RSAPrivateKey,
|
||||||
|
ec.EllipticCurvePrivateKey,
|
||||||
|
ed25519.Ed25519PrivateKey,
|
||||||
|
ed448.Ed448PrivateKey,
|
||||||
|
dsa.DSAPrivateKey,
|
||||||
|
),
|
||||||
|
):
|
||||||
|
raise InvalidCA(f"CA key is not a signing key (got {type(ca_key).__name__})")
|
||||||
|
|
||||||
leaf_key = _rsa.generate_private_key(public_exponent=65537, key_size=2048)
|
leaf_key = _rsa.generate_private_key(public_exponent=65537, key_size=2048)
|
||||||
|
|
||||||
now = datetime.datetime.now(datetime.timezone.utc)
|
now = datetime.datetime.now(datetime.UTC)
|
||||||
leaf_cert = (
|
leaf_cert = (
|
||||||
x509.CertificateBuilder()
|
x509.CertificateBuilder()
|
||||||
.subject_name(x509.Name([
|
.subject_name(
|
||||||
x509.NameAttribute(NameOID.COUNTRY_NAME, 'KR'),
|
x509.Name(
|
||||||
x509.NameAttribute(NameOID.ORGANIZATION_NAME, 'Samsung Electronics'),
|
[
|
||||||
x509.NameAttribute(NameOID.ORGANIZATIONAL_UNIT_NAME, f'uuid:{uuid}'),
|
x509.NameAttribute(NameOID.COUNTRY_NAME, "KR"),
|
||||||
x509.NameAttribute(NameOID.COMMON_NAME, f'urn:uuid:{uuid}'),
|
x509.NameAttribute(NameOID.ORGANIZATION_NAME, "Samsung Electronics"),
|
||||||
]))
|
x509.NameAttribute(NameOID.ORGANIZATIONAL_UNIT_NAME, f"uuid:{uuid}"),
|
||||||
|
x509.NameAttribute(NameOID.COMMON_NAME, f"urn:uuid:{uuid}"),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
.issuer_name(ca_cert.subject)
|
.issuer_name(ca_cert.subject)
|
||||||
.public_key(leaf_key.public_key())
|
.public_key(leaf_key.public_key())
|
||||||
.serial_number(x509.random_serial_number())
|
.serial_number(x509.random_serial_number())
|
||||||
@@ -124,9 +166,9 @@ def _mint_leaf_cert(ca_cert_pem: str, ca_key_pem: str, uuid: str) -> tuple[str,
|
|||||||
|
|
||||||
# Ensure a newline separates the leaf and CA blocks regardless of
|
# Ensure a newline separates the leaf and CA blocks regardless of
|
||||||
# whether the user's pasted CA PEM had a trailing newline.
|
# whether the user's pasted CA PEM had a trailing newline.
|
||||||
fullchain_pem = leaf_cert_pem.rstrip('\n') + '\n' + ca_cert_pem
|
fullchain_pem = leaf_cert_pem.rstrip("\n") + "\n" + ca_cert_pem
|
||||||
if not fullchain_pem.endswith('\n'):
|
if not fullchain_pem.endswith("\n"):
|
||||||
fullchain_pem += '\n'
|
fullchain_pem += "\n"
|
||||||
return fullchain_pem, leaf_key_pem
|
return fullchain_pem, leaf_key_pem
|
||||||
|
|
||||||
|
|
||||||
@@ -179,20 +221,19 @@ def _find_live_ports(host: str, ports: list[int], timeout: float) -> list[int]:
|
|||||||
if remaining <= 0:
|
if remaining <= 0:
|
||||||
break
|
break
|
||||||
for key, _ in sel.select(timeout=remaining):
|
for key, _ in sel.select(timeout=remaining):
|
||||||
|
sock = sockets[key.data]
|
||||||
try:
|
try:
|
||||||
# Data back means live; ECONNREFUSED (or any other socket
|
# Data back means live; ECONNREFUSED (or any other socket
|
||||||
# error) means the port is closed/unusable — rule it out.
|
# error) means the port is closed/unusable — rule it out.
|
||||||
key.fileobj.recv(1)
|
sock.recv(1)
|
||||||
except OSError:
|
except OSError:
|
||||||
sel.unregister(key.fileobj)
|
sel.unregister(sock)
|
||||||
live = [key.data for key in sel.get_map().values()]
|
live = [key.data for key in sel.get_map().values()]
|
||||||
finally:
|
finally:
|
||||||
sel.close()
|
sel.close()
|
||||||
for sock in sockets.values():
|
for sock in sockets.values():
|
||||||
try:
|
with contextlib.suppress(OSError):
|
||||||
sock.close()
|
sock.close()
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# The sweep's ICMP-based verdict isn't reliable on every network path --
|
# The sweep's ICMP-based verdict isn't reliable on every network path --
|
||||||
# issue #192 captured a segregated-VLAN device where it called three
|
# issue #192 captured a segregated-VLAN device where it called three
|
||||||
@@ -215,16 +256,29 @@ def _is_placeholder_serial(serial: str) -> bool:
|
|||||||
serial` check here (and the equivalent one in coordinator.py's
|
serial` check here (and the equivalent one in coordinator.py's
|
||||||
`_run_discovery`) doesn't catch it, and two such units get the same
|
`_run_discovery`) doesn't catch it, and two such units get the same
|
||||||
config-entry unique_id / entity unique_ids and collide (issue #83).
|
config-entry unique_id / entity unique_ids and collide (issue #83).
|
||||||
|
|
||||||
|
Issue #189: the DA_WM_A51_20_COMMON (ARTIK051) laundry board family
|
||||||
|
reports a flash-unset sentinel instead -- every character the same
|
||||||
|
repeated hex digit (a washer and a dryer, two different physical
|
||||||
|
units, both reported the literal serialNum 'FFFFFFFFFFFFFFF') -- which
|
||||||
|
the 'nothing' check above doesn't catch either, so the second unit's
|
||||||
|
config flow aborted as already configured.
|
||||||
"""
|
"""
|
||||||
return serial.strip().lower().startswith('nothing')
|
s = serial.strip()
|
||||||
|
if s.lower().startswith("nothing"):
|
||||||
|
return True
|
||||||
|
upper = s.upper()
|
||||||
|
return len(upper) >= 8 and len(set(upper)) == 1 and upper[0] in "0123456789ABCDEF"
|
||||||
|
|
||||||
|
|
||||||
def _probe_and_validate(host: str, ca_cert_pem: str, ca_key_pem: str) -> dict:
|
def _probe_and_validate(host: str, ca_cert_pem: str, ca_key_pem: str) -> dict:
|
||||||
"""Fetch UUID, mint leaf cert, probe each port. Returns config entry data dict."""
|
"""Fetch UUID, mint leaf cert, probe each port. Returns config entry data dict."""
|
||||||
import cbor2
|
import cbor2
|
||||||
from smartthings_local.protocol.dtls_session import DtlsCoapSession
|
from smartthings_local.protocol.dtls_session import DtlsCoapSession
|
||||||
|
|
||||||
from .registry.batch import parse_device0_batch
|
from .registry.batch import parse_device0_batch
|
||||||
from .registry.by_type import resolve as resolve_registry
|
from .registry.by_type import resolve as resolve_registry
|
||||||
|
from .registry.identity import read_identity
|
||||||
|
|
||||||
_LOGGER.debug("Fetching Samsung cloud UUID from %s", _SAMSUNG_CLOUD_HOST)
|
_LOGGER.debug("Fetching Samsung cloud UUID from %s", _SAMSUNG_CLOUD_HOST)
|
||||||
try:
|
try:
|
||||||
@@ -245,9 +299,7 @@ def _probe_and_validate(host: str, ca_cert_pem: str, ca_key_pem: str) -> dict:
|
|||||||
raise CannotConnect(f"Failed to mint leaf cert: {exc}") from exc
|
raise CannotConnect(f"Failed to mint leaf cert: {exc}") from exc
|
||||||
_LOGGER.debug("Leaf cert minted successfully")
|
_LOGGER.debug("Leaf cert minted successfully")
|
||||||
|
|
||||||
candidates = _find_live_ports(
|
candidates = _find_live_ports(host, PROBE_PORT_RANGE, LIVENESS_PROBE_TIMEOUT_S)
|
||||||
host, PROBE_PORT_RANGE, LIVENESS_PROBE_TIMEOUT_S
|
|
||||||
)
|
|
||||||
# No early "every port refused" fast-fail here: _find_live_ports always
|
# No early "every port refused" fast-fail here: _find_live_ports always
|
||||||
# rescues PREFERRED_PROBE_PORTS (issue #192), so candidates is never
|
# rescues PREFERRED_PROBE_PORTS (issue #192), so candidates is never
|
||||||
# empty as long as that table is non-empty and within PROBE_PORT_RANGE --
|
# empty as long as that table is non-empty and within PROBE_PORT_RANGE --
|
||||||
@@ -262,27 +314,29 @@ def _probe_and_validate(host: str, ca_cert_pem: str, ca_key_pem: str) -> dict:
|
|||||||
sess = None
|
sess = None
|
||||||
try:
|
try:
|
||||||
sess = DtlsCoapSession(
|
sess = DtlsCoapSession(
|
||||||
host, port,
|
host,
|
||||||
|
port,
|
||||||
cert_pem=fullchain_pem,
|
cert_pem=fullchain_pem,
|
||||||
key_pem=leaf_key_pem,
|
key_pem=leaf_key_pem,
|
||||||
)
|
)
|
||||||
sess.connect()
|
sess.connect()
|
||||||
sess.start_reader()
|
sess.start_reader()
|
||||||
code, payload = sess.get(['device', '0'], timeout=PROBE_GET_TIMEOUT_S)
|
code, payload = sess.get(["device", "0"], timeout=PROBE_GET_TIMEOUT_S)
|
||||||
if code != 0x45 or not payload:
|
if code != 0x45 or not payload:
|
||||||
raise CannotConnect(f"port {port}: unexpected code {code:#04x}")
|
raise CannotConnect(f"port {port}: unexpected code {code:#04x}")
|
||||||
body = cbor2.loads(payload)
|
body = cbor2.loads(payload)
|
||||||
resources = (
|
resources = parse_device0_batch(body) if isinstance(body, list) else {}
|
||||||
parse_device0_batch(body) if isinstance(body, list) else {}
|
serial = resources.get("/information/vs/0", {}).get("x.com.samsung.da.serialNum", "")
|
||||||
)
|
|
||||||
serial = (
|
|
||||||
resources
|
|
||||||
.get('/information/vs/0', {})
|
|
||||||
.get('x.com.samsung.da.serialNum', '')
|
|
||||||
)
|
|
||||||
if not serial or _is_placeholder_serial(serial):
|
if not serial or _is_placeholder_serial(serial):
|
||||||
serial = f"{host}:{port}"
|
serial = f"{host}:{port}"
|
||||||
recognized_registry = resolve_registry(resources)
|
# /oic/d's device type (read_identity) is the primary detection
|
||||||
|
# signal when a board populates it -- see registry/by_type's
|
||||||
|
# resolve(). read_identity is defensive on every GET it makes, so
|
||||||
|
# a device that doesn't answer /oic/p or /oic/d just yields an
|
||||||
|
# empty device_types tuple here, falling through to the model-
|
||||||
|
# string/resource-signature detection resolve() already did.
|
||||||
|
identity = read_identity(sess, None)
|
||||||
|
recognized_registry = resolve_registry(resources, device_types=identity.device_types)
|
||||||
return {
|
return {
|
||||||
"port": port,
|
"port": port,
|
||||||
"serial": serial,
|
"serial": serial,
|
||||||
@@ -297,10 +351,8 @@ def _probe_and_validate(host: str, ca_cert_pem: str, ca_key_pem: str) -> dict:
|
|||||||
_LOGGER.debug("port %d failed: %s", port, exc)
|
_LOGGER.debug("port %d failed: %s", port, exc)
|
||||||
finally:
|
finally:
|
||||||
if sess is not None:
|
if sess is not None:
|
||||||
try:
|
with contextlib.suppress(Exception):
|
||||||
sess.close()
|
sess.close()
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
raise CannotConnect(f"no port responded on {host}: {last_exc}")
|
raise CannotConnect(f"no port responded on {host}: {last_exc}")
|
||||||
|
|
||||||
|
|
||||||
@@ -320,22 +372,20 @@ class LocalThingsConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
) -> LocalThingsOptionsFlow:
|
) -> LocalThingsOptionsFlow:
|
||||||
return LocalThingsOptionsFlow()
|
return LocalThingsOptionsFlow()
|
||||||
|
|
||||||
def _create_entry(self, info: dict) -> FlowResult:
|
def _create_entry(self, info: dict) -> ConfigFlowResult:
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
title=f"Samsung Appliance ({self._host})",
|
title=f"Samsung Appliance ({self._host})",
|
||||||
data={
|
data={
|
||||||
CONF_HOST: self._host,
|
CONF_HOST: self._host,
|
||||||
CONF_PORT: info["port"],
|
CONF_PORT: info["port"],
|
||||||
CONF_CA_CERT_PEM: self._ca_cert_pem,
|
CONF_CA_CERT_PEM: self._ca_cert_pem,
|
||||||
CONF_CA_KEY_PEM: self._ca_key_pem,
|
CONF_CA_KEY_PEM: self._ca_key_pem,
|
||||||
CONF_LEAF_CERT_PEM: info["leaf_cert_pem"],
|
CONF_LEAF_CERT_PEM: info["leaf_cert_pem"],
|
||||||
CONF_LEAF_KEY_PEM: info["leaf_key_pem"],
|
CONF_LEAF_KEY_PEM: info["leaf_key_pem"],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(self, user_input: dict[str, Any] | None = None) -> ConfigFlowResult:
|
||||||
self, user_input: dict[str, Any] | None = None
|
|
||||||
) -> FlowResult:
|
|
||||||
existing = self.hass.config_entries.async_entries(DOMAIN)
|
existing = self.hass.config_entries.async_entries(DOMAIN)
|
||||||
has_creds = bool(existing)
|
has_creds = bool(existing)
|
||||||
|
|
||||||
@@ -345,10 +395,10 @@ class LocalThingsConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
self._host = user_input[CONF_HOST].strip()
|
self._host = user_input[CONF_HOST].strip()
|
||||||
if has_creds:
|
if has_creds:
|
||||||
self._ca_cert_pem = existing[0].data[CONF_CA_CERT_PEM]
|
self._ca_cert_pem = existing[0].data[CONF_CA_CERT_PEM]
|
||||||
self._ca_key_pem = existing[0].data[CONF_CA_KEY_PEM]
|
self._ca_key_pem = existing[0].data[CONF_CA_KEY_PEM]
|
||||||
else:
|
else:
|
||||||
self._ca_cert_pem = user_input[CONF_CA_CERT_PEM].strip()
|
self._ca_cert_pem = user_input[CONF_CA_CERT_PEM].strip()
|
||||||
self._ca_key_pem = user_input[CONF_CA_KEY_PEM].strip()
|
self._ca_key_pem = user_input[CONF_CA_KEY_PEM].strip()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
info = await self.hass.async_add_executor_job(
|
info = await self.hass.async_add_executor_job(
|
||||||
@@ -376,11 +426,13 @@ class LocalThingsConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
schema = vol.Schema({vol.Required(CONF_HOST): _TEXT})
|
schema = vol.Schema({vol.Required(CONF_HOST): _TEXT})
|
||||||
step_id = "user_reuse"
|
step_id = "user_reuse"
|
||||||
else:
|
else:
|
||||||
schema = vol.Schema({
|
schema = vol.Schema(
|
||||||
vol.Required(CONF_HOST): _TEXT,
|
{
|
||||||
vol.Required(CONF_CA_CERT_PEM): _MULTILINE,
|
vol.Required(CONF_HOST): _TEXT,
|
||||||
vol.Required(CONF_CA_KEY_PEM): _MULTILINE,
|
vol.Required(CONF_CA_CERT_PEM): _MULTILINE,
|
||||||
})
|
vol.Required(CONF_CA_KEY_PEM): _MULTILINE,
|
||||||
|
}
|
||||||
|
)
|
||||||
step_id = "user"
|
step_id = "user"
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
@@ -391,15 +443,16 @@ class LocalThingsConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
async def async_step_user_reuse(
|
async def async_step_user_reuse(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the localized host-only form for additional appliances."""
|
"""Handle the localized host-only form for additional appliances."""
|
||||||
return await self.async_step_user(user_input)
|
return await self.async_step_user(user_input)
|
||||||
|
|
||||||
async def async_step_confirm_unknown_type(
|
async def async_step_confirm_unknown_type(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Shown only when the probe already knows the device type is unrecognized."""
|
"""Shown only when the probe already knows the device type is unrecognized."""
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
|
assert self._pending_info is not None
|
||||||
return self._create_entry(self._pending_info)
|
return self._create_entry(self._pending_info)
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="confirm_unknown_type",
|
step_id="confirm_unknown_type",
|
||||||
@@ -430,9 +483,7 @@ class LocalThingsOptionsFlow(config_entries.OptionsFlow):
|
|||||||
def _coordinator(self):
|
def _coordinator(self):
|
||||||
return self.hass.data.get(DOMAIN, {}).get(self.config_entry.entry_id)
|
return self.hass.data.get(DOMAIN, {}).get(self.config_entry.entry_id)
|
||||||
|
|
||||||
async def async_step_init(
|
async def async_step_init(self, user_input: dict[str, Any] | None = None) -> ConfigFlowResult:
|
||||||
self, user_input: dict[str, Any] | None = None
|
|
||||||
) -> FlowResult:
|
|
||||||
return self.async_show_menu(
|
return self.async_show_menu(
|
||||||
step_id="init",
|
step_id="init",
|
||||||
menu_options=["settings", "debug_write"],
|
menu_options=["settings", "debug_write"],
|
||||||
@@ -440,25 +491,32 @@ class LocalThingsOptionsFlow(config_entries.OptionsFlow):
|
|||||||
|
|
||||||
async def async_step_settings(
|
async def async_step_settings(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
return self.async_create_entry(data=user_input)
|
return self.async_create_entry(data=user_input)
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="settings",
|
step_id="settings",
|
||||||
data_schema=vol.Schema({
|
data_schema=vol.Schema(
|
||||||
vol.Required(
|
{
|
||||||
CONF_BYPASS_REMOTE_CONTROL,
|
vol.Required(
|
||||||
default=self.config_entry.options.get(
|
CONF_BYPASS_REMOTE_CONTROL,
|
||||||
CONF_BYPASS_REMOTE_CONTROL, False
|
default=self.config_entry.options.get(CONF_BYPASS_REMOTE_CONTROL, False),
|
||||||
),
|
): bool,
|
||||||
): bool,
|
vol.Required(
|
||||||
}),
|
CONF_FINISH_TIME_HYSTERESIS_MINUTES,
|
||||||
|
default=self.config_entry.options.get(
|
||||||
|
CONF_FINISH_TIME_HYSTERESIS_MINUTES,
|
||||||
|
DEFAULT_FINISH_TIME_HYSTERESIS_MINUTES,
|
||||||
|
),
|
||||||
|
): _HYSTERESIS_MINUTES,
|
||||||
|
}
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_debug_write(
|
async def async_step_debug_write(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
coord = self._coordinator()
|
coord = self._coordinator()
|
||||||
if coord is None:
|
if coord is None:
|
||||||
return self.async_abort(reason="not_loaded")
|
return self.async_abort(reason="not_loaded")
|
||||||
@@ -470,38 +528,48 @@ class LocalThingsOptionsFlow(config_entries.OptionsFlow):
|
|||||||
hrefs = sorted(coord.last_resources.keys())
|
hrefs = sorted(coord.last_resources.keys())
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="debug_write",
|
step_id="debug_write",
|
||||||
data_schema=vol.Schema({
|
data_schema=vol.Schema(
|
||||||
vol.Required("href"): SelectSelector(SelectSelectorConfig(
|
{
|
||||||
options=hrefs,
|
vol.Required("href"): SelectSelector(
|
||||||
custom_value=True,
|
SelectSelectorConfig(
|
||||||
mode=SelectSelectorMode.DROPDOWN,
|
options=hrefs,
|
||||||
)),
|
custom_value=True,
|
||||||
}),
|
mode=SelectSelectorMode.DROPDOWN,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
}
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
def _show_debug_edit_form(
|
def _show_debug_edit_form(
|
||||||
self, href: str, current: dict, errors: dict[str, str], payload,
|
self,
|
||||||
) -> FlowResult:
|
href: str,
|
||||||
|
current: dict,
|
||||||
|
errors: dict[str, str],
|
||||||
|
payload,
|
||||||
|
) -> ConfigFlowResult:
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="debug_edit",
|
step_id="debug_edit",
|
||||||
data_schema=vol.Schema({
|
data_schema=vol.Schema(
|
||||||
vol.Required(
|
{
|
||||||
"payload", default=(payload if payload is not None else {}),
|
vol.Required(
|
||||||
): ObjectSelector(),
|
"payload",
|
||||||
}),
|
default=(payload if payload is not None else {}),
|
||||||
|
): ObjectSelector(),
|
||||||
|
}
|
||||||
|
),
|
||||||
errors=errors,
|
errors=errors,
|
||||||
description_placeholders={
|
description_placeholders={
|
||||||
"href": href,
|
"href": href,
|
||||||
"current_value": (
|
"current_value": (
|
||||||
json.dumps(current, indent=2, ensure_ascii=False)
|
json.dumps(current, indent=2, ensure_ascii=False) if current else "{}"
|
||||||
if current else "{}"
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_debug_edit(
|
async def async_step_debug_edit(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
coord = self._coordinator()
|
coord = self._coordinator()
|
||||||
if coord is None:
|
if coord is None:
|
||||||
return self.async_abort(reason="not_loaded")
|
return self.async_abort(reason="not_loaded")
|
||||||
@@ -517,11 +585,9 @@ class LocalThingsOptionsFlow(config_entries.OptionsFlow):
|
|||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
code, new_rep = await coord.async_raw_write(href, payload)
|
code, new_rep = await coord.async_raw_write(href, payload)
|
||||||
except Exception: # noqa: BLE001 - surfaced to the user below
|
except Exception:
|
||||||
_LOGGER.exception("debug raw write failed for %s", href)
|
_LOGGER.exception("debug raw write failed for %s", href)
|
||||||
return self._show_debug_edit_form(
|
return self._show_debug_edit_form(href, current, {"base": "write_failed"}, payload)
|
||||||
href, current, {"base": "write_failed"}, payload
|
|
||||||
)
|
|
||||||
self._debug_result = (code, new_rep)
|
self._debug_result = (code, new_rep)
|
||||||
return await self.async_step_debug_result()
|
return await self.async_step_debug_result()
|
||||||
|
|
||||||
@@ -529,22 +595,19 @@ class LocalThingsOptionsFlow(config_entries.OptionsFlow):
|
|||||||
|
|
||||||
async def async_step_debug_result(
|
async def async_step_debug_result(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> ConfigFlowResult:
|
||||||
code, new_rep = self._debug_result or (0, {})
|
code, new_rep = self._debug_result or (0, {})
|
||||||
return self.async_show_menu(
|
return self.async_show_menu(
|
||||||
step_id="debug_result",
|
step_id="debug_result",
|
||||||
menu_options=["debug_write", "finish"],
|
menu_options=["debug_write", "finish"],
|
||||||
description_placeholders={
|
description_placeholders={
|
||||||
"code": f"{code >> 5}.{code & 0x1f:02d} ({code:#04x})",
|
"code": f"{code >> 5}.{code & 0x1F:02d} ({code:#04x})",
|
||||||
"new_value": (
|
"new_value": (
|
||||||
json.dumps(new_rep, indent=2, ensure_ascii=False)
|
json.dumps(new_rep, indent=2, ensure_ascii=False) if new_rep else "{}"
|
||||||
if new_rep else "{}"
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_finish(
|
async def async_step_finish(self, user_input: dict[str, Any] | None = None) -> ConfigFlowResult:
|
||||||
self, user_input: dict[str, Any] | None = None
|
|
||||||
) -> FlowResult:
|
|
||||||
# Close the flow without altering saved options.
|
# Close the flow without altering saved options.
|
||||||
return self.async_create_entry(data=dict(self.config_entry.options))
|
return self.async_create_entry(data=dict(self.config_entry.options))
|
||||||
@@ -1,16 +1,24 @@
|
|||||||
DOMAIN = "localthings"
|
DOMAIN = "localthings"
|
||||||
|
|
||||||
PLATFORMS = [
|
PLATFORMS = [
|
||||||
"sensor", "binary_sensor", "switch", "number", "select", "button",
|
"sensor",
|
||||||
"time", "climate", "fan",
|
"binary_sensor",
|
||||||
|
"switch",
|
||||||
|
"number",
|
||||||
|
"select",
|
||||||
|
"button",
|
||||||
|
"time",
|
||||||
|
"climate",
|
||||||
|
"fan",
|
||||||
|
"water_heater",
|
||||||
]
|
]
|
||||||
|
|
||||||
CONF_HOST = "host"
|
CONF_HOST = "host"
|
||||||
CONF_PORT = "port"
|
CONF_PORT = "port"
|
||||||
CONF_CA_CERT_PEM = "ca_cert_pem"
|
CONF_CA_CERT_PEM = "ca_cert_pem"
|
||||||
CONF_CA_KEY_PEM = "ca_key_pem"
|
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
|
# 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
|
# device-wide remote-control-off write block for a specific device (issue
|
||||||
@@ -22,6 +30,17 @@ CONF_LEAF_KEY_PEM = "leaf_key_pem"
|
|||||||
# read, so devices this doesn't apply to see no behavior change.
|
# read, so devices this doesn't apply to see no behavior change.
|
||||||
CONF_BYPASS_REMOTE_CONTROL = "bypass_remote_control_lock"
|
CONF_BYPASS_REMOTE_CONTROL = "bypass_remote_control_lock"
|
||||||
|
|
||||||
|
# Options-flow key: minimum change (in minutes) required before a
|
||||||
|
# hysteresis-gated timestamp sensor (currently just finish_time) is allowed
|
||||||
|
# to report a new value. Devices commonly revise their own remaining-time
|
||||||
|
# estimate by a minute or two throughout a cycle, and finish_time = now() +
|
||||||
|
# remaining drifts by the poll interval between those revisions -- both push
|
||||||
|
# a fresh state (and a recorder/logbook entry) far more often than the
|
||||||
|
# estimate is meaningfully different. 0 disables the gate (every computed
|
||||||
|
# change is reported, today's behavior).
|
||||||
|
CONF_FINISH_TIME_HYSTERESIS_MINUTES = "finish_time_hysteresis_minutes"
|
||||||
|
DEFAULT_FINISH_TIME_HYSTERESIS_MINUTES = 3
|
||||||
|
|
||||||
# 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
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
"""Coordinator for Local Things integration."""
|
"""Coordinator for Local Things integration."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import contextlib
|
||||||
import ipaddress
|
import ipaddress
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
@@ -11,17 +13,29 @@ from datetime import timedelta
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import cbor2
|
import cbor2
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.exceptions import ServiceValidationError
|
from homeassistant.exceptions import ServiceValidationError
|
||||||
from homeassistant.helpers import issue_registry as ir
|
from homeassistant.helpers import issue_registry as ir
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
from smartthings_local.protocol.dtls_session import DtlsCoapSession
|
|
||||||
from smartthings_local.ocf.state_cache import StateCache
|
from smartthings_local.ocf.state_cache import StateCache
|
||||||
|
from smartthings_local.protocol.dtls_session import DtlsCoapSession
|
||||||
|
|
||||||
|
from .const import (
|
||||||
|
CONF_BYPASS_REMOTE_CONTROL,
|
||||||
|
CONF_HOST,
|
||||||
|
CONF_LEAF_CERT_PEM,
|
||||||
|
CONF_LEAF_KEY_PEM,
|
||||||
|
CONF_PORT,
|
||||||
|
DEVICE_SUPPORT_ISSUE_URL,
|
||||||
|
DOMAIN,
|
||||||
|
DTLS_LOCAL_PORT_BASE,
|
||||||
|
SUMMARY_INTERVAL_S,
|
||||||
|
)
|
||||||
|
from .observe import GRACE_PERIOD_S, MODE_OBSERVE, MODE_POLL, ObserveManager
|
||||||
|
from .registry import CAPABILITIES
|
||||||
|
from .registry.adapter import flatten
|
||||||
from .registry.batch import parse_device0_batch
|
from .registry.batch import parse_device0_batch
|
||||||
from .registry.by_type import resolve as resolve_registry
|
from .registry.by_type import resolve as resolve_registry
|
||||||
from .registry.capabilities.common import (
|
from .registry.capabilities.common import (
|
||||||
@@ -31,29 +45,25 @@ from .registry.capabilities.common import (
|
|||||||
remote_control_required_for_write,
|
remote_control_required_for_write,
|
||||||
)
|
)
|
||||||
from .registry.discovery import BoundEntity
|
from .registry.discovery import BoundEntity
|
||||||
from .registry import CAPABILITIES
|
from .registry.identity import DeviceIdentity, read_identity
|
||||||
from .registry.adapter import flatten
|
|
||||||
from .registry.identity import read_identity, DeviceIdentity
|
|
||||||
from .registry.subdevices import (
|
from .registry.subdevices import (
|
||||||
MAIN, Subdevice, canonical_view, discover_partitioned, enumerate_subdevices,
|
Subdevice,
|
||||||
|
canonical_view,
|
||||||
|
discover_partitioned,
|
||||||
|
enumerate_subdevices,
|
||||||
normalize_seed_batch,
|
normalize_seed_batch,
|
||||||
)
|
)
|
||||||
from .observe import ObserveManager, MODE_OBSERVE, MODE_POLL, GRACE_PERIOD_S
|
|
||||||
|
|
||||||
from .const import (
|
|
||||||
DOMAIN, CONF_HOST, CONF_PORT, CONF_LEAF_CERT_PEM, CONF_LEAF_KEY_PEM,
|
|
||||||
CONF_BYPASS_REMOTE_CONTROL, DEVICE_SUPPORT_ISSUE_URL, SUMMARY_INTERVAL_S,
|
|
||||||
DTLS_LOCAL_PORT_BASE,
|
|
||||||
)
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
_SEED_PATH = ['device', '0']
|
_SEED_PATH = ["device", "0"]
|
||||||
|
|
||||||
|
|
||||||
class _NoOpDescriptor:
|
class _NoOpDescriptor:
|
||||||
"""StateCache requires a descriptor with an on_observation hook. This
|
"""StateCache requires a descriptor with an on_observation hook. This
|
||||||
integration doesn't use per-capability observation hooks, so this is a
|
integration doesn't use per-capability observation hooks, so this is a
|
||||||
deliberate no-op, not a placeholder for missing functionality."""
|
deliberate no-op, not a placeholder for missing functionality."""
|
||||||
|
|
||||||
def on_observation(self, state: dict, href: str, rep: dict) -> None:
|
def on_observation(self, state: dict, href: str, rep: dict) -> None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -92,12 +102,26 @@ def _is_placeholder_serial(serial: str) -> bool:
|
|||||||
serial` check below doesn't catch it, and `device_serial` feeds both
|
serial` check below doesn't catch it, and `device_serial` feeds both
|
||||||
the HA device-registry identifier and every entity's unique_id
|
the HA device-registry identifier and every entity's unique_id
|
||||||
(entity.py), so two such units on the same install silently collide
|
(entity.py), so two such units on the same install silently collide
|
||||||
and the second one's entities get dropped (issue #83). Mirrors the
|
and the second one's entities get dropped (issue #83).
|
||||||
identical helper in config_flow.py's `_probe_and_validate` -- kept
|
|
||||||
separate rather than imported to avoid pulling the config-flow module
|
Issue #189: the DA_WM_A51_20_COMMON (ARTIK051) laundry board family
|
||||||
into the runtime coordinator's import graph for a two-line check.
|
reports a flash-unset sentinel instead -- every character the same
|
||||||
|
repeated hex digit (a washer and a dryer, two different physical
|
||||||
|
units, both reported the literal serialNum 'FFFFFFFFFFFFFFF') -- which
|
||||||
|
the 'nothing' check above doesn't catch either, so two such units
|
||||||
|
collided on the config-entry unique_id and the second couldn't be
|
||||||
|
added at all.
|
||||||
|
|
||||||
|
Mirrors the identical helper in config_flow.py's `_probe_and_validate`
|
||||||
|
-- kept separate rather than imported to avoid pulling the config-flow
|
||||||
|
module into the runtime coordinator's import graph for a two-line
|
||||||
|
check.
|
||||||
"""
|
"""
|
||||||
return serial.strip().lower().startswith('nothing')
|
s = serial.strip()
|
||||||
|
if s.lower().startswith("nothing"):
|
||||||
|
return True
|
||||||
|
upper = s.upper()
|
||||||
|
return len(upper) >= 8 and len(set(upper)) == 1 and upper[0] in "0123456789ABCDEF"
|
||||||
|
|
||||||
|
|
||||||
class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||||
@@ -157,6 +181,7 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
self._log,
|
self._log,
|
||||||
|
config_entry=entry,
|
||||||
name=f"{DOMAIN}_{entry.data[CONF_HOST]}",
|
name=f"{DOMAIN}_{entry.data[CONF_HOST]}",
|
||||||
update_interval=timedelta(seconds=SUMMARY_INTERVAL_S),
|
update_interval=timedelta(seconds=SUMMARY_INTERVAL_S),
|
||||||
)
|
)
|
||||||
@@ -215,7 +240,7 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
self._hot_hrefs: list[str] = []
|
self._hot_hrefs: list[str] = []
|
||||||
self._warm_hrefs: list[str] = []
|
self._warm_hrefs: list[str] = []
|
||||||
self.device_type_name: str | None = None
|
self.device_type_name: str | None = None
|
||||||
self.one_ui_version: str = ''
|
self.one_ui_version: str = ""
|
||||||
self._consecutive_poll_timeouts = 0
|
self._consecutive_poll_timeouts = 0
|
||||||
self._unbound_hrefs: list[str] = []
|
self._unbound_hrefs: list[str] = []
|
||||||
self._reconnect_times: list[float] = []
|
self._reconnect_times: list[float] = []
|
||||||
@@ -272,15 +297,15 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
that resource when present anyway -- it's informational, not an
|
that resource when present anyway -- it's informational, not an
|
||||||
identifier.
|
identifier.
|
||||||
"""
|
"""
|
||||||
if subdevice.kind == 'main':
|
if subdevice.kind == "main":
|
||||||
return self.device_info
|
return self.device_info
|
||||||
info = self.canonical_resources(subdevice).get('/information/vs/0', {})
|
info = self.canonical_resources(subdevice).get("/information/vs/0", {})
|
||||||
model_num = info.get('x.com.samsung.da.modelNum', '')
|
model_num = info.get("x.com.samsung.da.modelNum", "")
|
||||||
model = model_num.split('|', 1)[0] if model_num else ''
|
model = model_num.split("|", 1)[0] if model_num else ""
|
||||||
serial = info.get('x.com.samsung.da.serialNum') or None
|
serial = info.get("x.com.samsung.da.serialNum") or None
|
||||||
base_name = self.device_info.get('name') or 'Samsung Appliance'
|
base_name = self.device_info.get("name") or "Samsung Appliance"
|
||||||
if model:
|
if model:
|
||||||
label = model.replace('_', ' ').title()
|
label = model.replace("_", " ").title()
|
||||||
else:
|
else:
|
||||||
# This poll never got (or never will get) the subdevice's own
|
# This poll never got (or never will get) the subdevice's own
|
||||||
# identity resource -- fall back to a generic per-subdevice label
|
# identity resource -- fall back to a generic per-subdevice label
|
||||||
@@ -289,14 +314,15 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
# ordinal); UUID-prefixed subdevices are never more than one per
|
# ordinal); UUID-prefixed subdevices are never more than one per
|
||||||
# connection today, so there's no ordinal to show.
|
# connection today, so there's no ordinal to show.
|
||||||
label = (
|
label = (
|
||||||
f'Subdevice {subdevice.key}' if subdevice.kind == 'indexed'
|
f"Subdevice {subdevice.key}"
|
||||||
else 'Secondary Subdevice'
|
if subdevice.kind == "indexed"
|
||||||
|
else "Secondary Subdevice"
|
||||||
)
|
)
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={(DOMAIN, f"{self.device_serial}_{subdevice.key}")},
|
identifiers={(DOMAIN, f"{self.device_serial}_{subdevice.key}")},
|
||||||
via_device=(DOMAIN, self.device_serial),
|
via_device=(DOMAIN, self.device_serial),
|
||||||
name=f"{base_name} {label}",
|
name=f"{base_name} {label}",
|
||||||
manufacturer=self.device_info.get('manufacturer') or 'Samsung',
|
manufacturer=self.device_info.get("manufacturer") or "Samsung",
|
||||||
model=model or None,
|
model=model or None,
|
||||||
serial_number=serial,
|
serial_number=serial,
|
||||||
)
|
)
|
||||||
@@ -306,14 +332,19 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
return self._observe.mode
|
return self._observe.mode
|
||||||
|
|
||||||
def _connect_session(self) -> None:
|
def _connect_session(self) -> None:
|
||||||
host = self._entry.data[CONF_HOST]
|
host = self._entry.data[CONF_HOST]
|
||||||
port = self._entry.data[CONF_PORT]
|
port = self._entry.data[CONF_PORT]
|
||||||
cert_pem = self._entry.data[CONF_LEAF_CERT_PEM]
|
cert_pem = self._entry.data[CONF_LEAF_CERT_PEM]
|
||||||
key_pem = self._entry.data[CONF_LEAF_KEY_PEM]
|
key_pem = self._entry.data[CONF_LEAF_KEY_PEM]
|
||||||
|
|
||||||
sess = DtlsCoapSession(host, port, cert_pem=cert_pem, key_pem=key_pem,
|
sess = DtlsCoapSession(
|
||||||
on_notification=self._observe.on_notification,
|
host,
|
||||||
local_port=_local_source_port(host))
|
port,
|
||||||
|
cert_pem=cert_pem,
|
||||||
|
key_pem=key_pem,
|
||||||
|
on_notification=self._observe.on_notification,
|
||||||
|
local_port=_local_source_port(host),
|
||||||
|
)
|
||||||
sess.connect()
|
sess.connect()
|
||||||
sess.start_reader()
|
sess.start_reader()
|
||||||
self._session = sess
|
self._session = sess
|
||||||
@@ -328,10 +359,8 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
sess = self._session
|
sess = self._session
|
||||||
self._session = None
|
self._session = None
|
||||||
if sess is not None:
|
if sess is not None:
|
||||||
try:
|
with contextlib.suppress(Exception):
|
||||||
sess.close()
|
sess.close()
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
async def async_close(self) -> None:
|
async def async_close(self) -> None:
|
||||||
if self._subpoll_task is not None:
|
if self._subpoll_task is not None:
|
||||||
@@ -378,6 +407,7 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
if self._session is None:
|
if self._session is None:
|
||||||
self._connect_session()
|
self._connect_session()
|
||||||
sess = self._session
|
sess = self._session
|
||||||
|
assert sess is not None
|
||||||
try:
|
try:
|
||||||
# A slow device can still be mid-transfer (block 8, block 11)
|
# A slow device can still be mid-transfer (block 8, block 11)
|
||||||
# when a tighter deadline cuts it off — that's a poll that
|
# when a tighter deadline cuts it off — that's a poll that
|
||||||
@@ -432,10 +462,14 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
"""Re-poll a flat-mode prefixed subdevice's hrefs individually
|
"""Re-poll a flat-mode prefixed subdevice's hrefs individually
|
||||||
(issue #205) -- it has no Collection endpoint to batch-refresh
|
(issue #205) -- it has no Collection endpoint to batch-refresh
|
||||||
through (see enumerate_subdevices' fallback), so each canonical
|
through (see enumerate_subdevices' fallback), so each canonical
|
||||||
href confirmed at enumeration time gets its own GET under the
|
href assumed at enumeration time (cloned from the master's own
|
||||||
subdevice's prefix. A href failing to answer this cycle just drops
|
state, issue #265 -- not yet confirmed live under this subdevice's
|
||||||
out of the result, same "never let a sibling's flakiness fail the
|
own prefix) gets its own GET under the subdevice's prefix, which is
|
||||||
master's poll" posture as the Collection path above.
|
what turns the clone into this sibling's real value once it
|
||||||
|
answers. A href failing to answer this cycle just drops out of the
|
||||||
|
result and leaves whatever value is already cached (the clone, until
|
||||||
|
corrected) in place -- same "never let a sibling's flakiness fail
|
||||||
|
the master's poll" posture as the Collection path above.
|
||||||
|
|
||||||
Takes `sess` from the caller (already None-checked there) rather
|
Takes `sess` from the caller (already None-checked there) rather
|
||||||
than re-reading self._session -- async_close() can null that
|
than re-reading self._session -- async_close() can null that
|
||||||
@@ -447,7 +481,7 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
this method builds) -- those are already refreshed every 3s/6s by
|
this method builds) -- those are already refreshed every 3s/6s by
|
||||||
_run_subpolls, strictly more current than this once-per-summary-poll
|
_run_subpolls, strictly more current than this once-per-summary-poll
|
||||||
pass could offer, so re-fetching them here would only add GETs
|
pass could offer, so re-fetching them here would only add GETs
|
||||||
without adding freshness. A subdevice with many confirmed hrefs
|
without adding freshness. A subdevice with many assumed hrefs
|
||||||
(unlike a Collection batch, which is always one GET regardless of
|
(unlike a Collection batch, which is always one GET regardless of
|
||||||
count) is otherwise a summary-poll cost that scales with its href
|
count) is otherwise a summary-poll cost that scales with its href
|
||||||
count."""
|
count."""
|
||||||
@@ -462,7 +496,7 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
if not first:
|
if not first:
|
||||||
sess.pace()
|
sess.pace()
|
||||||
first = False
|
first = False
|
||||||
path = [s for s in actual.strip('/').split('/')]
|
path = actual.strip("/").split("/")
|
||||||
code, payload = sess.get(path, timeout=10.0)
|
code, payload = sess.get(path, timeout=10.0)
|
||||||
if code == 0x45 and payload:
|
if code == 0x45 and payload:
|
||||||
rep = cbor2.loads(payload)
|
rep = cbor2.loads(payload)
|
||||||
@@ -471,7 +505,9 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._log.debug(
|
self._log.debug(
|
||||||
"subdevice %s flat href %s poll failed: %s",
|
"subdevice %s flat href %s poll failed: %s",
|
||||||
subdevice.key, href, e,
|
subdevice.key,
|
||||||
|
href,
|
||||||
|
e,
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -486,12 +522,12 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
self._session.pace()
|
self._session.pace()
|
||||||
first = False
|
first = False
|
||||||
try:
|
try:
|
||||||
path = [s for s in href.strip('/').split('/')]
|
path = href.strip("/").split("/")
|
||||||
code, payload = self._session.get(path, timeout=10.0)
|
code, payload = self._session.get(path, timeout=10.0)
|
||||||
if code == 0x45 and payload:
|
if code == 0x45 and payload:
|
||||||
rep = cbor2.loads(payload)
|
rep = cbor2.loads(payload)
|
||||||
if isinstance(rep, dict):
|
if isinstance(rep, dict):
|
||||||
self._observe.apply(href, rep, source='poll')
|
self._observe.apply(href, rep, source="poll")
|
||||||
results[href] = rep
|
results[href] = rep
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._log.debug("sub-poll %s: %s", href, e)
|
self._log.debug("sub-poll %s: %s", href, e)
|
||||||
@@ -517,14 +553,12 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
if not hot and not warm:
|
if not hot and not warm:
|
||||||
return
|
return
|
||||||
step = self._SUBPOLL_STEP_S
|
step = self._SUBPOLL_STEP_S
|
||||||
for i in range(1, 10): # slots 1..9 (T+3 s … T+27 s)
|
for i in range(1, 10): # slots 1..9 (T+3 s … T+27 s)
|
||||||
await asyncio.sleep(step)
|
await asyncio.sleep(step)
|
||||||
hrefs = list(hot) + (list(warm) if i % 2 == 0 else [])
|
hrefs = list(hot) + (list(warm) if i % 2 == 0 else [])
|
||||||
async with self._session_lock:
|
async with self._session_lock:
|
||||||
try:
|
try:
|
||||||
await self.hass.async_add_executor_job(
|
await self.hass.async_add_executor_job(self._poll_hrefs_blocking, hrefs)
|
||||||
self._poll_hrefs_blocking, hrefs
|
|
||||||
)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._log.debug("sub-poll batch failed: %s", e)
|
self._log.debug("sub-poll batch failed: %s", e)
|
||||||
|
|
||||||
@@ -554,10 +588,12 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
sess = self._session
|
sess = self._session
|
||||||
if sess is None:
|
if sess is None:
|
||||||
return resources
|
return resources
|
||||||
oic_res = self._identity.raw.get('/oic/res', []) if self._identity else []
|
oic_res = self._identity.raw.get("/oic/res", []) if self._identity else []
|
||||||
probes: dict[str, bool] = {}
|
probes: dict[str, bool] = {}
|
||||||
subdevices, extra = enumerate_subdevices(
|
subdevices, extra = enumerate_subdevices(
|
||||||
sess, resources, oic_res,
|
sess,
|
||||||
|
resources,
|
||||||
|
oic_res,
|
||||||
probe_log=lambda href, found: probes.__setitem__(href, found),
|
probe_log=lambda href, found: probes.__setitem__(href, found),
|
||||||
)
|
)
|
||||||
self.subdevices = subdevices
|
self.subdevices = subdevices
|
||||||
@@ -573,7 +609,7 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
# cache would freeze it there exactly like a rejected candidate's
|
# cache would freeze it there exactly like a rejected candidate's
|
||||||
# reps (see _live_subdevice_resources). Kept aside for diagnostics and
|
# reps (see _live_subdevice_resources). Kept aside for diagnostics and
|
||||||
# for the numofsubdevice cross-check in _run_discovery instead.
|
# for the numofsubdevice cross-check in _run_discovery instead.
|
||||||
self._multidevice = extra.pop('/multidevice/vs/0', {})
|
self._multidevice = extra.pop("/multidevice/vs/0", {})
|
||||||
return {**resources, **extra}
|
return {**resources, **extra}
|
||||||
|
|
||||||
def _live_subdevice_resources(self, resources: dict[str, dict]) -> dict[str, dict]:
|
def _live_subdevice_resources(self, resources: dict[str, dict]) -> dict[str, dict]:
|
||||||
@@ -591,9 +627,11 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
kept: dict[str, dict] = {}
|
kept: dict[str, dict] = {}
|
||||||
skipped: dict[str, dict] = {}
|
skipped: dict[str, dict] = {}
|
||||||
for href, rep in resources.items():
|
for href, rep in resources.items():
|
||||||
bucket = skipped if any(
|
bucket = (
|
||||||
skip.subdevice.owns(href) for skip in self._skipped_subdevices
|
skipped
|
||||||
) else kept
|
if any(skip.subdevice.owns(href) for skip in self._skipped_subdevices)
|
||||||
|
else kept
|
||||||
|
)
|
||||||
bucket[href] = rep
|
bucket[href] = rep
|
||||||
self._skipped_subdevice_resources = skipped
|
self._skipped_subdevice_resources = skipped
|
||||||
return kept
|
return kept
|
||||||
@@ -603,21 +641,23 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
# ('7.0 Air conditioner' is Tizen Lite), which is useful when triaging
|
# ('7.0 Air conditioner' is Tizen Lite), which is useful when triaging
|
||||||
# an issue. It does not route: only a minority of hardware reports it
|
# an issue. It does not route: only a minority of hardware reports it
|
||||||
# at all, and every device that does is already typed by its modelNum.
|
# at all, and every device that does is already typed by its modelNum.
|
||||||
self.one_ui_version = (resources.get('/otninformation/vs/0', {})
|
self.one_ui_version = (
|
||||||
.get('swVersionInfo', {})
|
resources.get("/otninformation/vs/0", {})
|
||||||
.get('oneUiVersion', ''))
|
.get("swVersionInfo", {})
|
||||||
info = resources.get('/information/vs/0', {})
|
.get("oneUiVersion", "")
|
||||||
|
)
|
||||||
|
info = resources.get("/information/vs/0", {})
|
||||||
unbound: list[str] = []
|
unbound: list[str] = []
|
||||||
hot, warm = set(), set()
|
hot, warm = set(), set()
|
||||||
|
|
||||||
def _tier_log(href: str, tier: str) -> None:
|
def _tier_log(href: str, tier: str) -> None:
|
||||||
if tier == 'hot':
|
if tier == "hot":
|
||||||
hot.add(href)
|
hot.add(href)
|
||||||
elif tier == 'warm':
|
elif tier == "warm":
|
||||||
warm.add(href)
|
warm.add(href)
|
||||||
|
|
||||||
model_num = info.get('x.com.samsung.da.modelNum', '')
|
model_num = info.get("x.com.samsung.da.modelNum", "")
|
||||||
description = info.get('x.com.samsung.da.description', '')
|
description = info.get("x.com.samsung.da.description", "")
|
||||||
|
|
||||||
# Partitioned discovery (issue #177): the main pass binds every href
|
# Partitioned discovery (issue #177): the main pass binds every href
|
||||||
# owned by no subdevice; one further pass per *candidate* subdevice
|
# owned by no subdevice; one further pass per *candidate* subdevice
|
||||||
@@ -632,8 +672,13 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
# with no candidates (self.subdevices == []) this is exactly the
|
# with no candidates (self.subdevices == []) this is exactly the
|
||||||
# single discover() call this method used to make.
|
# single discover() call this method used to make.
|
||||||
bound, device_type_name, materialized, skipped = discover_partitioned(
|
bound, device_type_name, materialized, skipped = discover_partitioned(
|
||||||
resources, self.subdevices, resolve_registry, CAPABILITIES,
|
resources,
|
||||||
log=unbound.append, tier_log=_tier_log,
|
self.subdevices,
|
||||||
|
resolve_registry,
|
||||||
|
CAPABILITIES,
|
||||||
|
log=unbound.append,
|
||||||
|
tier_log=_tier_log,
|
||||||
|
oic_device_types=self._identity.device_types if self._identity else (),
|
||||||
)
|
)
|
||||||
self.subdevices = materialized
|
self.subdevices = materialized
|
||||||
self._skipped_subdevices = skipped
|
self._skipped_subdevices = skipped
|
||||||
@@ -641,7 +686,9 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
self._log.info(
|
self._log.info(
|
||||||
"subdevice %s (%s) answered its seed but produced no live "
|
"subdevice %s (%s) answered its seed but produced no live "
|
||||||
"primary state; not materialized (hrefs=%s)",
|
"primary state; not materialized (hrefs=%s)",
|
||||||
skip.subdevice.key, skip.subdevice.kind, list(skip.hrefs),
|
skip.subdevice.key,
|
||||||
|
skip.subdevice.kind,
|
||||||
|
list(skip.hrefs),
|
||||||
)
|
)
|
||||||
# Corroborating signal, not a gate (DESIGN-177.md section 4):
|
# Corroborating signal, not a gate (DESIGN-177.md section 4):
|
||||||
# /multidevice/vs/0's numofsubdevice is a plain count the issue
|
# /multidevice/vs/0's numofsubdevice is a plain count the issue
|
||||||
@@ -650,8 +697,7 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
# family is known to expose the resource at all, so a mismatch is a
|
# family is known to expose the resource at all, so a mismatch is a
|
||||||
# "look into this" signal for triage, not proof either side is
|
# "look into this" signal for triage, not proof either side is
|
||||||
# wrong.
|
# wrong.
|
||||||
numofsubdevice = self._multidevice.get(
|
numofsubdevice = self._multidevice.get("x.com.samsung.da.numofsubdevice")
|
||||||
'x.com.samsung.da.numofsubdevice')
|
|
||||||
if numofsubdevice is not None:
|
if numofsubdevice is not None:
|
||||||
try:
|
try:
|
||||||
reported = int(numofsubdevice)
|
reported = int(numofsubdevice)
|
||||||
@@ -662,32 +708,39 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
self._log.debug(
|
self._log.debug(
|
||||||
"/multidevice/vs/0 reports numofsubdevice=%r but %d "
|
"/multidevice/vs/0 reports numofsubdevice=%r but %d "
|
||||||
"subdevice(s) materialized (including the master)",
|
"subdevice(s) materialized (including the master)",
|
||||||
numofsubdevice, subdevice_count,
|
numofsubdevice,
|
||||||
|
subdevice_count,
|
||||||
)
|
)
|
||||||
if device_type_name is not None:
|
if device_type_name is not None:
|
||||||
self._log.debug("device type: %s (modelNum=%r)", device_type_name, model_num)
|
self._log.debug("device type: %s (modelNum=%r)", device_type_name, model_num)
|
||||||
else:
|
else:
|
||||||
# Both fields: detection reads each of them (board token, then
|
# All three: detection reads each of them (oic device type, then
|
||||||
# consumer-model code), and this line is what a user pastes into
|
# board token, then consumer-model code), and this line is what a
|
||||||
# an issue -- modelNum alone doesn't identify a washer or dryer.
|
# user pastes into an issue -- modelNum alone doesn't identify a
|
||||||
|
# washer or dryer, and device_types is often empty even when
|
||||||
|
# populated hardware exists for a type we don't map yet.
|
||||||
self._log.warning(
|
self._log.warning(
|
||||||
"unknown device type modelNum=%r description=%r; using common caps",
|
"unknown device type modelNum=%r description=%r device_types=%r; using common caps",
|
||||||
model_num, description,
|
model_num,
|
||||||
|
description,
|
||||||
|
self._identity.device_types if self._identity else (),
|
||||||
)
|
)
|
||||||
self.device_type_name = device_type_name
|
self.device_type_name = device_type_name
|
||||||
self.bound = bound
|
self.bound = bound
|
||||||
self._unbound_hrefs = unbound
|
self._unbound_hrefs = unbound
|
||||||
|
|
||||||
serial = info.get('x.com.samsung.da.serialNum', '')
|
serial = info.get("x.com.samsung.da.serialNum", "")
|
||||||
if not serial or _is_placeholder_serial(serial):
|
if not serial or _is_placeholder_serial(serial):
|
||||||
serial = self._entry.data[CONF_HOST]
|
serial = self._entry.data[CONF_HOST]
|
||||||
self.device_serial = serial
|
self.device_serial = serial
|
||||||
|
|
||||||
ident = self._identity
|
ident = self._identity
|
||||||
device_type = device_type_name.replace('_', ' ').title() if device_type_name else 'Appliance'
|
device_type = (
|
||||||
model = model_num.split('|', 1)[0] if model_num else (ident.model if ident else '')
|
device_type_name.replace("_", " ").title() if device_type_name else "Appliance"
|
||||||
name = f"Samsung {device_type} ({model})" if model else f"Samsung {device_type}"
|
)
|
||||||
mfr = (ident.manufacturer if ident else '') or 'Samsung'
|
model = model_num.split("|", 1)[0] if model_num else (ident.model if ident else "")
|
||||||
|
name = f"Samsung {device_type} ({model})" if model else f"Samsung {device_type}"
|
||||||
|
mfr = (ident.manufacturer if ident else "") or "Samsung"
|
||||||
|
|
||||||
self.device_info = DeviceInfo(
|
self.device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, serial)},
|
identifiers={(DOMAIN, serial)},
|
||||||
@@ -703,12 +756,18 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
self._discovered = True
|
self._discovered = True
|
||||||
self._log.info(
|
self._log.info(
|
||||||
"discovered %d entities (serial=%s) hot=%s warm=%s subdevices=%s",
|
"discovered %d entities (serial=%s) hot=%s warm=%s subdevices=%s",
|
||||||
len(bound), serial, self._hot_hrefs, self._warm_hrefs,
|
len(bound),
|
||||||
|
serial,
|
||||||
|
self._hot_hrefs,
|
||||||
|
self._warm_hrefs,
|
||||||
[su.key for su in self.subdevices],
|
[su.key for su in self.subdevices],
|
||||||
)
|
)
|
||||||
|
|
||||||
def _update_coverage_gap_issue(
|
def _update_coverage_gap_issue(
|
||||||
self, unknown_type: bool, unbound_hrefs: list[str], device_name: str,
|
self,
|
||||||
|
unknown_type: bool,
|
||||||
|
unbound_hrefs: list[str],
|
||||||
|
device_name: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Raise or clear a Repairs issue when capability coverage is incomplete.
|
"""Raise or clear a Repairs issue when capability coverage is incomplete.
|
||||||
|
|
||||||
@@ -720,7 +779,9 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
issue_id = f"device_gap_{self._entry.entry_id}"
|
issue_id = f"device_gap_{self._entry.entry_id}"
|
||||||
if unknown_type or unbound_hrefs:
|
if unknown_type or unbound_hrefs:
|
||||||
ir.async_create_issue(
|
ir.async_create_issue(
|
||||||
self.hass, DOMAIN, issue_id,
|
self.hass,
|
||||||
|
DOMAIN,
|
||||||
|
issue_id,
|
||||||
is_fixable=False,
|
is_fixable=False,
|
||||||
severity=ir.IssueSeverity.WARNING,
|
severity=ir.IssueSeverity.WARNING,
|
||||||
translation_key="device_gap",
|
translation_key="device_gap",
|
||||||
@@ -744,7 +805,9 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
if sess is None:
|
if sess is None:
|
||||||
return
|
return
|
||||||
await self.hass.async_add_executor_job(
|
await self.hass.async_add_executor_job(
|
||||||
self._observe.try_enter_observe_mode, sess, hrefs,
|
self._observe.try_enter_observe_mode,
|
||||||
|
sess,
|
||||||
|
hrefs,
|
||||||
self._OBSERVE_GRACE_PERIOD_S,
|
self._OBSERVE_GRACE_PERIOD_S,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -767,7 +830,21 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
normal on a flaky device; a run of them is a real problem. Any
|
normal on a flaky device; a run of them is a real problem. Any
|
||||||
other exception (a `ConnectionError`, an explicitly closed
|
other exception (a `ConnectionError`, an explicitly closed
|
||||||
session) is unambiguous and always reconnects immediately.
|
session) is unambiguous and always reconnects immediately.
|
||||||
|
|
||||||
|
Never defers before the first successful discovery (issue #254).
|
||||||
|
Deferring is a *mid-session* judgement call — "keep the entities we
|
||||||
|
already have and try again next cycle" — which is only coherent once
|
||||||
|
there are entities to keep. Pre-discovery the same exception type
|
||||||
|
means something else entirely: `_poll_once` calls `_connect_session`,
|
||||||
|
so `connect()`'s own handshake timeout surfaces here as a
|
||||||
|
`TimeoutError` too, and that is a dead connection, not a slow
|
||||||
|
transfer. Deferring it returned an empty dict instead of raising,
|
||||||
|
which `DataUpdateCoordinator` counts as a successful first refresh —
|
||||||
|
and since platforms enumerate `bound` exactly once, the entry loaded
|
||||||
|
with zero entities and stayed that way until a manual reload.
|
||||||
"""
|
"""
|
||||||
|
if not self._discovered:
|
||||||
|
return False
|
||||||
if not isinstance(e, TimeoutError):
|
if not isinstance(e, TimeoutError):
|
||||||
return False
|
return False
|
||||||
if self._observe.mode == MODE_OBSERVE and self._observe.recently_notified():
|
if self._observe.mode == MODE_OBSERVE and self._observe.recently_notified():
|
||||||
@@ -788,8 +865,7 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
warn window -- see _RECONNECT_WARN_WINDOW_S/_RECONNECT_WARN_THRESHOLD."""
|
warn window -- see _RECONNECT_WARN_WINDOW_S/_RECONNECT_WARN_THRESHOLD."""
|
||||||
now = time.monotonic()
|
now = time.monotonic()
|
||||||
self._reconnect_times = [
|
self._reconnect_times = [
|
||||||
t for t in self._reconnect_times
|
t for t in self._reconnect_times if now - t < self._RECONNECT_WARN_WINDOW_S
|
||||||
if now - t < self._RECONNECT_WARN_WINDOW_S
|
|
||||||
]
|
]
|
||||||
self._reconnect_times.append(now)
|
self._reconnect_times.append(now)
|
||||||
return len(self._reconnect_times) >= self._RECONNECT_WARN_THRESHOLD
|
return len(self._reconnect_times) >= self._RECONNECT_WARN_THRESHOLD
|
||||||
@@ -814,7 +890,8 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
self._log.debug(
|
self._log.debug(
|
||||||
"poll failed (%s), not yet treated as session "
|
"poll failed (%s), not yet treated as session "
|
||||||
"death; skipping this cycle: %s",
|
"death; skipping this cycle: %s",
|
||||||
type(e).__name__, e,
|
type(e).__name__,
|
||||||
|
e,
|
||||||
)
|
)
|
||||||
return flatten(self.bound, self._cache.snapshot())
|
return flatten(self.bound, self._cache.snapshot())
|
||||||
self._consecutive_poll_timeouts = 0
|
self._consecutive_poll_timeouts = 0
|
||||||
@@ -834,7 +911,15 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
except Exception as e2:
|
except Exception as e2:
|
||||||
self._log.error("poll failed after reconnect: %s", e2)
|
self._log.error("poll failed after reconnect: %s", e2)
|
||||||
snapshot = self._cache.snapshot()
|
snapshot = self._cache.snapshot()
|
||||||
if snapshot:
|
# `self._discovered` is the same precondition
|
||||||
|
# `_defer_reconnect_for` applies (issue #254): returning
|
||||||
|
# degraded-but-successful data is only meaningful once
|
||||||
|
# there are bound entities to carry it. Pre-discovery the
|
||||||
|
# cache happens to always be empty -- every apply() site
|
||||||
|
# is gated on post-discovery state -- so this arm is
|
||||||
|
# unreachable then, but that is a non-local accident
|
||||||
|
# across four call sites, not something to rely on.
|
||||||
|
if self._discovered and snapshot:
|
||||||
self._log.debug("Full error:", exc_info=e2)
|
self._log.debug("Full error:", exc_info=e2)
|
||||||
return flatten(self.bound, snapshot)
|
return flatten(self.bound, snapshot)
|
||||||
raise UpdateFailed(f"poll failed after reconnect: {e2}") from e2
|
raise UpdateFailed(f"poll failed after reconnect: {e2}") from e2
|
||||||
@@ -870,7 +955,7 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
self._enumerate_subdevices_blocking, resources
|
self._enumerate_subdevices_blocking, resources
|
||||||
)
|
)
|
||||||
|
|
||||||
source = 'sweep' if self._discovered else 'poll'
|
source = "sweep" if self._discovered else "poll"
|
||||||
first_cycle = not self._discovered
|
first_cycle = not self._discovered
|
||||||
if first_cycle:
|
if first_cycle:
|
||||||
# Discovery runs *before* the apply loop below, not after it, so
|
# Discovery runs *before* the apply loop below, not after it, so
|
||||||
@@ -903,18 +988,22 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
for href, rep in resources.items():
|
for href, rep in resources.items():
|
||||||
self._observe.apply(href, rep, source=source)
|
self._observe.apply(href, rep, source=source)
|
||||||
|
|
||||||
if first_cycle:
|
if first_cycle or just_downgraded_from_observe:
|
||||||
await self._attempt_observe_mode()
|
|
||||||
elif just_downgraded_from_observe:
|
|
||||||
await self._attempt_observe_mode()
|
await self._attempt_observe_mode()
|
||||||
elif self._observe.mode == MODE_POLL:
|
elif self._observe.mode == MODE_POLL:
|
||||||
await self._maybe_retry_observe_mode()
|
await self._maybe_retry_observe_mode()
|
||||||
|
|
||||||
# Schedule sub-polls for hot/warm hrefs between summary polls
|
# Schedule sub-polls for hot/warm hrefs between summary polls
|
||||||
# (no-op in observe-primary mode unless this cycle's sweep found a
|
# (no-op in observe-primary mode unless this cycle's sweep found a
|
||||||
# mismatch; _run_subpolls checks the mode/force).
|
# mismatch; _run_subpolls checks the mode/force). A background task,
|
||||||
|
# not async_create_task: this loop is self-limiting (cancelled and
|
||||||
|
# recreated every refresh cycle, see the cancel() above) and owned
|
||||||
|
# entirely by the coordinator, so it has no business being tracked by
|
||||||
|
# HA's own startup/shutdown sequencing -- async_create_task ties it
|
||||||
|
# in regardless, so a subpoll cycle in flight (up to ~27s,
|
||||||
|
# _SUBPOLL_STEP_S x 9 slots) delays both (issue #207).
|
||||||
if self._hot_hrefs or self._warm_hrefs:
|
if self._hot_hrefs or self._warm_hrefs:
|
||||||
self._subpoll_task = self.hass.async_create_task(
|
self._subpoll_task = self.hass.async_create_background_task(
|
||||||
self._run_subpolls(force=sweep_mismatch), name="localthings_subpoll"
|
self._run_subpolls(force=sweep_mismatch), name="localthings_subpoll"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -924,8 +1013,7 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
# Command dispatch (called by entity platforms in Task 5)
|
# Command dispatch (called by entity platforms in Task 5)
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
async def async_send_command(self, bound_entity: BoundEntity,
|
async def async_send_command(self, bound_entity: BoundEntity, payload: Any) -> None:
|
||||||
payload: Any) -> None:
|
|
||||||
"""Write a value to the device. Fire-and-forget style.
|
"""Write a value to the device. Fire-and-forget style.
|
||||||
|
|
||||||
A description-level validate_fn (currently SwitchDesc only) runs
|
A description-level validate_fn (currently SwitchDesc only) runs
|
||||||
@@ -942,23 +1030,23 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
without Smart Control (cycle start/pause/stop on /operational/state
|
without Smart Control (cycle start/pause/stop on /operational/state
|
||||||
still require it)."""
|
still require it)."""
|
||||||
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:
|
||||||
return
|
return
|
||||||
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)
|
bypass_remote_control = self._entry.options.get(CONF_BYPASS_REMOTE_CONTROL, False)
|
||||||
if (
|
if (
|
||||||
not bypass_remote_control
|
not bypass_remote_control
|
||||||
and remote_control_required_for_write(resources, href or '')
|
and remote_control_required_for_write(resources, href or "")
|
||||||
and not remote_control_enabled(resources)
|
and not remote_control_enabled(resources)
|
||||||
):
|
):
|
||||||
raise ServiceValidationError(
|
raise ServiceValidationError(
|
||||||
translation_domain=DOMAIN,
|
translation_domain=DOMAIN,
|
||||||
translation_key="remote_control_disabled",
|
translation_key="remote_control_disabled",
|
||||||
)
|
)
|
||||||
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:
|
||||||
error = validate_fn(payload, rep, resources)
|
error = validate_fn(payload, rep, resources)
|
||||||
if error:
|
if error:
|
||||||
@@ -998,8 +1086,8 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
# guard and the POST below all target that subdevice's real resource --
|
# guard and the POST below all target that subdevice's real resource --
|
||||||
# to_actual is the identity transform for MAIN, so a device with no
|
# to_actual is the identity transform for MAIN, so a device with no
|
||||||
# subdevices writes exactly where it always did.
|
# subdevices writes exactly where it always did.
|
||||||
write_href = bound_entity.subdevice.to_actual('/' + '/'.join(path_segs))
|
write_href = bound_entity.subdevice.to_actual("/" + "/".join(path_segs))
|
||||||
path_segs = [s for s in write_href.strip('/').split('/') if s]
|
path_segs = [s for s in write_href.strip("/").split("/") if s]
|
||||||
|
|
||||||
# Apply the write optimistically before starting the settle guard,
|
# Apply the write optimistically before starting the settle guard,
|
||||||
# not after -- mark_write_pending gates every source (poll, sweep,
|
# not after -- mark_write_pending gates every source (poll, sweep,
|
||||||
@@ -1049,24 +1137,24 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
# cache entry stays complete; the minimal `body` below is still
|
# cache entry stays complete; the minimal `body` below is still
|
||||||
# exactly what goes out over the wire.
|
# exactly what goes out over the wire.
|
||||||
optimistic_body = body
|
optimistic_body = body
|
||||||
new_options = body.get('x.com.samsung.da.options')
|
new_options = body.get("x.com.samsung.da.options")
|
||||||
if isinstance(new_options, list):
|
if isinstance(new_options, list):
|
||||||
cached_options = (self._cache.get(write_href) or {}).get('x.com.samsung.da.options')
|
cached_options = (self._cache.get(write_href) or {}).get("x.com.samsung.da.options")
|
||||||
optimistic_body = {
|
optimistic_body = {
|
||||||
**optimistic_body,
|
**optimistic_body,
|
||||||
'x.com.samsung.da.options': merge_options_field(cached_options, new_options),
|
"x.com.samsung.da.options": merge_options_field(cached_options, new_options),
|
||||||
}
|
}
|
||||||
# Same fact, items[] shape (e.g. airconditioner._climate_write's vendor
|
# Same fact, items[] shape (e.g. airconditioner._climate_write's vendor
|
||||||
# temperature write, which now carries only {id, desired} -- see that
|
# temperature write, which now carries only {id, desired} -- see that
|
||||||
# module for the write-side half of this).
|
# module for the write-side half of this).
|
||||||
new_items = body.get('x.com.samsung.da.items')
|
new_items = body.get("x.com.samsung.da.items")
|
||||||
if isinstance(new_items, list):
|
if isinstance(new_items, list):
|
||||||
cached_items = (self._cache.get(write_href) or {}).get('x.com.samsung.da.items')
|
cached_items = (self._cache.get(write_href) or {}).get("x.com.samsung.da.items")
|
||||||
optimistic_body = {
|
optimistic_body = {
|
||||||
**optimistic_body,
|
**optimistic_body,
|
||||||
'x.com.samsung.da.items': merge_items_field(cached_items, new_items),
|
"x.com.samsung.da.items": merge_items_field(cached_items, new_items),
|
||||||
}
|
}
|
||||||
self._observe.apply(write_href, optimistic_body, source='optimistic')
|
self._observe.apply(write_href, optimistic_body, source="optimistic")
|
||||||
self._observe.mark_write_pending(
|
self._observe.mark_write_pending(
|
||||||
write_href, settle_s=self._POST_TIMEOUT_S + self._POLL_TIMEOUT_S
|
write_href, settle_s=self._POST_TIMEOUT_S + self._POLL_TIMEOUT_S
|
||||||
)
|
)
|
||||||
@@ -1111,7 +1199,7 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
if rcode == 0x45 and payload:
|
if rcode == 0x45 and payload:
|
||||||
rep = cbor2.loads(payload)
|
rep = cbor2.loads(payload)
|
||||||
if isinstance(rep, dict):
|
if isinstance(rep, dict):
|
||||||
self._observe.apply(href, rep, source='poll')
|
self._observe.apply(href, rep, source="poll")
|
||||||
new_rep = rep
|
new_rep = rep
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._log.debug("raw write follow-up read failed: %s", e)
|
self._log.debug("raw write follow-up read failed: %s", e)
|
||||||
@@ -1130,13 +1218,13 @@ class LocalThingsCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
translation_domain=DOMAIN,
|
translation_domain=DOMAIN,
|
||||||
translation_key="debug_payload_empty",
|
translation_key="debug_payload_empty",
|
||||||
)
|
)
|
||||||
path_segs = [s for s in href.strip('/').split('/') if s]
|
path_segs = [s for s in href.strip("/").split("/") if s]
|
||||||
if not path_segs:
|
if not path_segs:
|
||||||
raise ServiceValidationError(
|
raise ServiceValidationError(
|
||||||
translation_domain=DOMAIN,
|
translation_domain=DOMAIN,
|
||||||
translation_key="resource_href_required",
|
translation_key="resource_href_required",
|
||||||
)
|
)
|
||||||
norm_href = '/' + '/'.join(path_segs)
|
norm_href = "/" + "/".join(path_segs)
|
||||||
async with self._session_lock:
|
async with self._session_lock:
|
||||||
code, new_rep = await self.hass.async_add_executor_job(
|
code, new_rep = await self.hass.async_add_executor_job(
|
||||||
self._raw_write_blocking, path_segs, body, norm_href
|
self._raw_write_blocking, path_segs, body, norm_href
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ device > the menu > Download diagnostics. This is what the Repairs issue
|
|||||||
users at: a redacted snapshot of the device's raw /device/0 state, plus
|
users at: a redacted snapshot of the device's raw /device/0 state, plus
|
||||||
enough version/coverage metadata to reproduce and diagnose the gap.
|
enough version/coverage metadata to reproduce and diagnose the gap.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from importlib.metadata import version as pkg_version
|
from importlib.metadata import version as pkg_version
|
||||||
@@ -67,7 +68,7 @@ async def async_get_config_entry_diagnostics(
|
|||||||
**_seed_diag(su),
|
**_seed_diag(su),
|
||||||
"bound_entity_count": len(matching),
|
"bound_entity_count": len(matching),
|
||||||
"hrefs": sorted({b.href for b in matching}),
|
"hrefs": sorted({b.href for b in matching}),
|
||||||
"model": res.get('/information/vs/0', {}).get('x.com.samsung.da.modelNum', ''),
|
"model": res.get("/information/vs/0", {}).get("x.com.samsung.da.modelNum", ""),
|
||||||
# Keyed by this subdevice's *canonical* hrefs, not the real ones
|
# Keyed by this subdevice's *canonical* hrefs, not the real ones
|
||||||
# it answers on -- '/mode/vs/0' rather than '/mode/vs/1' or
|
# it answers on -- '/mode/vs/0' rather than '/mode/vs/1' or
|
||||||
# '/<uuid>/mode/vs/0'. That's the form the registry and every
|
# '/<uuid>/mode/vs/0'. That's the form the registry and every
|
||||||
@@ -86,7 +87,9 @@ async def async_get_config_entry_diagnostics(
|
|||||||
"model": identity.model,
|
"model": identity.model,
|
||||||
"device_types": list(identity.device_types),
|
"device_types": list(identity.device_types),
|
||||||
"resources": redact_resources(identity.raw),
|
"resources": redact_resources(identity.raw),
|
||||||
} if identity is not None else None,
|
}
|
||||||
|
if identity is not None
|
||||||
|
else None,
|
||||||
"unbound_hrefs": sorted(coordinator._unbound_hrefs),
|
"unbound_hrefs": sorted(coordinator._unbound_hrefs),
|
||||||
# This subdevice's own resources, and only this subdevice's -- what
|
# This subdevice's own resources, and only this subdevice's -- what
|
||||||
# the module docstring and the adding-device-support skill have
|
# the module docstring and the adding-device-support skill have
|
||||||
@@ -131,11 +134,13 @@ async def async_get_config_entry_diagnostics(
|
|||||||
# candidate is never polled again and never enters the state
|
# candidate is never polled again and never enters the state
|
||||||
# cache, so `resources` above cannot contain them by
|
# cache, so `resources` above cannot contain them by
|
||||||
# construction.
|
# construction.
|
||||||
"resources": redact_resources({
|
"resources": redact_resources(
|
||||||
canon: rep
|
{
|
||||||
for href, rep in coordinator._skipped_subdevice_resources.items()
|
canon: rep
|
||||||
if (canon := skip.subdevice.to_canonical(href)) is not None
|
for href, rep in coordinator._skipped_subdevice_resources.items()
|
||||||
}),
|
if (canon := skip.subdevice.to_canonical(href)) is not None
|
||||||
|
}
|
||||||
|
),
|
||||||
}
|
}
|
||||||
for skip in coordinator._skipped_subdevices
|
for skip in coordinator._skipped_subdevices
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
"""Base entity for Local Things."""
|
"""Base entity for Local Things."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
|
||||||
from homeassistant.const import EntityCategory
|
from homeassistant.const import EntityCategory
|
||||||
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
|
from .const import DOMAIN
|
||||||
|
from .coordinator import LocalThingsCoordinator
|
||||||
from .registry.adapter import _key
|
from .registry.adapter import _key
|
||||||
from .registry.batch import is_stub_rep
|
from .registry.batch import is_stub_rep
|
||||||
from .registry.discovery import BoundEntity, _snake_to_title
|
from .registry.discovery import BoundEntity, _snake_to_title
|
||||||
|
|
||||||
from .const import DOMAIN
|
|
||||||
from .coordinator import LocalThingsCoordinator
|
|
||||||
|
|
||||||
|
def _is_included(bound: BoundEntity, coordinator: LocalThingsCoordinator) -> bool:
|
||||||
def _is_included(bound: BoundEntity, coordinator: 'LocalThingsCoordinator') -> bool:
|
|
||||||
"""Return False if the entity should not be registered for this device.
|
"""Return False if the entity should not be registered for this device.
|
||||||
|
|
||||||
Explicit exists_fn takes priority. Otherwise, if the entity has a field,
|
Explicit exists_fn takes priority. Otherwise, if the entity has a field,
|
||||||
@@ -63,7 +63,7 @@ def _derive_name(state_key: str) -> str:
|
|||||||
builds the {instance_name} placeholder those translations interpolate,
|
builds the {instance_name} placeholder those translations interpolate,
|
||||||
for a device that named its own compartments/ice makers.
|
for a device that named its own compartments/ice makers.
|
||||||
"""
|
"""
|
||||||
name = re.sub(r'(\d+)$', lambda m: f' {m.group()}' if int(m.group()) > 0 else '', state_key)
|
name = re.sub(r"(\d+)$", lambda m: f" {m.group()}" if int(m.group()) > 0 else "", state_key)
|
||||||
return _snake_to_title(name).strip()
|
return _snake_to_title(name).strip()
|
||||||
|
|
||||||
|
|
||||||
@@ -74,9 +74,9 @@ def _instance_display_name(bound: BoundEntity, state_key: str) -> str:
|
|||||||
source = bound.key_override or state_key
|
source = bound.key_override or state_key
|
||||||
suffix = f"_{bound.desc.key}"
|
suffix = f"_{bound.desc.key}"
|
||||||
if source.endswith(suffix):
|
if source.endswith(suffix):
|
||||||
source = source[:-len(suffix)]
|
source = source[: -len(suffix)]
|
||||||
elif bound.instance and source.endswith(bound.instance):
|
elif bound.instance and source.endswith(bound.instance):
|
||||||
source = source[:-len(bound.instance)] + bound.instance.replace("_", " ")
|
source = source[: -len(bound.instance)] + bound.instance.replace("_", " ")
|
||||||
return _derive_name(source)
|
return _derive_name(source)
|
||||||
|
|
||||||
|
|
||||||
@@ -91,9 +91,7 @@ class LocalThingsEntity(CoordinatorEntity[LocalThingsCoordinator]):
|
|||||||
self._state_key = _key(bound)
|
self._state_key = _key(bound)
|
||||||
self._attr_unique_id = f"{DOMAIN}_{coordinator.device_serial}_{self._state_key}"
|
self._attr_unique_id = f"{DOMAIN}_{coordinator.device_serial}_{self._state_key}"
|
||||||
if bound.desc.translation_placeholders is not None:
|
if bound.desc.translation_placeholders is not None:
|
||||||
self._attr_translation_placeholders = dict(
|
self._attr_translation_placeholders = dict(bound.desc.translation_placeholders)
|
||||||
bound.desc.translation_placeholders
|
|
||||||
)
|
|
||||||
elif bound.desc.use_instance_name:
|
elif bound.desc.use_instance_name:
|
||||||
self._attr_translation_placeholders = {
|
self._attr_translation_placeholders = {
|
||||||
"instance_name": _instance_display_name(bound, self._state_key)
|
"instance_name": _instance_display_name(bound, self._state_key)
|
||||||
|
|||||||
@@ -32,22 +32,24 @@ from .coordinator import LocalThingsCoordinator
|
|||||||
from .entity import LocalThingsEntity, _is_included
|
from .entity import LocalThingsEntity, _is_included
|
||||||
from .registry.capabilities.air_purifier import HREF_AIRFLOW
|
from .registry.capabilities.air_purifier import HREF_AIRFLOW
|
||||||
from .registry.capabilities.air_purifier import HREF_MODE as AIR_PURIFIER_FAN_HREF
|
from .registry.capabilities.air_purifier import HREF_MODE as AIR_PURIFIER_FAN_HREF
|
||||||
from .registry.capabilities.air_purifier import HREF_WIND_STRENGTH as AIR_PURIFIER_WIND_STRENGTH_HREF
|
from .registry.capabilities.air_purifier import (
|
||||||
|
HREF_WIND_STRENGTH as AIR_PURIFIER_WIND_STRENGTH_HREF,
|
||||||
|
)
|
||||||
from .registry.entities import FanDesc
|
from .registry.entities import FanDesc
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
POWER_HREF = '/power/0'
|
POWER_HREF = "/power/0"
|
||||||
POWER_VS_HREF = '/power/vs/0'
|
POWER_VS_HREF = "/power/vs/0"
|
||||||
_FAN_SPEED_FIELD = 'x.com.samsung.da.hood.fanSpeed'
|
_FAN_SPEED_FIELD = "x.com.samsung.da.hood.fanSpeed"
|
||||||
_SUPPORTED_FAN_SPEED_FIELD = 'x.com.samsung.da.hood.supportedFanSpeed'
|
_SUPPORTED_FAN_SPEED_FIELD = "x.com.samsung.da.hood.supportedFanSpeed"
|
||||||
_MIN_FAN_SPEED_FIELD = 'x.com.samsung.da.hood.settableMinFanSpeed'
|
_MIN_FAN_SPEED_FIELD = "x.com.samsung.da.hood.settableMinFanSpeed"
|
||||||
_MAX_FAN_SPEED_FIELD = 'x.com.samsung.da.hood.settableMaxFanSpeed'
|
_MAX_FAN_SPEED_FIELD = "x.com.samsung.da.hood.settableMaxFanSpeed"
|
||||||
_OFF_SPEED_CODE = '0'
|
_OFF_SPEED_CODE = "0"
|
||||||
|
|
||||||
_MODES_FIELD = 'x.com.samsung.da.modes'
|
_MODES_FIELD = "x.com.samsung.da.modes"
|
||||||
_SUPPORTED_MODES_FIELD = 'x.com.samsung.da.supportedModes'
|
_SUPPORTED_MODES_FIELD = "x.com.samsung.da.supportedModes"
|
||||||
_MODES_NAME_FIELD = 'x.com.samsung.da.modesName'
|
_MODES_NAME_FIELD = "x.com.samsung.da.modesName"
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@@ -116,7 +118,7 @@ class LocalThingsRangeHoodFan(LocalThingsEntity, FanEntity):
|
|||||||
resource instead, so this is False there."""
|
resource instead, so this is False there."""
|
||||||
rep = self._rep(self._bound.href)
|
rep = self._rep(self._bound.href)
|
||||||
return (
|
return (
|
||||||
str(rep.get(_MIN_FAN_SPEED_FIELD, '')) == _OFF_SPEED_CODE
|
str(rep.get(_MIN_FAN_SPEED_FIELD, "")) == _OFF_SPEED_CODE
|
||||||
or _OFF_SPEED_CODE in self._all_speed_codes()
|
or _OFF_SPEED_CODE in self._all_speed_codes()
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -150,19 +152,17 @@ class LocalThingsRangeHoodFan(LocalThingsEntity, FanEntity):
|
|||||||
"""Target whichever power resource this hood actually exposes."""
|
"""Target whichever power resource this hood actually exposes."""
|
||||||
resources = self._resources
|
resources = self._resources
|
||||||
target = POWER_HREF if POWER_HREF in resources else POWER_VS_HREF
|
target = POWER_HREF if POWER_HREF in resources else POWER_VS_HREF
|
||||||
return 'power', enabled, target
|
return "power", enabled, target
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
if self._speed_zero_is_off():
|
if self._speed_zero_is_off():
|
||||||
current = str(self._rep(self._bound.href).get(_FAN_SPEED_FIELD, '0'))
|
current = str(self._rep(self._bound.href).get(_FAN_SPEED_FIELD, "0"))
|
||||||
return current not in ('', _OFF_SPEED_CODE)
|
return current not in ("", _OFF_SPEED_CODE)
|
||||||
rep = self._rep(POWER_HREF)
|
rep = self._rep(POWER_HREF)
|
||||||
if 'value' in rep:
|
if "value" in rep:
|
||||||
return bool(rep.get('value'))
|
return bool(rep.get("value"))
|
||||||
return str(
|
return str(self._rep(POWER_VS_HREF).get("x.com.samsung.da.power", "")).lower() == "on"
|
||||||
self._rep(POWER_VS_HREF).get('x.com.samsung.da.power', '')
|
|
||||||
).lower() == 'on'
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speed_count(self) -> int:
|
def speed_count(self) -> int:
|
||||||
@@ -173,13 +173,15 @@ class LocalThingsRangeHoodFan(LocalThingsEntity, FanEntity):
|
|||||||
if not self.is_on:
|
if not self.is_on:
|
||||||
return 0
|
return 0
|
||||||
codes = self._active_speed_codes()
|
codes = self._active_speed_codes()
|
||||||
current = str(self._rep(self._bound.href).get(_FAN_SPEED_FIELD, ''))
|
current = str(self._rep(self._bound.href).get(_FAN_SPEED_FIELD, ""))
|
||||||
if not codes or current not in codes:
|
if not codes or current not in codes:
|
||||||
return None
|
return None
|
||||||
return ordered_list_item_to_percentage(codes, current)
|
return ordered_list_item_to_percentage(codes, current)
|
||||||
|
|
||||||
async def async_turn_on(
|
async def async_turn_on(
|
||||||
self, percentage: int | None = None, preset_mode: str | None = None,
|
self,
|
||||||
|
percentage: int | None = None,
|
||||||
|
preset_mode: str | None = None,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
) -> None:
|
) -> None:
|
||||||
if self._speed_zero_is_off():
|
if self._speed_zero_is_off():
|
||||||
@@ -192,20 +194,22 @@ class LocalThingsRangeHoodFan(LocalThingsEntity, FanEntity):
|
|||||||
return
|
return
|
||||||
codes = self._active_speed_codes()
|
codes = self._active_speed_codes()
|
||||||
if codes:
|
if codes:
|
||||||
await self.coordinator.async_send_command(self._bound, ('speed', codes[0]))
|
await self.coordinator.async_send_command(self._bound, ("speed", codes[0]))
|
||||||
return
|
return
|
||||||
await self.coordinator.async_send_command(
|
await self.coordinator.async_send_command(
|
||||||
self._bound, self._power_payload(True),
|
self._bound,
|
||||||
|
self._power_payload(True),
|
||||||
)
|
)
|
||||||
if percentage is not None:
|
if percentage is not None:
|
||||||
await self.async_set_percentage(percentage)
|
await self.async_set_percentage(percentage)
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs) -> None:
|
async def async_turn_off(self, **kwargs) -> None:
|
||||||
if self._speed_zero_is_off():
|
if self._speed_zero_is_off():
|
||||||
await self.coordinator.async_send_command(self._bound, ('speed', _OFF_SPEED_CODE))
|
await self.coordinator.async_send_command(self._bound, ("speed", _OFF_SPEED_CODE))
|
||||||
return
|
return
|
||||||
await self.coordinator.async_send_command(
|
await self.coordinator.async_send_command(
|
||||||
self._bound, self._power_payload(False),
|
self._bound,
|
||||||
|
self._power_payload(False),
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_set_percentage(self, percentage: int) -> None:
|
async def async_set_percentage(self, percentage: int) -> None:
|
||||||
@@ -217,10 +221,11 @@ class LocalThingsRangeHoodFan(LocalThingsEntity, FanEntity):
|
|||||||
return
|
return
|
||||||
if not self._speed_zero_is_off() and not self.is_on:
|
if not self._speed_zero_is_off() and not self.is_on:
|
||||||
await self.coordinator.async_send_command(
|
await self.coordinator.async_send_command(
|
||||||
self._bound, self._power_payload(True),
|
self._bound,
|
||||||
|
self._power_payload(True),
|
||||||
)
|
)
|
||||||
code = percentage_to_ordered_list_item(codes, percentage)
|
code = percentage_to_ordered_list_item(codes, percentage)
|
||||||
await self.coordinator.async_send_command(self._bound, ('speed', code))
|
await self.coordinator.async_send_command(self._bound, ("speed", code))
|
||||||
|
|
||||||
|
|
||||||
class LocalThingsAirPurifierFan(LocalThingsEntity, FanEntity):
|
class LocalThingsAirPurifierFan(LocalThingsEntity, FanEntity):
|
||||||
@@ -230,9 +235,7 @@ class LocalThingsAirPurifierFan(LocalThingsEntity, FanEntity):
|
|||||||
|
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
_enable_turn_on_off_backwards_compatibility = False
|
||||||
_attr_supported_features = (
|
_attr_supported_features = (
|
||||||
FanEntityFeature.PRESET_MODE
|
FanEntityFeature.PRESET_MODE | FanEntityFeature.TURN_ON | FanEntityFeature.TURN_OFF
|
||||||
| FanEntityFeature.TURN_ON
|
|
||||||
| FanEntityFeature.TURN_OFF
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, coordinator: LocalThingsCoordinator, bound) -> None:
|
def __init__(self, coordinator: LocalThingsCoordinator, bound) -> None:
|
||||||
@@ -253,14 +256,14 @@ class LocalThingsAirPurifierFan(LocalThingsEntity, FanEntity):
|
|||||||
correctly."""
|
correctly."""
|
||||||
resources = self._resources
|
resources = self._resources
|
||||||
target = POWER_VS_HREF if POWER_VS_HREF in resources else POWER_HREF
|
target = POWER_VS_HREF if POWER_VS_HREF in resources else POWER_HREF
|
||||||
return 'power', enabled, target
|
return "power", enabled, target
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
power = self._rep(POWER_VS_HREF).get('x.com.samsung.da.power')
|
power = self._rep(POWER_VS_HREF).get("x.com.samsung.da.power")
|
||||||
if power is not None:
|
if power is not None:
|
||||||
return str(power).lower() == 'on'
|
return str(power).lower() == "on"
|
||||||
return bool(self._rep(POWER_HREF).get('value'))
|
return bool(self._rep(POWER_HREF).get("value"))
|
||||||
|
|
||||||
def _label_for_code(self, code) -> str:
|
def _label_for_code(self, code) -> str:
|
||||||
"""Lowercased HA preset label for a device mode code.
|
"""Lowercased HA preset label for a device mode code.
|
||||||
@@ -284,8 +287,7 @@ class LocalThingsAirPurifierFan(LocalThingsEntity, FanEntity):
|
|||||||
@property
|
@property
|
||||||
def preset_modes(self) -> list[str]:
|
def preset_modes(self) -> list[str]:
|
||||||
return [
|
return [
|
||||||
self._label_for_code(code)
|
self._label_for_code(code) for code in self._mode_rep().get(_SUPPORTED_MODES_FIELD, ())
|
||||||
for code in self._mode_rep().get(_SUPPORTED_MODES_FIELD, ())
|
|
||||||
]
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -295,7 +297,9 @@ class LocalThingsAirPurifierFan(LocalThingsEntity, FanEntity):
|
|||||||
return self._label_for_code(code) if code is not None else None
|
return self._label_for_code(code) if code is not None else None
|
||||||
|
|
||||||
async def async_turn_on(
|
async def async_turn_on(
|
||||||
self, percentage: int | None = None, preset_mode: str | None = None,
|
self,
|
||||||
|
percentage: int | None = None,
|
||||||
|
preset_mode: str | None = None,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
) -> None:
|
) -> None:
|
||||||
await self.coordinator.async_send_command(self._bound, self._power_payload(True))
|
await self.coordinator.async_send_command(self._bound, self._power_payload(True))
|
||||||
@@ -311,22 +315,24 @@ class LocalThingsAirPurifierFan(LocalThingsEntity, FanEntity):
|
|||||||
# modesName-labelled board), not the lowercased HA value.
|
# modesName-labelled board), not the lowercased HA value.
|
||||||
for code in self._mode_rep().get(_SUPPORTED_MODES_FIELD, ()):
|
for code in self._mode_rep().get(_SUPPORTED_MODES_FIELD, ()):
|
||||||
if self._label_for_code(code) == preset_mode:
|
if self._label_for_code(code) == preset_mode:
|
||||||
await self.coordinator.async_send_command(self._bound, ('mode', code))
|
await self.coordinator.async_send_command(self._bound, ("mode", code))
|
||||||
return
|
return
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"%s: %r is not a valid preset mode (supported: %s)",
|
"%s: %r is not a valid preset mode (supported: %s)",
|
||||||
self.entity_id, preset_mode, self.preset_modes,
|
self.entity_id,
|
||||||
|
preset_mode,
|
||||||
|
self.preset_modes,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
_AIRFLOW_SPEED_FIELD = 'speed'
|
_AIRFLOW_SPEED_FIELD = "speed"
|
||||||
# Raw `speed` codes, low-to-high -- confirmed monotonic (Auto=0, Sleep=1,
|
# Raw `speed` codes, low-to-high -- confirmed monotonic (Auto=0, Sleep=1,
|
||||||
# Low=2, Medium=3, High=4) via air_purifier.py's module docstring. Ordered
|
# Low=2, Medium=3, High=4) via air_purifier.py's module docstring. Ordered
|
||||||
# as plain strings, same as _all_speed_codes above, so
|
# as plain strings, same as _all_speed_codes above, so
|
||||||
# ordered_list_item_to_percentage/percentage_to_ordered_list_item can treat
|
# ordered_list_item_to_percentage/percentage_to_ordered_list_item can treat
|
||||||
# it exactly like the range hood's numeric levels -- no named-preset table
|
# it exactly like the range hood's numeric levels -- no named-preset table
|
||||||
# needed since this board never reports mode names to hang one off of.
|
# needed since this board never reports mode names to hang one off of.
|
||||||
_AIRFLOW_SPEED_CODES = ('0', '1', '2', '3', '4')
|
_AIRFLOW_SPEED_CODES = ["0", "1", "2", "3", "4"]
|
||||||
|
|
||||||
|
|
||||||
class LocalThingsAirflowFan(LocalThingsEntity, FanEntity):
|
class LocalThingsAirflowFan(LocalThingsEntity, FanEntity):
|
||||||
@@ -335,9 +341,7 @@ class LocalThingsAirflowFan(LocalThingsEntity, FanEntity):
|
|||||||
|
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
_enable_turn_on_off_backwards_compatibility = False
|
||||||
_attr_supported_features = (
|
_attr_supported_features = (
|
||||||
FanEntityFeature.SET_SPEED
|
FanEntityFeature.SET_SPEED | FanEntityFeature.TURN_ON | FanEntityFeature.TURN_OFF
|
||||||
| FanEntityFeature.TURN_ON
|
|
||||||
| FanEntityFeature.TURN_OFF
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, coordinator: LocalThingsCoordinator, bound) -> None:
|
def __init__(self, coordinator: LocalThingsCoordinator, bound) -> None:
|
||||||
@@ -360,14 +364,14 @@ class LocalThingsAirflowFan(LocalThingsEntity, FanEntity):
|
|||||||
warn about)."""
|
warn about)."""
|
||||||
resources = self._resources
|
resources = self._resources
|
||||||
target = POWER_HREF if POWER_HREF in resources else POWER_VS_HREF
|
target = POWER_HREF if POWER_HREF in resources else POWER_VS_HREF
|
||||||
return 'power', enabled, target
|
return "power", enabled, target
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
power = self._rep(POWER_HREF)
|
power = self._rep(POWER_HREF)
|
||||||
if 'value' in power:
|
if "value" in power:
|
||||||
return bool(power.get('value'))
|
return bool(power.get("value"))
|
||||||
return str(self._rep(POWER_VS_HREF).get('x.com.samsung.da.power', '')).lower() == 'on'
|
return str(self._rep(POWER_VS_HREF).get("x.com.samsung.da.power", "")).lower() == "on"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speed_count(self) -> int:
|
def speed_count(self) -> int:
|
||||||
@@ -377,13 +381,15 @@ class LocalThingsAirflowFan(LocalThingsEntity, FanEntity):
|
|||||||
def percentage(self) -> int | None:
|
def percentage(self) -> int | None:
|
||||||
if not self.is_on:
|
if not self.is_on:
|
||||||
return 0
|
return 0
|
||||||
current = str(self._rep(self._bound.href).get(_AIRFLOW_SPEED_FIELD, ''))
|
current = str(self._rep(self._bound.href).get(_AIRFLOW_SPEED_FIELD, ""))
|
||||||
if current not in _AIRFLOW_SPEED_CODES:
|
if current not in _AIRFLOW_SPEED_CODES:
|
||||||
return None
|
return None
|
||||||
return ordered_list_item_to_percentage(_AIRFLOW_SPEED_CODES, current)
|
return ordered_list_item_to_percentage(_AIRFLOW_SPEED_CODES, current)
|
||||||
|
|
||||||
async def async_turn_on(
|
async def async_turn_on(
|
||||||
self, percentage: int | None = None, preset_mode: str | None = None,
|
self,
|
||||||
|
percentage: int | None = None,
|
||||||
|
preset_mode: str | None = None,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
) -> None:
|
) -> None:
|
||||||
await self.coordinator.async_send_command(self._bound, self._power_payload(True))
|
await self.coordinator.async_send_command(self._bound, self._power_payload(True))
|
||||||
@@ -400,4 +406,4 @@ class LocalThingsAirflowFan(LocalThingsEntity, FanEntity):
|
|||||||
if not self.is_on:
|
if not self.is_on:
|
||||||
await self.coordinator.async_send_command(self._bound, self._power_payload(True))
|
await self.coordinator.async_send_command(self._bound, self._power_payload(True))
|
||||||
code = percentage_to_ordered_list_item(_AIRFLOW_SPEED_CODES, percentage)
|
code = percentage_to_ordered_list_item(_AIRFLOW_SPEED_CODES, percentage)
|
||||||
await self.coordinator.async_send_command(self._bound, ('speed', int(code)))
|
await self.coordinator.async_send_command(self._bound, ("speed", int(code)))
|
||||||
@@ -12,5 +12,5 @@
|
|||||||
"pyOpenSSL>=23.0",
|
"pyOpenSSL>=23.0",
|
||||||
"smartthings-local>=0.1.1"
|
"smartthings-local>=0.1.1"
|
||||||
],
|
],
|
||||||
"version": "0.17.0"
|
"version": "0.18.0"
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,18 @@
|
|||||||
"""Number platform for Local Things."""
|
"""Number platform for Local Things."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.number import NumberEntity, NumberMode
|
from typing import cast
|
||||||
|
|
||||||
|
from homeassistant.components.number import NumberDeviceClass, NumberEntity, NumberMode
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .registry.entities import NumberDesc
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import LocalThingsCoordinator
|
from .coordinator import LocalThingsCoordinator
|
||||||
from .entity import LocalThingsEntity, _is_included
|
from .entity import LocalThingsEntity, _is_included
|
||||||
|
from .registry.entities import NumberDesc
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@@ -27,14 +29,15 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
|
|
||||||
class LocalThingsNumber(LocalThingsEntity, NumberEntity):
|
class LocalThingsNumber(LocalThingsEntity, NumberEntity):
|
||||||
|
|
||||||
_attr_mode = NumberMode.SLIDER
|
_attr_mode = NumberMode.SLIDER
|
||||||
|
|
||||||
def __init__(self, coordinator: LocalThingsCoordinator, bound) -> None:
|
def __init__(self, coordinator: LocalThingsCoordinator, bound) -> None:
|
||||||
super().__init__(coordinator, bound)
|
super().__init__(coordinator, bound)
|
||||||
desc: NumberDesc = bound.desc
|
desc = cast(NumberDesc, bound.desc)
|
||||||
self._attr_native_unit_of_measurement = desc.unit
|
self._attr_native_unit_of_measurement = desc.unit
|
||||||
self._attr_device_class = desc.device_class
|
self._attr_device_class = (
|
||||||
|
NumberDeviceClass(desc.device_class) if desc.device_class else None
|
||||||
|
)
|
||||||
if desc.native_min is not None:
|
if desc.native_min is not None:
|
||||||
self._attr_native_min_value = desc.native_min
|
self._attr_native_min_value = desc.native_min
|
||||||
if desc.native_max is not None:
|
if desc.native_max is not None:
|
||||||
@@ -44,13 +47,13 @@ class LocalThingsNumber(LocalThingsEntity, NumberEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def native_unit_of_measurement(self):
|
def native_unit_of_measurement(self):
|
||||||
desc: NumberDesc = self._bound.desc
|
desc = cast(NumberDesc, self._bound.desc)
|
||||||
if desc.unit_fn is not None:
|
if desc.unit_fn is not None:
|
||||||
return desc.unit_fn(self.coordinator.resource(self._bound.href))
|
return desc.unit_fn(self.coordinator.resource(self._bound.href))
|
||||||
return self._attr_native_unit_of_measurement
|
return self._attr_native_unit_of_measurement
|
||||||
|
|
||||||
def _range_from_resource(self) -> list | None:
|
def _range_from_resource(self) -> list | None:
|
||||||
desc: NumberDesc = self._bound.desc
|
desc = cast(NumberDesc, self._bound.desc)
|
||||||
if not desc.range_field:
|
if not desc.range_field:
|
||||||
return None
|
return None
|
||||||
r = self.coordinator.resource(self._bound.href).get(desc.range_field)
|
r = self.coordinator.resource(self._bound.href).get(desc.range_field)
|
||||||
@@ -58,34 +61,34 @@ class LocalThingsNumber(LocalThingsEntity, NumberEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def native_min_value(self) -> float:
|
def native_min_value(self) -> float:
|
||||||
desc: NumberDesc = self._bound.desc
|
desc = cast(NumberDesc, self._bound.desc)
|
||||||
if desc.native_min_fn is not None:
|
if desc.native_min_fn is not None:
|
||||||
return desc.native_min_fn(self.coordinator.resource(self._bound.href))
|
return desc.native_min_fn(self.coordinator.resource(self._bound.href))
|
||||||
r = self._range_from_resource()
|
r = self._range_from_resource()
|
||||||
if r is not None:
|
if r is not None:
|
||||||
return float(r[0])
|
return float(r[0])
|
||||||
if hasattr(self, '_attr_native_min_value'):
|
if hasattr(self, "_attr_native_min_value"):
|
||||||
return self._attr_native_min_value
|
return self._attr_native_min_value
|
||||||
return super().native_min_value
|
return super().native_min_value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_max_value(self) -> float:
|
def native_max_value(self) -> float:
|
||||||
desc: NumberDesc = self._bound.desc
|
desc = cast(NumberDesc, self._bound.desc)
|
||||||
if desc.native_max_fn is not None:
|
if desc.native_max_fn is not None:
|
||||||
return desc.native_max_fn(self.coordinator.resource(self._bound.href))
|
return desc.native_max_fn(self.coordinator.resource(self._bound.href))
|
||||||
r = self._range_from_resource()
|
r = self._range_from_resource()
|
||||||
if r is not None:
|
if r is not None:
|
||||||
return float(r[1])
|
return float(r[1])
|
||||||
if hasattr(self, '_attr_native_max_value'):
|
if hasattr(self, "_attr_native_max_value"):
|
||||||
return self._attr_native_max_value
|
return self._attr_native_max_value
|
||||||
return super().native_max_value
|
return super().native_max_value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_step(self) -> float:
|
def native_step(self) -> float | None:
|
||||||
desc: NumberDesc = self._bound.desc
|
desc = cast(NumberDesc, self._bound.desc)
|
||||||
if desc.step_fn is not None:
|
if desc.step_fn is not None:
|
||||||
return desc.step_fn(self.coordinator.resource(self._bound.href))
|
return desc.step_fn(self.coordinator.resource(self._bound.href))
|
||||||
if hasattr(self, '_attr_native_step'):
|
if hasattr(self, "_attr_native_step"):
|
||||||
return self._attr_native_step
|
return self._attr_native_step
|
||||||
return super().native_step
|
return super().native_step
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ are an external pip dependency we don't own, so behavior that would
|
|||||||
naturally live inside StateCache.apply_rep lives here instead, gating
|
naturally live inside StateCache.apply_rep lives here instead, gating
|
||||||
whether apply_rep is called at all.
|
whether apply_rep is called at all.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
@@ -15,16 +16,15 @@ import threading
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
import cbor2
|
import cbor2
|
||||||
|
|
||||||
from smartthings_local.ocf.state_cache import StateCache
|
|
||||||
from smartthings_local.ocf.observe_refresh import ObserveRefreshTask
|
from smartthings_local.ocf.observe_refresh import ObserveRefreshTask
|
||||||
|
from smartthings_local.ocf.state_cache import StateCache
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
REFRESH_INTERVAL_S = 6 * 3600.0
|
REFRESH_INTERVAL_S = 6 * 3600.0
|
||||||
|
|
||||||
MODE_OBSERVE = 'observe'
|
MODE_OBSERVE = "observe"
|
||||||
MODE_POLL = 'poll'
|
MODE_POLL = "poll"
|
||||||
|
|
||||||
DEFAULT_SETTLE_S = 4.0
|
DEFAULT_SETTLE_S = 4.0
|
||||||
GRACE_PERIOD_S = 15.0
|
GRACE_PERIOD_S = 15.0
|
||||||
@@ -73,6 +73,9 @@ class ObserveManager:
|
|||||||
self.subscribed_hrefs: set[str] = set()
|
self.subscribed_hrefs: set[str] = set()
|
||||||
self._notified: set[str] = set()
|
self._notified: set[str] = set()
|
||||||
self._last_notify_ts: float | None = None
|
self._last_notify_ts: float | None = None
|
||||||
|
# Wakes try_enter_observe_mode's grace wait early once enough hrefs
|
||||||
|
# have notified. Guards only `_notified` mutations + the `wait_for`.
|
||||||
|
self._notify_cond = threading.Condition()
|
||||||
self.fallback_hrefs: set[str] = set()
|
self.fallback_hrefs: set[str] = set()
|
||||||
self._refresh_task: ObserveRefreshTask | None = None
|
self._refresh_task: ObserveRefreshTask | None = None
|
||||||
self._refresh_stop: threading.Event | None = None
|
self._refresh_stop: threading.Event | None = None
|
||||||
@@ -130,7 +133,7 @@ class ObserveManager:
|
|||||||
happened to expire, i.e. the exact symptom this guard exists to
|
happened to expire, i.e. the exact symptom this guard exists to
|
||||||
prevent, just relocated to whichever write loses the race.
|
prevent, just relocated to whichever write loses the race.
|
||||||
"""
|
"""
|
||||||
if source != 'optimistic' and self._is_settling(href):
|
if source != "optimistic" and 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:
|
||||||
@@ -147,10 +150,12 @@ class ObserveManager:
|
|||||||
return
|
return
|
||||||
if not isinstance(rep, dict):
|
if not isinstance(rep, dict):
|
||||||
return
|
return
|
||||||
self._notified.add(href)
|
with self._notify_cond:
|
||||||
self._last_notify_ts = time.monotonic()
|
self._notified.add(href)
|
||||||
|
self._last_notify_ts = time.monotonic()
|
||||||
|
self._notify_cond.notify_all()
|
||||||
self.log.debug("observe notify: %s", href)
|
self.log.debug("observe notify: %s", href)
|
||||||
self.apply(href, rep, source='observe')
|
self.apply(href, rep, source="observe")
|
||||||
|
|
||||||
def recently_notified(self, window_s: float = PUSH_HEALTH_WINDOW_S) -> bool:
|
def recently_notified(self, window_s: float = PUSH_HEALTH_WINDOW_S) -> bool:
|
||||||
"""True if any OBSERVE notify has arrived within `window_s`.
|
"""True if any OBSERVE notify has arrived within `window_s`.
|
||||||
@@ -163,22 +168,25 @@ class ObserveManager:
|
|||||||
channel has been perfectly healthy").
|
channel has been perfectly healthy").
|
||||||
"""
|
"""
|
||||||
return (
|
return (
|
||||||
self._last_notify_ts is not None
|
self._last_notify_ts is not None and time.monotonic() - self._last_notify_ts < window_s
|
||||||
and time.monotonic() - self._last_notify_ts < window_s
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def try_enter_observe_mode(
|
def try_enter_observe_mode(
|
||||||
self, session, hrefs: list[str],
|
self,
|
||||||
|
session,
|
||||||
|
hrefs: list[str],
|
||||||
grace_period_s: float = GRACE_PERIOD_S,
|
grace_period_s: float = GRACE_PERIOD_S,
|
||||||
success_fraction: float = SUCCESS_FRACTION,
|
success_fraction: float = SUCCESS_FRACTION,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Blocking — subscribes to every href then sleeps for the whole
|
"""Blocking — subscribes to every href then waits up to
|
||||||
grace period. Caller must run this in an executor, never on the
|
`grace_period_s`, returning early once `success_fraction` of hrefs
|
||||||
|
have notified. Caller must run this in an executor, never on the
|
||||||
event loop."""
|
event loop."""
|
||||||
self._notified.clear()
|
with self._notify_cond:
|
||||||
|
self._notified.clear()
|
||||||
subscribed: set[str] = set()
|
subscribed: set[str] = set()
|
||||||
for href in hrefs:
|
for href in hrefs:
|
||||||
segs = [s for s in href.strip('/').split('/') if s]
|
segs = [s for s in href.strip("/").split("/") if s]
|
||||||
try:
|
try:
|
||||||
session.subscribe(segs)
|
session.subscribe(segs)
|
||||||
subscribed.add(href)
|
subscribed.add(href)
|
||||||
@@ -190,10 +198,16 @@ class ObserveManager:
|
|||||||
self.subscribed_hrefs = set()
|
self.subscribed_hrefs = set()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
time.sleep(grace_period_s)
|
def _fraction_reached() -> bool:
|
||||||
|
return len(set(self._notified) & subscribed) / len(subscribed) >= success_fraction
|
||||||
|
|
||||||
fraction = len(set(self._notified) & subscribed) / len(subscribed)
|
with self._notify_cond:
|
||||||
if fraction >= success_fraction:
|
reached = self._notify_cond.wait_for(
|
||||||
|
_fraction_reached,
|
||||||
|
timeout=grace_period_s,
|
||||||
|
)
|
||||||
|
|
||||||
|
if reached:
|
||||||
self.subscribed_hrefs = subscribed
|
self.subscribed_hrefs = subscribed
|
||||||
self._set_mode(MODE_OBSERVE)
|
self._set_mode(MODE_OBSERVE)
|
||||||
self.start_refresh_task(session)
|
self.start_refresh_task(session)
|
||||||
@@ -256,7 +270,8 @@ class ObserveManager:
|
|||||||
found = True
|
found = True
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
"observe missed a change on %s (sweep disagrees with cache): %s",
|
"observe missed a change on %s (sweep disagrees with cache): %s",
|
||||||
href, diff,
|
href,
|
||||||
|
diff,
|
||||||
)
|
)
|
||||||
return found
|
return found
|
||||||
|
|
||||||
@@ -268,15 +283,19 @@ class ObserveManager:
|
|||||||
|
|
||||||
def start_refresh_task(self, session) -> None:
|
def start_refresh_task(self, session) -> None:
|
||||||
self._stop_refresh_task()
|
self._stop_refresh_task()
|
||||||
paths = [tuple(h.strip('/').split('/')) for h in self.subscribed_hrefs]
|
paths = [tuple(h.strip("/").split("/")) for h in self.subscribed_hrefs]
|
||||||
self._refresh_task = ObserveRefreshTask(
|
self._refresh_task = ObserveRefreshTask(
|
||||||
session, paths, interval_s=REFRESH_INTERVAL_S, logger=self.log,
|
session,
|
||||||
|
paths,
|
||||||
|
interval_s=REFRESH_INTERVAL_S,
|
||||||
|
logger=self.log,
|
||||||
)
|
)
|
||||||
self._refresh_stop = threading.Event()
|
self._refresh_stop = threading.Event()
|
||||||
self._refresh_thread = threading.Thread(
|
self._refresh_thread = threading.Thread(
|
||||||
target=self._refresh_task.run_forever,
|
target=self._refresh_task.run_forever,
|
||||||
args=(self._refresh_stop,),
|
args=(self._refresh_stop,),
|
||||||
daemon=True, name='localthings-observe-refresh',
|
daemon=True,
|
||||||
|
name="localthings-observe-refresh",
|
||||||
)
|
)
|
||||||
self._refresh_thread.start()
|
self._refresh_thread.start()
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ to the matching capabilities, and flattens the result into HA-ready entity
|
|||||||
state. The DTLS/CoAP transport itself lives in the smartthings-local
|
state. The DTLS/CoAP transport itself lives in the smartthings-local
|
||||||
package, not here.
|
package, not here.
|
||||||
"""
|
"""
|
||||||
from .adapter import flatten, _key
|
|
||||||
|
from .adapter import _key, flatten
|
||||||
from .discovery import BoundEntity, discover
|
from .discovery import BoundEntity, discover
|
||||||
from .registry import CAPABILITIES
|
from .registry import CAPABILITIES
|
||||||
|
|
||||||
__all__ = ['CAPABILITIES', 'discover', 'BoundEntity', 'flatten', '_key']
|
__all__ = ["CAPABILITIES", "BoundEntity", "_key", "discover", "flatten"]
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
"""Adapter: BoundEntity list → flat state dict and command dispatch."""
|
"""Adapter: BoundEntity list → flat state dict and command dispatch."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"""OCF /device/0 batch response parser."""
|
"""OCF /device/0 batch response parser."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
||||||
@@ -11,7 +12,7 @@ def is_stub_rep(rep: dict) -> bool:
|
|||||||
never populate. Conflating the two used to make every field-gated entity
|
never populate. Conflating the two used to make every field-gated entity
|
||||||
on a permanently-empty resource look like a not-yet-fetched stub forever,
|
on a permanently-empty resource look like a not-yet-fetched stub forever,
|
||||||
creating phantom always-"unknown" entities (issue #127)."""
|
creating phantom always-"unknown" entities (issue #127)."""
|
||||||
return isinstance(rep, dict) and set(rep.keys()) == {'href'}
|
return isinstance(rep, dict) and set(rep.keys()) == {"href"}
|
||||||
|
|
||||||
|
|
||||||
def parse_device0_batch(device0: list) -> dict[str, dict]:
|
def parse_device0_batch(device0: list) -> dict[str, dict]:
|
||||||
@@ -22,11 +23,11 @@ def parse_device0_batch(device0: list) -> dict[str, dict]:
|
|||||||
is_stub_rep to tell "not fetched yet" apart from a confirmed-empty {}.
|
is_stub_rep to tell "not fetched yet" apart from a confirmed-empty {}.
|
||||||
"""
|
"""
|
||||||
out = {}
|
out = {}
|
||||||
for entry in device0[1:]: # skip [0] (device-level rep)
|
for entry in device0[1:]: # skip [0] (device-level rep)
|
||||||
if not isinstance(entry, dict):
|
if not isinstance(entry, dict):
|
||||||
continue
|
continue
|
||||||
href = entry.get('href')
|
href = entry.get("href")
|
||||||
rep = entry.get('rep')
|
rep = entry.get("rep")
|
||||||
if not href:
|
if not href:
|
||||||
continue
|
continue
|
||||||
if isinstance(rep, dict):
|
if isinstance(rep, dict):
|
||||||
|
|||||||
@@ -1,39 +1,63 @@
|
|||||||
"""Per-device-type registries."""
|
"""Per-device-type registries."""
|
||||||
import re
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from ._base import DeviceRegistry
|
import re
|
||||||
|
from collections.abc import Sequence
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
air_dresser, air_purifier, airconditioner, cooktop, dehumidifier,
|
air_dresser,
|
||||||
dishwasher, dryer, induction_cooktop, microwave, oven, range as _range,
|
air_monitor,
|
||||||
range_hood, refrigerator, vacuum_station, washer, water_purifier,
|
air_purifier,
|
||||||
|
airconditioner,
|
||||||
|
cooktop,
|
||||||
|
dehumidifier,
|
||||||
|
dishwasher,
|
||||||
|
dryer,
|
||||||
|
ehs,
|
||||||
|
induction_cooktop,
|
||||||
|
microwave,
|
||||||
|
oven,
|
||||||
|
range_hood,
|
||||||
|
refrigerator,
|
||||||
|
vacuum_station,
|
||||||
|
washer,
|
||||||
|
water_purifier,
|
||||||
)
|
)
|
||||||
|
from . import (
|
||||||
|
range as _range,
|
||||||
|
)
|
||||||
|
from ._base import DeviceRegistry
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'DeviceRegistry', 'resolve', 'for_device_by_model',
|
"DeviceRegistry",
|
||||||
'for_device_by_resources', '_board_tokens',
|
"_board_tokens",
|
||||||
|
"for_device_by_model",
|
||||||
|
"for_device_by_oic_type",
|
||||||
|
"for_device_by_resources",
|
||||||
|
"resolve",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# One entry per registry, no aliases: every key here is reachable from
|
# One entry per registry, no aliases: every key here is reachable from
|
||||||
# `_BOARD_TOKEN_TO_KEY`, `_CONSUMER_PREFIX_TO_KEY`, or `for_device_by_resources`.
|
# `_BOARD_TOKEN_TO_KEY`, `_CONSUMER_PREFIX_TO_KEY`, or `for_device_by_resources`.
|
||||||
_REGISTRY_BY_KEY: dict[str, DeviceRegistry] = {
|
_REGISTRY_BY_KEY: dict[str, DeviceRegistry] = {
|
||||||
'air_dresser': air_dresser.REGISTRY,
|
"air_dresser": air_dresser.REGISTRY,
|
||||||
'air_purifier': air_purifier.REGISTRY,
|
"air_monitor": air_monitor.REGISTRY,
|
||||||
'airconditioner': airconditioner.REGISTRY,
|
"air_purifier": air_purifier.REGISTRY,
|
||||||
'cooktop': cooktop.REGISTRY,
|
"airconditioner": airconditioner.REGISTRY,
|
||||||
'dehumidifier': dehumidifier.REGISTRY,
|
"cooktop": cooktop.REGISTRY,
|
||||||
'dishwasher': dishwasher.REGISTRY,
|
"dehumidifier": dehumidifier.REGISTRY,
|
||||||
'dryer': dryer.REGISTRY,
|
"dishwasher": dishwasher.REGISTRY,
|
||||||
'induction_cooktop': induction_cooktop.REGISTRY,
|
"dryer": dryer.REGISTRY,
|
||||||
'microwave': microwave.REGISTRY,
|
"ehs": ehs.REGISTRY,
|
||||||
'oven': oven.REGISTRY,
|
"induction_cooktop": induction_cooktop.REGISTRY,
|
||||||
'range': _range.REGISTRY,
|
"microwave": microwave.REGISTRY,
|
||||||
'range_hood': range_hood.REGISTRY,
|
"oven": oven.REGISTRY,
|
||||||
'refrigerator': refrigerator.REGISTRY,
|
"range": _range.REGISTRY,
|
||||||
'vacuum_station': vacuum_station.REGISTRY,
|
"range_hood": range_hood.REGISTRY,
|
||||||
'washer': washer.REGISTRY,
|
"refrigerator": refrigerator.REGISTRY,
|
||||||
'water_purifier': water_purifier.REGISTRY,
|
"vacuum_station": vacuum_station.REGISTRY,
|
||||||
|
"washer": washer.REGISTRY,
|
||||||
|
"water_purifier": water_purifier.REGISTRY,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -43,13 +67,13 @@ _REGISTRY_BY_KEY: dict[str, DeviceRegistry] = {
|
|||||||
# internal board-family prefix there, and dishwasher's modelNum contains
|
# internal board-family prefix there, and dishwasher's modelNum contains
|
||||||
# the substring 'WW', so a modelNum-only rule misroutes both.
|
# the substring 'WW', so a modelNum-only rule misroutes both.
|
||||||
_CONSUMER_PREFIX_TO_KEY: dict[str, str] = {
|
_CONSUMER_PREFIX_TO_KEY: dict[str, str] = {
|
||||||
'WW': 'washer',
|
"WW": "washer",
|
||||||
'WD': 'washer',
|
"WD": "washer",
|
||||||
'WF': 'washer',
|
"WF": "washer",
|
||||||
'WV': 'washer', # FlexWash twin units (e.g. WV55M9600AW) -- issue #19
|
"WV": "washer", # FlexWash twin units (e.g. WV55M9600AW) -- issue #19
|
||||||
'WA': 'washer', # Top-load washers (e.g. WA8000T) -- issue #106
|
"WA": "washer", # Top-load washers (e.g. WA8000T) -- issue #106
|
||||||
'DV': 'dryer',
|
"DV": "dryer",
|
||||||
'DW': 'dishwasher',
|
"DW": "dishwasher",
|
||||||
}
|
}
|
||||||
|
|
||||||
# Board-family token -> registry key, matched against whole tokens of
|
# Board-family token -> registry key, matched against whole tokens of
|
||||||
@@ -71,36 +95,40 @@ _CONSUMER_PREFIX_TO_KEY: dict[str, str] = {
|
|||||||
# air-conditioner spellings below), which is a statement about the hardware,
|
# air-conditioner spellings below), which is a statement about the hardware,
|
||||||
# not a shortcut.
|
# not a shortcut.
|
||||||
_BOARD_TOKEN_TO_KEY: dict[str, str] = {
|
_BOARD_TOKEN_TO_KEY: dict[str, str] = {
|
||||||
'REF': 'refrigerator',
|
"REF": "refrigerator",
|
||||||
# Air conditioners. Every one of these is a distinct board family with
|
# Air conditioners. Every one of these is a distinct board family with
|
||||||
# the same resource surface: room (issues #37, #91), package, Korean
|
# the same resource surface: room (issues #37, #91), package, Korean
|
||||||
# (#136), window (#87), 2-in-1 floor+wall (#150, #153), system/commercial
|
# (#136), window (#87), 2-in-1 floor+wall (#150, #153), system/commercial
|
||||||
# (#52), cassette (#191), and ARA-WW wall-mount (#115, #116, #117, #120).
|
# (#52), cassette (#191), and ARA-WW wall-mount (#115, #116, #117, #120).
|
||||||
'RAC': 'airconditioner',
|
"RAC": "airconditioner",
|
||||||
'PRAC': 'airconditioner',
|
"PRAC": "airconditioner",
|
||||||
'KRAC': 'airconditioner',
|
"KRAC": "airconditioner",
|
||||||
'WAC': 'airconditioner',
|
"WAC": "airconditioner",
|
||||||
'FAC': 'airconditioner',
|
"FAC": "airconditioner",
|
||||||
'CAWW': 'airconditioner',
|
"CAWW": "airconditioner",
|
||||||
'CAC': 'airconditioner', # issue #191 -- TP1X_DA-AC-CAC-01001_0000
|
"CAC": "airconditioner", # issue #191 -- TP1X_DA-AC-CAC-01001_0000
|
||||||
'ARA': 'airconditioner',
|
"ARA": "airconditioner",
|
||||||
'DHM': 'dehumidifier', # issue #88 -- target humidity, no climate
|
"DHM": "dehumidifier", # issue #88 -- target humidity, no climate
|
||||||
'TVTL': 'air_purifier', # issue #56 (ARTIK051)
|
"EHS": "ehs", # Eco Heating System air-to-water heat pump --
|
||||||
'VTWW': 'air_purifier', # issue #151 (BESPOKE Cube Air)
|
# zone1 space heating/cooling + dhw domestic
|
||||||
'AVT': 'air_purifier', # issue #190 -- AVT-WW-TP1-23-AXX500, a
|
# hot water, its own /mode/*/vs/0 and
|
||||||
# next-gen BESPOKE Cube Air board; same
|
# /temperatures/*/vs/0 resource shapes
|
||||||
# lineage as VTWW above but the '-WW-'
|
"TVTL": "air_purifier", # issue #56 (ARTIK051)
|
||||||
# delimiter now falls one letter to the
|
"VTWW": "air_purifier", # issue #151 (BESPOKE Cube Air)
|
||||||
# left ('A-VTWW-' -> 'AVT-WW-'), splitting
|
"AVT": "air_purifier", # issue #190 -- AVT-WW-TP1-23-AXX500, a
|
||||||
# into a token the existing entry can't see
|
# next-gen BESPOKE Cube Air board; same
|
||||||
'AIR': 'air_purifier', # issue #130 (TP1X_DA-AC-AIR)
|
# lineage as VTWW above but the '-WW-'
|
||||||
'WATERPURIFIER': 'water_purifier', # issue #90
|
# delimiter now falls one letter to the
|
||||||
'ADW': 'dishwasher',
|
# left ('A-VTWW-' -> 'AVT-WW-'), splitting
|
||||||
'AHD': 'range_hood',
|
# into a token the existing entry can't see
|
||||||
'RANGE': 'range', # issue #44 -- cooktop+oven combo
|
"AIR": "air_purifier", # issue #130 (TP1X_DA-AC-AIR)
|
||||||
'OVEN': 'oven', # issue #55 -- wall oven, no burners
|
"WATERPURIFIER": "water_purifier", # issue #90
|
||||||
'MICROWAVE': 'microwave', # issues #66, #121
|
"ADW": "dishwasher",
|
||||||
'COOKTOP': 'induction_cooktop', # issue #86 -- standalone, no oven
|
"AHD": "range_hood",
|
||||||
|
"RANGE": "range", # issue #44 -- cooktop+oven combo
|
||||||
|
"OVEN": "oven", # issue #55 -- wall oven, no burners
|
||||||
|
"MICROWAVE": "microwave", # issues #66, #121
|
||||||
|
"COOKTOP": "induction_cooktop", # issue #86 -- standalone, no oven
|
||||||
# Legacy ARTIK051 gas cooktops ('ARTIK051_GB_CT_001'), whose burner state
|
# Legacy ARTIK051 gas cooktops ('ARTIK051_GB_CT_001'), whose burner state
|
||||||
# lives in /mode/vs/0's options array. Deliberately a bare two-letter
|
# lives in /mode/vs/0's options array. Deliberately a bare two-letter
|
||||||
# token, and so the loosest entry in this table -- it is only ever
|
# token, and so the loosest entry in this table -- it is only ever
|
||||||
@@ -108,12 +136,14 @@ _BOARD_TOKEN_TO_KEY: dict[str, str] = {
|
|||||||
# `description` ('ARTIK051_GLOBAL_COOKTOP') would otherwise read as an
|
# `description` ('ARTIK051_GLOBAL_COOKTOP') would otherwise read as an
|
||||||
# induction cooktop via the COOKTOP entry above. See `for_device_by_model`
|
# induction cooktop via the COOKTOP entry above. See `for_device_by_model`
|
||||||
# for the field ordering that makes that resolve correctly.
|
# for the field ordering that makes that resolve correctly.
|
||||||
'CT': 'cooktop',
|
"CT": "cooktop",
|
||||||
'VSKR': 'vacuum_station', # issue #131 -- stick-vacuum clean station
|
"VSKR": "vacuum_station", # issue #131 -- stick-vacuum clean station
|
||||||
'DF': 'air_dresser', # issue #162
|
"DF": "air_dresser", # issue #162
|
||||||
|
"VSWW": "vacuum_station", # issue #219
|
||||||
|
"ASM": "air_monitor", # issue #210 -- Air Monitor Plus
|
||||||
}
|
}
|
||||||
|
|
||||||
_TOKEN_SPLIT_RE = re.compile(r'[^A-Z0-9]+')
|
_TOKEN_SPLIT_RE = re.compile(r"[^A-Z0-9]+")
|
||||||
|
|
||||||
|
|
||||||
def _board_tokens(value: str, cut_at: str) -> list[str]:
|
def _board_tokens(value: str, cut_at: str) -> list[str]:
|
||||||
@@ -124,11 +154,11 @@ def _board_tokens(value: str, cut_at: str) -> list[str]:
|
|||||||
contain anything) and after description's first '/' (a '/DC92-...' board
|
contain anything) and after description's first '/' (a '/DC92-...' board
|
||||||
part number).
|
part number).
|
||||||
"""
|
"""
|
||||||
head = (value or '').split(cut_at, 1)[0].upper()
|
head = (value or "").split(cut_at, 1)[0].upper()
|
||||||
return [t for t in _TOKEN_SPLIT_RE.split(head) if t]
|
return [t for t in _TOKEN_SPLIT_RE.split(head) if t]
|
||||||
|
|
||||||
|
|
||||||
def _board_family_key(value: str, cut_at: str) -> Optional[str]:
|
def _board_family_key(value: str, cut_at: str) -> str | None:
|
||||||
"""First `_BOARD_TOKEN_TO_KEY` hit among `value`'s tokens, or None.
|
"""First `_BOARD_TOKEN_TO_KEY` hit among `value`'s tokens, or None.
|
||||||
|
|
||||||
No known modelNum or description yields two *conflicting* board keys, so
|
No known modelNum or description yields two *conflicting* board keys, so
|
||||||
@@ -147,8 +177,8 @@ def _board_family_key(value: str, cut_at: str) -> Optional[str]:
|
|||||||
matching carve-out for this exact pair.
|
matching carve-out for this exact pair.
|
||||||
"""
|
"""
|
||||||
tokens = _board_tokens(value, cut_at)
|
tokens = _board_tokens(value, cut_at)
|
||||||
if 'REF' in tokens and 'WATERPURIFIER' in tokens:
|
if "REF" in tokens and "WATERPURIFIER" in tokens:
|
||||||
return 'water_purifier'
|
return "water_purifier"
|
||||||
for token in tokens:
|
for token in tokens:
|
||||||
key = _BOARD_TOKEN_TO_KEY.get(token)
|
key = _BOARD_TOKEN_TO_KEY.get(token)
|
||||||
if key is not None:
|
if key is not None:
|
||||||
@@ -156,7 +186,7 @@ def _board_family_key(value: str, cut_at: str) -> Optional[str]:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _consumer_model_key(description: str) -> Optional[str]:
|
def _consumer_model_key(description: str) -> str | None:
|
||||||
"""Registry key from the consumer-model token in `description`, or None.
|
"""Registry key from the consumer-model token in `description`, or None.
|
||||||
|
|
||||||
Usually that token is the last '_'-delimited segment before any
|
Usually that token is the last '_'-delimited segment before any
|
||||||
@@ -181,7 +211,7 @@ def _consumer_model_key(description: str) -> Optional[str]:
|
|||||||
that ambiguity resolves correctly without this function needing to know
|
that ambiguity resolves correctly without this function needing to know
|
||||||
about unrelated device families.
|
about unrelated device families.
|
||||||
"""
|
"""
|
||||||
segments = (description or '').split('/', 1)[0].split('_')
|
segments = (description or "").split("/", 1)[0].split("_")
|
||||||
for segment in reversed(segments):
|
for segment in reversed(segments):
|
||||||
key = _CONSUMER_PREFIX_TO_KEY.get(segment[:2].upper())
|
key = _CONSUMER_PREFIX_TO_KEY.get(segment[:2].upper())
|
||||||
if key is not None:
|
if key is not None:
|
||||||
@@ -189,7 +219,70 @@ def _consumer_model_key(description: str) -> Optional[str]:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def for_device_by_model(model_num: str, description: str) -> Optional[DeviceRegistry]:
|
# /oic/d's `rt` (OCF's own device-type declaration, see registry/identity.py)
|
||||||
|
# -> registry key. This is the device naming its own type -- no board-part
|
||||||
|
# guessing involved -- so it's consulted before modelNum/description at all.
|
||||||
|
#
|
||||||
|
# Every value must already be a key in `_REGISTRY_BY_KEY` (checked by
|
||||||
|
# `test_every_oic_type_resolves_to_a_real_registry`). That's why this list
|
||||||
|
# stops well short of the full OCF/SmartThings device-type vocabulary: a
|
||||||
|
# compiled list of `x.com.st.d.*` types will include plenty of device
|
||||||
|
# categories (lights, switches, sensors, locks, cameras, TVs, generic energy
|
||||||
|
# meters, ...) no Samsung DA appliance dump could ever report and this
|
||||||
|
# integration has no registry for -- and 'oic.d.robotcleaner' names an
|
||||||
|
# actual robot vacuum, a different product from the clean/auto-empty
|
||||||
|
# *station* `vacuum_station` covers (see that registry's own module
|
||||||
|
# docstring); mapping it there would misroute a genuine robot-vacuum dump
|
||||||
|
# into a registry with no vacuum-body capabilities at all. Add a row only
|
||||||
|
# once there's a real registry key on the right-hand side to point at.
|
||||||
|
#
|
||||||
|
# `x.com.st.d.*` entries are SmartThings' own vendor extension to the OCF
|
||||||
|
# device-type vocabulary (used for categories with no `oic.d.*` equivalent),
|
||||||
|
# same prefix convention as the `x.com.samsung.da.*` resource fields
|
||||||
|
# elsewhere in this codebase.
|
||||||
|
#
|
||||||
|
# `oic.d.cooktop` is deliberately absent, and is the one measured type left out.
|
||||||
|
# A TP1X_DA-KS-COOKTOP induction reports it, but `cooktop` and
|
||||||
|
# `induction_cooktop` are two unrelated registries that happen to share the
|
||||||
|
# English word (see by_type/cooktop.py's docstring: the NA9300K gas family keeps
|
||||||
|
# burner state in /mode/vs/0's options array, a completely different OCF
|
||||||
|
# surface). The OCF type does not distinguish them, so mapping it to either key
|
||||||
|
# would silently misroute the other -- and as the *primary* signal it would
|
||||||
|
# override a `COOKTOP`/`CT` board token that had it right. Same reasoning as
|
||||||
|
# `oic.d.robotcleaner` above: no unambiguous key to point at, so no row.
|
||||||
|
_OIC_TYPE_TO_KEY: dict[str, str] = {
|
||||||
|
"oic.d.airconditioner": "airconditioner",
|
||||||
|
"oic.d.airpurifier": "air_purifier",
|
||||||
|
"oic.d.dishwasher": "dishwasher",
|
||||||
|
"oic.d.dryer": "dryer",
|
||||||
|
"oic.d.oven": "oven",
|
||||||
|
"oic.d.refrigerator": "refrigerator",
|
||||||
|
"oic.d.washer": "washer",
|
||||||
|
"x.com.st.d.airqualitysensor": "air_monitor",
|
||||||
|
"x.com.st.d.hood": "range_hood", # AHD-WW-TP1-22-COMMON
|
||||||
|
"x.com.st.d.stickcleaner": "vacuum_station",
|
||||||
|
"x.com.st.d.steamcloset": "air_dresser",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def for_device_by_oic_type(device_types: Sequence[str]) -> DeviceRegistry | None:
|
||||||
|
"""Device-type detection from /oic/d's `rt` -- OCF's own device-type
|
||||||
|
declaration.
|
||||||
|
|
||||||
|
The primary path when a dump carries it: the device names its own type,
|
||||||
|
so there's nothing to infer from board part numbers. Most hardware still
|
||||||
|
doesn't populate `/oic/d` usefully -- see `resolve()`'s docstring -- so
|
||||||
|
this only ever helps a minority of dumps, and `for_device_by_model`/
|
||||||
|
`for_device_by_resources` remain load-bearing for everything else.
|
||||||
|
"""
|
||||||
|
for device_type in device_types:
|
||||||
|
key = _OIC_TYPE_TO_KEY.get(device_type)
|
||||||
|
if key is not None:
|
||||||
|
return _REGISTRY_BY_KEY[key]
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def for_device_by_model(model_num: str, description: str) -> DeviceRegistry | None:
|
||||||
"""Device-type detection from /information/vs/0's model strings.
|
"""Device-type detection from /information/vs/0's model strings.
|
||||||
|
|
||||||
The primary path: the board named in `modelNum` determines the resource
|
The primary path: the board named in `modelNum` determines the resource
|
||||||
@@ -219,70 +312,79 @@ def for_device_by_model(model_num: str, description: str) -> Optional[DeviceRegi
|
|||||||
known type, None otherwise.
|
known type, None otherwise.
|
||||||
"""
|
"""
|
||||||
key = (
|
key = (
|
||||||
_board_family_key(model_num, '|')
|
_board_family_key(model_num, "|")
|
||||||
or _board_family_key(description, '/')
|
or _board_family_key(description, "/")
|
||||||
or _consumer_model_key(description)
|
or _consumer_model_key(description)
|
||||||
)
|
)
|
||||||
return _REGISTRY_BY_KEY.get(key) if key else None
|
return _REGISTRY_BY_KEY.get(key) if key else None
|
||||||
|
|
||||||
|
|
||||||
def for_device_by_resources(resources: dict[str, dict]) -> Optional[DeviceRegistry]:
|
def for_device_by_resources(resources: dict[str, dict]) -> DeviceRegistry | None:
|
||||||
"""Detect a device family from a distinctive local-resource signature.
|
"""Detect a device family from a distinctive local-resource signature.
|
||||||
|
|
||||||
For boards that ship no ``/information/vs/0`` at all, leaving
|
This runs first as an override path for non-standard devices, not because
|
||||||
`for_device_by_model` nothing to read. Some newer cooktops are the
|
resource signatures are inherently more trustworthy than OIC/model
|
||||||
|
metadata. It also types boards that ship no ``/information/vs/0`` at all,
|
||||||
|
leaving `for_device_by_model` nothing to read. Some newer cooktops are the
|
||||||
original case: their mode resource still identifies them, carrying a
|
original case: their mode resource still identifies them, carrying a
|
||||||
DeviceType option and multiple per-burner OperationState options.
|
DeviceType option and multiple per-burner OperationState options.
|
||||||
|
|
||||||
Require two independent shapes for every signature here, never one, so
|
Require two independent shapes for every signature here, never one, so
|
||||||
an unrelated family's ``/mode/vs/0`` isn't misclassified.
|
putting this ahead of OIC/model metadata cannot let a common resource
|
||||||
|
misclassify an unrelated family.
|
||||||
"""
|
"""
|
||||||
mode = resources.get('/mode/vs/0', {})
|
mode = resources.get("/mode/vs/0", {})
|
||||||
options = mode.get('x.com.samsung.da.options') or ()
|
options = mode.get("x.com.samsung.da.options") or ()
|
||||||
has_device_type = any(
|
has_device_type = any(
|
||||||
isinstance(option, str) and option.startswith('DeviceType_')
|
isinstance(option, str) and option.startswith("DeviceType_") for option in options
|
||||||
for option in options
|
|
||||||
)
|
)
|
||||||
operation_states = sum(
|
operation_states = sum(
|
||||||
1 for option in options
|
1 for option in options if isinstance(option, str) and option.startswith("OperationState")
|
||||||
if isinstance(option, str) and option.startswith('OperationState')
|
|
||||||
)
|
)
|
||||||
if has_device_type and operation_states >= 2:
|
if has_device_type and operation_states >= 2:
|
||||||
return _REGISTRY_BY_KEY['cooktop']
|
return _REGISTRY_BY_KEY["cooktop"]
|
||||||
if (
|
if "/hood/fanspeed/vs/0" in resources and "/hood/lamp/vs/0" in resources:
|
||||||
'/hood/fanspeed/vs/0' in resources
|
return _REGISTRY_BY_KEY["range_hood"]
|
||||||
and '/hood/lamp/vs/0' in resources
|
|
||||||
):
|
|
||||||
return _REGISTRY_BY_KEY['range_hood']
|
|
||||||
# Oven/range/microwave boards that report no /information/vs/0 at all
|
# Oven/range/microwave boards that report no /information/vs/0 at all
|
||||||
# (issue #74's NE63B8411SS, issue #172's ME8000T -- the resource is simply
|
# (issue #74's NE63B8411SS, issue #172's ME8000T -- the resource is simply
|
||||||
# absent from the dump, not just empty) can't be matched via
|
# absent from the dump, not just empty) can't be matched via
|
||||||
# for_device_by_model's modelNum tokens either. Mode vocabulary alongside
|
# for_device_by_model's modelNum tokens either. Mode vocabulary alongside
|
||||||
# the oven cavity resource (/oven/vs/0) is a safe signature.
|
# the oven cavity resource (/oven/vs/0) is a safe two-resource signature;
|
||||||
supported_modes = mode.get('x.com.samsung.da.supportedModes') or ()
|
# it also corrects Qooker's generic oic.d.oven / OVEN metadata (issue
|
||||||
if '/oven/vs/0' in resources:
|
# PR #225) when resource detection runs before metadata.
|
||||||
|
supported_modes = mode.get("x.com.samsung.da.supportedModes") or ()
|
||||||
|
if not isinstance(supported_modes, (list, tuple)):
|
||||||
|
supported_modes = ()
|
||||||
|
cavity = resources.get("/oven/vs/0")
|
||||||
|
if isinstance(cavity, dict):
|
||||||
if any(
|
if any(
|
||||||
m in supported_modes
|
m in supported_modes for m in ("MicroWave", "MicroWaveGrill", "MicroWaveConvection")
|
||||||
for m in ('MicroWave', 'MicroWaveGrill', 'MicroWaveConvection')
|
|
||||||
):
|
):
|
||||||
return _REGISTRY_BY_KEY['microwave']
|
return _REGISTRY_BY_KEY["microwave"]
|
||||||
if 'Bake' in supported_modes:
|
if "Bake" in supported_modes:
|
||||||
if '/cooktopmonitoring/vs/0' in resources or '/cooktop/status/vs/0' in resources:
|
if "/cooktopmonitoring/vs/0" in resources or "/cooktop/status/vs/0" in resources:
|
||||||
return _REGISTRY_BY_KEY['range']
|
return _REGISTRY_BY_KEY["range"]
|
||||||
return _REGISTRY_BY_KEY['oven']
|
return _REGISTRY_BY_KEY["oven"]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def resolve(resources: dict[str, dict]) -> Optional[DeviceRegistry]:
|
def resolve(
|
||||||
|
resources: dict[str, dict],
|
||||||
|
device_types: Sequence[str] = (),
|
||||||
|
) -> DeviceRegistry | None:
|
||||||
"""Device type for a parsed /device/0 dump, or None if unrecognized.
|
"""Device type for a parsed /device/0 dump, or None if unrecognized.
|
||||||
|
|
||||||
The single entry point for detection -- the coordinator, the config
|
The single entry point for detection -- the coordinator, the config
|
||||||
flow's probe and the golden-regression harness all call this, so the
|
flow's probe and the golden-regression harness all call this, so the
|
||||||
order can't drift between what ships and what the tests assert.
|
order can't drift between what ships and what the tests assert.
|
||||||
|
|
||||||
Model strings first (`for_device_by_model`), then a distinctive resource
|
Distinctive resource signatures run first because they describe the live
|
||||||
signature (`for_device_by_resources`) for boards that report no
|
capability surface a registry must bind. They are deliberately strict in
|
||||||
/information/vs/0 at all.
|
`for_device_by_resources`: each requires multiple independent details, so
|
||||||
|
this can correct misleading metadata (Qooker's generic ``oic.d.oven``)
|
||||||
|
without a common href overriding an unrelated family. When no signature
|
||||||
|
matches, `/oic/d`'s `rt` (read separately from the /device/0 dump -- see
|
||||||
|
registry/identity.py) wins over model-string parsing.
|
||||||
|
|
||||||
`/otninformation/vs/0`'s oneUiVersion is deliberately not consulted. It
|
`/otninformation/vs/0`'s oneUiVersion is deliberately not consulted. It
|
||||||
reads like the obvious signal -- the device naming its own type, e.g.
|
reads like the obvious signal -- the device naming its own type, e.g.
|
||||||
@@ -291,8 +393,12 @@ def resolve(resources: dict[str, dict]) -> Optional[DeviceRegistry]:
|
|||||||
device-support issue has ever been fixed by adding a mapping for it. It
|
device-support issue has ever been fixed by adding a mapping for it. It
|
||||||
is still reported in diagnostics as a firmware-generation marker.
|
is still reported in diagnostics as a firmware-generation marker.
|
||||||
"""
|
"""
|
||||||
info = resources.get('/information/vs/0', {})
|
info = resources.get("/information/vs/0", {})
|
||||||
return for_device_by_model(
|
return (
|
||||||
info.get('x.com.samsung.da.modelNum', ''),
|
for_device_by_resources(resources)
|
||||||
info.get('x.com.samsung.da.description', ''),
|
or for_device_by_oic_type(device_types)
|
||||||
) or for_device_by_resources(resources)
|
or for_device_by_model(
|
||||||
|
info.get("x.com.samsung.da.modelNum", ""),
|
||||||
|
info.get("x.com.samsung.da.description", ""),
|
||||||
|
)
|
||||||
|
)
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
"""Base DeviceRegistry dataclass and builder."""
|
"""Base DeviceRegistry dataclass and builder."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
@@ -9,6 +10,7 @@ from ..capability import Capability
|
|||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class DeviceRegistry:
|
class DeviceRegistry:
|
||||||
"""Registry of capabilities for a specific device type."""
|
"""Registry of capabilities for a specific device type."""
|
||||||
|
|
||||||
name: str
|
name: str
|
||||||
capabilities: dict[str, list[Capability]]
|
capabilities: dict[str, list[Capability]]
|
||||||
pattern_capabilities: list[Capability] = field(default_factory=list)
|
pattern_capabilities: list[Capability] = field(default_factory=list)
|
||||||
@@ -31,17 +33,19 @@ def _build(caps: list[Capability]) -> dict[str, list[Capability]]:
|
|||||||
|
|
||||||
for cap in caps:
|
for cap in caps:
|
||||||
if cap.href is None:
|
if cap.href is None:
|
||||||
raise ValueError(f"Use pattern_capabilities for href=None caps")
|
raise ValueError("Use pattern_capabilities for href=None caps")
|
||||||
if cap.href_prefix is not None:
|
if cap.href_prefix is not None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"href_prefix is only valid for pattern caps (href=None); "
|
f"href_prefix is only valid for pattern caps (href=None); "
|
||||||
f"cap with href={cap.href!r} must not set href_prefix")
|
f"cap with href={cap.href!r} must not set href_prefix"
|
||||||
|
)
|
||||||
out.setdefault(cap.href, []).append(cap)
|
out.setdefault(cap.href, []).append(cap)
|
||||||
|
|
||||||
# Validate that multi-cap hrefs have proper discrimination
|
# Validate that multi-cap hrefs have proper discrimination
|
||||||
for href, cs in out.items():
|
for href, cs in out.items():
|
||||||
if len(cs) > 1 and any(c.rt_filter is None and c.match_fn is None for c in cs):
|
if len(cs) > 1 and any(c.rt_filter is None and c.match_fn is None for c in cs):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"href {href!r} has multiple caps but at least one lacks rt_filter and match_fn")
|
f"href {href!r} has multiple caps but at least one lacks rt_filter and match_fn"
|
||||||
|
)
|
||||||
|
|
||||||
return out
|
return out
|
||||||
@@ -1,24 +1,31 @@
|
|||||||
"""AirDresser device registry (issue #162).
|
"""AirDresser device registry (issue #162).
|
||||||
|
|
||||||
Reuses washer/dryer/dishwasher's shared laundry surface -- job-beginning
|
Reuses washer/dryer/dishwasher's shared laundry surface -- job-beginning
|
||||||
status, operational state, and diagnosis. air_dresser.py holds the two
|
status, operational state, diagnosis, and (issue #208) the buzzer-sound
|
||||||
|
select -- /buzzersound/vs/0's rep on this board is the plain
|
||||||
|
{setBuzzerSound, supportedBuzzerSound} shape laundry.BUZZER_SOUND already
|
||||||
|
expects, no AirDresser-specific wiring needed. air_dresser.py holds the two
|
||||||
pieces specific to this device type: a minimal wrinkle-prevent-only
|
pieces specific to this device type: a minimal wrinkle-prevent-only
|
||||||
/washer/vs/0 capability, and the course select's own translation key.
|
/washer/vs/0 capability, and the course select's own translation key.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..capabilities import air_dresser, common, dishwasher, ignored, laundry, operational
|
from ..capabilities import air_dresser, common, dishwasher, ignored, laundry, operational
|
||||||
from ._base import DeviceRegistry, _build
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
REGISTRY = DeviceRegistry(
|
REGISTRY = DeviceRegistry(
|
||||||
name='air_dresser',
|
name="air_dresser",
|
||||||
capabilities=_build([
|
capabilities=_build(
|
||||||
*ignored.IGNORED,
|
[
|
||||||
*common.UNIVERSAL,
|
*ignored.IGNORED,
|
||||||
*common.POWER,
|
*common.UNIVERSAL,
|
||||||
air_dresser.AIR_DRESSER_SETTINGS,
|
*common.POWER,
|
||||||
air_dresser.AIR_DRESSER_COURSE,
|
air_dresser.AIR_DRESSER_SETTINGS,
|
||||||
air_dresser.AIR_DRESSER_SANITIZE,
|
air_dresser.AIR_DRESSER_COURSE,
|
||||||
laundry.JOB_BEGINNING_STATUS,
|
air_dresser.AIR_DRESSER_SANITIZE,
|
||||||
operational.OPERATIONAL_STATE,
|
laundry.BUZZER_SOUND,
|
||||||
dishwasher.DIAGNOSIS,
|
laundry.JOB_BEGINNING_STATUS,
|
||||||
]),
|
operational.OPERATIONAL_STATE,
|
||||||
|
dishwasher.DIAGNOSIS,
|
||||||
|
]
|
||||||
|
),
|
||||||
)
|
)
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
"""Air Monitor Plus device registry (issue #210).
|
||||||
|
|
||||||
|
A standalone, battery-powered air-quality sensor puck (ASM-KR-TP1-22-*
|
||||||
|
board) -- no controllable state at all beyond the do-not-disturb window,
|
||||||
|
so this registry is almost entirely sensors. No common.POWER: there's no
|
||||||
|
`/power/*` resource on this board, only `/energy/battery/vs/0`.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from ..capabilities import air_monitor, common, ignored
|
||||||
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
|
REGISTRY = DeviceRegistry(
|
||||||
|
name="air_monitor",
|
||||||
|
capabilities=_build(
|
||||||
|
[
|
||||||
|
*ignored.IGNORED,
|
||||||
|
*common.UNIVERSAL,
|
||||||
|
*air_monitor.COVERAGE,
|
||||||
|
air_monitor.SENSORS,
|
||||||
|
air_monitor.HUMIDITY,
|
||||||
|
air_monitor.BATTERY,
|
||||||
|
air_monitor.AIR_QUALITY_STANDARD,
|
||||||
|
air_monitor.DND,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
)
|
||||||
@@ -25,33 +25,36 @@ match_fn discriminators that keep them from colliding):
|
|||||||
Reuses dishwasher.DIAGNOSIS for /diagnosis/vs/0 (identical field/write
|
Reuses dishwasher.DIAGNOSIS for /diagnosis/vs/0 (identical field/write
|
||||||
contract).
|
contract).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..capabilities import air_purifier, airconditioner, common, dishwasher, ignored
|
from ..capabilities import air_purifier, airconditioner, common, dishwasher, ignored
|
||||||
from ._base import DeviceRegistry, _build
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
REGISTRY = DeviceRegistry(
|
REGISTRY = DeviceRegistry(
|
||||||
name='air_purifier',
|
name="air_purifier",
|
||||||
capabilities=_build([
|
capabilities=_build(
|
||||||
*ignored.IGNORED,
|
[
|
||||||
*common.UNIVERSAL,
|
*ignored.IGNORED,
|
||||||
*common.POWER,
|
*common.UNIVERSAL,
|
||||||
dishwasher.DIAGNOSIS,
|
*common.POWER,
|
||||||
air_purifier.AIR_QUALITY,
|
dishwasher.DIAGNOSIS,
|
||||||
air_purifier.FILTER,
|
air_purifier.AIR_QUALITY,
|
||||||
air_purifier.DEVICE_ACTIVE,
|
air_purifier.FILTER,
|
||||||
air_purifier.AIRFLOW_GENERIC,
|
air_purifier.DEVICE_ACTIVE,
|
||||||
air_purifier.AIRFLOW_VS_FALLBACK,
|
air_purifier.AIRFLOW_GENERIC,
|
||||||
air_purifier.MODE,
|
air_purifier.AIRFLOW_VS_FALLBACK,
|
||||||
air_purifier.FAN,
|
air_purifier.MODE,
|
||||||
air_purifier.WIND_STRENGTH_FAN,
|
air_purifier.FAN,
|
||||||
air_purifier.DISPLAY,
|
air_purifier.WIND_STRENGTH_FAN,
|
||||||
air_purifier.HEPA_FILTER,
|
air_purifier.DISPLAY,
|
||||||
air_purifier.PANEL_STATUS,
|
air_purifier.HEPA_FILTER,
|
||||||
air_purifier.PET_FILTER_ACTIVATION,
|
air_purifier.PANEL_STATUS,
|
||||||
air_purifier.SOUND_MODE,
|
air_purifier.PET_FILTER_ACTIVATION,
|
||||||
air_purifier.SOUND_OUTPUT,
|
air_purifier.SOUND_MODE,
|
||||||
air_purifier.SOUND_VOLUME,
|
air_purifier.SOUND_OUTPUT,
|
||||||
airconditioner.DISPLAY_LIGHT,
|
air_purifier.SOUND_VOLUME,
|
||||||
airconditioner.MUTE_ONCE,
|
airconditioner.DISPLAY_LIGHT,
|
||||||
*air_purifier.COVERAGE,
|
airconditioner.MUTE_ONCE,
|
||||||
]),
|
*air_purifier.COVERAGE,
|
||||||
|
]
|
||||||
|
),
|
||||||
)
|
)
|
||||||
@@ -16,31 +16,34 @@ uses unconditionally.
|
|||||||
|
|
||||||
Reuses dishwasher.DIAGNOSIS for /diagnosis/vs/0.
|
Reuses dishwasher.DIAGNOSIS for /diagnosis/vs/0.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..capabilities import airconditioner, common, dishwasher, ignored
|
from ..capabilities import airconditioner, common, dishwasher, ignored
|
||||||
from ._base import DeviceRegistry, _build
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
REGISTRY = DeviceRegistry(
|
REGISTRY = DeviceRegistry(
|
||||||
name='airconditioner',
|
name="airconditioner",
|
||||||
capabilities=_build([
|
capabilities=_build(
|
||||||
*ignored.IGNORED,
|
[
|
||||||
*[c for c in common.UNIVERSAL if c is not common.ENERGY_METER],
|
*ignored.IGNORED,
|
||||||
airconditioner.ENERGY_METER_GENERIC,
|
*[c for c in common.UNIVERSAL if c is not common.ENERGY_METER],
|
||||||
airconditioner.ENERGY_METER_LEGACY,
|
airconditioner.ENERGY_METER_GENERIC,
|
||||||
dishwasher.DIAGNOSIS,
|
airconditioner.ENERGY_METER_LEGACY,
|
||||||
airconditioner.CLIMATE,
|
dishwasher.DIAGNOSIS,
|
||||||
airconditioner.AIR_PURIFY,
|
airconditioner.CLIMATE,
|
||||||
airconditioner.AUTO_CLEAN,
|
airconditioner.AIR_PURIFY,
|
||||||
airconditioner.AIR_FILTER,
|
airconditioner.AUTO_CLEAN,
|
||||||
airconditioner.AIR_QUALITY,
|
airconditioner.AIR_FILTER,
|
||||||
airconditioner.DISPLAY_LIGHT,
|
airconditioner.AIR_QUALITY,
|
||||||
airconditioner.MUTE_ONCE,
|
airconditioner.DISPLAY_LIGHT,
|
||||||
airconditioner.CURRENT_LIMIT,
|
airconditioner.MUTE_ONCE,
|
||||||
airconditioner.ANOMALY_LOAD,
|
airconditioner.CURRENT_LIMIT,
|
||||||
airconditioner.ABSENCE_POWER_SAVING,
|
airconditioner.ANOMALY_LOAD,
|
||||||
airconditioner.MOTION_DETECT_WIND,
|
airconditioner.ABSENCE_POWER_SAVING,
|
||||||
airconditioner.CURRENT_TEMPERATURE,
|
airconditioner.MOTION_DETECT_WIND,
|
||||||
airconditioner.CURRENT_TEMPERATURE_VS,
|
airconditioner.CURRENT_TEMPERATURE,
|
||||||
airconditioner.HUMIDITY,
|
airconditioner.CURRENT_TEMPERATURE_VS,
|
||||||
*airconditioner.COVERAGE,
|
airconditioner.HUMIDITY,
|
||||||
]),
|
*airconditioner.COVERAGE,
|
||||||
|
]
|
||||||
|
),
|
||||||
)
|
)
|
||||||
@@ -12,15 +12,16 @@ key is unchanged: it's relied on by the legacy ARTIK051 'CT' modelNum token
|
|||||||
from ..capabilities import common, cooktop, ignored
|
from ..capabilities import common, cooktop, ignored
|
||||||
from ._base import DeviceRegistry, _build
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
|
|
||||||
REGISTRY = DeviceRegistry(
|
REGISTRY = DeviceRegistry(
|
||||||
name='gas_cooktop',
|
name="gas_cooktop",
|
||||||
capabilities=_build([
|
capabilities=_build(
|
||||||
*ignored.IGNORED,
|
[
|
||||||
cooktop.COOKTOP_POWER,
|
*ignored.IGNORED,
|
||||||
cooktop.COOKTOP_MODE,
|
cooktop.COOKTOP_POWER,
|
||||||
cooktop.COOKTOP_CONNECTED,
|
cooktop.COOKTOP_MODE,
|
||||||
cooktop.PAIRED_HOOD_STATUS,
|
cooktop.COOKTOP_CONNECTED,
|
||||||
common.FIRMWARE_UPDATE,
|
cooktop.PAIRED_HOOD_STATUS,
|
||||||
]),
|
common.FIRMWARE_UPDATE,
|
||||||
|
]
|
||||||
|
),
|
||||||
)
|
)
|
||||||
@@ -4,20 +4,23 @@ Shares the DA_AC_ board family with airconditioner.py (power, air filter,
|
|||||||
auto-clean, mute-once all use the identical resource shapes), so those three
|
auto-clean, mute-once all use the identical resource shapes), so those three
|
||||||
Capability objects are reused directly rather than duplicated.
|
Capability objects are reused directly rather than duplicated.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..capabilities import airconditioner, common, dehumidifier, ignored
|
from ..capabilities import airconditioner, common, dehumidifier, ignored
|
||||||
from ._base import DeviceRegistry, _build
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
REGISTRY = DeviceRegistry(
|
REGISTRY = DeviceRegistry(
|
||||||
name='dehumidifier',
|
name="dehumidifier",
|
||||||
capabilities=_build([
|
capabilities=_build(
|
||||||
*ignored.IGNORED,
|
[
|
||||||
*common.UNIVERSAL,
|
*ignored.IGNORED,
|
||||||
*common.POWER,
|
*common.UNIVERSAL,
|
||||||
dehumidifier.MODE,
|
*common.POWER,
|
||||||
dehumidifier.HUMIDITY,
|
dehumidifier.MODE,
|
||||||
airconditioner.AUTO_CLEAN,
|
dehumidifier.HUMIDITY,
|
||||||
airconditioner.AIR_FILTER,
|
airconditioner.AUTO_CLEAN,
|
||||||
airconditioner.MUTE_ONCE,
|
airconditioner.AIR_FILTER,
|
||||||
*dehumidifier.COVERAGE,
|
airconditioner.MUTE_ONCE,
|
||||||
]),
|
*dehumidifier.COVERAGE,
|
||||||
|
]
|
||||||
|
),
|
||||||
)
|
)
|
||||||
@@ -1,23 +1,26 @@
|
|||||||
"""Dishwasher device registry."""
|
"""Dishwasher device registry."""
|
||||||
|
|
||||||
from ..capabilities import common, dishwasher, ignored, laundry, operational
|
from ..capabilities import common, dishwasher, ignored, laundry, operational
|
||||||
from ._base import DeviceRegistry, _build
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
REGISTRY = DeviceRegistry(
|
REGISTRY = DeviceRegistry(
|
||||||
name='dishwasher',
|
name="dishwasher",
|
||||||
capabilities=_build([
|
capabilities=_build(
|
||||||
*ignored.IGNORED,
|
[
|
||||||
*common.UNIVERSAL,
|
*ignored.IGNORED,
|
||||||
*common.POWER,
|
*common.UNIVERSAL,
|
||||||
common.WATER_METER,
|
*common.POWER,
|
||||||
common.WATER_FILTER,
|
common.WATER_METER,
|
||||||
operational.OPERATIONAL_STATE,
|
common.WATER_FILTER,
|
||||||
dishwasher.CYCLE_OPTIONS,
|
operational.OPERATIONAL_STATE,
|
||||||
dishwasher.DISHWASHER_SETTINGS,
|
dishwasher.CYCLE_OPTIONS,
|
||||||
dishwasher.DIAGNOSIS,
|
dishwasher.DISHWASHER_SETTINGS,
|
||||||
dishwasher.OPERATION_ORIGIN,
|
dishwasher.DIAGNOSIS,
|
||||||
laundry.JOB_BEGINNING_STATUS,
|
dishwasher.OPERATION_ORIGIN,
|
||||||
laundry.DOOR_LED,
|
laundry.JOB_BEGINNING_STATUS,
|
||||||
laundry.SOUND_MODE,
|
laundry.DOOR_LED,
|
||||||
laundry.SOUND_VOLUME,
|
laundry.SOUND_MODE,
|
||||||
]),
|
laundry.SOUND_VOLUME,
|
||||||
|
]
|
||||||
|
),
|
||||||
)
|
)
|
||||||
@@ -9,22 +9,25 @@ objects the washer registry uses -- washer and dryer expose the same
|
|||||||
DA_WM_-family surface, so they stay consistent instead of each carrying a
|
DA_WM_-family surface, so they stay consistent instead of each carrying a
|
||||||
bespoke variant.
|
bespoke variant.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..capabilities import common, dryer, ignored, laundry, operational
|
from ..capabilities import common, dryer, ignored, laundry, operational
|
||||||
from ._base import DeviceRegistry, _build
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
REGISTRY = DeviceRegistry(
|
REGISTRY = DeviceRegistry(
|
||||||
name='dryer',
|
name="dryer",
|
||||||
capabilities=_build([
|
capabilities=_build(
|
||||||
*ignored.IGNORED,
|
[
|
||||||
*common.UNIVERSAL,
|
*ignored.IGNORED,
|
||||||
*common.POWER,
|
*common.UNIVERSAL,
|
||||||
operational.OPERATIONAL_STATE,
|
*common.POWER,
|
||||||
laundry.DOOR_LED,
|
operational.OPERATIONAL_STATE,
|
||||||
laundry.SOUND_MODE,
|
laundry.DOOR_LED,
|
||||||
laundry.BUZZER_SOUND,
|
laundry.SOUND_MODE,
|
||||||
laundry.JOB_BEGINNING_STATUS,
|
laundry.BUZZER_SOUND,
|
||||||
dryer.DRYER_SETTINGS,
|
laundry.JOB_BEGINNING_STATUS,
|
||||||
dryer.DRYER_COURSE,
|
dryer.DRYER_SETTINGS,
|
||||||
dryer.DRYER_DIAGNOSIS,
|
dryer.DRYER_COURSE,
|
||||||
]),
|
dryer.DRYER_DIAGNOSIS,
|
||||||
|
]
|
||||||
|
),
|
||||||
)
|
)
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
"""EHS (Eco Heating System) air-to-water heat pump device registry
|
||||||
|
(Samsung TP1X_DA_AC_EHS-class).
|
||||||
|
|
||||||
|
Shares the DA_AC_ board prefix with the room-AC family in
|
||||||
|
airconditioner.py, but its /mode/*/vs/0 and /temperatures/*/vs/0 resources
|
||||||
|
are its own shape (two independent loops: zone1 space heating/cooling and
|
||||||
|
dhw domestic hot water), not airconditioner.py's HREF_MODE/HREF_TEMP* OCF
|
||||||
|
pattern -- so nothing from that module is reused here except MUTE_ONCE,
|
||||||
|
whose /option/muteonce/vs/0 field shape (`muteonce`) is identical on this
|
||||||
|
family's dump.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from ..capabilities import airconditioner, common, ehs, ignored
|
||||||
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
|
REGISTRY = DeviceRegistry(
|
||||||
|
name="ehs",
|
||||||
|
capabilities=_build(
|
||||||
|
[
|
||||||
|
*ignored.IGNORED,
|
||||||
|
*common.UNIVERSAL,
|
||||||
|
airconditioner.MUTE_ONCE,
|
||||||
|
ehs.ZONE_POWER,
|
||||||
|
ehs.ZONE_MODE,
|
||||||
|
ehs.ZONE_TEMPERATURE,
|
||||||
|
ehs.DHW,
|
||||||
|
*ehs.DHW_CONSUMED,
|
||||||
|
ehs.AWAY_MODE,
|
||||||
|
*ehs.COVERAGE,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
)
|
||||||
@@ -11,20 +11,24 @@ units pair with. Distinct registry key from cooktop.REGISTRY ('cooktop')
|
|||||||
embedded in /mode/vs/0's options array, a completely different OCF
|
embedded in /mode/vs/0's options array, a completely different OCF
|
||||||
surface that happens to share the English word "cooktop").
|
surface that happens to share the English word "cooktop").
|
||||||
"""
|
"""
|
||||||
from ..capabilities import common, cooktop as cooktop_caps, ignored
|
|
||||||
|
from ..capabilities import common, ignored
|
||||||
|
from ..capabilities import cooktop as cooktop_caps
|
||||||
from ..capabilities import range as range_caps
|
from ..capabilities import range as range_caps
|
||||||
from ._base import DeviceRegistry, _build
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
REGISTRY = DeviceRegistry(
|
REGISTRY = DeviceRegistry(
|
||||||
name='induction_cooktop',
|
name="induction_cooktop",
|
||||||
capabilities=_build([
|
capabilities=_build(
|
||||||
*ignored.IGNORED,
|
[
|
||||||
*common.UNIVERSAL,
|
*ignored.IGNORED,
|
||||||
*common.POWER,
|
*common.UNIVERSAL,
|
||||||
range_caps.COOKTOP_STATUS,
|
*common.POWER,
|
||||||
range_caps.COOKTOP_SPEC,
|
range_caps.COOKTOP_STATUS,
|
||||||
range_caps.COOKTOP_SAFETY,
|
range_caps.COOKTOP_SPEC,
|
||||||
range_caps.PROBE_STATUS,
|
range_caps.COOKTOP_SAFETY,
|
||||||
cooktop_caps.PAIRED_HOOD_STATUS,
|
range_caps.PROBE_STATUS,
|
||||||
]),
|
cooktop_caps.PAIRED_HOOD_STATUS,
|
||||||
|
]
|
||||||
|
),
|
||||||
)
|
)
|
||||||
@@ -16,22 +16,25 @@ has no sibling `/power/0` or `/power/vs/0` resource; fan.py's
|
|||||||
LocalThingsRangeHoodFan falls back to treating fan speed 0 as off in that
|
LocalThingsRangeHoodFan falls back to treating fan speed 0 as off in that
|
||||||
case (see its `_speed_zero_is_off` check).
|
case (see its `_speed_zero_is_off` check).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..capabilities import common, ignored, microwave, oven, range_hood
|
from ..capabilities import common, ignored, microwave, oven, range_hood
|
||||||
from ._base import DeviceRegistry, _build
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
REGISTRY = DeviceRegistry(
|
REGISTRY = DeviceRegistry(
|
||||||
name='microwave',
|
name="microwave",
|
||||||
capabilities=_build([
|
capabilities=_build(
|
||||||
*ignored.IGNORED,
|
[
|
||||||
*common.UNIVERSAL,
|
*ignored.IGNORED,
|
||||||
*common.POWER,
|
*common.UNIVERSAL,
|
||||||
microwave.MICROWAVE_CAVITY,
|
*common.POWER,
|
||||||
microwave.MICROWAVE_SETPOINT,
|
microwave.MICROWAVE_CAVITY,
|
||||||
microwave.MICROWAVE_MODE,
|
microwave.MICROWAVE_SETPOINT,
|
||||||
oven.OVEN_OPERATIONAL_STATE,
|
microwave.MICROWAVE_MODE,
|
||||||
oven.OVEN_DOOR,
|
oven.OVEN_OPERATIONAL_STATE,
|
||||||
oven.OVEN_CONNECTED,
|
oven.OVEN_DOOR,
|
||||||
oven.OVEN_RECIPE_COOK,
|
oven.OVEN_CONNECTED,
|
||||||
range_hood.HOOD_FAN,
|
oven.OVEN_RECIPE_COOK,
|
||||||
]),
|
range_hood.HOOD_FAN,
|
||||||
|
]
|
||||||
|
),
|
||||||
)
|
)
|
||||||
@@ -1,20 +1,23 @@
|
|||||||
"""Oven device registry."""
|
"""Oven device registry."""
|
||||||
|
|
||||||
from ..capabilities import common, ignored, oven
|
from ..capabilities import common, ignored, oven
|
||||||
from ._base import DeviceRegistry, _build
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
REGISTRY = DeviceRegistry(
|
REGISTRY = DeviceRegistry(
|
||||||
name='oven',
|
name="oven",
|
||||||
capabilities=_build([
|
capabilities=_build(
|
||||||
*ignored.IGNORED,
|
[
|
||||||
*common.UNIVERSAL,
|
*ignored.IGNORED,
|
||||||
*common.POWER,
|
*common.UNIVERSAL,
|
||||||
oven.OVEN_CAVITY,
|
*common.POWER,
|
||||||
oven.OVEN_SETPOINT,
|
oven.OVEN_CAVITY,
|
||||||
oven.OVEN_MODE,
|
oven.OVEN_SETPOINT,
|
||||||
oven.OVEN_OPERATIONAL_STATE,
|
oven.OVEN_MODE,
|
||||||
oven.OVEN_DOOR,
|
oven.OVEN_OPERATIONAL_STATE,
|
||||||
oven.OVEN_CONNECTED,
|
oven.OVEN_DOOR,
|
||||||
oven.OVEN_SPEC,
|
oven.OVEN_CONNECTED,
|
||||||
oven.OVEN_RECIPE_COOK,
|
oven.OVEN_SPEC,
|
||||||
]),
|
oven.OVEN_RECIPE_COOK,
|
||||||
|
]
|
||||||
|
),
|
||||||
)
|
)
|
||||||
@@ -5,26 +5,29 @@ connected capabilities wholesale (a range's oven half is the same OCF
|
|||||||
surface as a standalone oven) and adds the cooktop-specific capabilities
|
surface as a standalone oven) and adds the cooktop-specific capabilities
|
||||||
for the burner half.
|
for the burner half.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..capabilities import common, ignored, oven
|
from ..capabilities import common, ignored, oven
|
||||||
from ..capabilities import range as range_caps
|
from ..capabilities import range as range_caps
|
||||||
from ._base import DeviceRegistry, _build
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
REGISTRY = DeviceRegistry(
|
REGISTRY = DeviceRegistry(
|
||||||
name='range',
|
name="range",
|
||||||
capabilities=_build([
|
capabilities=_build(
|
||||||
*ignored.IGNORED,
|
[
|
||||||
*common.UNIVERSAL,
|
*ignored.IGNORED,
|
||||||
*common.POWER,
|
*common.UNIVERSAL,
|
||||||
oven.OVEN_CAVITY,
|
*common.POWER,
|
||||||
oven.OVEN_SETPOINT,
|
oven.OVEN_CAVITY,
|
||||||
oven.OVEN_MODE,
|
oven.OVEN_SETPOINT,
|
||||||
oven.OVEN_OPERATIONAL_STATE,
|
oven.OVEN_MODE,
|
||||||
oven.OVEN_DOOR,
|
oven.OVEN_OPERATIONAL_STATE,
|
||||||
oven.OVEN_CONNECTED,
|
oven.OVEN_DOOR,
|
||||||
oven.OVEN_SPEC,
|
oven.OVEN_CONNECTED,
|
||||||
range_caps.COOKTOP_STATUS,
|
oven.OVEN_SPEC,
|
||||||
range_caps.COOKTOP_SPEC,
|
range_caps.COOKTOP_STATUS,
|
||||||
range_caps.COOKTOP_SAFETY,
|
range_caps.COOKTOP_SPEC,
|
||||||
range_caps.COOKTOP_MONITORING,
|
range_caps.COOKTOP_SAFETY,
|
||||||
]),
|
range_caps.COOKTOP_MONITORING,
|
||||||
|
]
|
||||||
|
),
|
||||||
)
|
)
|
||||||
@@ -3,21 +3,22 @@
|
|||||||
from ..capabilities import common, ignored, range_hood
|
from ..capabilities import common, ignored, range_hood
|
||||||
from ._base import DeviceRegistry, _build
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
|
|
||||||
REGISTRY = DeviceRegistry(
|
REGISTRY = DeviceRegistry(
|
||||||
name='range_hood',
|
name="range_hood",
|
||||||
capabilities=_build([
|
capabilities=_build(
|
||||||
*ignored.IGNORED,
|
[
|
||||||
range_hood.HOOD_ALARMS,
|
*ignored.IGNORED,
|
||||||
common.ENERGY_METER,
|
range_hood.HOOD_ALARMS,
|
||||||
common.FIRMWARE_UPDATE,
|
common.ENERGY_METER,
|
||||||
range_hood.AFTER_RUN,
|
common.FIRMWARE_UPDATE,
|
||||||
range_hood.HOOD_FAN,
|
range_hood.AFTER_RUN,
|
||||||
range_hood.HOOD_LAMP,
|
range_hood.HOOD_FAN,
|
||||||
range_hood.HOOD_FILTER,
|
range_hood.HOOD_LAMP,
|
||||||
range_hood.AIR_QUALITY,
|
range_hood.HOOD_FILTER,
|
||||||
range_hood.AIR_LEVEL_CHECK,
|
range_hood.AIR_QUALITY,
|
||||||
range_hood.AUTO_VENTILATION,
|
range_hood.AIR_LEVEL_CHECK,
|
||||||
*range_hood.COVERAGE,
|
range_hood.AUTO_VENTILATION,
|
||||||
]),
|
*range_hood.COVERAGE,
|
||||||
|
]
|
||||||
|
),
|
||||||
)
|
)
|
||||||
@@ -1,37 +1,40 @@
|
|||||||
"""Refrigerator device registry."""
|
"""Refrigerator device registry."""
|
||||||
|
|
||||||
from ..capabilities import common, dishwasher, fridge, ignored
|
from ..capabilities import common, dishwasher, fridge, ignored
|
||||||
from ._base import DeviceRegistry, _build
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
REGISTRY = DeviceRegistry(
|
REGISTRY = DeviceRegistry(
|
||||||
name='refrigerator',
|
name="refrigerator",
|
||||||
capabilities=_build([
|
capabilities=_build(
|
||||||
*ignored.IGNORED,
|
[
|
||||||
*common.UNIVERSAL,
|
*ignored.IGNORED,
|
||||||
*common.POWER,
|
*common.UNIVERSAL,
|
||||||
fridge.STATUS_LOCK,
|
*common.POWER,
|
||||||
fridge.DOOR_ALERT,
|
fridge.STATUS_LOCK,
|
||||||
common.WATER_FILTER,
|
fridge.DOOR_ALERT,
|
||||||
dishwasher.DIAGNOSIS,
|
common.WATER_FILTER,
|
||||||
fridge.ICEMAKER_NIGHTTIME,
|
dishwasher.DIAGNOSIS,
|
||||||
fridge.FLEX_ZONE,
|
fridge.ICEMAKER_NIGHTTIME,
|
||||||
fridge.REFRIGERATION,
|
fridge.FLEX_ZONE,
|
||||||
fridge.AUTOFILL,
|
fridge.REFRIGERATION,
|
||||||
fridge.WELCOME_LIGHTING,
|
fridge.AUTOFILL,
|
||||||
fridge.CABINET_LIGHT,
|
fridge.WELCOME_LIGHTING,
|
||||||
fridge.CABINET_LIGHT_ENHANCED,
|
fridge.CABINET_LIGHT,
|
||||||
fridge.SABBATH,
|
fridge.CABINET_LIGHT_ENHANCED,
|
||||||
fridge.BEVERAGE_ZONE,
|
fridge.SABBATH,
|
||||||
fridge.PANTRY_ZONE,
|
fridge.BEVERAGE_ZONE,
|
||||||
fridge.DEFROST_DELAY,
|
fridge.PANTRY_ZONE,
|
||||||
fridge.DEFROST_DELAY_NATIVE_DUPLICATE,
|
fridge.DEFROST_DELAY,
|
||||||
fridge.DEFROST_BLOCK_STATUS,
|
fridge.DEFROST_DELAY_NATIVE_DUPLICATE,
|
||||||
fridge.DEFINITE_TEMPERATURE_COOLER,
|
fridge.DEFROST_BLOCK_STATUS,
|
||||||
fridge.DOORS_FALLBACK,
|
fridge.DEFINITE_TEMPERATURE_COOLER,
|
||||||
fridge.TEMPERATURES_FALLBACK,
|
fridge.DOORS_FALLBACK,
|
||||||
fridge.ICEMAKER_STATUS_FALLBACK,
|
fridge.TEMPERATURES_FALLBACK,
|
||||||
fridge.ICEMAKER_STATUS_NATIVE_DUPLICATE,
|
fridge.ICEMAKER_STATUS_FALLBACK,
|
||||||
fridge.REFRIGERATION_FALLBACK,
|
fridge.ICEMAKER_STATUS_NATIVE_DUPLICATE,
|
||||||
]),
|
fridge.REFRIGERATION_FALLBACK,
|
||||||
|
]
|
||||||
|
),
|
||||||
pattern_capabilities=[
|
pattern_capabilities=[
|
||||||
fridge.TEMP_CURRENT_GENERIC,
|
fridge.TEMP_CURRENT_GENERIC,
|
||||||
fridge.TEMP_SETPOINT,
|
fridge.TEMP_SETPOINT,
|
||||||
|
|||||||
@@ -5,18 +5,21 @@ covers the station's own dustbag/dustbin/UV-sanitize state and not any
|
|||||||
vacuum-body control (suction, battery, cleaning mode) -- the diagnostics
|
vacuum-body control (suction, battery, cleaning mode) -- the diagnostics
|
||||||
dump this was built from reports none of that.
|
dump this was built from reports none of that.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..capabilities import common, ignored, vacuum_station
|
from ..capabilities import common, ignored, vacuum_station
|
||||||
from ._base import DeviceRegistry, _build
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
REGISTRY = DeviceRegistry(
|
REGISTRY = DeviceRegistry(
|
||||||
name='vacuum_station',
|
name="vacuum_station",
|
||||||
capabilities=_build([
|
capabilities=_build(
|
||||||
*ignored.IGNORED,
|
[
|
||||||
*common.UNIVERSAL,
|
*ignored.IGNORED,
|
||||||
*common.POWER,
|
*common.UNIVERSAL,
|
||||||
vacuum_station.DUSTBAG,
|
*common.POWER,
|
||||||
vacuum_station.DUSTBAG_USAGE,
|
vacuum_station.DUSTBAG,
|
||||||
vacuum_station.DUSTBIN_SETTING,
|
vacuum_station.DUSTBAG_USAGE,
|
||||||
vacuum_station.CLEANSTATION_STATUS,
|
vacuum_station.DUSTBIN_SETTING,
|
||||||
]),
|
vacuum_station.CLEANSTATION_STATUS,
|
||||||
|
]
|
||||||
|
),
|
||||||
)
|
)
|
||||||
@@ -1,19 +1,22 @@
|
|||||||
"""Washer device registry."""
|
"""Washer device registry."""
|
||||||
|
|
||||||
from ..capabilities import common, dishwasher, ignored, laundry, operational, washer
|
from ..capabilities import common, dishwasher, ignored, laundry, operational, washer
|
||||||
from ._base import DeviceRegistry, _build
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
REGISTRY = DeviceRegistry(
|
REGISTRY = DeviceRegistry(
|
||||||
name='washer',
|
name="washer",
|
||||||
capabilities=_build([
|
capabilities=_build(
|
||||||
*ignored.IGNORED,
|
[
|
||||||
*common.UNIVERSAL,
|
*ignored.IGNORED,
|
||||||
*common.POWER,
|
*common.UNIVERSAL,
|
||||||
washer.WASHER_SETTINGS,
|
*common.POWER,
|
||||||
washer.WASHER_COURSE,
|
washer.WASHER_SETTINGS,
|
||||||
laundry.BUZZER_SOUND,
|
washer.WASHER_COURSE,
|
||||||
laundry.JOB_BEGINNING_STATUS,
|
laundry.BUZZER_SOUND,
|
||||||
common.WATER_METER,
|
laundry.JOB_BEGINNING_STATUS,
|
||||||
operational.OPERATIONAL_STATE,
|
common.WATER_METER,
|
||||||
dishwasher.DIAGNOSIS,
|
operational.OPERATIONAL_STATE,
|
||||||
]),
|
dishwasher.DIAGNOSIS,
|
||||||
|
]
|
||||||
|
),
|
||||||
)
|
)
|
||||||
@@ -1,25 +1,27 @@
|
|||||||
"""Water-purifier device registry (Samsung TP2X_WATERPURIFIER-class, issue #90).
|
"""Water-purifier device registry (Samsung TP2X_WATERPURIFIER-class, issue #90)."""
|
||||||
"""
|
|
||||||
from ..capabilities import common, ignored, water_purifier
|
from ..capabilities import common, ignored, water_purifier
|
||||||
from ._base import DeviceRegistry, _build
|
from ._base import DeviceRegistry, _build
|
||||||
|
|
||||||
REGISTRY = DeviceRegistry(
|
REGISTRY = DeviceRegistry(
|
||||||
name='water_purifier',
|
name="water_purifier",
|
||||||
capabilities=_build([
|
capabilities=_build(
|
||||||
*ignored.IGNORED,
|
[
|
||||||
*common.UNIVERSAL,
|
*ignored.IGNORED,
|
||||||
common.WATER_FILTER,
|
*common.UNIVERSAL,
|
||||||
water_purifier.DISPENSE,
|
common.WATER_FILTER,
|
||||||
water_purifier.STATUS,
|
water_purifier.DISPENSE,
|
||||||
water_purifier.FAVORITE_CAPACITY,
|
water_purifier.STATUS,
|
||||||
water_purifier.FAVORITE_HOTWATER,
|
water_purifier.FAVORITE_CAPACITY,
|
||||||
water_purifier.COFFEE,
|
water_purifier.FAVORITE_HOTWATER,
|
||||||
water_purifier.LOCK,
|
water_purifier.COFFEE,
|
||||||
water_purifier.CUP_STATE,
|
water_purifier.LOCK,
|
||||||
water_purifier.SOUND_MODE,
|
water_purifier.CUP_STATE,
|
||||||
water_purifier.SOUND_OUTPUT,
|
water_purifier.SOUND_MODE,
|
||||||
water_purifier.SOUND_VOLUME,
|
water_purifier.SOUND_OUTPUT,
|
||||||
water_purifier.STATISTIC_POUR,
|
water_purifier.SOUND_VOLUME,
|
||||||
*water_purifier.COVERAGE,
|
water_purifier.STATISTIC_POUR,
|
||||||
]),
|
*water_purifier.COVERAGE,
|
||||||
|
]
|
||||||
|
),
|
||||||
)
|
)
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
from . import (
|
|
||||||
common, cooktop, dishwasher, fridge, ignored, laundry, operational, oven,
|
|
||||||
range_hood,
|
|
||||||
)
|
|
||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
|
from . import (
|
||||||
|
common,
|
||||||
|
fridge,
|
||||||
|
ignored,
|
||||||
|
laundry,
|
||||||
|
operational,
|
||||||
|
oven,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _is_capability(v):
|
def _is_capability(v):
|
||||||
@@ -18,5 +22,13 @@ _OVEN_GLOBAL_CAPS = [
|
|||||||
oven.OVEN_CAVITY,
|
oven.OVEN_CAVITY,
|
||||||
]
|
]
|
||||||
|
|
||||||
ALL = [v for mod in (common, operational, laundry, fridge)
|
ALL = (
|
||||||
for v in vars(mod).values() if _is_capability(v)] + _OVEN_GLOBAL_CAPS + ignored.IGNORED
|
[
|
||||||
|
v
|
||||||
|
for mod in (common, operational, laundry, fridge)
|
||||||
|
for v in vars(mod).values()
|
||||||
|
if _is_capability(v)
|
||||||
|
]
|
||||||
|
+ _OVEN_GLOBAL_CAPS
|
||||||
|
+ ignored.IGNORED
|
||||||
|
)
|
||||||
@@ -32,49 +32,59 @@ machinery:
|
|||||||
/airdresseroption/sanitize/vs/0 -> AIR_DRESSER_SANITIZE (issue #157 only;
|
/airdresseroption/sanitize/vs/0 -> AIR_DRESSER_SANITIZE (issue #157 only;
|
||||||
#162's board doesn't report this resource at all)
|
#162's board doesn't report this resource at all)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
from ..entities import SwitchDesc
|
from ..entities import SwitchDesc
|
||||||
from .laundry import cycle_select
|
from .laundry import cycle_select
|
||||||
|
|
||||||
|
|
||||||
def _wrinkle_write(p, rep, href=None):
|
def _wrinkle_write(p, rep, href=None):
|
||||||
if p not in ('On', 'Off'):
|
if p not in ("On", "Off"):
|
||||||
return None
|
return None
|
||||||
return ['washer', 'vs', '0'], {'x.com.samsung.da.wrinklePrevent': p}
|
return ["washer", "vs", "0"], {"x.com.samsung.da.wrinklePrevent": p}
|
||||||
|
|
||||||
|
|
||||||
def _sanitize_write(p, rep, href=None):
|
def _sanitize_write(p, rep, href=None):
|
||||||
if p not in ('On', 'Off'):
|
if p not in ("On", "Off"):
|
||||||
return None
|
return None
|
||||||
return ['airdresseroption', 'sanitize', 'vs', '0'], {'x.com.samsung.da.sanitize': p}
|
return ["airdresseroption", "sanitize", "vs", "0"], {"x.com.samsung.da.sanitize": p}
|
||||||
|
|
||||||
|
|
||||||
AIR_DRESSER_SETTINGS = Capability(
|
AIR_DRESSER_SETTINGS = Capability(
|
||||||
href='/washer/vs/0',
|
href="/washer/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
SwitchDesc(key='wrinkle_prevent', field='x.com.samsung.da.wrinklePrevent',
|
SwitchDesc(
|
||||||
icon='mdi:iron',
|
key="wrinkle_prevent",
|
||||||
value_fn=lambda v: v == 'On',
|
field="x.com.samsung.da.wrinklePrevent",
|
||||||
write_fn=_wrinkle_write),
|
icon="mdi:iron",
|
||||||
|
value_fn=lambda v: v == "On",
|
||||||
|
write_fn=_wrinkle_write,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
AIR_DRESSER_COURSE = Capability(
|
AIR_DRESSER_COURSE = Capability(
|
||||||
href='/course/vs/0',
|
href="/course/vs/0",
|
||||||
entities=(
|
entities=(
|
||||||
cycle_select(translation_key='air_dresser_cycle', icon='mdi:tshirt-crew',
|
cycle_select(
|
||||||
table_href='/st/airdressercourse/vs/0'),
|
translation_key="air_dresser_cycle",
|
||||||
|
icon="mdi:tshirt-crew",
|
||||||
|
table_href="/st/airdressercourse/vs/0",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
AIR_DRESSER_SANITIZE = Capability(
|
AIR_DRESSER_SANITIZE = Capability(
|
||||||
href='/airdresseroption/sanitize/vs/0',
|
href="/airdresseroption/sanitize/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
SwitchDesc(key='sanitize', field='x.com.samsung.da.sanitize',
|
SwitchDesc(
|
||||||
icon='mdi:weather-sunny',
|
key="sanitize",
|
||||||
value_fn=lambda v: v == 'On',
|
field="x.com.samsung.da.sanitize",
|
||||||
write_fn=_sanitize_write),
|
icon="mdi:weather-sunny",
|
||||||
|
value_fn=lambda v: v == "On",
|
||||||
|
write_fn=_sanitize_write,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
"""Capabilities for the Samsung Air Monitor Plus family (ASM-KR-TP1-22-*
|
||||||
|
board, issue #210) -- a small battery-powered standalone air-quality sensor
|
||||||
|
puck, not a controllable appliance. No `/power/*` resource at all (battery
|
||||||
|
only); this registry deliberately doesn't include common.POWER.
|
||||||
|
|
||||||
|
`/sensors/vs/0` is the same {type, value: [...]} items-list shape
|
||||||
|
air_purifier.AIR_QUALITY and range_hood.AIR_QUALITY already read via
|
||||||
|
common.sensor_item_value -- reused here rather than re-decoded, including
|
||||||
|
the same dust/fine_dust/super_fine_dust/odor/clean_level keys so this
|
||||||
|
device shares those capabilities' catalog entries. This board additionally
|
||||||
|
reports a CO2 reading the other two families don't.
|
||||||
|
|
||||||
|
A second `value` list element on the particulate-matter types (e.g. Dust's
|
||||||
|
`['31', '2']`) reads like a coarse quality-grade code, but nothing on this
|
||||||
|
board (no `supportedGrades`/similar field, no repeated dump to compare
|
||||||
|
against) confirms what its scale means -- left unbound rather than guessed,
|
||||||
|
per the adding-device-support skill's "still never invent... from nothing"
|
||||||
|
rule. Same reasoning `air_purifier.AIR_QUALITY` already applies to this
|
||||||
|
shape; index 0 is the only slot any family has ever read.
|
||||||
|
|
||||||
|
Dust/FineDust/SuperFineDust aren't assigned an HA `device_class`
|
||||||
|
(pm10/pm25/pm1) or `unit` despite the values reading like plausible
|
||||||
|
ug/m3 particulate readings in a physically consistent order (coarser
|
||||||
|
>= finer): Samsung's own two-tier Korean convention (i.e. "fine dust"/
|
||||||
|
"ultra-fine dust") maps only to a PM10/PM2.5 pair, and this board's
|
||||||
|
three-tier naming doesn't confirm where the extra tier or a PM1 reading
|
||||||
|
actually fits. The adding-device-support skill's read-side rule says
|
||||||
|
leave unit/device_class unset when the dump gives no field that
|
||||||
|
nominates one -- a wrong guess would silently mislabel every reading
|
||||||
|
forever, and the write-side rejection safety net doesn't cover reads.
|
||||||
|
Exposed as plain `measurement` sensors named after the device's own
|
||||||
|
field instead (matching air_purifier.AIR_QUALITY's existing precedent).
|
||||||
|
"""
|
||||||
|
|
||||||
|
from datetime import time as dt_time
|
||||||
|
|
||||||
|
from ..capability import Capability
|
||||||
|
from ..entities import BinarySensorDesc, SensorDesc, SwitchDesc, TimeDesc
|
||||||
|
from .air_purifier import _AIR_QUALITY_SENSORS
|
||||||
|
from .common import int_or_none, sensor_item_value
|
||||||
|
|
||||||
|
SENSORS = Capability(
|
||||||
|
href="/sensors/vs/0",
|
||||||
|
poll_tier="warm",
|
||||||
|
entities=(
|
||||||
|
*(
|
||||||
|
SensorDesc(
|
||||||
|
key=key,
|
||||||
|
field="x.com.samsung.da.items",
|
||||||
|
icon=icon,
|
||||||
|
state_class="measurement",
|
||||||
|
value_fn=lambda items, t=sensor_type: sensor_item_value(items, t),
|
||||||
|
)
|
||||||
|
for key, icon, sensor_type in _AIR_QUALITY_SENSORS
|
||||||
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="co2",
|
||||||
|
field="x.com.samsung.da.items",
|
||||||
|
device_class="carbon_dioxide",
|
||||||
|
state_class="measurement",
|
||||||
|
unit="ppm",
|
||||||
|
value_fn=lambda items: sensor_item_value(items, "CO2"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
HUMIDITY = Capability(
|
||||||
|
href="/humidity/vs/0",
|
||||||
|
poll_tier="warm",
|
||||||
|
entities=(
|
||||||
|
SensorDesc(
|
||||||
|
key="humidity",
|
||||||
|
field="x.com.samsung.da.humidity",
|
||||||
|
device_class="humidity",
|
||||||
|
state_class="measurement",
|
||||||
|
unit="%",
|
||||||
|
value_fn=int_or_none,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
BATTERY = Capability(
|
||||||
|
href="/energy/battery/vs/0",
|
||||||
|
poll_tier="warm",
|
||||||
|
entities=(
|
||||||
|
SensorDesc(
|
||||||
|
key="battery",
|
||||||
|
field="x.com.samsung.da.battery",
|
||||||
|
device_class="battery",
|
||||||
|
state_class="measurement",
|
||||||
|
unit="%",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
value_fn=int_or_none,
|
||||||
|
),
|
||||||
|
BinarySensorDesc(
|
||||||
|
key="battery_charging",
|
||||||
|
field="x.com.samsung.da.charging",
|
||||||
|
device_class="battery_charging",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
value_fn=lambda v: v == "On",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
AIR_QUALITY_STANDARD = Capability(
|
||||||
|
href="/airqualitystandard/vs/0",
|
||||||
|
poll_tier="cold",
|
||||||
|
entities=(
|
||||||
|
SensorDesc(
|
||||||
|
key="air_quality_standard",
|
||||||
|
field="x.com.samsung.da.standard",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_hms(v):
|
||||||
|
"""'HH:MM:SS' -> datetime.time, same contract as laundry._parse_hm but
|
||||||
|
tolerant of the trailing ':SS' this board's dnd start/end times carry."""
|
||||||
|
if not v:
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
parts = v.split(":")
|
||||||
|
return dt_time(int(parts[0]), int(parts[1]))
|
||||||
|
except (ValueError, IndexError):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _dnd_time_write(field):
|
||||||
|
def _write(p, rep, href=None):
|
||||||
|
return ["dnd", "vs", "0"], {field: f"{p.hour:02d}:{p.minute:02d}:00"}
|
||||||
|
|
||||||
|
return _write
|
||||||
|
|
||||||
|
|
||||||
|
# Issue #210: no idle-vs-active dump pair exists for this href (only one
|
||||||
|
# dump total, DND never toggled in it), so this write contract is an
|
||||||
|
# educated guess, not a confirmed one -- symmetric with the read side
|
||||||
|
# (writing the same 'true'/'false' string shape and 'HH:MM:SS' format the
|
||||||
|
# device itself reports back) rather than invented from nothing, but still
|
||||||
|
# needs a reporter to actually flip it on real hardware and confirm. See
|
||||||
|
# the adding-device-support skill's "Educated guesses are fine" section.
|
||||||
|
DND = Capability(
|
||||||
|
href="/dnd/vs/0",
|
||||||
|
poll_tier="cold",
|
||||||
|
entities=(
|
||||||
|
SwitchDesc(
|
||||||
|
key="dnd",
|
||||||
|
field="x.com.samsung.da.value",
|
||||||
|
icon="mdi:sleep",
|
||||||
|
entity_category="config",
|
||||||
|
value_fn=lambda v: v == "true",
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["dnd", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.value": "true" if p == "On" else "false"},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TimeDesc(
|
||||||
|
key="dnd_start",
|
||||||
|
field="x.com.samsung.da.startTime",
|
||||||
|
icon="mdi:clock-start",
|
||||||
|
entity_category="config",
|
||||||
|
value_fn=_parse_hms,
|
||||||
|
write_fn=_dnd_time_write("x.com.samsung.da.startTime"),
|
||||||
|
),
|
||||||
|
TimeDesc(
|
||||||
|
key="dnd_end",
|
||||||
|
field="x.com.samsung.da.endTime",
|
||||||
|
icon="mdi:clock-end",
|
||||||
|
entity_category="config",
|
||||||
|
value_fn=_parse_hms,
|
||||||
|
write_fn=_dnd_time_write("x.com.samsung.da.endTime"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Air-monitor-scoped coverage: hrefs with no explainable live state,
|
||||||
|
# following the 'don't guess' rule.
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
_AM_IGNORED = [
|
||||||
|
# A single bare integer ('keepnormal': 0) with no description, no
|
||||||
|
# supported-values list, and no second dump to compare against -- opaque.
|
||||||
|
"/keepnormalstate/vs/0",
|
||||||
|
# {'remove': ''} -- looks like data-sink/cache-clearing plumbing, not a
|
||||||
|
# live user-facing field.
|
||||||
|
"/sensordatasinks/vs/0",
|
||||||
|
]
|
||||||
|
|
||||||
|
COVERAGE = [Capability(href=h) for h in _AM_IGNORED]
|
||||||
@@ -57,9 +57,15 @@ was unreliable on both units in that second round (Low/Medium collided on
|
|||||||
one unit, stuck at 0 throughout on the other), so AIRFLOW_VS_FALLBACK below
|
one unit, stuck at 0 throughout on the other), so AIRFLOW_VS_FALLBACK below
|
||||||
stays a plain read-only diagnostic even after this change.
|
stays a plain read-only diagnostic even after this change.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
from ..entities import (
|
from ..entities import (
|
||||||
BinarySensorDesc, FanDesc, NumberDesc, SelectDesc, SensorDesc, SwitchDesc,
|
BinarySensorDesc,
|
||||||
|
FanDesc,
|
||||||
|
NumberDesc,
|
||||||
|
SelectDesc,
|
||||||
|
SensorDesc,
|
||||||
|
SwitchDesc,
|
||||||
)
|
)
|
||||||
from .common import filter_usage_percent, int_or_none, sensor_item_value
|
from .common import filter_usage_percent, int_or_none, sensor_item_value
|
||||||
from .laundry import bool_option_exists, bool_option_value, option_value, option_write
|
from .laundry import bool_option_exists, bool_option_value, option_value, option_write
|
||||||
@@ -72,28 +78,33 @@ from .laundry import bool_option_exists, bool_option_value, option_value, option
|
|||||||
# supportedModes at all (see the module docstring's Comode_Off finding).
|
# supportedModes at all (see the module docstring's Comode_Off finding).
|
||||||
# Both board generations share the /mode/vs/0 href, so FAN and MODE below
|
# Both board generations share the /mode/vs/0 href, so FAN and MODE below
|
||||||
# are mutually exclusive via this presence check rather than colliding.
|
# are mutually exclusive via this presence check rather than colliding.
|
||||||
HREF_MODE = '/mode/vs/0'
|
HREF_MODE = "/mode/vs/0"
|
||||||
HREF_AIRFLOW = '/airflow/0'
|
HREF_AIRFLOW = "/airflow/0"
|
||||||
HREF_WIND_STRENGTH = '/wind/strength/vs/0'
|
HREF_WIND_STRENGTH = "/wind/strength/vs/0"
|
||||||
|
|
||||||
|
|
||||||
def _has_top_level_modes(rep, resources):
|
def _has_top_level_modes(rep, resources):
|
||||||
return isinstance(rep.get('x.com.samsung.da.supportedModes'), (list, tuple))
|
return isinstance(rep.get("x.com.samsung.da.supportedModes"), (list, tuple))
|
||||||
|
|
||||||
|
|
||||||
_AIR_QUALITY_SENSORS = (
|
_AIR_QUALITY_SENSORS = (
|
||||||
('dust', 'mdi:blur', 'Dust'),
|
("dust", "mdi:blur", "Dust"),
|
||||||
('fine_dust', 'mdi:blur', 'FineDust'),
|
("fine_dust", "mdi:blur", "FineDust"),
|
||||||
('super_fine_dust', 'mdi:blur', 'SuperFineDust'),
|
("super_fine_dust", "mdi:blur", "SuperFineDust"),
|
||||||
('odor', 'mdi:scent', 'Odor'),
|
("odor", "mdi:scent", "Odor"),
|
||||||
('clean_level', 'mdi:air-filter', 'CleanLevel'),
|
("clean_level", "mdi:air-filter", "CleanLevel"),
|
||||||
)
|
)
|
||||||
|
|
||||||
AIR_QUALITY = Capability(
|
AIR_QUALITY = Capability(
|
||||||
href='/sensors/vs/0',
|
href="/sensors/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=tuple(
|
entities=tuple(
|
||||||
SensorDesc(key=key, field='x.com.samsung.da.items', icon=icon,
|
SensorDesc(
|
||||||
value_fn=lambda items, t=sensor_type: sensor_item_value(items, t))
|
key=key,
|
||||||
|
field="x.com.samsung.da.items",
|
||||||
|
icon=icon,
|
||||||
|
value_fn=lambda items, t=sensor_type: sensor_item_value(items, t),
|
||||||
|
)
|
||||||
for key, icon, sensor_type in _AIR_QUALITY_SENSORS
|
for key, icon, sensor_type in _AIR_QUALITY_SENSORS
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -103,8 +114,8 @@ def _consumable_state(items, name):
|
|||||||
"""Read a `/consumable/vs/0`-style items[] entry -- {name, state} pairs,
|
"""Read a `/consumable/vs/0`-style items[] entry -- {name, state} pairs,
|
||||||
unlike AIR_QUALITY's {type, value} shape above."""
|
unlike AIR_QUALITY's {type, value} shape above."""
|
||||||
for item in items or ():
|
for item in items or ():
|
||||||
if isinstance(item, dict) and item.get('x.com.samsung.da.name') == name:
|
if isinstance(item, dict) and item.get("x.com.samsung.da.name") == name:
|
||||||
return item.get('x.com.samsung.da.state')
|
return item.get("x.com.samsung.da.state")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@@ -115,46 +126,53 @@ def _consumable_state(items, name):
|
|||||||
# which counts the same direction) rather than "filter life," which would
|
# which counts the same direction) rather than "filter life," which would
|
||||||
# imply the opposite direction.
|
# imply the opposite direction.
|
||||||
FILTER = Capability(
|
FILTER = Capability(
|
||||||
href='/consumable/vs/0',
|
href="/consumable/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='filter_progress', field='x.com.samsung.da.items',
|
SensorDesc(
|
||||||
unit='%', state_class='measurement',
|
key="filter_progress",
|
||||||
icon='mdi:air-filter', entity_category='diagnostic',
|
field="x.com.samsung.da.items",
|
||||||
value_fn=lambda items: int_or_none(
|
unit="%",
|
||||||
_consumable_state(items, 'FilterProgress'))),
|
state_class="measurement",
|
||||||
|
icon="mdi:air-filter",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
value_fn=lambda items: int_or_none(_consumable_state(items, "FilterProgress")),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
DEVICE_ACTIVE = Capability(
|
DEVICE_ACTIVE = Capability(
|
||||||
href='/devicespecificinfo/vs/0',
|
href="/devicespecificinfo/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
BinarySensorDesc(key='device_active', field='x.com.samsung.da.deviceActive',
|
BinarySensorDesc(
|
||||||
icon='mdi:check-network-outline',
|
key="device_active",
|
||||||
entity_category='diagnostic',
|
field="x.com.samsung.da.deviceActive",
|
||||||
value_fn=lambda v: bool(v)),
|
icon="mdi:check-network-outline",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
value_fn=lambda v: bool(v),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _power_write(power_href, value):
|
def _power_write(power_href, value):
|
||||||
"""Shared 'power' payload handling for this family's three FanDesc write
|
"""Shared 'power' payload handling for this family's three FanDesc write
|
||||||
functions -- targets whichever power href fan.py's _power_payload picked
|
functions -- targets whichever power href fan.py's _power_payload picked
|
||||||
(the board may only report /power/0); a hardcoded vendor href here would
|
(the board may only report /power/0); a hardcoded vendor href here would
|
||||||
silently no-op on such a board even though the entity's own is_on
|
silently no-op on such a board even though the entity's own is_on
|
||||||
already falls back to reading it correctly."""
|
already falls back to reading it correctly."""
|
||||||
if power_href == '/power/0':
|
if power_href == "/power/0":
|
||||||
return ['power', '0'], {'value': bool(value)}
|
return ["power", "0"], {"value": bool(value)}
|
||||||
return (['power', 'vs', '0'],
|
return (["power", "vs", "0"], {"x.com.samsung.da.power": "On" if value else "Off"})
|
||||||
{'x.com.samsung.da.power': 'On' if value else 'Off'})
|
|
||||||
|
|
||||||
|
|
||||||
def _airflow_fan_write(payload, rep, href=None):
|
def _airflow_fan_write(payload, rep, href=None):
|
||||||
kind, value, *args = payload
|
kind, value, *args = payload
|
||||||
if kind == 'power':
|
if kind == "power":
|
||||||
return _power_write(args[0] if args else '/power/vs/0', value)
|
return _power_write(args[0] if args else "/power/vs/0", value)
|
||||||
if kind == 'speed':
|
if kind == "speed":
|
||||||
return ['airflow', '0'], {'speed': int(value)}
|
return ["airflow", "0"], {"speed": int(value)}
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@@ -178,12 +196,15 @@ def _airflow_fan_write(payload, rep, href=None):
|
|||||||
# same key would collide if a future board ever reported both.
|
# same key would collide if a future board ever reported both.
|
||||||
AIRFLOW_GENERIC = Capability(
|
AIRFLOW_GENERIC = Capability(
|
||||||
href=HREF_AIRFLOW,
|
href=HREF_AIRFLOW,
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
FanDesc(key='airflow_fan', field='speed', write_fn=_airflow_fan_write),
|
FanDesc(key="airflow_fan", field="speed", write_fn=_airflow_fan_write),
|
||||||
SensorDesc(key='fan_direction', field='direction',
|
SensorDesc(
|
||||||
icon='mdi:rotate-3d-variant',
|
key="fan_direction",
|
||||||
entity_category='diagnostic'),
|
field="direction",
|
||||||
|
icon="mdi:rotate-3d-variant",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -192,17 +213,24 @@ AIRFLOW_GENERIC = Capability(
|
|||||||
# docstring): it collided Low/Medium on one unit and stuck at 0 throughout
|
# docstring): it collided Low/Medium on one unit and stuck at 0 throughout
|
||||||
# on the other in the same properly-spaced round.
|
# on the other in the same properly-spaced round.
|
||||||
AIRFLOW_VS_FALLBACK = Capability(
|
AIRFLOW_VS_FALLBACK = Capability(
|
||||||
href='/airflow/vs/0',
|
href="/airflow/vs/0",
|
||||||
match_fn=lambda rep, resources: '/airflow/0' not in resources,
|
match_fn=lambda rep, resources: "/airflow/0" not in resources,
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='fan_speed_level', field='x.com.samsung.da.speedLevel',
|
SensorDesc(
|
||||||
icon='mdi:fan',
|
key="fan_speed_level",
|
||||||
state_class='measurement', entity_category='diagnostic',
|
field="x.com.samsung.da.speedLevel",
|
||||||
value_fn=int_or_none),
|
icon="mdi:fan",
|
||||||
SensorDesc(key='fan_direction', field='x.com.samsung.da.direction',
|
state_class="measurement",
|
||||||
icon='mdi:rotate-3d-variant',
|
entity_category="diagnostic",
|
||||||
entity_category='diagnostic'),
|
value_fn=int_or_none,
|
||||||
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="fan_direction",
|
||||||
|
field="x.com.samsung.da.direction",
|
||||||
|
icon="mdi:rotate-3d-variant",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -214,37 +242,43 @@ def _light_write(payload, rep, href=None):
|
|||||||
# merges the same way everywhere. If some unit replaces the field
|
# merges the same way everywhere. If some unit replaces the field
|
||||||
# outright instead, this would drop Comode/OptionCode alongside it on
|
# outright instead, this would drop Comode/OptionCode alongside it on
|
||||||
# the next light toggle; revisit if a real device report surfaces that.
|
# the next light toggle; revisit if a real device report surfaces that.
|
||||||
return ['mode', 'vs', '0'], {
|
return ["mode", "vs", "0"], {
|
||||||
'x.com.samsung.da.options': option_write('Light', payload),
|
"x.com.samsung.da.options": option_write("Light", payload),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MODE = Capability(
|
MODE = Capability(
|
||||||
href='/mode/vs/0',
|
href="/mode/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
match_fn=lambda rep, resources: not _has_top_level_modes(rep, resources),
|
match_fn=lambda rep, resources: not _has_top_level_modes(rep, resources),
|
||||||
entities=(
|
entities=(
|
||||||
SwitchDesc(key='display_light', icon='mdi:led-on',
|
SwitchDesc(
|
||||||
entity_category='config',
|
key="display_light",
|
||||||
rep_fn=bool_option_value('Light'),
|
icon="mdi:led-on",
|
||||||
exists_fn=bool_option_exists('Light'),
|
entity_category="config",
|
||||||
write_fn=_light_write),
|
rep_fn=bool_option_value("Light"),
|
||||||
|
exists_fn=bool_option_exists("Light"),
|
||||||
|
write_fn=_light_write,
|
||||||
|
),
|
||||||
# Read-only -- confirmed NOT the fan-speed selector (see module
|
# Read-only -- confirmed NOT the fan-speed selector (see module
|
||||||
# docstring), actual purpose still unconfirmed.
|
# docstring), actual purpose still unconfirmed.
|
||||||
SensorDesc(key='operating_mode', icon='mdi:fan',
|
SensorDesc(
|
||||||
entity_category='diagnostic',
|
key="operating_mode",
|
||||||
rep_fn=lambda rep: option_value(rep.get('x.com.samsung.da.options'), 'Comode'),
|
icon="mdi:fan",
|
||||||
exists_fn=bool_option_exists('Comode')),
|
entity_category="diagnostic",
|
||||||
|
rep_fn=lambda rep: option_value(rep.get("x.com.samsung.da.options"), "Comode"),
|
||||||
|
exists_fn=bool_option_exists("Comode"),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _fan_write(payload, rep, href=None):
|
def _fan_write(payload, rep, href=None):
|
||||||
kind, value, *args = payload
|
kind, value, *args = payload
|
||||||
if kind == 'power':
|
if kind == "power":
|
||||||
return _power_write(args[0] if args else '/power/vs/0', value)
|
return _power_write(args[0] if args else "/power/vs/0", value)
|
||||||
if kind == 'mode':
|
if kind == "mode":
|
||||||
return ['mode', 'vs', '0'], {'x.com.samsung.da.modes': [value]}
|
return ["mode", "vs", "0"], {"x.com.samsung.da.modes": [value]}
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@@ -252,7 +286,7 @@ def _first_fan_mode(rep):
|
|||||||
"""Representative scalar for the fan entity in the flattened state
|
"""Representative scalar for the fan entity in the flattened state
|
||||||
(golden/regression), mirroring airconditioner.py's own _first_mode --
|
(golden/regression), mirroring airconditioner.py's own _first_mode --
|
||||||
the real entity computes its state from live coordinator reads."""
|
the real entity computes its state from live coordinator reads."""
|
||||||
modes = rep.get('x.com.samsung.da.modes')
|
modes = rep.get("x.com.samsung.da.modes")
|
||||||
if isinstance(modes, (list, tuple)):
|
if isinstance(modes, (list, tuple)):
|
||||||
return modes[0] if modes else None
|
return modes[0] if modes else None
|
||||||
return modes
|
return modes
|
||||||
@@ -265,21 +299,25 @@ def _first_fan_mode(rep):
|
|||||||
# convenient modes are modeled as a preset rather than a speed number.
|
# convenient modes are modeled as a preset rather than a speed number.
|
||||||
FAN = Capability(
|
FAN = Capability(
|
||||||
href=HREF_MODE,
|
href=HREF_MODE,
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
match_fn=_has_top_level_modes,
|
match_fn=_has_top_level_modes,
|
||||||
entities=(
|
entities=(
|
||||||
FanDesc(key='fan', translation_key='air_purifier_fan',
|
FanDesc(
|
||||||
rep_fn=_first_fan_mode, write_fn=_fan_write),
|
key="fan",
|
||||||
|
translation_key="air_purifier_fan",
|
||||||
|
rep_fn=_first_fan_mode,
|
||||||
|
write_fn=_fan_write,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _wind_strength_fan_write(payload, rep, href=None):
|
def _wind_strength_fan_write(payload, rep, href=None):
|
||||||
kind, value, *args = payload
|
kind, value, *args = payload
|
||||||
if kind == 'power':
|
if kind == "power":
|
||||||
return _power_write(args[0] if args else '/power/vs/0', value)
|
return _power_write(args[0] if args else "/power/vs/0", value)
|
||||||
if kind == 'mode':
|
if kind == "mode":
|
||||||
return ['wind', 'strength', 'vs', '0'], {'x.com.samsung.da.modes': value}
|
return ["wind", "strength", "vs", "0"], {"x.com.samsung.da.modes": value}
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@@ -298,10 +336,14 @@ def _wind_strength_fan_write(payload, rep, href=None):
|
|||||||
# comment on this exact hazard -- missed here in the initial cut).
|
# comment on this exact hazard -- missed here in the initial cut).
|
||||||
WIND_STRENGTH_FAN = Capability(
|
WIND_STRENGTH_FAN = Capability(
|
||||||
href=HREF_WIND_STRENGTH,
|
href=HREF_WIND_STRENGTH,
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
FanDesc(key='wind_strength_fan', translation_key='air_purifier_fan',
|
FanDesc(
|
||||||
field='x.com.samsung.da.modes', write_fn=_wind_strength_fan_write),
|
key="wind_strength_fan",
|
||||||
|
translation_key="air_purifier_fan",
|
||||||
|
field="x.com.samsung.da.modes",
|
||||||
|
write_fn=_wind_strength_fan_write,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -315,16 +357,20 @@ WIND_STRENGTH_FAN = Capability(
|
|||||||
# separate hrefs on this dump, so they're two independent physical controls,
|
# separate hrefs on this dump, so they're two independent physical controls,
|
||||||
# not a duplicate encoding of one.
|
# not a duplicate encoding of one.
|
||||||
DISPLAY = Capability(
|
DISPLAY = Capability(
|
||||||
href='/display/vs/0',
|
href="/display/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
SwitchDesc(key='display', field='mode',
|
SwitchDesc(
|
||||||
icon='mdi:monitor',
|
key="display",
|
||||||
entity_category='config',
|
field="mode",
|
||||||
value_fn=lambda v: v == 'On',
|
icon="mdi:monitor",
|
||||||
write_fn=lambda p, rep, href=None: (
|
entity_category="config",
|
||||||
['display', 'vs', '0'],
|
value_fn=lambda v: v == "On",
|
||||||
{'mode': 'On' if p == 'On' else 'Off'})),
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["display", "vs", "0"],
|
||||||
|
{"mode": "On" if p == "On" else "Off"},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -333,18 +379,27 @@ DISPLAY = Capability(
|
|||||||
# seen on this one dump, so the option list there is reused as-is rather
|
# seen on this one dump, so the option list there is reused as-is rather
|
||||||
# than re-deriving it from a single sample.
|
# than re-deriving it from a single sample.
|
||||||
HEPA_FILTER = Capability(
|
HEPA_FILTER = Capability(
|
||||||
href='/filter/hepafilter/vs/0',
|
href="/filter/hepafilter/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='hepa_filter_usage', rep_fn=filter_usage_percent,
|
SensorDesc(
|
||||||
unit='%', state_class='measurement',
|
key="hepa_filter_usage",
|
||||||
icon='mdi:air-filter', entity_category='diagnostic'),
|
rep_fn=filter_usage_percent,
|
||||||
SensorDesc(key='hepa_filter_status', field='x.com.samsung.da.filterStatus',
|
unit="%",
|
||||||
device_class='enum',
|
state_class="measurement",
|
||||||
options=('normal', 'wash', 'replace'),
|
icon="mdi:air-filter",
|
||||||
translation_key='filter_status',
|
entity_category="diagnostic",
|
||||||
icon='mdi:air-filter', entity_category='diagnostic',
|
),
|
||||||
value_fn=lambda v: v.lower() if isinstance(v, str) else v),
|
SensorDesc(
|
||||||
|
key="hepa_filter_status",
|
||||||
|
field="x.com.samsung.da.filterStatus",
|
||||||
|
device_class="enum",
|
||||||
|
options=("normal", "wash", "replace"),
|
||||||
|
translation_key="filter_status",
|
||||||
|
icon="mdi:air-filter",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
value_fn=lambda v: v.lower() if isinstance(v, str) else v,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -353,27 +408,35 @@ HEPA_FILTER = Capability(
|
|||||||
# supportedStatus list is present to check against -- exposed as a plain
|
# supportedStatus list is present to check against -- exposed as a plain
|
||||||
# diagnostic sensor rather than an asserted binary_sensor polarity.
|
# diagnostic sensor rather than an asserted binary_sensor polarity.
|
||||||
PANEL_STATUS = Capability(
|
PANEL_STATUS = Capability(
|
||||||
href='/panel/vs/0',
|
href="/panel/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='panel_status', field='status',
|
SensorDesc(
|
||||||
icon='mdi:archive-outline', entity_category='diagnostic'),
|
key="panel_status",
|
||||||
|
field="status",
|
||||||
|
icon="mdi:archive-outline",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Pet-care filter mode -- a plain On/Off field with no vendor prefix, same
|
# Pet-care filter mode -- a plain On/Off field with no vendor prefix, same
|
||||||
# convention as airconditioner.MUTE_ONCE.
|
# convention as airconditioner.MUTE_ONCE.
|
||||||
PET_FILTER_ACTIVATION = Capability(
|
PET_FILTER_ACTIVATION = Capability(
|
||||||
href='/petfilteractivation/vs/0',
|
href="/petfilteractivation/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
SwitchDesc(key='pet_filter_activation', field='status',
|
SwitchDesc(
|
||||||
icon='mdi:paw',
|
key="pet_filter_activation",
|
||||||
entity_category='config',
|
field="status",
|
||||||
value_fn=lambda v: v == 'On',
|
icon="mdi:paw",
|
||||||
write_fn=lambda p, rep, href=None: (
|
entity_category="config",
|
||||||
['petfilteractivation', 'vs', '0'],
|
value_fn=lambda v: v == "On",
|
||||||
{'status': 'On' if p == 'On' else 'Off'})),
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["petfilteractivation", "vs", "0"],
|
||||||
|
{"status": "On" if p == "On" else "Off"},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -385,49 +448,62 @@ PET_FILTER_ACTIVATION = Capability(
|
|||||||
# separate descriptors reading the live supported values instead of a
|
# separate descriptors reading the live supported values instead of a
|
||||||
# hardcoded table.
|
# hardcoded table.
|
||||||
SOUND_MODE = Capability(
|
SOUND_MODE = Capability(
|
||||||
href='/settings/sound/mode/vs/0',
|
href="/settings/sound/mode/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
# Distinct translation_key from laundry.SOUND_MODE's shared
|
# Distinct translation_key from laundry.SOUND_MODE's shared
|
||||||
# 'sound_mode' catalog entry -- that one's state table is
|
# 'sound_mode' catalog entry -- that one's state table is
|
||||||
# {voice, tone, mute}, but this board's supportedModes is
|
# {voice, tone, mute}, but this board's supportedModes is
|
||||||
# {mute, buzzer}. Sharing the key would leave 'buzzer' unlabelled
|
# {mute, buzzer}. Sharing the key would leave 'buzzer' unlabelled
|
||||||
# (falls through to the raw code) since the catalogs don't overlap.
|
# (falls through to the raw code) since the catalogs don't overlap.
|
||||||
SelectDesc(key='sound_mode', translation_key='air_purifier_sound_mode',
|
SelectDesc(
|
||||||
field='mode',
|
key="sound_mode",
|
||||||
icon='mdi:volume-high',
|
translation_key="air_purifier_sound_mode",
|
||||||
entity_category='config',
|
field="mode",
|
||||||
options_field='supportedModes',
|
icon="mdi:volume-high",
|
||||||
write_fn=lambda p, rep, href=None: (
|
entity_category="config",
|
||||||
['settings', 'sound', 'mode', 'vs', '0'], {'mode': p})),
|
options_field="supportedModes",
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["settings", "sound", "mode", "vs", "0"],
|
||||||
|
{"mode": p},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Read-only descriptor of which sound output the unit has -- only one value
|
# Read-only descriptor of which sound output the unit has -- only one value
|
||||||
# seen, no alternatives to select between.
|
# seen, no alternatives to select between.
|
||||||
SOUND_OUTPUT = Capability(
|
SOUND_OUTPUT = Capability(
|
||||||
href='/settings/sound/output/vs/0',
|
href="/settings/sound/output/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='sound_output', field='deviceType',
|
SensorDesc(
|
||||||
icon='mdi:volume-high', entity_category='diagnostic'),
|
key="sound_output",
|
||||||
|
field="deviceType",
|
||||||
|
icon="mdi:volume-high",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
SOUND_VOLUME = Capability(
|
SOUND_VOLUME = Capability(
|
||||||
href='/settings/sound/volume/vs/0',
|
href="/settings/sound/volume/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
NumberDesc(key='sound_volume', field='level',
|
NumberDesc(
|
||||||
icon='mdi:volume-medium',
|
key="sound_volume",
|
||||||
entity_category='config',
|
field="level",
|
||||||
native_min_fn=lambda rep: int_or_none(rep.get('minLevel')) or 0,
|
icon="mdi:volume-medium",
|
||||||
native_max_fn=lambda rep: int_or_none(rep.get('maxLevel')) or 0,
|
entity_category="config",
|
||||||
step_fn=lambda rep: int_or_none(rep.get('resolution')) or 1,
|
native_min_fn=lambda rep: int_or_none(rep.get("minLevel")) or 0,
|
||||||
value_fn=int_or_none,
|
native_max_fn=lambda rep: int_or_none(rep.get("maxLevel")) or 0,
|
||||||
write_fn=lambda p, rep, href=None: (
|
step_fn=lambda rep: int_or_none(rep.get("resolution")) or 1,
|
||||||
['settings', 'sound', 'volume', 'vs', '0'],
|
value_fn=int_or_none,
|
||||||
{'level': str(int(p))})),
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["settings", "sound", "volume", "vs", "0"],
|
||||||
|
{"level": str(int(p))},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -444,22 +520,22 @@ SOUND_VOLUME = Capability(
|
|||||||
# colliding with a family-local bare Capability on the same href raises in
|
# colliding with a family-local bare Capability on the same href raises in
|
||||||
# _build()); left as a possible follow-up DRY cleanup.
|
# _build()); left as a possible follow-up DRY cleanup.
|
||||||
COVERAGE = [
|
COVERAGE = [
|
||||||
Capability(href='/humidity/0'),
|
Capability(href="/humidity/0"),
|
||||||
Capability(href='/humidity/vs/0'),
|
Capability(href="/humidity/vs/0"),
|
||||||
Capability(href='/airlevelcheck/vs/0'), # periodic air-quality sensing scheduler plumbing
|
Capability(href="/airlevelcheck/vs/0"), # periodic air-quality sensing scheduler plumbing
|
||||||
Capability(href='/availablecontrolsets/vs/0'), # opaque hex-encoded control-set bitmap
|
Capability(href="/availablecontrolsets/vs/0"), # opaque hex-encoded control-set bitmap
|
||||||
Capability(href='/da/softreset/vs/0'), # soft-reset trigger plumbing
|
Capability(href="/da/softreset/vs/0"), # soft-reset trigger plumbing
|
||||||
Capability(href='/keepnormalstate/vs/0'), # internal keep-normal flag
|
Capability(href="/keepnormalstate/vs/0"), # internal keep-normal flag
|
||||||
Capability(href='/personality/presence/vs/0'), # presence-personalization plumbing (empty here)
|
Capability(href="/personality/presence/vs/0"), # presence-personalization plumbing (empty here)
|
||||||
Capability(href='/reserverulesets/vs/0'), # opaque hex-encoded schedule reservation blob
|
Capability(href="/reserverulesets/vs/0"), # opaque hex-encoded schedule reservation blob
|
||||||
# Do-not-disturb/auto-sleep schedule (visible/startTime/endTime/
|
# Do-not-disturb/auto-sleep schedule (visible/startTime/endTime/
|
||||||
# useTimeSetting/functionState) -- every field reads its inert default
|
# useTimeSetting/functionState) -- every field reads its inert default
|
||||||
# on the only dump seen (times both '00:00:00', useTimeSetting/
|
# on the only dump seen (times both '00:00:00', useTimeSetting/
|
||||||
# functionState both 'false'). Same "needs a multi-field schedule
|
# functionState both 'false'). Same "needs a multi-field schedule
|
||||||
# editor" treatment as fridge.py's /defrost/reservation/vs/0.
|
# editor" treatment as fridge.py's /defrost/reservation/vs/0.
|
||||||
Capability(href='/dnd/autosleep/vs/0'),
|
Capability(href="/dnd/autosleep/vs/0"),
|
||||||
# Empty ({}) on the A-VTWW-TP2-21 dump (issue #151) -- this board's
|
# Empty ({}) on the A-VTWW-TP2-21 dump (issue #151) -- this board's
|
||||||
# convenient-mode-equivalent behavior lives entirely in WIND_STRENGTH_FAN
|
# convenient-mode-equivalent behavior lives entirely in WIND_STRENGTH_FAN
|
||||||
# above instead.
|
# above instead.
|
||||||
Capability(href='/mode/convenient/vs/0'),
|
Capability(href="/mode/convenient/vs/0"),
|
||||||
]
|
]
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -10,12 +10,17 @@ against live device dumps:
|
|||||||
/water/consumption/vs/0 -> x.com.samsung.da.cumulativeWater
|
/water/consumption/vs/0 -> x.com.samsung.da.cumulativeWater
|
||||||
/filter/waterfilter/vs/0 -> x.com.samsung.da.filterUsage / filterStatus
|
/filter/waterfilter/vs/0 -> x.com.samsung.da.filterUsage / filterStatus
|
||||||
"""
|
"""
|
||||||
from datetime import datetime, timezone
|
|
||||||
|
from datetime import UTC, datetime
|
||||||
|
|
||||||
from ..batch import is_stub_rep
|
from ..batch import is_stub_rep
|
||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
from ..entities import (
|
from ..entities import (
|
||||||
BinarySensorDesc, ButtonDesc, SelectDesc, SensorDesc, SwitchDesc,
|
BinarySensorDesc,
|
||||||
|
ButtonDesc,
|
||||||
|
SelectDesc,
|
||||||
|
SensorDesc,
|
||||||
|
SwitchDesc,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -56,7 +61,7 @@ def parse_iso_utc(raw):
|
|||||||
dt = datetime.fromisoformat(raw)
|
dt = datetime.fromisoformat(raw)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return None
|
return None
|
||||||
return dt if dt.tzinfo is not None else dt.replace(tzinfo=timezone.utc)
|
return dt if dt.tzinfo is not None else dt.replace(tzinfo=UTC)
|
||||||
|
|
||||||
|
|
||||||
def filter_usage_percent(rep):
|
def filter_usage_percent(rep):
|
||||||
@@ -65,23 +70,23 @@ def filter_usage_percent(rep):
|
|||||||
`filterCapacityUnit` (Hours, e.g. 100 of a 500 capacity), so a plain
|
`filterCapacityUnit` (Hours, e.g. 100 of a 500 capacity), so a plain
|
||||||
value with a '%' unit would be wrong -- normalize to used/capacity.
|
value with a '%' unit would be wrong -- normalize to used/capacity.
|
||||||
Returns None when capacity is missing/zero."""
|
Returns None when capacity is missing/zero."""
|
||||||
used = _num(rep.get('x.com.samsung.da.filterUsage'))
|
used = _num(rep.get("x.com.samsung.da.filterUsage"))
|
||||||
cap = _num(rep.get('x.com.samsung.da.filterCapacity'))
|
cap = _num(rep.get("x.com.samsung.da.filterCapacity"))
|
||||||
if used is None or not cap:
|
if used is None or not cap:
|
||||||
return None
|
return None
|
||||||
return round(used / cap * 100)
|
return round(used / cap * 100)
|
||||||
|
|
||||||
|
|
||||||
def normalize_temp_unit(raw, default='°F'):
|
def normalize_temp_unit(raw, default="°F"):
|
||||||
"""'C'/'Celsius' -> '°C', 'F'/'Fahrenheit' -> '°F'. Falls back to
|
"""'C'/'Celsius' -> '°C', 'F'/'Fahrenheit' -> '°F'. Falls back to
|
||||||
`default` for any other/missing value. Shared by fridge.py and oven.py,
|
`default` for any other/missing value. Shared by fridge.py and oven.py,
|
||||||
both of which read a per-device unit off a `/temperature*` resource
|
both of which read a per-device unit off a `/temperature*` resource
|
||||||
instead of assuming one (see fridge.py's module docstring, issue #7)."""
|
instead of assuming one (see fridge.py's module docstring, issue #7)."""
|
||||||
raw = (raw or '').strip().upper()
|
raw = (raw or "").strip().upper()
|
||||||
if raw.startswith('C'):
|
if raw.startswith("C"):
|
||||||
return '°C'
|
return "°C"
|
||||||
if raw.startswith('F'):
|
if raw.startswith("F"):
|
||||||
return '°F'
|
return "°F"
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
|
||||||
@@ -112,15 +117,15 @@ def _active_alarm_codes(items):
|
|||||||
the same rule to the whole '_OFF' suffix convention.
|
the same rule to the whole '_OFF' suffix convention.
|
||||||
"""
|
"""
|
||||||
if not items or not isinstance(items, list):
|
if not items or not isinstance(items, list):
|
||||||
return 'none'
|
return "none"
|
||||||
codes = [
|
codes = [
|
||||||
i.get('x.com.samsung.da.code')
|
i.get("x.com.samsung.da.code")
|
||||||
for i in items
|
for i in items
|
||||||
if i.get('x.com.samsung.da.code')
|
if i.get("x.com.samsung.da.code")
|
||||||
and str(i.get('x.com.samsung.da.state', '')).lower() != 'deleted'
|
and str(i.get("x.com.samsung.da.state", "")).lower() != "deleted"
|
||||||
and not str(i.get('x.com.samsung.da.code', '')).lower().endswith('_off')
|
and not str(i.get("x.com.samsung.da.code", "")).lower().endswith("_off")
|
||||||
]
|
]
|
||||||
return ', '.join(codes) if codes else 'none'
|
return ", ".join(codes) if codes else "none"
|
||||||
|
|
||||||
|
|
||||||
def merge_options_field(cached, new_tokens):
|
def merge_options_field(cached, new_tokens):
|
||||||
@@ -137,12 +142,12 @@ def merge_options_field(cached, new_tokens):
|
|||||||
body it applies straight to the cache no longer carries them."""
|
body it applies straight to the cache no longer carries them."""
|
||||||
merged = list(cached or [])
|
merged = list(cached or [])
|
||||||
for token in new_tokens or ():
|
for token in new_tokens or ():
|
||||||
if not isinstance(token, str) or '_' not in token:
|
if not isinstance(token, str) or "_" not in token:
|
||||||
continue
|
continue
|
||||||
prefix = token.split('_', 1)[0]
|
prefix = token.split("_", 1)[0]
|
||||||
replaced = False
|
replaced = False
|
||||||
for i, o in enumerate(merged):
|
for i, o in enumerate(merged):
|
||||||
if isinstance(o, str) and o.startswith(prefix + '_'):
|
if isinstance(o, str) and o.startswith(prefix + "_"):
|
||||||
merged[i] = token
|
merged[i] = token
|
||||||
replaced = True
|
replaced = True
|
||||||
if not replaced:
|
if not replaced:
|
||||||
@@ -168,9 +173,9 @@ def merge_items_field(cached, new_items):
|
|||||||
for new_item in new_items or ():
|
for new_item in new_items or ():
|
||||||
if not isinstance(new_item, dict):
|
if not isinstance(new_item, dict):
|
||||||
continue
|
continue
|
||||||
item_id = new_item.get('x.com.samsung.da.id')
|
item_id = new_item.get("x.com.samsung.da.id")
|
||||||
for i, existing in enumerate(merged):
|
for i, existing in enumerate(merged):
|
||||||
if isinstance(existing, dict) and existing.get('x.com.samsung.da.id') == item_id:
|
if isinstance(existing, dict) and existing.get("x.com.samsung.da.id") == item_id:
|
||||||
merged[i] = {**existing, **new_item}
|
merged[i] = {**existing, **new_item}
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
@@ -182,9 +187,9 @@ def merge_items_field(cached, new_items):
|
|||||||
# washers, dryers, and dishwashers; absent on fridge/oven/AC. Static for the
|
# washers, dryers, and dishwashers; absent on fridge/oven/AC. Static for the
|
||||||
# life of a given board, so reading them from the /device/0 seed (no dedicated
|
# life of a given board, so reading them from the /device/0 seed (no dedicated
|
||||||
# poll_tier) is enough.
|
# poll_tier) is enough.
|
||||||
_SETINFO_HREF = '/wm/setinfo/vs/0'
|
_SETINFO_HREF = "/wm/setinfo/vs/0"
|
||||||
_POWER_ON_OFF_FIELD = 'x.com.samsung.da.isModelSettingPowerOnOff'
|
_POWER_ON_OFF_FIELD = "x.com.samsung.da.isModelSettingPowerOnOff"
|
||||||
_WITHOUT_SC_FIELD = 'x.com.samsung.da.isModelSettingWithoutSC'
|
_WITHOUT_SC_FIELD = "x.com.samsung.da.isModelSettingWithoutSC"
|
||||||
|
|
||||||
|
|
||||||
def model_allows_power_on_off(resources: dict) -> bool:
|
def model_allows_power_on_off(resources: dict) -> bool:
|
||||||
@@ -201,7 +206,7 @@ def model_allows_power_on_off(resources: dict) -> bool:
|
|||||||
flag = setinfo.get(_POWER_ON_OFF_FIELD)
|
flag = setinfo.get(_POWER_ON_OFF_FIELD)
|
||||||
if flag is None:
|
if flag is None:
|
||||||
return True
|
return True
|
||||||
return str(flag).lower() != 'false'
|
return str(flag).lower() != "false"
|
||||||
|
|
||||||
|
|
||||||
def model_setting_without_sc(resources: dict) -> bool:
|
def model_setting_without_sc(resources: dict) -> bool:
|
||||||
@@ -213,7 +218,7 @@ def model_setting_without_sc(resources: dict) -> bool:
|
|||||||
the flag name is settings-specific, not a blanket remote-control bypass.
|
the flag name is settings-specific, not a blanket remote-control bypass.
|
||||||
"""
|
"""
|
||||||
setinfo = resources.get(_SETINFO_HREF) or {}
|
setinfo = resources.get(_SETINFO_HREF) or {}
|
||||||
return str(setinfo.get(_WITHOUT_SC_FIELD, '')).lower() == 'true'
|
return str(setinfo.get(_WITHOUT_SC_FIELD, "")).lower() == "true"
|
||||||
|
|
||||||
|
|
||||||
def _power_switch_exists(rep, resources):
|
def _power_switch_exists(rep, resources):
|
||||||
@@ -228,14 +233,15 @@ def sensor_item_value(items, sensor_type, index=0):
|
|||||||
"""Pull one reading out of a `/sensors/vs/0`-style items[] list -- each
|
"""Pull one reading out of a `/sensors/vs/0`-style items[] list -- each
|
||||||
item is `{type, value: [...]}`; `index` picks which slot of a possibly
|
item is `{type, value: [...]}`; `index` picks which slot of a possibly
|
||||||
multi-value reading to read (index 0 is the raw measurement on every
|
multi-value reading to read (index 0 is the raw measurement on every
|
||||||
family seen so far). Shared by range_hood.AIR_QUALITY and
|
family seen so far). Shared by range_hood.AIR_QUALITY,
|
||||||
air_purifier.AIR_QUALITY, which read the same resource shape."""
|
air_purifier.AIR_QUALITY, and air_monitor.SENSORS, which all read the
|
||||||
|
same resource shape against the same {type, sensor_type} keys."""
|
||||||
for item in items or ():
|
for item in items or ():
|
||||||
if not isinstance(item, dict):
|
if not isinstance(item, dict):
|
||||||
continue
|
continue
|
||||||
if item.get('x.com.samsung.da.type') != sensor_type:
|
if item.get("x.com.samsung.da.type") != sensor_type:
|
||||||
continue
|
continue
|
||||||
values = item.get('x.com.samsung.da.value') or ()
|
values = item.get("x.com.samsung.da.value") or []
|
||||||
if index < len(values):
|
if index < len(values):
|
||||||
try:
|
try:
|
||||||
return int(values[index])
|
return int(values[index])
|
||||||
@@ -258,67 +264,97 @@ def sensor_item_value(items, sensor_type, index=0):
|
|||||||
# choice. Every device registry lists both caps of each pair.
|
# choice. Every device registry lists both caps of each pair.
|
||||||
|
|
||||||
POWER_GENERIC = Capability(
|
POWER_GENERIC = Capability(
|
||||||
href='/power/0',
|
href="/power/0",
|
||||||
# Neither href of this pair carried a poll_tier before (issue #56's
|
# Neither href of this pair carried a poll_tier before (issue #56's
|
||||||
# follow-up), so power state only ever refreshed on the once-per-30s
|
# follow-up), so power state only ever refreshed on the once-per-30s
|
||||||
# summary poll instead of the subscribe/subpoll cadence 'warm' and 'hot'
|
# summary poll instead of the subscribe/subpoll cadence 'warm' and 'hot'
|
||||||
# hrefs get -- the same "signal drives real-time state, but sat in the
|
# hrefs get -- the same "signal drives real-time state, but sat in the
|
||||||
# slow default tier" gap as REMOTE_CONTROL_GENERIC/VS_FALLBACK above.
|
# slow default tier" gap as REMOTE_CONTROL_GENERIC/VS_FALLBACK above.
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
# Writable when firmware allows remote power; otherwise a read-only
|
# Writable when firmware allows remote power; otherwise a read-only
|
||||||
# binary_sensor with the same key keeps HA state without a dead switch.
|
# binary_sensor with the same key keeps HA state without a dead switch.
|
||||||
SwitchDesc(key='power_switch', field='value',
|
SwitchDesc(
|
||||||
value_fn=lambda v: bool(v),
|
key="power_switch",
|
||||||
exists_fn=_power_switch_exists,
|
field="value",
|
||||||
write_fn=lambda p, rep, href=None: (
|
value_fn=lambda v: bool(v),
|
||||||
['power', '0'], {'value': p == 'On'})),
|
exists_fn=_power_switch_exists,
|
||||||
BinarySensorDesc(key='power_switch', field='value',
|
write_fn=lambda p, rep, href=None: (["power", "0"], {"value": p == "On"}),
|
||||||
device_class='power',
|
),
|
||||||
value_fn=lambda v: bool(v),
|
BinarySensorDesc(
|
||||||
exists_fn=_power_sensor_exists),
|
key="power_switch",
|
||||||
|
field="value",
|
||||||
|
device_class="power",
|
||||||
|
value_fn=lambda v: bool(v),
|
||||||
|
exists_fn=_power_sensor_exists,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
POWER_VS_FALLBACK = Capability(
|
POWER_VS_FALLBACK = Capability(
|
||||||
href='/power/vs/0',
|
href="/power/vs/0",
|
||||||
match_fn=lambda rep, resources: '/power/0' not in resources,
|
match_fn=lambda rep, resources: "/power/0" not in resources,
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
SwitchDesc(key='power_switch', field='x.com.samsung.da.power',
|
SwitchDesc(
|
||||||
value_fn=lambda v: v == 'On',
|
key="power_switch",
|
||||||
exists_fn=_power_switch_exists,
|
field="x.com.samsung.da.power",
|
||||||
write_fn=lambda p, rep, href=None: (
|
value_fn=lambda v: v == "On",
|
||||||
['power', 'vs', '0'],
|
exists_fn=_power_switch_exists,
|
||||||
{'x.com.samsung.da.power': 'On' if p == 'On' else 'Off'})),
|
write_fn=lambda p, rep, href=None: (
|
||||||
BinarySensorDesc(key='power_switch', field='x.com.samsung.da.power',
|
["power", "vs", "0"],
|
||||||
device_class='power',
|
{"x.com.samsung.da.power": "On" if p == "On" else "Off"},
|
||||||
value_fn=lambda v: v == 'On',
|
),
|
||||||
exists_fn=_power_sensor_exists),
|
),
|
||||||
|
BinarySensorDesc(
|
||||||
|
key="power_switch",
|
||||||
|
field="x.com.samsung.da.power",
|
||||||
|
device_class="power",
|
||||||
|
value_fn=lambda v: v == "On",
|
||||||
|
exists_fn=_power_sensor_exists,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
KIDS_LOCK_GENERIC = Capability(
|
KIDS_LOCK_GENERIC = Capability(
|
||||||
href='/kidslock/0',
|
href="/kidslock/0",
|
||||||
entities=(
|
entities=(
|
||||||
SwitchDesc(key='child_lock', field='value',
|
# Read-only like KIDS_LOCK_VS_FALLBACK (issues #181/#183) -- not a
|
||||||
device_class='lock',
|
# SwitchDesc. SwitchDesc's `device_class='lock'` was never honored
|
||||||
value_fn=lambda v: bool(v),
|
# by HA (its switch platform only accepts 'outlet'/'switch'),
|
||||||
write_fn=lambda p, rep, href=None: (
|
# leaving a plain switch whose 'On' state meant different things
|
||||||
['kidslock', '0'], {'value': p == 'On'})),
|
# on different boards. As a BinarySensorDesc with `device_class='lock'`,
|
||||||
|
# both kids-lock surfaces read with the same polarity: 'On' means
|
||||||
|
# open/unlocked, per HA's lock device_class. The inversion in
|
||||||
|
# value_fn here (and in the fallback below) keeps the on-the-wire
|
||||||
|
# truth (value=False on /kidslock/0, kidsLock='Ready' on /kidslock/vs/0
|
||||||
|
# both mean kids lock NOT active) consistent with that polarity.
|
||||||
|
BinarySensorDesc(
|
||||||
|
key="child_lock", field="value", device_class="lock", value_fn=lambda v: not bool(v)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
KIDS_LOCK_VS_FALLBACK = Capability(
|
KIDS_LOCK_VS_FALLBACK = Capability(
|
||||||
href='/kidslock/vs/0',
|
href="/kidslock/vs/0",
|
||||||
match_fn=lambda rep, resources: '/kidslock/0' not in resources,
|
match_fn=lambda rep, resources: "/kidslock/0" not in resources,
|
||||||
entities=(
|
entities=(
|
||||||
SwitchDesc(key='child_lock', field='x.com.samsung.da.kidsLock',
|
# Read-only, not a SwitchDesc (issues #181/#183): the write side of
|
||||||
device_class='lock',
|
# this capability wrote 'Enable', a value no dump in the fixture
|
||||||
value_fn=lambda v: v != 'Ready',
|
# corpus has ever reported back -- every one reports either 'Ready'
|
||||||
write_fn=lambda p, rep, href=None: (
|
# or 'Run', so it was never a confirmed contract. #181's reporter
|
||||||
['kidslock', 'vs', '0'],
|
# confirmed this directly: writing the *correct* value ('Run')
|
||||||
{'x.com.samsung.da.kidsLock': 'Enable' if p == 'On' else 'Ready'})),
|
# still 4.05s, and the SmartThings app itself has no control for
|
||||||
|
# it either -- the resource is genuinely read-only on this
|
||||||
|
# hardware, not just wrong-valued. Polarity matches
|
||||||
|
# KIDS_LOCK_GENERIC above -- 'On' means open/unlocked, so
|
||||||
|
# kidsLock='Ready' (kids lock NOT active) renders as 'On'.
|
||||||
|
BinarySensorDesc(
|
||||||
|
key="child_lock",
|
||||||
|
field="x.com.samsung.da.kidsLock",
|
||||||
|
device_class="lock",
|
||||||
|
value_fn=lambda v: v == "Ready",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -334,12 +370,12 @@ def remote_control_enabled(resources: dict) -> bool:
|
|||||||
once-per-30s cold summary poll. True (assume enabled) when neither
|
once-per-30s cold summary poll. True (assume enabled) when neither
|
||||||
href is present -- most device types don't report this capability
|
href is present -- most device types don't report this capability
|
||||||
at all."""
|
at all."""
|
||||||
generic = resources.get('/remotectrl/0')
|
generic = resources.get("/remotectrl/0")
|
||||||
if generic is not None:
|
if generic is not None:
|
||||||
return bool(generic.get('value'))
|
return bool(generic.get("value"))
|
||||||
fallback = resources.get('/remotectrl/vs/0')
|
fallback = resources.get("/remotectrl/vs/0")
|
||||||
if fallback is not None:
|
if fallback is not None:
|
||||||
return str(fallback.get('x.com.samsung.da.remoteControlEnabled')).lower() == 'true'
|
return str(fallback.get("x.com.samsung.da.remoteControlEnabled")).lower() == "true"
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@@ -353,39 +389,48 @@ def remote_control_required_for_write(resources: dict, bound_href: str) -> bool:
|
|||||||
"""
|
"""
|
||||||
if not model_setting_without_sc(resources):
|
if not model_setting_without_sc(resources):
|
||||||
return True
|
return True
|
||||||
href = bound_href or ''
|
href = bound_href or ""
|
||||||
return href.startswith('/operational/state')
|
return href.startswith("/operational/state")
|
||||||
|
|
||||||
|
|
||||||
REMOTE_CONTROL_GENERIC = Capability(
|
REMOTE_CONTROL_GENERIC = Capability(
|
||||||
href='/remotectrl/0',
|
href="/remotectrl/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
BinarySensorDesc(key='remote_control', field='value',
|
BinarySensorDesc(
|
||||||
device_class='connectivity',
|
key="remote_control",
|
||||||
value_fn=lambda v: bool(v)),
|
field="value",
|
||||||
|
device_class="connectivity",
|
||||||
|
value_fn=lambda v: bool(v),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
REMOTE_CONTROL_VS_FALLBACK = Capability(
|
REMOTE_CONTROL_VS_FALLBACK = Capability(
|
||||||
href='/remotectrl/vs/0',
|
href="/remotectrl/vs/0",
|
||||||
match_fn=lambda rep, resources: '/remotectrl/0' not in resources,
|
match_fn=lambda rep, resources: "/remotectrl/0" not in resources,
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
BinarySensorDesc(key='remote_control',
|
BinarySensorDesc(
|
||||||
field='x.com.samsung.da.remoteControlEnabled',
|
key="remote_control",
|
||||||
device_class='connectivity',
|
field="x.com.samsung.da.remoteControlEnabled",
|
||||||
value_fn=lambda v: str(v).lower() == 'true'),
|
device_class="connectivity",
|
||||||
|
value_fn=lambda v: str(v).lower() == "true",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
ALARMS = Capability(
|
ALARMS = Capability(
|
||||||
href='/alarms/vs/0',
|
href="/alarms/vs/0",
|
||||||
poll_tier='hot',
|
poll_tier="hot",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='alarm_code', field='x.com.samsung.da.items',
|
SensorDesc(
|
||||||
icon='mdi:alert',
|
key="alarm_code",
|
||||||
entity_category='diagnostic', value_fn=_active_alarm_codes),
|
field="x.com.samsung.da.items",
|
||||||
|
icon="mdi:alert",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
value_fn=_active_alarm_codes,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -397,10 +442,10 @@ ALARMS = Capability(
|
|||||||
# fridge's 93 W) still shows it (issue #6). cumulativePower is absent on at
|
# fridge's 93 W) still shows it (issue #6). cumulativePower is absent on at
|
||||||
# least one washer model; the exists_fn makes that explicit rather than relying
|
# least one washer model; the exists_fn makes that explicit rather than relying
|
||||||
# on the generic field-presence gate.
|
# on the generic field-presence gate.
|
||||||
_DEAD_INSTANTANEOUS_POWER = '-500'
|
_DEAD_INSTANTANEOUS_POWER = "-500"
|
||||||
|
|
||||||
ENERGY_METER = Capability(
|
ENERGY_METER = Capability(
|
||||||
href='/energy/consumption/vs/0',
|
href="/energy/consumption/vs/0",
|
||||||
entities=(
|
entities=(
|
||||||
# `is_stub_rep(rep)` keeps the stub carve-out (see entity._is_included):
|
# `is_stub_rep(rep)` keeps the stub carve-out (see entity._is_included):
|
||||||
# an explicit exists_fn otherwise bypasses it, which would drop the
|
# an explicit exists_fn otherwise bypasses it, which would drop the
|
||||||
@@ -409,75 +454,123 @@ ENERGY_METER = Capability(
|
|||||||
# answer, so it falls through to the normal field/sentinel checks like
|
# answer, so it falls through to the normal field/sentinel checks like
|
||||||
# any populated rep. On a populated rep, hide power only for the dead
|
# any populated rep. On a populated rep, hide power only for the dead
|
||||||
# sentinel or an absent field.
|
# sentinel or an absent field.
|
||||||
SensorDesc(key='power_watts', field='x.com.samsung.da.instantaneousPower',
|
SensorDesc(
|
||||||
device_class='power', state_class='measurement',
|
key="power_watts",
|
||||||
unit='W', value_fn=clamp_power,
|
field="x.com.samsung.da.instantaneousPower",
|
||||||
exists_fn=lambda rep, resources: is_stub_rep(rep) or (
|
device_class="power",
|
||||||
rep.get('x.com.samsung.da.instantaneousPower')
|
state_class="measurement",
|
||||||
not in (None, _DEAD_INSTANTANEOUS_POWER))),
|
unit="W",
|
||||||
SensorDesc(key='energy_kwh', field='x.com.samsung.da.cumulativePower',
|
value_fn=clamp_power,
|
||||||
device_class='energy',
|
exists_fn=lambda rep, resources: (
|
||||||
state_class='total_increasing', unit='kWh', value_fn=wh_to_kwh,
|
is_stub_rep(rep)
|
||||||
exists_fn=lambda rep, resources: (
|
or (
|
||||||
is_stub_rep(rep) or 'x.com.samsung.da.cumulativePower' in rep)),
|
rep.get("x.com.samsung.da.instantaneousPower")
|
||||||
|
not in (None, _DEAD_INSTANTANEOUS_POWER)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="energy_kwh",
|
||||||
|
field="x.com.samsung.da.cumulativePower",
|
||||||
|
device_class="energy",
|
||||||
|
state_class="total_increasing",
|
||||||
|
unit="kWh",
|
||||||
|
value_fn=wh_to_kwh,
|
||||||
|
exists_fn=lambda rep, resources: (
|
||||||
|
is_stub_rep(rep) or "x.com.samsung.da.cumulativePower" in rep
|
||||||
|
),
|
||||||
|
),
|
||||||
# cumulativeConsumption is a second, independently-varying running
|
# cumulativeConsumption is a second, independently-varying running
|
||||||
# total alongside cumulativePower -- some fridges (issue #26) report
|
# total alongside cumulativePower -- some fridges (issue #26) report
|
||||||
# both. Self-gates off where only cumulativePower is present. The
|
# both. Self-gates off where only cumulativePower is present. The
|
||||||
# `is_stub_rep(rep) or` keeps the same stub carve-out as power_watts/
|
# `is_stub_rep(rep) or` keeps the same stub carve-out as power_watts/
|
||||||
# energy_kwh above -- without it, an exists_fn permanently drops the
|
# energy_kwh above -- without it, an exists_fn permanently drops the
|
||||||
# entity if setup happens to land on a not-yet-fetched stub.
|
# entity if setup happens to land on a not-yet-fetched stub.
|
||||||
SensorDesc(key='power_energy_kwh', field='x.com.samsung.da.cumulativeConsumption',
|
SensorDesc(
|
||||||
device_class='energy',
|
key="power_energy_kwh",
|
||||||
state_class='total_increasing', unit='kWh', value_fn=wh_to_kwh,
|
field="x.com.samsung.da.cumulativeConsumption",
|
||||||
exists_fn=lambda rep, resources: (
|
device_class="energy",
|
||||||
is_stub_rep(rep) or 'x.com.samsung.da.cumulativeConsumption' in rep)),
|
state_class="total_increasing",
|
||||||
|
unit="kWh",
|
||||||
|
value_fn=wh_to_kwh,
|
||||||
|
exists_fn=lambda rep, resources: (
|
||||||
|
is_stub_rep(rep) or "x.com.samsung.da.cumulativeConsumption" in rep
|
||||||
|
),
|
||||||
|
),
|
||||||
# AI Energy Mode's lifetime savings estimate vs. an unoptimized
|
# AI Energy Mode's lifetime savings estimate vs. an unoptimized
|
||||||
# baseline -- present on some models (e.g. TP1X_REF_21K, issue #21/
|
# baseline -- present on some models (e.g. TP1X_REF_21K, issue #21/
|
||||||
# #27) and absent on others (issue #20/#26), unlike cumulativePower.
|
# #27) and absent on others (issue #20/#26), unlike cumulativePower.
|
||||||
SensorDesc(key='energy_saved_kwh', field='x.com.samsung.da.cumulativeSavedPower',
|
SensorDesc(
|
||||||
device_class='energy',
|
key="energy_saved_kwh",
|
||||||
state_class='total_increasing', unit='kWh', value_fn=wh_to_kwh,
|
field="x.com.samsung.da.cumulativeSavedPower",
|
||||||
exists_fn=lambda rep, resources: (
|
device_class="energy",
|
||||||
is_stub_rep(rep) or 'x.com.samsung.da.cumulativeSavedPower' in rep)),
|
state_class="total_increasing",
|
||||||
|
unit="kWh",
|
||||||
|
value_fn=wh_to_kwh,
|
||||||
|
exists_fn=lambda rep, resources: (
|
||||||
|
is_stub_rep(rep) or "x.com.samsung.da.cumulativeSavedPower" in rep
|
||||||
|
),
|
||||||
|
),
|
||||||
# Monthly billing-cycle totals -- the completed prior month and the
|
# Monthly billing-cycle totals -- the completed prior month and the
|
||||||
# in-progress current month. Not ever-increasing (each resets at
|
# in-progress current month. Not ever-increasing (each resets at
|
||||||
# month boundary), so no state_class.
|
# month boundary), so no state_class.
|
||||||
SensorDesc(key='energy_last_month_kwh', field='x.com.samsung.da.monthlyConsumption',
|
SensorDesc(
|
||||||
device_class='energy',
|
key="energy_last_month_kwh",
|
||||||
unit='kWh', value_fn=wh_to_kwh,
|
field="x.com.samsung.da.monthlyConsumption",
|
||||||
exists_fn=lambda rep, resources: (
|
device_class="energy",
|
||||||
is_stub_rep(rep) or 'x.com.samsung.da.monthlyConsumption' in rep)),
|
unit="kWh",
|
||||||
SensorDesc(key='energy_this_month_kwh', field='x.com.samsung.da.thismonthlyConsumption',
|
value_fn=wh_to_kwh,
|
||||||
device_class='energy',
|
exists_fn=lambda rep, resources: (
|
||||||
unit='kWh', value_fn=wh_to_kwh,
|
is_stub_rep(rep) or "x.com.samsung.da.monthlyConsumption" in rep
|
||||||
exists_fn=lambda rep, resources: (
|
),
|
||||||
is_stub_rep(rep) or 'x.com.samsung.da.thismonthlyConsumption' in rep)),
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="energy_this_month_kwh",
|
||||||
|
field="x.com.samsung.da.thismonthlyConsumption",
|
||||||
|
device_class="energy",
|
||||||
|
unit="kWh",
|
||||||
|
value_fn=wh_to_kwh,
|
||||||
|
exists_fn=lambda rep, resources: (
|
||||||
|
is_stub_rep(rep) or "x.com.samsung.da.thismonthlyConsumption" in rep
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
WATER_METER = Capability(
|
WATER_METER = Capability(
|
||||||
href='/water/consumption/vs/0',
|
href="/water/consumption/vs/0",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='water_liters', field='x.com.samsung.da.cumulativeWater',
|
SensorDesc(
|
||||||
device_class='water',
|
key="water_liters",
|
||||||
state_class='total_increasing', unit='L', icon='mdi:water',
|
field="x.com.samsung.da.cumulativeWater",
|
||||||
value_fn=_ml_to_l),
|
device_class="water",
|
||||||
|
state_class="total_increasing",
|
||||||
|
unit="L",
|
||||||
|
icon="mdi:water",
|
||||||
|
value_fn=_ml_to_l,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
WATER_FILTER = Capability(
|
WATER_FILTER = Capability(
|
||||||
href='/filter/waterfilter/vs/0',
|
href="/filter/waterfilter/vs/0",
|
||||||
match_fn=lambda rep, _: rep.get('x.com.samsung.da.filterStatus', '').lower() != 'notused',
|
match_fn=lambda rep, _: rep.get("x.com.samsung.da.filterStatus", "").lower() != "notused",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='filter_usage', field='x.com.samsung.da.filterUsage',
|
SensorDesc(
|
||||||
unit='%', state_class='measurement',
|
key="filter_usage",
|
||||||
icon='mdi:filter'),
|
field="x.com.samsung.da.filterUsage",
|
||||||
SensorDesc(key='filter_status', field='x.com.samsung.da.filterStatus',
|
unit="%",
|
||||||
icon='mdi:filter-check',
|
state_class="measurement",
|
||||||
device_class='enum', options=('normal', 'wash', 'replace'),
|
icon="mdi:filter",
|
||||||
value_fn=lambda value: (
|
),
|
||||||
value.lower() if isinstance(value, str) else value
|
SensorDesc(
|
||||||
)),
|
key="filter_status",
|
||||||
|
field="x.com.samsung.da.filterStatus",
|
||||||
|
icon="mdi:filter-check",
|
||||||
|
device_class="enum",
|
||||||
|
options=("normal", "wash", "replace"),
|
||||||
|
value_fn=lambda value: value.lower() if isinstance(value, str) else value,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -501,28 +594,28 @@ WATER_FILTER = Capability(
|
|||||||
def _ai_energy_supported_levels(rep):
|
def _ai_energy_supported_levels(rep):
|
||||||
"""supportedAiLevel as a list -- a stray scalar (e.g. a string) must not
|
"""supportedAiLevel as a list -- a stray scalar (e.g. a string) must not
|
||||||
be len()-checked as if it were a list."""
|
be len()-checked as if it were a list."""
|
||||||
sl = rep.get('supportedAiLevel')
|
sl = rep.get("supportedAiLevel")
|
||||||
return list(sl) if isinstance(sl, (list, tuple)) else []
|
return list(sl) if isinstance(sl, (list, tuple)) else []
|
||||||
|
|
||||||
|
|
||||||
def _ai_energy_level_options(resources):
|
def _ai_energy_level_options(resources):
|
||||||
rep = resources.get('/energy/ailevel/vs/0') or {}
|
rep = resources.get("/energy/ailevel/vs/0") or {}
|
||||||
return ['0', *_ai_energy_supported_levels(rep)]
|
return ["0", *_ai_energy_supported_levels(rep)]
|
||||||
|
|
||||||
|
|
||||||
def _ai_energy_level_write(p, rep, href=None):
|
def _ai_energy_level_write(p, rep, href=None):
|
||||||
return ['energy', 'ailevel', 'vs', '0'], {'aiLevel': p}
|
return ["energy", "ailevel", "vs", "0"], {"aiLevel": p}
|
||||||
|
|
||||||
|
|
||||||
def _ai_energy_level_switch_write(p, rep, href=None):
|
def _ai_energy_level_switch_write(p, rep, href=None):
|
||||||
levels = _ai_energy_supported_levels(rep)
|
levels = _ai_energy_supported_levels(rep)
|
||||||
on_level = levels[0] if levels else '1'
|
on_level = levels[0] if levels else "1"
|
||||||
return ['energy', 'ailevel', 'vs', '0'], {'aiLevel': on_level if p == 'On' else '0'}
|
return ["energy", "ailevel", "vs", "0"], {"aiLevel": on_level if p == "On" else "0"}
|
||||||
|
|
||||||
|
|
||||||
AI_ENERGY_LEVEL = Capability(
|
AI_ENERGY_LEVEL = Capability(
|
||||||
href='/energy/ailevel/vs/0',
|
href="/energy/ailevel/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
# No is_stub_rep carve-out on either side, unlike most exists_fn
|
# No is_stub_rep carve-out on either side, unlike most exists_fn
|
||||||
# gates in this file -- entity creation only ever runs once, against
|
# gates in this file -- entity creation only ever runs once, against
|
||||||
@@ -540,60 +633,78 @@ AI_ENERGY_LEVEL = Capability(
|
|||||||
# until a reload if the device's very first poll stubs this
|
# until a reload if the device's very first poll stubs this
|
||||||
# cold-tier href, the same reload already required to fix which
|
# cold-tier href, the same reload already required to fix which
|
||||||
# platform got picked in that case.
|
# platform got picked in that case.
|
||||||
SwitchDesc(key='ai_energy_level', field='aiLevel',
|
SwitchDesc(
|
||||||
icon='mdi:leaf',
|
key="ai_energy_level",
|
||||||
entity_category='config',
|
field="aiLevel",
|
||||||
value_fn=lambda v: v != '0',
|
icon="mdi:leaf",
|
||||||
exists_fn=lambda rep, resources: (
|
entity_category="config",
|
||||||
len(_ai_energy_supported_levels(rep)) == 1),
|
value_fn=lambda v: v != "0",
|
||||||
write_fn=_ai_energy_level_switch_write),
|
exists_fn=lambda rep, resources: len(_ai_energy_supported_levels(rep)) == 1,
|
||||||
SelectDesc(key='ai_energy_level', field='aiLevel',
|
write_fn=_ai_energy_level_switch_write,
|
||||||
icon='mdi:leaf',
|
),
|
||||||
entity_category='config',
|
SelectDesc(
|
||||||
options=_ai_energy_level_options,
|
key="ai_energy_level",
|
||||||
exists_fn=lambda rep, resources: (
|
field="aiLevel",
|
||||||
len(_ai_energy_supported_levels(rep)) > 1),
|
icon="mdi:leaf",
|
||||||
write_fn=_ai_energy_level_write),
|
entity_category="config",
|
||||||
|
options=_ai_energy_level_options,
|
||||||
|
exists_fn=lambda rep, resources: len(_ai_energy_supported_levels(rep)) > 1,
|
||||||
|
write_fn=_ai_energy_level_write,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
FIRMWARE_UPDATE = Capability(
|
FIRMWARE_UPDATE = Capability(
|
||||||
href='/otninformation/vs/0',
|
href="/otninformation/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
BinarySensorDesc(
|
BinarySensorDesc(
|
||||||
key='firmware_update',
|
key="firmware_update",
|
||||||
field='x.com.samsung.da.newVersionAvailable',
|
field="x.com.samsung.da.newVersionAvailable",
|
||||||
device_class='update',
|
device_class="update",
|
||||||
entity_category='diagnostic',
|
entity_category="diagnostic",
|
||||||
value_fn=lambda v: str(v).lower() == 'true' if v is not None else None,
|
value_fn=lambda v: str(v).lower() == "true" if v is not None else None,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
SELF_CHECK = Capability(
|
SELF_CHECK = Capability(
|
||||||
href='/selfcheck/vs/0',
|
href="/selfcheck/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='selfcheck_status', field='x.com.samsung.da.status',
|
SensorDesc(
|
||||||
icon='mdi:stethoscope',
|
key="selfcheck_status",
|
||||||
entity_category='diagnostic'),
|
field="x.com.samsung.da.status",
|
||||||
SensorDesc(key='selfcheck_result', field='x.com.samsung.da.result',
|
icon="mdi:stethoscope",
|
||||||
icon='mdi:clipboard-check-outline',
|
entity_category="diagnostic",
|
||||||
entity_category='diagnostic'),
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="selfcheck_result",
|
||||||
|
field="x.com.samsung.da.result",
|
||||||
|
icon="mdi:clipboard-check-outline",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
),
|
||||||
# List of error codes from the last self-check; joined for display.
|
# List of error codes from the last self-check; joined for display.
|
||||||
# Not every fridge reports the field, hence the exists_fn.
|
# Not every fridge reports the field, hence the exists_fn.
|
||||||
SensorDesc(key='selfcheck_error', field='x.com.samsung.da.error',
|
SensorDesc(
|
||||||
icon='mdi:alert-circle-outline',
|
key="selfcheck_error",
|
||||||
entity_category='diagnostic',
|
field="x.com.samsung.da.error",
|
||||||
exists_fn=lambda rep, resources: (
|
icon="mdi:alert-circle-outline",
|
||||||
is_stub_rep(rep) or 'x.com.samsung.da.error' in rep),
|
entity_category="diagnostic",
|
||||||
value_fn=lambda v: (', '.join(v) if v else None) if isinstance(v, list) else v),
|
exists_fn=lambda rep, resources: is_stub_rep(rep) or "x.com.samsung.da.error" in rep,
|
||||||
ButtonDesc(key='selfcheck_start', field='', payload='Start',
|
value_fn=lambda v: (", ".join(v) if v else None) if isinstance(v, list) else v,
|
||||||
icon='mdi:play-circle-outline',
|
),
|
||||||
entity_category='diagnostic',
|
ButtonDesc(
|
||||||
write_fn=lambda p, rep, href=None: (
|
key="selfcheck_start",
|
||||||
['selfcheck', 'vs', '0'], {'x.com.samsung.da.status': p})),
|
field="",
|
||||||
|
payload="Start",
|
||||||
|
icon="mdi:play-circle-outline",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["selfcheck", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.status": p},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -13,16 +13,15 @@ from ..batch import is_stub_rep
|
|||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
from ..entities import BinarySensorDesc, SensorDesc
|
from ..entities import BinarySensorDesc, SensorDesc
|
||||||
|
|
||||||
|
_INACTIVE_OPERATION_STATES = {"Off", "Ready"}
|
||||||
_INACTIVE_OPERATION_STATES = {'Off', 'Ready'}
|
|
||||||
|
|
||||||
|
|
||||||
def _option_value(options, prefix):
|
def _option_value(options, prefix):
|
||||||
"""Return the value from the first ``<prefix>_<value>`` option."""
|
"""Return the value from the first ``<prefix>_<value>`` option."""
|
||||||
marker = prefix + '_'
|
marker = prefix + "_"
|
||||||
for option in options or ():
|
for option in options or ():
|
||||||
if isinstance(option, str) and option.startswith(marker):
|
if isinstance(option, str) and option.startswith(marker):
|
||||||
return option[len(marker):]
|
return option[len(marker) :]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@@ -32,7 +31,7 @@ def _operation_slots(options) -> tuple[int, ...]:
|
|||||||
for option in options or ():
|
for option in options or ():
|
||||||
if not isinstance(option, str):
|
if not isinstance(option, str):
|
||||||
continue
|
continue
|
||||||
match = re.match(r'^OperationState(\d+)_', option)
|
match = re.match(r"^OperationState(\d+)_", option)
|
||||||
if match:
|
if match:
|
||||||
slots.add(int(match.group(1)))
|
slots.add(int(match.group(1)))
|
||||||
return tuple(sorted(slots))
|
return tuple(sorted(slots))
|
||||||
@@ -40,10 +39,7 @@ def _operation_slots(options) -> tuple[int, ...]:
|
|||||||
|
|
||||||
def _any_burner_active(options):
|
def _any_burner_active(options):
|
||||||
"""True when any advertised burner slot is not idle."""
|
"""True when any advertised burner slot is not idle."""
|
||||||
states = [
|
states = [_option_value(options, f"OperationState{slot}") for slot in _operation_slots(options)]
|
||||||
_option_value(options, f'OperationState{slot}')
|
|
||||||
for slot in _operation_slots(options)
|
|
||||||
]
|
|
||||||
states = [state for state in states if state is not None]
|
states = [state for state in states if state is not None]
|
||||||
return any(state not in _INACTIVE_OPERATION_STATES for state in states)
|
return any(state not in _INACTIVE_OPERATION_STATES for state in states)
|
||||||
|
|
||||||
@@ -56,15 +52,15 @@ def _int_or_none(value):
|
|||||||
|
|
||||||
|
|
||||||
COOKTOP_POWER = Capability(
|
COOKTOP_POWER = Capability(
|
||||||
href='/power/vs/0',
|
href="/power/vs/0",
|
||||||
poll_tier='hot',
|
poll_tier="hot",
|
||||||
entities=(
|
entities=(
|
||||||
BinarySensorDesc(
|
BinarySensorDesc(
|
||||||
key='power_state',
|
key="power_state",
|
||||||
field='x.com.samsung.da.power',
|
field="x.com.samsung.da.power",
|
||||||
device_class='power',
|
device_class="power",
|
||||||
icon='mdi:stove',
|
icon="mdi:stove",
|
||||||
value_fn=lambda value: str(value).lower() == 'on',
|
value_fn=lambda value: str(value).lower() == "on",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -77,109 +73,107 @@ COOKTOP_POWER = Capability(
|
|||||||
_SUPPORTED_OPERATION_SLOTS = tuple(range(8))
|
_SUPPORTED_OPERATION_SLOTS = tuple(range(8))
|
||||||
|
|
||||||
COOKTOP_MODE = Capability(
|
COOKTOP_MODE = Capability(
|
||||||
href='/mode/vs/0',
|
href="/mode/vs/0",
|
||||||
poll_tier='hot',
|
poll_tier="hot",
|
||||||
entities=(
|
entities=(
|
||||||
BinarySensorDesc(
|
BinarySensorDesc(
|
||||||
key='any_burner_active',
|
key="any_burner_active",
|
||||||
field='x.com.samsung.da.options',
|
field="x.com.samsung.da.options",
|
||||||
device_class='running',
|
device_class="running",
|
||||||
icon='mdi:fire',
|
icon="mdi:fire",
|
||||||
value_fn=_any_burner_active,
|
value_fn=_any_burner_active,
|
||||||
),
|
),
|
||||||
*(
|
*(
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key=f'burner_{slot}_state',
|
key=f"burner_{slot}_state",
|
||||||
field='x.com.samsung.da.options',
|
field="x.com.samsung.da.options",
|
||||||
translation_key='burner_state',
|
translation_key="burner_state",
|
||||||
translation_placeholders={'number': str(slot)},
|
translation_placeholders={"number": str(slot)},
|
||||||
icon='mdi:gas-burner',
|
icon="mdi:gas-burner",
|
||||||
value_fn=lambda options, slot=slot: _option_value(
|
value_fn=lambda options, slot=slot: _option_value(options, f"OperationState{slot}"),
|
||||||
options, f'OperationState{slot}'
|
|
||||||
),
|
|
||||||
exists_fn=lambda rep, resources, slot=slot: (
|
exists_fn=lambda rep, resources, slot=slot: (
|
||||||
is_stub_rep(rep) or _option_value(
|
is_stub_rep(rep)
|
||||||
rep.get('x.com.samsung.da.options'),
|
or _option_value(
|
||||||
f'OperationState{slot}',
|
rep.get("x.com.samsung.da.options"),
|
||||||
) is not None
|
f"OperationState{slot}",
|
||||||
|
)
|
||||||
|
is not None
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
for slot in _SUPPORTED_OPERATION_SLOTS
|
for slot in _SUPPORTED_OPERATION_SLOTS
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='main_timer_state',
|
key="main_timer_state",
|
||||||
field='x.com.samsung.da.options',
|
field="x.com.samsung.da.options",
|
||||||
icon='mdi:timer-outline',
|
icon="mdi:timer-outline",
|
||||||
value_fn=lambda options: _option_value(options, 'MainTimerState'),
|
value_fn=lambda options: _option_value(options, "MainTimerState"),
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='main_timer_current',
|
key="main_timer_current",
|
||||||
field='x.com.samsung.da.options',
|
field="x.com.samsung.da.options",
|
||||||
icon='mdi:timer-sand',
|
icon="mdi:timer-sand",
|
||||||
enabled_default=False,
|
enabled_default=False,
|
||||||
value_fn=lambda options: _int_or_none(
|
value_fn=lambda options: _int_or_none(_option_value(options, "MainTimerCurrent")),
|
||||||
_option_value(options, 'MainTimerCurrent')
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
COOKTOP_CONNECTED = Capability(
|
COOKTOP_CONNECTED = Capability(
|
||||||
href='/connected/vs/0',
|
href="/connected/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
BinarySensorDesc(
|
BinarySensorDesc(
|
||||||
key='cloud_connected',
|
key="cloud_connected",
|
||||||
field='x.com.samsung.da.connected',
|
field="x.com.samsung.da.connected",
|
||||||
device_class='connectivity',
|
device_class="connectivity",
|
||||||
entity_category='diagnostic',
|
entity_category="diagnostic",
|
||||||
value_fn=lambda value: str(value).lower() == 'on',
|
value_fn=lambda value: str(value).lower() == "on",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
PAIRED_HOOD_STATUS = Capability(
|
PAIRED_HOOD_STATUS = Capability(
|
||||||
href='/bluetooth/hood/status/vs/0',
|
href="/bluetooth/hood/status/vs/0",
|
||||||
poll_tier='hot',
|
poll_tier="hot",
|
||||||
entities=(
|
entities=(
|
||||||
BinarySensorDesc(
|
BinarySensorDesc(
|
||||||
key='paired_hood_connected',
|
key="paired_hood_connected",
|
||||||
field='connectionState',
|
field="connectionState",
|
||||||
device_class='connectivity',
|
device_class="connectivity",
|
||||||
value_fn=lambda value: str(value).lower() == 'connected',
|
value_fn=lambda value: str(value).lower() == "connected",
|
||||||
),
|
),
|
||||||
BinarySensorDesc(
|
BinarySensorDesc(
|
||||||
key='paired_hood_power',
|
key="paired_hood_power",
|
||||||
field='power',
|
field="power",
|
||||||
device_class='running',
|
device_class="running",
|
||||||
value_fn=lambda value: str(value).lower() == 'on',
|
value_fn=lambda value: str(value).lower() == "on",
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='paired_hood_fan_speed',
|
key="paired_hood_fan_speed",
|
||||||
field='fanSpeed',
|
field="fanSpeed",
|
||||||
icon='mdi:fan',
|
icon="mdi:fan",
|
||||||
value_fn=_int_or_none,
|
value_fn=_int_or_none,
|
||||||
),
|
),
|
||||||
BinarySensorDesc(
|
BinarySensorDesc(
|
||||||
key='paired_hood_light',
|
key="paired_hood_light",
|
||||||
field='lampState',
|
field="lampState",
|
||||||
device_class='light',
|
device_class="light",
|
||||||
value_fn=lambda value: str(value).lower() == 'on',
|
value_fn=lambda value: str(value).lower() == "on",
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='paired_hood_model',
|
key="paired_hood_model",
|
||||||
field='micomModelId',
|
field="micomModelId",
|
||||||
icon='mdi:information-outline',
|
icon="mdi:information-outline",
|
||||||
entity_category='diagnostic',
|
entity_category="diagnostic",
|
||||||
enabled_default=False,
|
enabled_default=False,
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='paired_hood_firmware',
|
key="paired_hood_firmware",
|
||||||
field='firmwareVersion',
|
field="firmwareVersion",
|
||||||
icon='mdi:chip',
|
icon="mdi:chip",
|
||||||
entity_category='diagnostic',
|
entity_category="diagnostic",
|
||||||
enabled_default=False,
|
enabled_default=False,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ humidity -- not temperature -- is this device's primary control, and there
|
|||||||
is no climate composite: power, mode, and humidity are exposed as separate
|
is no climate composite: power, mode, and humidity are exposed as separate
|
||||||
entities rather than folded into one card.
|
entities rather than folded into one card.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
from ..entities import NumberDesc, SelectDesc, SensorDesc
|
from ..entities import NumberDesc, SelectDesc, SensorDesc
|
||||||
from .common import int_or_none
|
from .common import int_or_none
|
||||||
@@ -16,21 +17,26 @@ def _first_mode(rep):
|
|||||||
"""Representative scalar for the operating-mode select. `modes` is a
|
"""Representative scalar for the operating-mode select. `modes` is a
|
||||||
single-element list on every dump seen so far, mirroring
|
single-element list on every dump seen so far, mirroring
|
||||||
airconditioner._first_mode's handling of the same field shape."""
|
airconditioner._first_mode's handling of the same field shape."""
|
||||||
modes = rep.get('x.com.samsung.da.modes')
|
modes = rep.get("x.com.samsung.da.modes")
|
||||||
if isinstance(modes, (list, tuple)):
|
if isinstance(modes, (list, tuple)):
|
||||||
return modes[0] if modes else None
|
return modes[0] if modes else None
|
||||||
return modes
|
return modes
|
||||||
|
|
||||||
|
|
||||||
MODE = Capability(
|
MODE = Capability(
|
||||||
href='/mode/vs/0',
|
href="/mode/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
SelectDesc(key='operating_mode', rep_fn=_first_mode,
|
SelectDesc(
|
||||||
icon='mdi:tune-variant',
|
key="operating_mode",
|
||||||
options_field='x.com.samsung.da.supportedModes',
|
rep_fn=_first_mode,
|
||||||
write_fn=lambda p, rep, href=None: (
|
icon="mdi:tune-variant",
|
||||||
['mode', 'vs', '0'], {'x.com.samsung.da.modes': [p]})),
|
options_field="x.com.samsung.da.supportedModes",
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["mode", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.modes": [p]},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -43,21 +49,31 @@ MODE = Capability(
|
|||||||
# dump's values" section). Step comes live from the device's own `increment`
|
# dump's values" section). Step comes live from the device's own `increment`
|
||||||
# field.
|
# field.
|
||||||
HUMIDITY = Capability(
|
HUMIDITY = Capability(
|
||||||
href='/humidity/vs/0',
|
href="/humidity/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='humidity', field='x.com.samsung.da.humidity',
|
SensorDesc(
|
||||||
device_class='humidity', unit='%', state_class='measurement',
|
key="humidity",
|
||||||
value_fn=int_or_none),
|
field="x.com.samsung.da.humidity",
|
||||||
NumberDesc(key='target_humidity', field='x.com.samsung.da.desiredHumidity',
|
device_class="humidity",
|
||||||
device_class='humidity', unit='%',
|
unit="%",
|
||||||
icon='mdi:water-percent',
|
state_class="measurement",
|
||||||
entity_category='config',
|
value_fn=int_or_none,
|
||||||
value_fn=int_or_none,
|
),
|
||||||
step_fn=lambda rep: int_or_none(rep.get('increment')) or 1,
|
NumberDesc(
|
||||||
write_fn=lambda p, rep, href=None: (
|
key="target_humidity",
|
||||||
['humidity', 'vs', '0'],
|
field="x.com.samsung.da.desiredHumidity",
|
||||||
{'x.com.samsung.da.desiredHumidity': str(int(round(float(p))))})),
|
device_class="humidity",
|
||||||
|
unit="%",
|
||||||
|
icon="mdi:water-percent",
|
||||||
|
entity_category="config",
|
||||||
|
value_fn=int_or_none,
|
||||||
|
step_fn=lambda rep: int_or_none(rep.get("increment")) or 1,
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["humidity", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.desiredHumidity": str(round(float(p)))},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -69,17 +85,17 @@ HUMIDITY = Capability(
|
|||||||
# families' schemas.
|
# families' schemas.
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
_DHM_IGNORED = [
|
_DHM_IGNORED = [
|
||||||
'/availablecontrolsets/vs/0', # opaque hex-encoded control-set bitmap (id: DHM)
|
"/availablecontrolsets/vs/0", # opaque hex-encoded control-set bitmap (id: DHM)
|
||||||
'/da/softreset/vs/0', # soft-reset trigger plumbing
|
"/da/softreset/vs/0", # soft-reset trigger plumbing
|
||||||
'/keepnormalstate/vs/0', # internal keep-normal flag
|
"/keepnormalstate/vs/0", # internal keep-normal flag
|
||||||
'/personality/presence/vs/0', # presence-personalization plumbing (empty item value)
|
"/personality/presence/vs/0", # presence-personalization plumbing (empty item value)
|
||||||
'/reserverulesets/vs/0', # opaque hex-encoded schedule reservation blob
|
"/reserverulesets/vs/0", # opaque hex-encoded schedule reservation blob
|
||||||
'/sensors/vs/0', # empty {} on this dump
|
"/sensors/vs/0", # empty {} on this dump
|
||||||
'/welcome/humidity/vs/0', # welcome-mode plumbing (requestId/operatingStatus, inert)
|
"/welcome/humidity/vs/0", # welcome-mode plumbing (requestId/operatingStatus, inert)
|
||||||
# Only supportedModes ([Off, Sleep]) is present -- no live "current
|
# Only supportedModes ([Off, Sleep]) is present -- no live "current
|
||||||
# value" field on this dump to confirm the read/write contract, so per
|
# value" field on this dump to confirm the read/write contract, so per
|
||||||
# the 'don't guess' rule this is left unmodeled rather than assumed.
|
# the 'don't guess' rule this is left unmodeled rather than assumed.
|
||||||
'/mode/convenient/vs/0',
|
"/mode/convenient/vs/0",
|
||||||
]
|
]
|
||||||
|
|
||||||
COVERAGE = [Capability(href=h) for h in _DHM_IGNORED]
|
COVERAGE = [Capability(href=h) for h in _DHM_IGNORED]
|
||||||
@@ -6,6 +6,7 @@ The /course/vs/0 cycle select and its options-array machinery are shared with
|
|||||||
washer and dryer in laundry.py; only the dishwasher-specific options (storm
|
washer and dryer in laundry.py; only the dishwasher-specific options (storm
|
||||||
wash, auto release dry) are read locally here.
|
wash, auto release dry) are read locally here.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
from ..entities import ButtonDesc, SelectDesc, SensorDesc, SwitchDesc
|
from ..entities import ButtonDesc, SelectDesc, SensorDesc, SwitchDesc
|
||||||
from .laundry import bool_option_switch, cycle_select
|
from .laundry import bool_option_switch, cycle_select
|
||||||
@@ -15,20 +16,28 @@ from .laundry import bool_option_switch, cycle_select
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
DISHWASHER_SETTINGS = Capability(
|
DISHWASHER_SETTINGS = Capability(
|
||||||
href='/dishwasher/vs/0',
|
href="/dishwasher/vs/0",
|
||||||
entities=(
|
entities=(
|
||||||
SwitchDesc(key='sanitize', field='x.com.samsung.da.sanitize',
|
SwitchDesc(
|
||||||
icon='mdi:bacteria',
|
key="sanitize",
|
||||||
value_fn=lambda v: v == 'On',
|
field="x.com.samsung.da.sanitize",
|
||||||
write_fn=lambda p, rep, href=None: (
|
icon="mdi:bacteria",
|
||||||
['dishwasher', 'vs', '0'],
|
value_fn=lambda v: v == "On",
|
||||||
{'x.com.samsung.da.sanitize': 'On' if p == 'On' else 'Off'})),
|
write_fn=lambda p, rep, href=None: (
|
||||||
SelectDesc(key='heated_dry', field='x.com.samsung.da.heatedDry',
|
["dishwasher", "vs", "0"],
|
||||||
icon='mdi:heat-wave',
|
{"x.com.samsung.da.sanitize": "On" if p == "On" else "Off"},
|
||||||
options_field='x.com.samsung.da.supportedHeatedDry',
|
),
|
||||||
write_fn=lambda p, rep, href=None: (
|
),
|
||||||
['dishwasher', 'vs', '0'],
|
SelectDesc(
|
||||||
{'x.com.samsung.da.heatedDry': p})),
|
key="heated_dry",
|
||||||
|
field="x.com.samsung.da.heatedDry",
|
||||||
|
icon="mdi:heat-wave",
|
||||||
|
options_field="x.com.samsung.da.supportedHeatedDry",
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["dishwasher", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.heatedDry": p},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -42,13 +51,13 @@ DISHWASHER_SETTINGS = Capability(
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
CYCLE_OPTIONS = Capability(
|
CYCLE_OPTIONS = Capability(
|
||||||
href='/course/vs/0',
|
href="/course/vs/0",
|
||||||
entities=(
|
entities=(
|
||||||
cycle_select(translation_key='dishwasher_cycle', icon='mdi:dishwasher'),
|
cycle_select(translation_key="dishwasher_cycle", icon="mdi:dishwasher"),
|
||||||
bool_option_switch('storm_wash', 'mdi:weather-lightning-rainy',
|
bool_option_switch("storm_wash", "mdi:weather-lightning-rainy", "StormWashZone"),
|
||||||
'StormWashZone'),
|
bool_option_switch(
|
||||||
bool_option_switch('auto_release_dry', 'mdi:door-open',
|
"auto_release_dry", "mdi:door-open", "AutoDoorRelease", gate_on_presence=True
|
||||||
'AutoDoorRelease', gate_on_presence=True),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -57,26 +66,35 @@ CYCLE_OPTIONS = Capability(
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
DIAGNOSIS = Capability(
|
DIAGNOSIS = Capability(
|
||||||
href='/diagnosis/vs/0',
|
href="/diagnosis/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='diagnosis_status', field='x.com.samsung.da.diagnosisStart',
|
SensorDesc(
|
||||||
icon='mdi:stethoscope',
|
key="diagnosis_status",
|
||||||
entity_category='diagnostic'),
|
field="x.com.samsung.da.diagnosisStart",
|
||||||
ButtonDesc(key='diagnosis_start', field='', payload='Start',
|
icon="mdi:stethoscope",
|
||||||
icon='mdi:play-circle-outline',
|
entity_category="diagnostic",
|
||||||
entity_category='diagnostic',
|
),
|
||||||
write_fn=lambda p, rep, href=None: (
|
ButtonDesc(
|
||||||
['diagnosis', 'vs', '0'], {'x.com.samsung.da.diagnosisStart': p})),
|
key="diagnosis_start",
|
||||||
|
field="",
|
||||||
|
payload="Start",
|
||||||
|
icon="mdi:play-circle-outline",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["diagnosis", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.diagnosisStart": p},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
OPERATION_ORIGIN = Capability(
|
OPERATION_ORIGIN = Capability(
|
||||||
href='/operation/origin/vs/0',
|
href="/operation/origin/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='operation_origin', field='origin',
|
SensorDesc(
|
||||||
icon='mdi:remote',
|
key="operation_origin", field="origin", icon="mdi:remote", entity_category="diagnostic"
|
||||||
entity_category='diagnostic'),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -8,31 +8,32 @@ the /course/vs/0 cycle select -- lives in laundry.py.
|
|||||||
/course/vs/0 -> DRYER_COURSE (shared cycle select; see below)
|
/course/vs/0 -> DRYER_COURSE (shared cycle select; see below)
|
||||||
/diagnosis/vs/0 -> DRYER_DIAGNOSIS
|
/diagnosis/vs/0 -> DRYER_DIAGNOSIS
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
from ..entities import SensorDesc, SwitchDesc
|
from ..entities import SensorDesc, SwitchDesc
|
||||||
from .laundry import cycle_select
|
from .laundry import cycle_select
|
||||||
|
|
||||||
|
|
||||||
def _wrinkle_write(p, rep, href=None):
|
def _wrinkle_write(p, rep, href=None):
|
||||||
if p not in ('On', 'Off'):
|
if p not in ("On", "Off"):
|
||||||
return None
|
return None
|
||||||
return ['washer', 'vs', '0'], {'x.com.samsung.da.wrinklePrevent': p}
|
return ["washer", "vs", "0"], {"x.com.samsung.da.wrinklePrevent": p}
|
||||||
|
|
||||||
|
|
||||||
DRYER_SETTINGS = Capability(
|
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',
|
SensorDesc(key="dry_level", field="x.com.samsung.da.dryLevel", icon="mdi:water-percent"),
|
||||||
icon='mdi:water-percent'),
|
SensorDesc(key="dry_time", field="x.com.samsung.da.dryTime", icon="mdi:timer"),
|
||||||
SensorDesc(key='dry_time', field='x.com.samsung.da.dryTime',
|
SensorDesc(key="dryer_type", field="x.com.samsung.da.dryerType", icon="mdi:tumble-dryer"),
|
||||||
icon='mdi:timer'),
|
SwitchDesc(
|
||||||
SensorDesc(key='dryer_type', field='x.com.samsung.da.dryerType',
|
key="wrinkle_prevent",
|
||||||
icon='mdi:tumble-dryer'),
|
field="x.com.samsung.da.wrinklePrevent",
|
||||||
SwitchDesc(key='wrinkle_prevent', field='x.com.samsung.da.wrinklePrevent',
|
icon="mdi:iron",
|
||||||
icon='mdi:iron',
|
value_fn=lambda v: v == "On",
|
||||||
value_fn=lambda v: v == 'On',
|
write_fn=_wrinkle_write,
|
||||||
write_fn=_wrinkle_write),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -49,18 +50,22 @@ DRYER_SETTINGS = Capability(
|
|||||||
# course and is ignored (ignored.py) -- the mirror of how /st/washercourse/vs/0
|
# course and is ignored (ignored.py) -- the mirror of how /st/washercourse/vs/0
|
||||||
# is ignored for washers.
|
# is ignored for washers.
|
||||||
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(
|
||||||
table_href='/st/dryercourse/vs/0'),
|
translation_key="dryer_cycle",
|
||||||
|
icon="mdi:tumble-dryer",
|
||||||
|
table_href="/st/dryercourse/vs/0",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
DRYER_DIAGNOSIS = Capability(
|
DRYER_DIAGNOSIS = Capability(
|
||||||
href='/diagnosis/vs/0',
|
href="/diagnosis/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='diagnosis', field='x.com.samsung.da.diagnosisStart',
|
SensorDesc(
|
||||||
entity_category='diagnostic'),
|
key="diagnosis", field="x.com.samsung.da.diagnosisStart", entity_category="diagnostic"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -0,0 +1,228 @@
|
|||||||
|
"""Capabilities for the Samsung EHS (Eco Heating System) air-to-water heat
|
||||||
|
pump family (TP1X_DA_AC_EHS-class, model TP1X_DA_AC_EHS_01001_0000).
|
||||||
|
|
||||||
|
An EHS unit runs two independently-controlled loops off one outdoor unit:
|
||||||
|
space heating/cooling ("zone1", through /mode/vs/0, /power/vs/0,
|
||||||
|
/temperatures/indoor/vs/0) and domestic hot water ("dhw", through
|
||||||
|
/mode/dhw/vs/0, /power/dhw/vs/0, /temperatures/dhw/vs/0). There's no shared
|
||||||
|
vocabulary with the room-AC family in airconditioner.py beyond the DA_AC_
|
||||||
|
board prefix -- EHS reports its own /mode/*/vs/0 and /temperatures/*/vs/0
|
||||||
|
shapes, not airconditioner.py's HREF_MODE/HREF_TEMP* OCF-pattern hrefs.
|
||||||
|
|
||||||
|
zone1 has no HA platform with matching semantics (it's a leaving-water-
|
||||||
|
temperature setpoint, not a thermostat with HVAC modes airconditioner.py's
|
||||||
|
climate.py would fit), so it stays switch/select/number/sensor -- same shape
|
||||||
|
as dehumidifier.py's power/mode/humidity split. dhw is a real HA
|
||||||
|
water_heater.py -- see DHW below and water_heater.py's module docstring --
|
||||||
|
following the same primary-resource-plus-sibling-reads pattern as
|
||||||
|
airconditioner.py's CLIMATE/climate.py.
|
||||||
|
|
||||||
|
Verified against a real TP1X_DA_AC_EHS_01001_0000 diagnostics dump
|
||||||
|
(firmware AEH-WW-TP1-22-AE6000_17260402, TizenRT 3.1 / DAWIT 2.0).
|
||||||
|
"""
|
||||||
|
|
||||||
|
from ..capability import Capability
|
||||||
|
from ..entities import NumberDesc, SelectDesc, SensorDesc, SwitchDesc, WaterHeaterDesc
|
||||||
|
from .common import normalize_temp_unit
|
||||||
|
|
||||||
|
|
||||||
|
def _num(v):
|
||||||
|
try:
|
||||||
|
return float(v)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _first_mode(rep):
|
||||||
|
"""Representative scalar for a mode select -- `modes` is a single-element
|
||||||
|
list on every dump seen so far, mirroring airconditioner._first_mode /
|
||||||
|
dehumidifier._first_mode's handling of the same field shape."""
|
||||||
|
modes = rep.get("x.com.samsung.da.modes")
|
||||||
|
if isinstance(modes, (list, tuple)):
|
||||||
|
return modes[0] if modes else None
|
||||||
|
return modes
|
||||||
|
|
||||||
|
|
||||||
|
def _temp_unit(rep):
|
||||||
|
return normalize_temp_unit(rep.get("x.com.samsung.da.unit"), "°C")
|
||||||
|
|
||||||
|
|
||||||
|
def _bounds(rep, default_min, default_max):
|
||||||
|
"""The resource's own (minimum, maximum) pair, or the defaults.
|
||||||
|
|
||||||
|
Both ends together or neither -- a board reporting only one would
|
||||||
|
otherwise pair a real device bound with an invented default, which
|
||||||
|
looks plausible and is silently wrong. Same rule as
|
||||||
|
climate._range()/water_heater._range(), and the same reason
|
||||||
|
oven._setpoint_bounds resolves its pair in one place.
|
||||||
|
"""
|
||||||
|
lo = _num(rep.get("x.com.samsung.da.minimum"))
|
||||||
|
hi = _num(rep.get("x.com.samsung.da.maximum"))
|
||||||
|
return (lo, hi) if (lo is not None and hi is not None) else (default_min, default_max)
|
||||||
|
|
||||||
|
|
||||||
|
def _step(rep, default):
|
||||||
|
"""`is None`, not `or` -- `or` collapses a genuine 0 (issue #160)."""
|
||||||
|
step = _num(rep.get("x.com.samsung.da.increment"))
|
||||||
|
return default if step is None else step
|
||||||
|
|
||||||
|
|
||||||
|
ZONE_POWER = Capability(
|
||||||
|
href="/power/vs/0",
|
||||||
|
poll_tier="warm",
|
||||||
|
entities=(
|
||||||
|
SwitchDesc(
|
||||||
|
key="zone_power",
|
||||||
|
field="x.com.samsung.da.power",
|
||||||
|
icon="mdi:radiator",
|
||||||
|
value_fn=lambda v: v == "On",
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["power", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.power": "On" if p == "On" else "Off"},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
ZONE_MODE = Capability(
|
||||||
|
href="/mode/vs/0",
|
||||||
|
poll_tier="warm",
|
||||||
|
entities=(
|
||||||
|
SelectDesc(
|
||||||
|
key="zone_mode",
|
||||||
|
rep_fn=_first_mode,
|
||||||
|
icon="mdi:sun-snowflake-variant",
|
||||||
|
options_field="x.com.samsung.da.supportedModes",
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["mode", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.modes": [p]},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
# type=Water/unit=Celsius on this dump names the space-heating loop's flow/
|
||||||
|
# room setpoint, not a literal water temperature -- Samsung EHS zone control
|
||||||
|
# is leaving-water-temperature-based, same convention as the dhw loop below.
|
||||||
|
ZONE_TEMPERATURE = Capability(
|
||||||
|
href="/temperatures/indoor/vs/0",
|
||||||
|
poll_tier="warm",
|
||||||
|
entities=(
|
||||||
|
SensorDesc(
|
||||||
|
key="zone_temperature",
|
||||||
|
field="x.com.samsung.da.current",
|
||||||
|
device_class="temperature",
|
||||||
|
unit_fn=_temp_unit,
|
||||||
|
state_class="measurement",
|
||||||
|
value_fn=_num,
|
||||||
|
),
|
||||||
|
NumberDesc(
|
||||||
|
key="zone_target_temperature",
|
||||||
|
field="x.com.samsung.da.desired",
|
||||||
|
device_class="temperature",
|
||||||
|
unit_fn=_temp_unit,
|
||||||
|
entity_category="config",
|
||||||
|
value_fn=_num,
|
||||||
|
native_min_fn=lambda rep: _bounds(rep, 5.0, 30.0)[0],
|
||||||
|
native_max_fn=lambda rep: _bounds(rep, 5.0, 30.0)[1],
|
||||||
|
step_fn=lambda rep: _step(rep, 0.5),
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["temperatures", "indoor", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.desired": str(float(p))},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
# Canonical dhw resource hrefs. water_heater.py binds the primary HREF_DHW_MODE
|
||||||
|
# via DHW below and reads the sibling power/temperature hrefs off the
|
||||||
|
# coordinator snapshot -- same primary-plus-siblings shape as
|
||||||
|
# airconditioner.py's HREF_MODE/CLIMATE_CONSUMED_HREFS. Declared once here
|
||||||
|
# and imported by water_heater.py, so a new sibling read can't drift out of
|
||||||
|
# sync with its DHW_CONSUMED_HREFS coverage entry below.
|
||||||
|
HREF_DHW_POWER = "/power/dhw/vs/0" # on/off
|
||||||
|
HREF_DHW_MODE = "/mode/dhw/vs/0" # primary (bound by DHW) -- current_operation
|
||||||
|
HREF_DHW_TEMPERATURE = "/temperatures/dhw/vs/0" # current/target temperature
|
||||||
|
|
||||||
|
DHW_CONSUMED_HREFS = [HREF_DHW_POWER, HREF_DHW_TEMPERATURE]
|
||||||
|
|
||||||
|
|
||||||
|
def _dhw_write(payload, rep, href=None):
|
||||||
|
"""Map a (kind, value) command from the water_heater platform to the
|
||||||
|
(path_segs, body) for that one sub-write -- same contract as
|
||||||
|
airconditioner._climate_write, just across the dhw loop's three
|
||||||
|
resources instead of the AC's power/mode/temperature/wind set."""
|
||||||
|
kind, value = payload
|
||||||
|
if kind == "power":
|
||||||
|
return (["power", "dhw", "vs", "0"], {"x.com.samsung.da.power": "On" if value else "Off"})
|
||||||
|
if kind == "mode":
|
||||||
|
return (["mode", "dhw", "vs", "0"], {"x.com.samsung.da.modes": [value]})
|
||||||
|
if kind == "temperature":
|
||||||
|
return (["temperatures", "dhw", "vs", "0"], {"x.com.samsung.da.desired": str(float(value))})
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
DHW = Capability(
|
||||||
|
href=HREF_DHW_MODE,
|
||||||
|
poll_tier="warm",
|
||||||
|
entities=(
|
||||||
|
WaterHeaterDesc(
|
||||||
|
key="water_heater", translation_key="dhw", rep_fn=_first_mode, write_fn=_dhw_write
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
# Power and temperature are read by the composite DHW entity above, not
|
||||||
|
# given their own entities -- coverage-only caps so discover() reports no
|
||||||
|
# gap (see airconditioner.py's CLIMATE_CONSUMED_HREFS for the same pattern).
|
||||||
|
DHW_CONSUMED = [Capability(href=h, poll_tier="warm") for h in DHW_CONSUMED_HREFS]
|
||||||
|
|
||||||
|
# Deliberately a plain config switch, not water_heater's AWAY_MODE feature.
|
||||||
|
# HA core's smartthings water_heater does wire this same Samsung capability
|
||||||
|
# (CUSTOM_OUTING_MODE) up to WaterHeaterEntityFeature.AWAY_MODE, and the DHW
|
||||||
|
# operation-mode map above is taken from that integration -- so the
|
||||||
|
# divergence is worth stating. /option/outgoing/vs/0 is device-wide: one
|
||||||
|
# `away` flag covering the whole unit, zone1 included (it has no dhw-scoped
|
||||||
|
# sibling href, unlike every other resource in this loop). Hanging it off
|
||||||
|
# the DHW card would present a device-wide setting as if it only affected
|
||||||
|
# hot water. It stays a switch until a board turns up with a per-loop away
|
||||||
|
# resource to bind instead.
|
||||||
|
AWAY_MODE = Capability(
|
||||||
|
href="/option/outgoing/vs/0",
|
||||||
|
poll_tier="cold",
|
||||||
|
entities=(
|
||||||
|
SwitchDesc(
|
||||||
|
key="away_mode",
|
||||||
|
field="x.com.samsung.da.away",
|
||||||
|
icon="mdi:home-export-outline",
|
||||||
|
entity_category="config",
|
||||||
|
value_fn=lambda v: v == "On",
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["option", "outgoing", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.away": "On" if p == "On" else "Off"},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# EHS-scoped coverage: opaque vendor plumbing (hex-encoded factory/cycle/
|
||||||
|
# schedule blobs) or resources with no confirmed write contract on this
|
||||||
|
# dump, following the same 'don't guess' rule as dehumidifier._DHM_IGNORED.
|
||||||
|
# Not in the global ignored.IGNORED since these are EHS-only shapes that
|
||||||
|
# would need their own verification on other device families.
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
_EHS_IGNORED = [
|
||||||
|
"/availablecontrolsets/vs/0", # opaque hex-encoded control-set bitmap (id: EHS)
|
||||||
|
"/da/softreset/vs/0", # soft-reset trigger plumbing
|
||||||
|
"/diagnosis/vs/0", # empty {} on this dump
|
||||||
|
"/ehscycle/vs/0", # opaque hex-encoded indoor/outdoor cycle log
|
||||||
|
"/ehsfsv/vs/0", # opaque hex-encoded factory setting values
|
||||||
|
"/option/dhwdisplay/vs/0", # front-panel DHW-display show/hide, cosmetic only
|
||||||
|
"/reserverulesets/vs/0", # opaque hex-encoded schedule reservation blob
|
||||||
|
"/sac/installationinfo/vs/0", # static outdoor/indoor installation info, diagnostic only
|
||||||
|
"/actions/zone1/vs/0", # zone1 schedule/timer program -- unmodeled for now
|
||||||
|
"/actions/dhw/vs/0", # DHW schedule/timer program -- unmodeled for now
|
||||||
|
]
|
||||||
|
|
||||||
|
COVERAGE = [Capability(href=h) for h in _EHS_IGNORED]
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -23,114 +23,106 @@ override. Grow it as real /device/0 dumps surface more universal noise —
|
|||||||
do not add a href here on a guess. If a href's relevance is unclear, leave
|
do not add a href here on a guess. If a href's relevance is unclear, leave
|
||||||
it unbound so it surfaces as a gap for a human to look at.
|
it unbound so it surfaces as a gap for a human to look at.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
|
|
||||||
IGNORED: list[Capability] = [
|
IGNORED: list[Capability] = [
|
||||||
# Device serial/model is read directly by the coordinator for HA device
|
# Device serial/model is read directly by the coordinator for HA device
|
||||||
# identity, not modeled as an entity capability.
|
# identity, not modeled as an entity capability.
|
||||||
Capability(href='/information/vs/0'),
|
Capability(href="/information/vs/0"),
|
||||||
|
|
||||||
# Bixby voice assistant: feature negotiation, account provisioning
|
# Bixby voice assistant: feature negotiation, account provisioning
|
||||||
# (Samsung account email, access tokens), terms-of-service state, and
|
# (Samsung account email, access tokens), terms-of-service state, and
|
||||||
# enable/disable status.
|
# enable/disable status.
|
||||||
Capability(href='/voice/feature/vs/0'),
|
Capability(href="/voice/feature/vs/0"),
|
||||||
Capability(href='/voice/provisioning/vs/0'),
|
Capability(href="/voice/provisioning/vs/0"),
|
||||||
Capability(href='/bixby/vs/0'),
|
Capability(href="/bixby/vs/0"),
|
||||||
Capability(href='/bixby/status/vs/0'),
|
Capability(href="/bixby/status/vs/0"),
|
||||||
Capability(href='/bixbyuservalidate/vs/0'),
|
Capability(href="/bixbyuservalidate/vs/0"),
|
||||||
Capability(href='/bixbyterms/vs/0'),
|
Capability(href="/bixbyterms/vs/0"),
|
||||||
|
|
||||||
# Network/WiFi housekeeping — MAC addresses, supported auth/crypto
|
# Network/WiFi housekeeping — MAC addresses, supported auth/crypto
|
||||||
# types, no controllable or observable appliance state.
|
# types, no controllable or observable appliance state.
|
||||||
Capability(href='/wirelessinfo/vs/0'),
|
Capability(href="/wirelessinfo/vs/0"),
|
||||||
Capability(href='/connectionconfig/vs/0'),
|
Capability(href="/connectionconfig/vs/0"),
|
||||||
|
|
||||||
# Static or internal-protocol metadata, not entity-worthy.
|
# Static or internal-protocol metadata, not entity-worthy.
|
||||||
Capability(href='/quickcontrol/info/vs/0'),
|
Capability(href="/quickcontrol/info/vs/0"),
|
||||||
Capability(href='/realtimenotiforclient/vs/0'),
|
Capability(href="/realtimenotiforclient/vs/0"),
|
||||||
Capability(href='/file/information/vs/0'),
|
Capability(href="/file/information/vs/0"),
|
||||||
Capability(href='/configuration/vs/0'), # region/countryCode
|
Capability(href="/configuration/vs/0"), # region/countryCode
|
||||||
Capability(href='/setting/vs/0'), # supported/selected UI language
|
Capability(href="/setting/vs/0"), # supported/selected UI language
|
||||||
Capability(href='/timezone/vs/0'), # redundant with HA's own timezone
|
Capability(href="/timezone/vs/0"), # redundant with HA's own timezone
|
||||||
Capability(href='/wm/setinfo/vs/0'), # model/manufacturing metadata
|
Capability(href="/wm/setinfo/vs/0"), # model/manufacturing metadata
|
||||||
# Resource-monitoring poll-interval config (a bare minPeriod in
|
# Resource-monitoring poll-interval config (a bare minPeriod in
|
||||||
# milliseconds, issue #165's TP1X_REF_21K fridge) -- internal transport
|
# milliseconds, issue #165's TP1X_REF_21K fridge) -- internal transport
|
||||||
# plumbing, not appliance state.
|
# plumbing, not appliance state.
|
||||||
Capability(href='/rm/control/vs/0'),
|
Capability(href="/rm/control/vs/0"),
|
||||||
|
|
||||||
# Demand Response Load Control — utility-company grid signals; requires
|
# Demand Response Load Control — utility-company grid signals; requires
|
||||||
# cloud registration with a utility program we don't support locally.
|
# cloud registration with a utility program we don't support locally.
|
||||||
Capability(href='/drlc/vs/0'),
|
Capability(href="/drlc/vs/0"),
|
||||||
|
|
||||||
# Redundant with capabilities already declared elsewhere.
|
# Redundant with capabilities already declared elsewhere.
|
||||||
# /speakersound/vs/0 duplicates /settings/sound/volume/vs/0 (laundry.SOUND_VOLUME).
|
# /speakersound/vs/0 duplicates /settings/sound/volume/vs/0 (laundry.SOUND_VOLUME).
|
||||||
Capability(href='/speakersound/vs/0'),
|
Capability(href="/speakersound/vs/0"),
|
||||||
# /wm/editcourse/vs/0 has no entities of its own -- x.com.samsung.da.
|
# /wm/editcourse/vs/0 has no entities of its own -- x.com.samsung.da.
|
||||||
# editCourseList is read directly out of the resource snapshot by
|
# editCourseList is read directly out of the resource snapshot by
|
||||||
# dishwasher.CYCLE_OPTIONS's and washer.WASHER_COURSE's cycle select
|
# dishwasher.CYCLE_OPTIONS's and washer.WASHER_COURSE's cycle select
|
||||||
# (options=_cycle_options) to build that device's actual supported
|
# (options=_cycle_options) to build that device's actual supported
|
||||||
# course list, rather than exposing this href's raw byte string
|
# course list, rather than exposing this href's raw byte string
|
||||||
# through its own entity.
|
# through its own entity.
|
||||||
Capability(href='/wm/editcourse/vs/0'),
|
Capability(href="/wm/editcourse/vs/0"),
|
||||||
|
|
||||||
# Bixby audio feedback (chime + volume played when Bixby starts/stops
|
# Bixby audio feedback (chime + volume played when Bixby starts/stops
|
||||||
# listening) — only meaningful with Bixby enabled, which this
|
# listening) — only meaningful with Bixby enabled, which this
|
||||||
# integration has no local path to configure or use.
|
# integration has no local path to configure or use.
|
||||||
Capability(href='/sec/networkaudio/audio/vs/0'),
|
Capability(href="/sec/networkaudio/audio/vs/0"),
|
||||||
|
|
||||||
# Static Bespoke-product-line flag, not appliance state.
|
# Static Bespoke-product-line flag, not appliance state.
|
||||||
Capability(href='/bespoke/vs/0'),
|
Capability(href="/bespoke/vs/0"),
|
||||||
# Empty resource on every dump seen so far — nothing to expose.
|
# Empty resource on every dump seen so far — nothing to expose.
|
||||||
Capability(href='/defrost/prediction/vs/0'),
|
Capability(href="/defrost/prediction/vs/0"),
|
||||||
# Seasonal defrost schedule (start/period/end per season). Automating
|
# Seasonal defrost schedule (start/period/end per season). Automating
|
||||||
# this cleanly would need a multi-field schedule editor; the practical
|
# this cleanly would need a multi-field schedule editor; the practical
|
||||||
# on/off control is fridge.DEFROST_DELAY.
|
# on/off control is fridge.DEFROST_DELAY.
|
||||||
Capability(href='/defrost/reservation/vs/0'),
|
Capability(href="/defrost/reservation/vs/0"),
|
||||||
# Warranty/service-plan enrollment status — every field reads "Unknown"
|
# Warranty/service-plan enrollment status — every field reads "Unknown"
|
||||||
# on hardware not enrolled in a Samsung Care+ style program.
|
# on hardware not enrolled in a Samsung Care+ style program.
|
||||||
Capability(href='/dginformation/vs/0'),
|
Capability(href="/dginformation/vs/0"),
|
||||||
# OCF-native vacation-mode flag (fridge). Only one value ('RVACATION_OFF')
|
# OCF-native vacation-mode flag (fridge). Only one value ('RVACATION_OFF')
|
||||||
# has ever been seen in `modes` (issue #7's dump) -- no real choice to
|
# has ever been seen in `modes` (issue #7's dump) -- no real choice to
|
||||||
# expose yet. Revisit if a device surfaces it toggled on.
|
# expose yet. Revisit if a device surfaces it toggled on.
|
||||||
Capability(href='/mode/0'),
|
Capability(href="/mode/0"),
|
||||||
# Opaque integer with no supportedModes/options list to interpret it
|
# Opaque integer with no supportedModes/options list to interpret it
|
||||||
# against — meaning unclear from the raw resource alone.
|
# against — meaning unclear from the raw resource alone.
|
||||||
Capability(href='/runningmode/vs/0'),
|
Capability(href="/runningmode/vs/0"),
|
||||||
|
|
||||||
# Demand-response energy planner — same utility-program dependency as
|
# Demand-response energy planner — same utility-program dependency as
|
||||||
# /drlc/vs/0 above; every dump seen so far is inert (plan: 'none').
|
# /drlc/vs/0 above; every dump seen so far is inert (plan: 'none').
|
||||||
Capability(href='/energy/planner/vs/0'),
|
Capability(href="/energy/planner/vs/0"),
|
||||||
# Temperature-unit display preference, redundant with HA's own units.
|
# Temperature-unit display preference, redundant with HA's own units.
|
||||||
Capability(href='/wm/submode/vs/0'),
|
Capability(href="/wm/submode/vs/0"),
|
||||||
|
|
||||||
# Read-only re-encoding of the course already exposed by
|
# Read-only re-encoding of the course already exposed by
|
||||||
# washer.WASHER_COURSE at /course/vs/0 (x.com.samsung.da.st.washerMode
|
# washer.WASHER_COURSE at /course/vs/0 (x.com.samsung.da.st.washerMode
|
||||||
# is literally "Table_02_Course_<same hex code>").
|
# is literally "Table_02_Course_<same hex code>").
|
||||||
Capability(href='/st/washercourse/vs/0'),
|
Capability(href="/st/washercourse/vs/0"),
|
||||||
# Dryer counterpart of the above: re-encoding of the course already
|
# Dryer counterpart of the above: re-encoding of the course already
|
||||||
# exposed by dryer.DRYER_COURSE at /course/vs/0
|
# exposed by dryer.DRYER_COURSE at /course/vs/0
|
||||||
# (x.com.samsung.da.st.dryerMode is "Table_03_Course_<same hex code>").
|
# (x.com.samsung.da.st.dryerMode is "Table_03_Course_<same hex code>").
|
||||||
Capability(href='/st/dryercourse/vs/0'),
|
Capability(href="/st/dryercourse/vs/0"),
|
||||||
# AirDresser counterpart of the above (issue #157): read only for its
|
# AirDresser counterpart of the above (issue #157): read only for its
|
||||||
# courseTable id (air_dresser.AIR_DRESSER_COURSE's table_href), no
|
# courseTable id (air_dresser.AIR_DRESSER_COURSE's table_href), no
|
||||||
# entity of its own -- same "no entity, just the table id" role as
|
# entity of its own -- same "no entity, just the table id" role as
|
||||||
# /st/washercourse/vs/0 and /st/dryercourse/vs/0.
|
# /st/washercourse/vs/0 and /st/dryercourse/vs/0.
|
||||||
Capability(href='/st/airdressercourse/vs/0'),
|
Capability(href="/st/airdressercourse/vs/0"),
|
||||||
# Empty on every washer dump seen so far.
|
# Empty on every washer dump seen so far.
|
||||||
Capability(href='/wm/welcomemsg/vs/0'),
|
Capability(href="/wm/welcomemsg/vs/0"),
|
||||||
# User-saved custom course slots (F1-FA). No controllable/observable
|
# User-saved custom course slots (F1-FA). No controllable/observable
|
||||||
# state without a multi-slot editor; revisit if that becomes valuable.
|
# state without a multi-slot editor; revisit if that becomes valuable.
|
||||||
Capability(href='/wm/personalcourse/vs/0'),
|
Capability(href="/wm/personalcourse/vs/0"),
|
||||||
# OCF-native energy resource is empty ({}) on washer hardware seen so
|
# OCF-native energy resource is empty ({}) on washer hardware seen so
|
||||||
# far, unlike /power/0, /kidslock/0, /remotectrl/0 which do carry real
|
# far, unlike /power/0, /kidslock/0, /remotectrl/0 which do carry real
|
||||||
# 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.
|
# Empty ({}) on every washer dump seen so far -- nothing to expose.
|
||||||
Capability(href='/cycleinterface/vs/0'),
|
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"),
|
||||||
# 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)
|
||||||
@@ -139,13 +131,12 @@ IGNORED: list[Capability] = [
|
|||||||
# time, progress percentage) with no write path -- not worth building a
|
# time, progress percentage) with no write path -- not worth building a
|
||||||
# parallel write-capable capability around an unverified generic OCF
|
# parallel write-capable capability around an unverified generic OCF
|
||||||
# write contract.
|
# write contract.
|
||||||
Capability(href='/operational/state/0'),
|
Capability(href="/operational/state/0"),
|
||||||
|
|
||||||
# Cooktop guided-cooking/recipe status (issue #86, TP1X_DA-KS-COOKTOP
|
# Cooktop guided-cooking/recipe status (issue #86, TP1X_DA-KS-COOKTOP
|
||||||
# family): sequenceNumber, operationBurnerNumber, a stageInfo block, and
|
# family): sequenceNumber, operationBurnerNumber, a stageInfo block, and
|
||||||
# a textData.menu string -- every field empty/zero on the only dump
|
# a textData.menu string -- every field empty/zero on the only dump
|
||||||
# seen so far (device idle, no guided-cooking program active). Same
|
# seen so far (device idle, no guided-cooking program active). Same
|
||||||
# "don't guess" treatment as the microwave family's /recipe/cook/vs/0.
|
# "don't guess" treatment as the microwave family's /recipe/cook/vs/0.
|
||||||
# Revisit if a dump with an active recipe surfaces.
|
# Revisit if a dump with an active recipe surfaces.
|
||||||
Capability(href='/cooktop/recipe/status/vs/0'),
|
Capability(href="/cooktop/recipe/status/vs/0"),
|
||||||
]
|
]
|
||||||
@@ -19,33 +19,34 @@ Resource hrefs seen across laundry dumps:
|
|||||||
Door-LED keys use NO `x.com.samsung.da.` prefix -- `setBrightness` /
|
Door-LED keys use NO `x.com.samsung.da.` prefix -- `setBrightness` /
|
||||||
`setNightLight` -- preserved exactly as they appear in the OCF resource rep.
|
`setNightLight` -- preserved exactly as they appear in the OCF resource rep.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from datetime import time as dt_time
|
from datetime import time as dt_time
|
||||||
|
|
||||||
from ...catalog import has_entity_translation
|
from ...catalog import has_entity_translation
|
||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
from ..entities import NumberDesc, SelectDesc, SensorDesc, SwitchDesc, TimeDesc
|
from ..entities import NumberDesc, SelectDesc, SensorDesc, SwitchDesc, TimeDesc
|
||||||
|
|
||||||
_LED_LEVELS = ('Low', 'High')
|
_LED_LEVELS = ("Low", "High")
|
||||||
_SOUND_MODES = ('voice', 'tone', 'mute')
|
_SOUND_MODES = ("voice", "tone", "mute")
|
||||||
|
|
||||||
|
|
||||||
def _led_brightness_write(p, rep, href=None):
|
def _led_brightness_write(p, rep, href=None):
|
||||||
if p not in _LED_LEVELS:
|
if p not in _LED_LEVELS:
|
||||||
return None
|
return None
|
||||||
return ['doorled', 'light', 'vs', '0'], {'setBrightness': p}
|
return ["doorled", "light", "vs", "0"], {"setBrightness": p}
|
||||||
|
|
||||||
|
|
||||||
def _led_night_write(p, rep, href=None):
|
def _led_night_write(p, rep, href=None):
|
||||||
if p not in ('On', 'Off'):
|
if p not in ("On", "Off"):
|
||||||
return None
|
return None
|
||||||
return ['doorled', 'light', 'vs', '0'], {'setNightLight': p}
|
return ["doorled", "light", "vs", "0"], {"setNightLight": p}
|
||||||
|
|
||||||
|
|
||||||
def _parse_hm(v):
|
def _parse_hm(v):
|
||||||
if not v:
|
if not v:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
h, m = v.split(':')
|
h, m = v.split(":")
|
||||||
return dt_time(int(h), int(m))
|
return dt_time(int(h), int(m))
|
||||||
except Exception:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
@@ -54,66 +55,95 @@ def _parse_hm(v):
|
|||||||
def _sound_mode_write(p, rep, href=None):
|
def _sound_mode_write(p, rep, href=None):
|
||||||
if p not in _SOUND_MODES:
|
if p not in _SOUND_MODES:
|
||||||
return None
|
return None
|
||||||
return ['settings', 'sound', 'mode', 'vs', '0'], {'mode': p}
|
return ["settings", "sound", "mode", "vs", "0"], {"mode": p}
|
||||||
|
|
||||||
|
|
||||||
DOOR_LED = Capability(
|
DOOR_LED = Capability(
|
||||||
href='/doorled/light/vs/0',
|
href="/doorled/light/vs/0",
|
||||||
entities=(
|
entities=(
|
||||||
SelectDesc(key='led_brightness', field='setBrightness',
|
SelectDesc(
|
||||||
icon='mdi:brightness-6',
|
key="led_brightness",
|
||||||
entity_category='config',
|
field="setBrightness",
|
||||||
options=_LED_LEVELS, write_fn=_led_brightness_write),
|
icon="mdi:brightness-6",
|
||||||
SwitchDesc(key='led_night_light', field='setNightLight',
|
entity_category="config",
|
||||||
icon='mdi:weather-night',
|
options=_LED_LEVELS,
|
||||||
entity_category='config',
|
write_fn=_led_brightness_write,
|
||||||
value_fn=lambda v: v == 'On',
|
),
|
||||||
write_fn=_led_night_write),
|
SwitchDesc(
|
||||||
SelectDesc(key='led_night_brightness', field='setNightLightBrightness',
|
key="led_night_light",
|
||||||
icon='mdi:brightness-4',
|
field="setNightLight",
|
||||||
entity_category='config',
|
icon="mdi:weather-night",
|
||||||
options=_LED_LEVELS,
|
entity_category="config",
|
||||||
write_fn=lambda p, rep, href=None: (
|
value_fn=lambda v: v == "On",
|
||||||
['doorled', 'light', 'vs', '0'],
|
write_fn=_led_night_write,
|
||||||
{'setNightLightBrightness': p})),
|
),
|
||||||
TimeDesc(key='led_night_start', field='setNightLightTimeStart',
|
SelectDesc(
|
||||||
icon='mdi:clock-start',
|
key="led_night_brightness",
|
||||||
entity_category='config',
|
field="setNightLightBrightness",
|
||||||
value_fn=_parse_hm,
|
icon="mdi:brightness-4",
|
||||||
write_fn=lambda p, rep, href=None: (
|
entity_category="config",
|
||||||
['doorled', 'light', 'vs', '0'],
|
options=_LED_LEVELS,
|
||||||
{'setNightLightTimeStart': f'{p.hour:02d}:{p.minute:02d}'})),
|
write_fn=lambda p, rep, href=None: (
|
||||||
TimeDesc(key='led_night_end', field='setNightLightTimeEnd',
|
["doorled", "light", "vs", "0"],
|
||||||
icon='mdi:clock-end',
|
{"setNightLightBrightness": p},
|
||||||
entity_category='config',
|
),
|
||||||
value_fn=_parse_hm,
|
),
|
||||||
write_fn=lambda p, rep, href=None: (
|
TimeDesc(
|
||||||
['doorled', 'light', 'vs', '0'],
|
key="led_night_start",
|
||||||
{'setNightLightTimeEnd': f'{p.hour:02d}:{p.minute:02d}'})),
|
field="setNightLightTimeStart",
|
||||||
|
icon="mdi:clock-start",
|
||||||
|
entity_category="config",
|
||||||
|
value_fn=_parse_hm,
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["doorled", "light", "vs", "0"],
|
||||||
|
{"setNightLightTimeStart": f"{p.hour:02d}:{p.minute:02d}"},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TimeDesc(
|
||||||
|
key="led_night_end",
|
||||||
|
field="setNightLightTimeEnd",
|
||||||
|
icon="mdi:clock-end",
|
||||||
|
entity_category="config",
|
||||||
|
value_fn=_parse_hm,
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["doorled", "light", "vs", "0"],
|
||||||
|
{"setNightLightTimeEnd": f"{p.hour:02d}:{p.minute:02d}"},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
SOUND_MODE = Capability(
|
SOUND_MODE = Capability(
|
||||||
href='/settings/sound/mode/vs/0',
|
href="/settings/sound/mode/vs/0",
|
||||||
entities=(
|
entities=(
|
||||||
SelectDesc(key='sound_mode', field='mode',
|
SelectDesc(
|
||||||
icon='mdi:volume-high',
|
key="sound_mode",
|
||||||
entity_category='config',
|
field="mode",
|
||||||
options=_SOUND_MODES, write_fn=_sound_mode_write),
|
icon="mdi:volume-high",
|
||||||
|
entity_category="config",
|
||||||
|
options=_SOUND_MODES,
|
||||||
|
write_fn=_sound_mode_write,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
SOUND_VOLUME = Capability(
|
SOUND_VOLUME = Capability(
|
||||||
href='/settings/sound/volume/vs/0',
|
href="/settings/sound/volume/vs/0",
|
||||||
entities=(
|
entities=(
|
||||||
NumberDesc(key='sound_volume', field='level',
|
NumberDesc(
|
||||||
icon='mdi:volume-medium',
|
key="sound_volume",
|
||||||
entity_category='config',
|
field="level",
|
||||||
native_min=0, native_max=15, step=5,
|
icon="mdi:volume-medium",
|
||||||
value_fn=lambda v: int(v) if v is not None else None,
|
entity_category="config",
|
||||||
write_fn=lambda p, rep, href=None: (
|
native_min=0,
|
||||||
['settings', 'sound', 'volume', 'vs', '0'],
|
native_max=15,
|
||||||
{'level': str(int(p))})),
|
step=5,
|
||||||
|
value_fn=lambda v: int(v) if v is not None else None,
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["settings", "sound", "volume", "vs", "0"],
|
||||||
|
{"level": str(int(p))},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -125,21 +155,25 @@ SOUND_VOLUME = Capability(
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
BUZZER_SOUND = Capability(
|
BUZZER_SOUND = Capability(
|
||||||
href='/buzzersound/vs/0',
|
href="/buzzersound/vs/0",
|
||||||
entities=(
|
entities=(
|
||||||
SelectDesc(key='buzzer_sound', field='setBuzzerSound',
|
SelectDesc(
|
||||||
icon='mdi:volume-high',
|
key="buzzer_sound",
|
||||||
entity_category='config',
|
field="setBuzzerSound",
|
||||||
options_field='supportedBuzzerSound',
|
icon="mdi:volume-high",
|
||||||
write_fn=lambda p, rep, href=None: (
|
entity_category="config",
|
||||||
['buzzersound', 'vs', '0'], {'setBuzzerSound': p})),
|
options_field="supportedBuzzerSound",
|
||||||
SelectDesc(key='finish_sound', field='setFinishSound',
|
write_fn=lambda p, rep, href=None: (["buzzersound", "vs", "0"], {"setBuzzerSound": p}),
|
||||||
icon='mdi:bell-ring',
|
),
|
||||||
entity_category='config',
|
SelectDesc(
|
||||||
exists_fn=lambda rep, resources: 'supportedFinishSound' in rep,
|
key="finish_sound",
|
||||||
options_field='supportedFinishSound',
|
field="setFinishSound",
|
||||||
write_fn=lambda p, rep, href=None: (
|
icon="mdi:bell-ring",
|
||||||
['buzzersound', 'vs', '0'], {'setFinishSound': p})),
|
entity_category="config",
|
||||||
|
exists_fn=lambda rep, resources: "supportedFinishSound" in rep,
|
||||||
|
options_field="supportedFinishSound",
|
||||||
|
write_fn=lambda p, rep, href=None: (["buzzersound", "vs", "0"], {"setFinishSound": p}),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -174,29 +208,29 @@ BUZZER_SOUND = Capability(
|
|||||||
|
|
||||||
def hex_pairs(codes):
|
def hex_pairs(codes):
|
||||||
"""'1C1D21...' -> ['1C', '1D', '21', ...]."""
|
"""'1C1D21...' -> ['1C', '1D', '21', ...]."""
|
||||||
return [codes[i:i + 2] for i in range(0, len(codes) - 1, 2)]
|
return [codes[i : i + 2] for i in range(0, len(codes) - 1, 2)]
|
||||||
|
|
||||||
|
|
||||||
def parse_edit_course_list(raw):
|
def parse_edit_course_list(raw):
|
||||||
"""'EditCourseList_1C1D21...' -> ['1C', '1D', '21', ...]."""
|
"""'EditCourseList_1C1D21...' -> ['1C', '1D', '21', ...]."""
|
||||||
if not isinstance(raw, str) or '_' not in raw:
|
if not isinstance(raw, str) or "_" not in raw:
|
||||||
return []
|
return []
|
||||||
return hex_pairs(raw.split('_', 1)[1])
|
return hex_pairs(raw.split("_", 1)[1])
|
||||||
|
|
||||||
|
|
||||||
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'))
|
codes = parse_edit_course_list(rep.get("x.com.samsung.da.editCourseList"))
|
||||||
if codes:
|
if codes:
|
||||||
return codes
|
return codes
|
||||||
return _course_codes_from_supported_options(resources.get('/course/vs/0') or {})
|
return _course_codes_from_supported_options(resources.get("/course/vs/0") or {})
|
||||||
|
|
||||||
|
|
||||||
def option_value(options, prefix):
|
def option_value(options, prefix):
|
||||||
"""Find `<prefix>_<value>` in the options array and return <value>."""
|
"""Find `<prefix>_<value>` in the options array and return <value>."""
|
||||||
for o in (options or []):
|
for o in options or []:
|
||||||
if isinstance(o, str) and o.startswith(prefix + '_'):
|
if isinstance(o, str) and o.startswith(prefix + "_"):
|
||||||
return o.split('_', 1)[1]
|
return o.split("_", 1)[1]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@@ -238,7 +272,7 @@ def _course_codes_from_supported_options(course_rep):
|
|||||||
enough (double digits) that colliding by chance on both checks is
|
enough (double digits) that colliding by chance on both checks is
|
||||||
unlikely, and no device seen so far actually needs it.
|
unlikely, and no device seen so far actually needs it.
|
||||||
"""
|
"""
|
||||||
raw = course_rep.get('x.com.samsung.da.supportedOptions')
|
raw = course_rep.get("x.com.samsung.da.supportedOptions")
|
||||||
hexstr = raw[0] if isinstance(raw, list) and raw else raw
|
hexstr = raw[0] if isinstance(raw, list) and raw else raw
|
||||||
if not isinstance(hexstr, str) or len(hexstr) < 3:
|
if not isinstance(hexstr, str) or len(hexstr) < 3:
|
||||||
return []
|
return []
|
||||||
@@ -246,14 +280,14 @@ def _course_codes_from_supported_options(course_rep):
|
|||||||
if len(body) % 2:
|
if len(body) % 2:
|
||||||
return []
|
return []
|
||||||
total_bytes = len(body) // 2
|
total_bytes = len(body) // 2
|
||||||
current = option_value(course_rep.get('x.com.samsung.da.options'), 'Course')
|
current = option_value(course_rep.get("x.com.samsung.da.options"), "Course")
|
||||||
for k in range(1, total_bytes + 1):
|
for k in range(1, total_bytes + 1):
|
||||||
if total_bytes % k:
|
if total_bytes % k:
|
||||||
continue
|
continue
|
||||||
n = total_bytes // k
|
n = total_bytes // k
|
||||||
if n < 2:
|
if n < 2:
|
||||||
continue
|
continue
|
||||||
firsts = [body[i * k * 2:i * k * 2 + 2] for i in range(n)]
|
firsts = [body[i * k * 2 : i * k * 2 + 2] for i in range(n)]
|
||||||
if len(set(firsts)) != n:
|
if len(set(firsts)) != n:
|
||||||
continue
|
continue
|
||||||
if current is not None and current not in firsts:
|
if current is not None and current not in firsts:
|
||||||
@@ -265,20 +299,20 @@ def _course_codes_from_supported_options(course_rep):
|
|||||||
def option_write(prefix, new_value):
|
def option_write(prefix, new_value):
|
||||||
"""A one-token x.com.samsung.da.options write -- see the module comment
|
"""A one-token x.com.samsung.da.options write -- see the module comment
|
||||||
above cycle_options for why this doesn't read/rewrite the whole array."""
|
above cycle_options for why this doesn't read/rewrite the whole array."""
|
||||||
return [f'{prefix}_{new_value}']
|
return [f"{prefix}_{new_value}"]
|
||||||
|
|
||||||
|
|
||||||
def cycle_write(p, rep, href=None):
|
def cycle_write(p, rep, href=None):
|
||||||
if not rep.get('x.com.samsung.da.options'):
|
if not rep.get("x.com.samsung.da.options"):
|
||||||
return None
|
return None
|
||||||
return ['course', 'vs', '0'], {
|
return ["course", "vs", "0"], {
|
||||||
'x.com.samsung.da.options': option_write('Course', p),
|
"x.com.samsung.da.options": option_write("Course", p),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def _table_id(resources, table_href):
|
def _table_id(resources, table_href):
|
||||||
rep = resources.get(table_href) or {}
|
rep = resources.get(table_href) or {}
|
||||||
return rep.get('x.com.samsung.da.st.courseTable')
|
return rep.get("x.com.samsung.da.st.courseTable")
|
||||||
|
|
||||||
|
|
||||||
def cycle_select(*, translation_key, icon, table_href=None):
|
def cycle_select(*, translation_key, icon, table_href=None):
|
||||||
@@ -316,18 +350,21 @@ def cycle_select(*, translation_key, icon, table_href=None):
|
|||||||
"""
|
"""
|
||||||
key = translation_key
|
key = translation_key
|
||||||
if table_href is not None:
|
if table_href is not None:
|
||||||
|
|
||||||
def key(resources):
|
def key(resources):
|
||||||
table = _table_id(resources, table_href)
|
table = _table_id(resources, table_href)
|
||||||
if not isinstance(table, str) or not table:
|
if not isinstance(table, str) or not table:
|
||||||
return 'cycle'
|
return "cycle"
|
||||||
candidate = f'{translation_key}_{table.lower()}'
|
candidate = f"{translation_key}_{table.lower()}"
|
||||||
return candidate if has_entity_translation('select', candidate) else 'cycle'
|
return candidate if has_entity_translation("select", candidate) else "cycle"
|
||||||
|
|
||||||
return SelectDesc(
|
return SelectDesc(
|
||||||
key='cycle', icon=icon, translation_key=key,
|
key="cycle",
|
||||||
|
icon=icon,
|
||||||
|
translation_key=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"),
|
||||||
write_fn=cycle_write,
|
write_fn=cycle_write,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -344,27 +381,30 @@ def cycle_select(*, translation_key, icon, table_href=None):
|
|||||||
|
|
||||||
def bool_option_write(prefix):
|
def bool_option_write(prefix):
|
||||||
def write(p, rep, href=None):
|
def write(p, rep, href=None):
|
||||||
if p not in ('On', 'Off'):
|
if p not in ("On", "Off"):
|
||||||
return None
|
return None
|
||||||
if not rep.get('x.com.samsung.da.options'):
|
if not rep.get("x.com.samsung.da.options"):
|
||||||
return None
|
return None
|
||||||
return ['course', 'vs', '0'], {
|
return ["course", "vs", "0"], {
|
||||||
'x.com.samsung.da.options': option_write(prefix, p),
|
"x.com.samsung.da.options": option_write(prefix, p),
|
||||||
}
|
}
|
||||||
|
|
||||||
return write
|
return write
|
||||||
|
|
||||||
|
|
||||||
def bool_option_value(prefix):
|
def bool_option_value(prefix):
|
||||||
return lambda rep: option_value(rep.get('x.com.samsung.da.options'), prefix) == 'On'
|
return lambda rep: option_value(rep.get("x.com.samsung.da.options"), prefix) == "On"
|
||||||
|
|
||||||
|
|
||||||
def bool_option_exists(prefix):
|
def bool_option_exists(prefix):
|
||||||
return lambda rep, resources: option_value(
|
return lambda rep, resources: (
|
||||||
rep.get('x.com.samsung.da.options'), prefix) is not None
|
option_value(rep.get("x.com.samsung.da.options"), prefix) is not None
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def bool_option_switch(key, icon, prefix, *, entity_category=None,
|
def bool_option_switch(
|
||||||
gate_on_presence=False, validate_fn=None):
|
key, icon, prefix, *, entity_category=None, gate_on_presence=False, validate_fn=None
|
||||||
|
):
|
||||||
"""A SwitchDesc over a '<prefix>_On'/'<prefix>_Off' options[] token.
|
"""A SwitchDesc over a '<prefix>_On'/'<prefix>_Off' options[] token.
|
||||||
|
|
||||||
gate_on_presence self-gates the entity off on models that never report
|
gate_on_presence self-gates the entity off on models that never report
|
||||||
@@ -376,7 +416,9 @@ def bool_option_switch(key, icon, prefix, *, entity_category=None,
|
|||||||
building one, if needed, is the caller's job.
|
building one, if needed, is the caller's job.
|
||||||
"""
|
"""
|
||||||
return SwitchDesc(
|
return SwitchDesc(
|
||||||
key=key, icon=icon, entity_category=entity_category,
|
key=key,
|
||||||
|
icon=icon,
|
||||||
|
entity_category=entity_category,
|
||||||
exists_fn=bool_option_exists(prefix) if gate_on_presence else None,
|
exists_fn=bool_option_exists(prefix) if gate_on_presence else None,
|
||||||
rep_fn=bool_option_value(prefix),
|
rep_fn=bool_option_value(prefix),
|
||||||
write_fn=bool_option_write(prefix),
|
write_fn=bool_option_write(prefix),
|
||||||
@@ -394,11 +436,13 @@ def bool_option_switch(key, icon, prefix, *, entity_category=None,
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
JOB_BEGINNING_STATUS = Capability(
|
JOB_BEGINNING_STATUS = Capability(
|
||||||
href='/wm/jobbeginingstatus/vs/0',
|
href="/wm/jobbeginingstatus/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='job_beginning_status',
|
SensorDesc(
|
||||||
field='x.com.samsung.da.currentStatus',
|
key="job_beginning_status",
|
||||||
entity_category='diagnostic'),
|
field="x.com.samsung.da.currentStatus",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -36,6 +36,7 @@ Note: cooking-mode writes are unproven here, same caveat as oven.py's
|
|||||||
OVEN_MODE -- exposed as a SelectDesc for fidelity, first real-world write
|
OVEN_MODE -- exposed as a SelectDesc for fidelity, first real-world write
|
||||||
is also the test.
|
is also the test.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
from ..entities import NumberDesc, SelectDesc, SensorDesc, SwitchDesc
|
from ..entities import NumberDesc, SelectDesc, SensorDesc, SwitchDesc
|
||||||
from .common import int_or_none, normalize_temp_unit
|
from .common import int_or_none, normalize_temp_unit
|
||||||
@@ -53,17 +54,17 @@ from .laundry import option_value, option_write
|
|||||||
# board's own /mode/vs/0 supportedModes reports; an entry here that a device
|
# board's own /mode/vs/0 supportedModes reports; an entry here that a device
|
||||||
# never sends just never gets picked.
|
# never sends just never gets picked.
|
||||||
_MICROWAVE_MODES = (
|
_MICROWAVE_MODES = (
|
||||||
'NoOperation',
|
"NoOperation",
|
||||||
'MicroWave',
|
"MicroWave",
|
||||||
'MicroWaveGrill',
|
"MicroWaveGrill",
|
||||||
'MicroWaveConvection',
|
"MicroWaveConvection",
|
||||||
'Convection',
|
"Convection",
|
||||||
'AirFryer',
|
"AirFryer",
|
||||||
'Grill',
|
"Grill",
|
||||||
'Autocook',
|
"Autocook",
|
||||||
'AutocookCustom',
|
"AutocookCustom",
|
||||||
'Deodorization',
|
"Deodorization",
|
||||||
'KeepWarm',
|
"KeepWarm",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Convection/MicroWaveConvection modeSpec on issue #121's dump: tempMinC 40,
|
# Convection/MicroWaveConvection modeSpec on issue #121's dump: tempMinC 40,
|
||||||
@@ -82,9 +83,9 @@ def _microwave_temp_unit(rep):
|
|||||||
carries a per-item x.com.samsung.da.unit field. Both known dumps for
|
carries a per-item x.com.samsung.da.unit field. Both known dumps for
|
||||||
this family report 'Celsius'; kept live rather than hardcoded per the
|
this family report 'Celsius'; kept live rather than hardcoded per the
|
||||||
fridge/oven convention (issue #7)."""
|
fridge/oven convention (issue #7)."""
|
||||||
items = rep.get('x.com.samsung.da.items') or []
|
items = rep.get("x.com.samsung.da.items") or []
|
||||||
unit = items[0].get('x.com.samsung.da.unit') if items else None
|
unit = items[0].get("x.com.samsung.da.unit") if items else None
|
||||||
return normalize_temp_unit(unit, default='°C')
|
return normalize_temp_unit(unit, default="°C")
|
||||||
|
|
||||||
|
|
||||||
def _setpoint_write(p, rep, href=None):
|
def _setpoint_write(p, rep, href=None):
|
||||||
@@ -98,12 +99,12 @@ def _setpoint_write(p, rep, href=None):
|
|||||||
temp_i = int(round(temp / SETPOINT_STEP_C) * SETPOINT_STEP_C)
|
temp_i = int(round(temp / SETPOINT_STEP_C) * SETPOINT_STEP_C)
|
||||||
if not (SETPOINT_MIN_C <= temp_i <= SETPOINT_MAX_C):
|
if not (SETPOINT_MIN_C <= temp_i <= SETPOINT_MAX_C):
|
||||||
return None
|
return None
|
||||||
items = rep.get('x.com.samsung.da.items')
|
items = rep.get("x.com.samsung.da.items")
|
||||||
if not items:
|
if not items:
|
||||||
return None
|
return None
|
||||||
items = [dict(it) for it in items]
|
items = [dict(it) for it in items]
|
||||||
items[0]['x.com.samsung.da.desired'] = str(temp_i)
|
items[0]["x.com.samsung.da.desired"] = str(temp_i)
|
||||||
return ['temperatures', 'vs', '0'], {'x.com.samsung.da.items': items}
|
return ["temperatures", "vs", "0"], {"x.com.samsung.da.items": items}
|
||||||
|
|
||||||
|
|
||||||
def _power_level_watts(v):
|
def _power_level_watts(v):
|
||||||
@@ -111,7 +112,7 @@ def _power_level_watts(v):
|
|||||||
if v is None:
|
if v is None:
|
||||||
return None
|
return None
|
||||||
s = str(v).strip()
|
s = str(v).strip()
|
||||||
if s.upper().endswith('W'):
|
if s.upper().endswith("W"):
|
||||||
s = s[:-1]
|
s = s[:-1]
|
||||||
return int_or_none(s)
|
return int_or_none(s)
|
||||||
|
|
||||||
@@ -123,71 +124,71 @@ def _cooking_mode_options(resources):
|
|||||||
pattern as oven._oven_mode_options -- a fixed list here would offer
|
pattern as oven._oven_mode_options -- a fixed list here would offer
|
||||||
users modes their own unit doesn't have (issue #152's ME7500D reports
|
users modes their own unit doesn't have (issue #152's ME7500D reports
|
||||||
only 4 of _MICROWAVE_MODES' 11)."""
|
only 4 of _MICROWAVE_MODES' 11)."""
|
||||||
rep = resources.get('/mode/vs/0') or {}
|
rep = resources.get("/mode/vs/0") or {}
|
||||||
live = rep.get('x.com.samsung.da.supportedModes')
|
live = rep.get("x.com.samsung.da.supportedModes")
|
||||||
return list(live) if live else list(_MICROWAVE_MODES)
|
return list(live) if live else list(_MICROWAVE_MODES)
|
||||||
|
|
||||||
|
|
||||||
def _mode_write(p, rep, href=None):
|
def _mode_write(p, rep, href=None):
|
||||||
valid = rep.get('x.com.samsung.da.supportedModes') or _MICROWAVE_MODES
|
valid = rep.get("x.com.samsung.da.supportedModes") or _MICROWAVE_MODES
|
||||||
if p not in valid:
|
if p not in valid:
|
||||||
return None
|
return None
|
||||||
return ['mode', 'vs', '0'], {'x.com.samsung.da.modes': [p]}
|
return ["mode", "vs", "0"], {"x.com.samsung.da.modes": [p]}
|
||||||
|
|
||||||
|
|
||||||
def _sound_write(p, rep, href=None):
|
def _sound_write(p, rep, href=None):
|
||||||
if p not in ('On', 'Off'):
|
if p not in ("On", "Off"):
|
||||||
return None
|
return None
|
||||||
if not rep.get('x.com.samsung.da.options'):
|
if not rep.get("x.com.samsung.da.options"):
|
||||||
return None
|
return None
|
||||||
return ['mode', 'vs', '0'], {
|
return ["mode", "vs", "0"], {
|
||||||
'x.com.samsung.da.options': option_write('Sound', p),
|
"x.com.samsung.da.options": option_write("Sound", p),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def _lamp_exists(rep, resources):
|
def _lamp_exists(rep, resources):
|
||||||
return option_value(rep.get('x.com.samsung.da.options'), 'Lamp') is not None
|
return option_value(rep.get("x.com.samsung.da.options"), "Lamp") is not None
|
||||||
|
|
||||||
|
|
||||||
def _filter_remind_exists(rep, resources):
|
def _filter_remind_exists(rep, resources):
|
||||||
return option_value(rep.get('x.com.samsung.da.options'), 'FilterRemind') is not None
|
return option_value(rep.get("x.com.samsung.da.options"), "FilterRemind") is not None
|
||||||
|
|
||||||
|
|
||||||
def _remind_beep_exists(rep, resources):
|
def _remind_beep_exists(rep, resources):
|
||||||
return option_value(rep.get('x.com.samsung.da.options'), 'RemindBeep') is not None
|
return option_value(rep.get("x.com.samsung.da.options"), "RemindBeep") is not None
|
||||||
|
|
||||||
|
|
||||||
def _lamp_write(p, rep, href=None):
|
def _lamp_write(p, rep, href=None):
|
||||||
if p not in ('On', 'Off'):
|
if p not in ("On", "Off"):
|
||||||
return None
|
return None
|
||||||
if not rep.get('x.com.samsung.da.options'):
|
if not rep.get("x.com.samsung.da.options"):
|
||||||
return None
|
return None
|
||||||
# 'High' and 'Off' are the two tokens actually confirmed on live dumps
|
# 'High' and 'Off' are the two tokens actually confirmed on live dumps
|
||||||
# (issues #137/#152) -- 'On' has never been observed and the device
|
# (issues #137/#152) -- 'On' has never been observed and the device
|
||||||
# likely doesn't recognize it (see module docstring).
|
# likely doesn't recognize it (see module docstring).
|
||||||
token = 'High' if p == 'On' else 'Off'
|
token = "High" if p == "On" else "Off"
|
||||||
return ['mode', 'vs', '0'], {
|
return ["mode", "vs", "0"], {
|
||||||
'x.com.samsung.da.options': option_write('Lamp', token),
|
"x.com.samsung.da.options": option_write("Lamp", token),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def _filter_remind_write(p, rep, href=None):
|
def _filter_remind_write(p, rep, href=None):
|
||||||
if p not in ('On', 'Off'):
|
if p not in ("On", "Off"):
|
||||||
return None
|
return None
|
||||||
if not rep.get('x.com.samsung.da.options'):
|
if not rep.get("x.com.samsung.da.options"):
|
||||||
return None
|
return None
|
||||||
return ['mode', 'vs', '0'], {
|
return ["mode", "vs", "0"], {
|
||||||
'x.com.samsung.da.options': option_write('FilterRemind', p),
|
"x.com.samsung.da.options": option_write("FilterRemind", p),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def _remind_beep_write(p, rep, href=None):
|
def _remind_beep_write(p, rep, href=None):
|
||||||
if p not in ('On', 'Off'):
|
if p not in ("On", "Off"):
|
||||||
return None
|
return None
|
||||||
if not rep.get('x.com.samsung.da.options'):
|
if not rep.get("x.com.samsung.da.options"):
|
||||||
return None
|
return None
|
||||||
return ['mode', 'vs', '0'], {
|
return ["mode", "vs", "0"], {
|
||||||
'x.com.samsung.da.options': option_write('RemindBeep', p),
|
"x.com.samsung.da.options": option_write("RemindBeep", p),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -196,71 +197,102 @@ def _remind_beep_write(p, rep, href=None):
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
MICROWAVE_CAVITY = Capability(
|
MICROWAVE_CAVITY = Capability(
|
||||||
href='/oven/vs/0',
|
href="/oven/vs/0",
|
||||||
poll_tier='hot',
|
poll_tier="hot",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='cavity_state', field='x.com.samsung.da.state'),
|
SensorDesc(key="cavity_state", field="x.com.samsung.da.state"),
|
||||||
SensorDesc(key='power_level', field='x.com.samsung.da.powerLevel',
|
SensorDesc(
|
||||||
unit='W', value_fn=_power_level_watts),
|
key="power_level",
|
||||||
|
field="x.com.samsung.da.powerLevel",
|
||||||
|
unit="W",
|
||||||
|
value_fn=_power_level_watts,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
MICROWAVE_SETPOINT = Capability(
|
MICROWAVE_SETPOINT = Capability(
|
||||||
href='/temperatures/vs/0',
|
href="/temperatures/vs/0",
|
||||||
poll_tier='hot',
|
poll_tier="hot",
|
||||||
entities=(
|
entities=(
|
||||||
NumberDesc(key='setpoint', field='x.com.samsung.da.items',
|
NumberDesc(
|
||||||
device_class='temperature', unit_fn=_microwave_temp_unit,
|
key="setpoint",
|
||||||
native_min=float(SETPOINT_MIN_C), native_max=float(SETPOINT_MAX_C),
|
field="x.com.samsung.da.items",
|
||||||
step=float(SETPOINT_STEP_C), icon='mdi:thermometer-chevron-up',
|
device_class="temperature",
|
||||||
exists_fn=lambda rep, resources: _microwave_temp_unit(rep) == '°C',
|
unit_fn=_microwave_temp_unit,
|
||||||
value_fn=lambda items: int_or_none(
|
native_min=float(SETPOINT_MIN_C),
|
||||||
(items[0].get('x.com.samsung.da.desired') if items else None)),
|
native_max=float(SETPOINT_MAX_C),
|
||||||
write_fn=_setpoint_write),
|
step=float(SETPOINT_STEP_C),
|
||||||
SensorDesc(key='current_temp_c', field='x.com.samsung.da.items',
|
icon="mdi:thermometer-chevron-up",
|
||||||
device_class='temperature',
|
exists_fn=lambda rep, resources: _microwave_temp_unit(rep) == "°C",
|
||||||
state_class='measurement', unit_fn=_microwave_temp_unit,
|
value_fn=lambda items: int_or_none(
|
||||||
value_fn=lambda items: int_or_none(
|
items[0].get("x.com.samsung.da.desired") if items else None
|
||||||
(items[0].get('x.com.samsung.da.current') if items else None))),
|
),
|
||||||
|
write_fn=_setpoint_write,
|
||||||
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="current_temp_c",
|
||||||
|
field="x.com.samsung.da.items",
|
||||||
|
device_class="temperature",
|
||||||
|
state_class="measurement",
|
||||||
|
unit_fn=_microwave_temp_unit,
|
||||||
|
value_fn=lambda items: int_or_none(
|
||||||
|
items[0].get("x.com.samsung.da.current") if items else None
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
MICROWAVE_MODE = Capability(
|
MICROWAVE_MODE = Capability(
|
||||||
href='/mode/vs/0',
|
href="/mode/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
# SelectDesc first — test_microwave_mode_options_nonempty uses entities[0]
|
# SelectDesc first — test_microwave_mode_options_nonempty uses entities[0]
|
||||||
SelectDesc(key='cooking_mode', field='x.com.samsung.da.modes',
|
SelectDesc(
|
||||||
icon='mdi:tune',
|
key="cooking_mode",
|
||||||
options=_cooking_mode_options,
|
field="x.com.samsung.da.modes",
|
||||||
value_fn=lambda v: v[0] if v else None,
|
icon="mdi:tune",
|
||||||
write_fn=_mode_write),
|
options=_cooking_mode_options,
|
||||||
SwitchDesc(key='sound', field='x.com.samsung.da.options',
|
value_fn=lambda v: v[0] if v else None,
|
||||||
icon='mdi:volume-high',
|
write_fn=_mode_write,
|
||||||
entity_category='config',
|
),
|
||||||
value_fn=lambda opts: option_value(opts, 'Sound') == 'On',
|
SwitchDesc(
|
||||||
write_fn=_sound_write),
|
key="sound",
|
||||||
SwitchDesc(key='lamp', field='x.com.samsung.da.options',
|
field="x.com.samsung.da.options",
|
||||||
icon='mdi:track-light',
|
icon="mdi:volume-high",
|
||||||
exists_fn=_lamp_exists,
|
entity_category="config",
|
||||||
value_fn=lambda opts: option_value(opts, 'Lamp') not in (None, 'Off'),
|
value_fn=lambda opts: option_value(opts, "Sound") == "On",
|
||||||
write_fn=_lamp_write),
|
write_fn=_sound_write,
|
||||||
|
),
|
||||||
|
SwitchDesc(
|
||||||
|
key="lamp",
|
||||||
|
field="x.com.samsung.da.options",
|
||||||
|
icon="mdi:track-light",
|
||||||
|
exists_fn=_lamp_exists,
|
||||||
|
value_fn=lambda opts: option_value(opts, "Lamp") not in (None, "Off"),
|
||||||
|
write_fn=_lamp_write,
|
||||||
|
),
|
||||||
# issue #181: Filter Reminder / End Signal Reminder toggles,
|
# issue #181: Filter Reminder / End Signal Reminder toggles,
|
||||||
# confirmed present (both On and Off observed across dumps -- see
|
# confirmed present (both On and Off observed across dumps -- see
|
||||||
# issue #152's ME7500D fixtures) but only on boards that carry the
|
# issue #152's ME7500D fixtures) but only on boards that carry the
|
||||||
# FilterRemind_*/RemindBeep_* tokens; gated off elsewhere (e.g. the
|
# FilterRemind_*/RemindBeep_* tokens; gated off elsewhere (e.g. the
|
||||||
# MW7300B combi dump has neither) rather than assumed universal.
|
# MW7300B combi dump has neither) rather than assumed universal.
|
||||||
SwitchDesc(key='filter_remind', field='x.com.samsung.da.options',
|
SwitchDesc(
|
||||||
icon='mdi:air-filter',
|
key="filter_remind",
|
||||||
entity_category='config',
|
field="x.com.samsung.da.options",
|
||||||
exists_fn=_filter_remind_exists,
|
icon="mdi:air-filter",
|
||||||
value_fn=lambda opts: option_value(opts, 'FilterRemind') == 'On',
|
entity_category="config",
|
||||||
write_fn=_filter_remind_write),
|
exists_fn=_filter_remind_exists,
|
||||||
SwitchDesc(key='remind_beep', field='x.com.samsung.da.options',
|
value_fn=lambda opts: option_value(opts, "FilterRemind") == "On",
|
||||||
icon='mdi:bell-ring',
|
write_fn=_filter_remind_write,
|
||||||
entity_category='config',
|
),
|
||||||
exists_fn=_remind_beep_exists,
|
SwitchDesc(
|
||||||
value_fn=lambda opts: option_value(opts, 'RemindBeep') == 'On',
|
key="remind_beep",
|
||||||
write_fn=_remind_beep_write),
|
field="x.com.samsung.da.options",
|
||||||
|
icon="mdi:bell-ring",
|
||||||
|
entity_category="config",
|
||||||
|
exists_fn=_remind_beep_exists,
|
||||||
|
value_fn=lambda opts: option_value(opts, "RemindBeep") == "On",
|
||||||
|
write_fn=_remind_beep_write,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -2,15 +2,21 @@
|
|||||||
|
|
||||||
Shared by dryer/dishwasher/oven/washer families.
|
Shared by dryer/dishwasher/oven/washer families.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import math
|
import math
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import UTC, datetime, timedelta
|
||||||
|
|
||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
from ..entities import BinarySensorDesc, ButtonDesc, NumberDesc, SensorDesc
|
from ..entities import BinarySensorDesc, ButtonDesc, NumberDesc, SensorDesc
|
||||||
|
|
||||||
_SAMSUNG_STATE_TO_OCF = {
|
_SAMSUNG_STATE_TO_OCF = {
|
||||||
'Ready': 'idle', 'Run': 'active', 'Running': 'active',
|
"Ready": "idle",
|
||||||
'Pause': 'pause', 'Paused': 'pause', 'End': 'idle', 'Stop': 'idle',
|
"Run": "active",
|
||||||
|
"Running": "active",
|
||||||
|
"Pause": "pause",
|
||||||
|
"Paused": "pause",
|
||||||
|
"End": "idle",
|
||||||
|
"Stop": "idle",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -19,7 +25,7 @@ def _to_ocf(v):
|
|||||||
|
|
||||||
|
|
||||||
def _progress(v):
|
def _progress(v):
|
||||||
return 'Idle' if v in (None, 'None') else v
|
return "Idle" if v in (None, "None") else v
|
||||||
|
|
||||||
|
|
||||||
def _int(v):
|
def _int(v):
|
||||||
@@ -32,8 +38,8 @@ def _int(v):
|
|||||||
def _is_active(rep):
|
def _is_active(rep):
|
||||||
"""Check if appliance is actively running and cycle is not finished."""
|
"""Check if appliance is actively running and cycle is not finished."""
|
||||||
return (
|
return (
|
||||||
_SAMSUNG_STATE_TO_OCF.get(rep.get('x.com.samsung.da.state')) == 'active'
|
_SAMSUNG_STATE_TO_OCF.get(rep.get("x.com.samsung.da.state")) == "active"
|
||||||
and rep.get('x.com.samsung.da.progress') != 'Finish'
|
and rep.get("x.com.samsung.da.progress") != "Finish"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -42,7 +48,7 @@ def _remaining_seconds(raw):
|
|||||||
if not isinstance(raw, str):
|
if not isinstance(raw, str):
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
parts = [int(p) for p in raw.split(':')]
|
parts = [int(p) for p in raw.split(":")]
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -69,7 +75,7 @@ def _delay_hours(v):
|
|||||||
def _format_delay(hours):
|
def _format_delay(hours):
|
||||||
total_minutes = round(max(float(hours), 0) * 60)
|
total_minutes = round(max(float(hours), 0) * 60)
|
||||||
h, m = divmod(total_minutes, 60)
|
h, m = divmod(total_minutes, 60)
|
||||||
return f'{h}:{m:02d}:00'
|
return f"{h}:{m:02d}:00"
|
||||||
|
|
||||||
|
|
||||||
def _delay_field(rep):
|
def _delay_field(rep):
|
||||||
@@ -79,29 +85,37 @@ def _delay_field(rep):
|
|||||||
device itself is using; default to delayStartTime for hardware that
|
device itself is using; default to delayStartTime for hardware that
|
||||||
reports neither yet (matches prior behavior)."""
|
reports neither yet (matches prior behavior)."""
|
||||||
return (
|
return (
|
||||||
'x.com.samsung.da.delayEndTime' if 'x.com.samsung.da.delayEndTime' in rep
|
"x.com.samsung.da.delayEndTime"
|
||||||
else 'x.com.samsung.da.delayStartTime'
|
if "x.com.samsung.da.delayEndTime" in rep
|
||||||
|
else "x.com.samsung.da.delayStartTime"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _finish_time(rep):
|
def _finish_time(rep):
|
||||||
if not _is_active(rep):
|
if not _is_active(rep):
|
||||||
return None
|
return None
|
||||||
total_s = _remaining_seconds(rep.get('x.com.samsung.da.remainingTime'))
|
total_s = _remaining_seconds(rep.get("x.com.samsung.da.remainingTime"))
|
||||||
if not total_s:
|
if not total_s:
|
||||||
return None
|
return None
|
||||||
return datetime.now(timezone.utc) + timedelta(seconds=total_s)
|
# Round to whole minutes -- remainingTime itself only has minute
|
||||||
|
# resolution, but datetime.now() always carries fresh seconds/
|
||||||
|
# microseconds, so an unrounded result changes on nearly every poll
|
||||||
|
# even when the device-reported remaining time hasn't. That floods
|
||||||
|
# the recorder history/logbook with values that look identical once
|
||||||
|
# the UI rounds them down for display.
|
||||||
|
finish = datetime.now(UTC) + timedelta(seconds=total_s)
|
||||||
|
return finish.replace(second=0, microsecond=0)
|
||||||
|
|
||||||
|
|
||||||
def _completion_minutes(rep):
|
def _completion_minutes(rep):
|
||||||
"""Parse remaining time into minutes directly from device payload."""
|
"""Parse remaining time into minutes directly from device payload."""
|
||||||
raw = rep.get('x.com.samsung.da.remainingTime') or rep.get('remainingTime')
|
raw = rep.get("x.com.samsung.da.remainingTime") or rep.get("remainingTime")
|
||||||
total_s = _remaining_seconds(raw)
|
total_s = _remaining_seconds(raw)
|
||||||
if total_s is None:
|
if total_s is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Avoid the firmware bug where it freezes at 1 minute post-cycle
|
# Avoid the firmware bug where it freezes at 1 minute post-cycle
|
||||||
if rep.get('x.com.samsung.da.progress') == 'Finish':
|
if rep.get("x.com.samsung.da.progress") == "Finish":
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
return math.ceil(total_s / 60)
|
return math.ceil(total_s / 60)
|
||||||
@@ -110,21 +124,29 @@ def _completion_minutes(rep):
|
|||||||
# Shared by dryer/dishwasher/oven/washer -- oven.py imports this directly
|
# Shared by dryer/dishwasher/oven/washer -- oven.py imports this directly
|
||||||
# rather than keeping its own copy, since both wrote the identical
|
# rather than keeping its own copy, since both wrote the identical
|
||||||
# state='Ready' RMW.
|
# state='Ready' RMW.
|
||||||
STOP_BUTTON = ButtonDesc(key='stop', field='', payload='Ready',
|
STOP_BUTTON = ButtonDesc(
|
||||||
icon='mdi:stop',
|
key="stop",
|
||||||
write_fn=lambda p, rep, href=None: (
|
field="",
|
||||||
['operational', 'state', 'vs', '0'],
|
payload="Ready",
|
||||||
{'x.com.samsung.da.state': p}))
|
icon="mdi:stop",
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["operational", "state", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.state": p},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
OPERATIONAL_STATE = Capability(
|
OPERATIONAL_STATE = Capability(
|
||||||
href='/operational/state/vs/0',
|
href="/operational/state/vs/0",
|
||||||
poll_tier='hot',
|
poll_tier="hot",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='machine_state', field='x.com.samsung.da.state',
|
SensorDesc(
|
||||||
device_class='enum',
|
key="machine_state",
|
||||||
options=('idle', 'active', 'pause'),
|
field="x.com.samsung.da.state",
|
||||||
translation_key='machine_state', value_fn=_to_ocf),
|
device_class="enum",
|
||||||
|
options=("idle", "active", "pause"),
|
||||||
|
translation_key="machine_state",
|
||||||
|
value_fn=_to_ocf,
|
||||||
|
),
|
||||||
# cycle_active is a bool derived from machine_state; used by the
|
# cycle_active is a bool derived from machine_state; used by the
|
||||||
# adapter to gate oven writes (cycle_active_field='cycle_active').
|
# adapter to gate oven writes (cycle_active_field='cycle_active').
|
||||||
# Harmless for non-oven appliances — just an extra bool in state.
|
# Harmless for non-oven appliances — just an extra bool in state.
|
||||||
@@ -134,56 +156,85 @@ OPERATIONAL_STATE = Capability(
|
|||||||
# start/pause/stop buttons below) is shared across the dryer/
|
# start/pause/stop buttons below) is shared across the dryer/
|
||||||
# dishwasher/oven/washer families, and 'cycle' is laundry-specific
|
# dishwasher/oven/washer families, and 'cycle' is laundry-specific
|
||||||
# vocabulary that doesn't fit an oven's bake/roast/etc.
|
# vocabulary that doesn't fit an oven's bake/roast/etc.
|
||||||
BinarySensorDesc(key='cycle_active', device_class='running',
|
BinarySensorDesc(
|
||||||
rep_fn=lambda rep: (
|
key="cycle_active",
|
||||||
_SAMSUNG_STATE_TO_OCF.get(rep.get('x.com.samsung.da.state')) == 'active'
|
device_class="running",
|
||||||
and rep.get('x.com.samsung.da.progress') != 'Finish'
|
rep_fn=lambda rep: (
|
||||||
)),
|
_SAMSUNG_STATE_TO_OCF.get(rep.get("x.com.samsung.da.state")) == "active"
|
||||||
SensorDesc(key='progress', icon='mdi:progress-wrench',
|
and rep.get("x.com.samsung.da.progress") != "Finish"
|
||||||
rep_fn=lambda rep: (
|
),
|
||||||
'Idle' if _SAMSUNG_STATE_TO_OCF.get(rep.get('x.com.samsung.da.state')) != 'active'
|
),
|
||||||
else _progress(rep.get('x.com.samsung.da.progress'))
|
SensorDesc(
|
||||||
)),
|
key="progress",
|
||||||
|
icon="mdi:progress-wrench",
|
||||||
SensorDesc(key='progress_percentage',
|
rep_fn=lambda rep: (
|
||||||
unit='%', state_class='measurement',
|
"Idle"
|
||||||
rep_fn=lambda rep: (
|
if _SAMSUNG_STATE_TO_OCF.get(rep.get("x.com.samsung.da.state")) != "active"
|
||||||
0 if _SAMSUNG_STATE_TO_OCF.get(rep.get('x.com.samsung.da.state')) != 'active'
|
else _progress(rep.get("x.com.samsung.da.progress"))
|
||||||
else _int(rep.get('x.com.samsung.da.progressPercentage'))
|
),
|
||||||
)),
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="progress_percentage",
|
||||||
|
unit="%",
|
||||||
|
state_class="measurement",
|
||||||
|
rep_fn=lambda rep: (
|
||||||
|
0
|
||||||
|
if _SAMSUNG_STATE_TO_OCF.get(rep.get("x.com.samsung.da.state")) != "active"
|
||||||
|
else _int(rep.get("x.com.samsung.da.progressPercentage"))
|
||||||
|
),
|
||||||
|
),
|
||||||
# Only show finish time when machine is actively running. Samsung
|
# Only show finish time when machine is actively running. Samsung
|
||||||
# firmware leaves a stale remainingTime after a cycle ends, and
|
# firmware leaves a stale remainingTime after a cycle ends, and
|
||||||
# freezes it at '00:01:00' when progress reaches 'Finish'.
|
# freezes it at '00:01:00' when progress reaches 'Finish'.
|
||||||
SensorDesc(key='finish_time', device_class='timestamp',
|
SensorDesc(
|
||||||
rep_fn=_finish_time),
|
key="finish_time", device_class="timestamp", hysteresis=True, rep_fn=_finish_time
|
||||||
|
),
|
||||||
SensorDesc(key='completion_minutes',
|
SensorDesc(
|
||||||
icon='mdi:clock-outline', unit='min',
|
key="completion_minutes",
|
||||||
device_class='duration', state_class='measurement',
|
icon="mdi:clock-outline",
|
||||||
exists_fn=lambda rep, resources: _completion_minutes(rep) is not None,
|
unit="min",
|
||||||
rep_fn=_completion_minutes),
|
device_class="duration",
|
||||||
|
state_class="measurement",
|
||||||
NumberDesc(key='delay_start_hours', icon='mdi:timer-plus-outline',
|
exists_fn=lambda rep, resources: _completion_minutes(rep) is not None,
|
||||||
device_class='duration', unit='h',
|
rep_fn=_completion_minutes,
|
||||||
native_min=0, native_max=24, step=1,
|
),
|
||||||
rep_fn=lambda rep: _delay_hours(
|
NumberDesc(
|
||||||
rep.get('x.com.samsung.da.delayStartTime')
|
key="delay_start_hours",
|
||||||
or rep.get('x.com.samsung.da.delayEndTime')),
|
icon="mdi:timer-plus-outline",
|
||||||
write_fn=lambda p, rep, href=None: (
|
device_class="duration",
|
||||||
['operational', 'state', 'vs', '0'],
|
unit="h",
|
||||||
{_delay_field(rep): _format_delay(p)})),
|
native_min=0,
|
||||||
ButtonDesc(key='start', field='', payload='Run',
|
native_max=24,
|
||||||
icon='mdi:play',
|
step=1,
|
||||||
write_fn=lambda p, rep, href=None: (
|
rep_fn=lambda rep: _delay_hours(
|
||||||
['operational', 'state', 'vs', '0'],
|
rep.get("x.com.samsung.da.delayStartTime")
|
||||||
{'x.com.samsung.da.state': p})),
|
or rep.get("x.com.samsung.da.delayEndTime")
|
||||||
ButtonDesc(key='pause', field='', payload='Pause',
|
),
|
||||||
icon='mdi:pause',
|
write_fn=lambda p, rep, href=None: (
|
||||||
write_fn=lambda p, rep, href=None: (
|
["operational", "state", "vs", "0"],
|
||||||
['operational', 'state', 'vs', '0'],
|
{_delay_field(rep): _format_delay(p)},
|
||||||
{'x.com.samsung.da.state': p})),
|
),
|
||||||
|
),
|
||||||
|
ButtonDesc(
|
||||||
|
key="start",
|
||||||
|
field="",
|
||||||
|
payload="Run",
|
||||||
|
icon="mdi:play",
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["operational", "state", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.state": p},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ButtonDesc(
|
||||||
|
key="pause",
|
||||||
|
field="",
|
||||||
|
payload="Pause",
|
||||||
|
icon="mdi:pause",
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["operational", "state", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.state": p},
|
||||||
|
),
|
||||||
|
),
|
||||||
STOP_BUTTON,
|
STOP_BUTTON,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -22,12 +22,17 @@ _start_open.md). Mode writes are also unreliable — the oven rolls them back
|
|||||||
once a cycle is active. OVEN_MODE is provided as a SelectDesc for fidelity
|
once a cycle is active. OVEN_MODE is provided as a SelectDesc for fidelity
|
||||||
but is effectively read-only in practice.
|
but is effectively read-only in practice.
|
||||||
"""
|
"""
|
||||||
from datetime import datetime, timezone, timedelta
|
|
||||||
|
from datetime import UTC, datetime, timedelta
|
||||||
|
|
||||||
from ..batch import is_stub_rep
|
from ..batch import is_stub_rep
|
||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
from ..entities import (
|
from ..entities import (
|
||||||
BinarySensorDesc, NumberDesc, SelectDesc, SensorDesc, SwitchDesc,
|
BinarySensorDesc,
|
||||||
|
NumberDesc,
|
||||||
|
SelectDesc,
|
||||||
|
SensorDesc,
|
||||||
|
SwitchDesc,
|
||||||
)
|
)
|
||||||
from .common import normalize_temp_unit
|
from .common import normalize_temp_unit
|
||||||
from .operational import STOP_BUTTON
|
from .operational import STOP_BUTTON
|
||||||
@@ -61,26 +66,26 @@ SETPOINT_STEP_F = 5
|
|||||||
# the adding-device-support skill's preference for device-reported option
|
# the adding-device-support skill's preference for device-reported option
|
||||||
# lists over hardcoded ones.
|
# lists over hardcoded ones.
|
||||||
_OVEN_MODES = (
|
_OVEN_MODES = (
|
||||||
'NoOperation',
|
"NoOperation",
|
||||||
'Bake',
|
"Bake",
|
||||||
'Broil',
|
"Broil",
|
||||||
'Convection',
|
"Convection",
|
||||||
'ConvectionBake',
|
"ConvectionBake",
|
||||||
'ConvectionBroil',
|
"ConvectionBroil",
|
||||||
'FrozenPizzaPlus',
|
"FrozenPizzaPlus",
|
||||||
'SlowCook',
|
"SlowCook",
|
||||||
'PlateWarm',
|
"PlateWarm",
|
||||||
'AirFry',
|
"AirFry",
|
||||||
)
|
)
|
||||||
|
|
||||||
_SAMSUNG_STATE_TO_OCF = {
|
_SAMSUNG_STATE_TO_OCF = {
|
||||||
'Ready': 'idle',
|
"Ready": "idle",
|
||||||
'Run': 'active',
|
"Run": "active",
|
||||||
'Running': 'active',
|
"Running": "active",
|
||||||
'Pause': 'pause',
|
"Pause": "pause",
|
||||||
'Paused': 'pause',
|
"Paused": "pause",
|
||||||
'End': 'idle',
|
"End": "idle",
|
||||||
'Stop': 'idle',
|
"Stop": "idle",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -99,11 +104,11 @@ def _finish_time(remaining_str):
|
|||||||
if not remaining_str:
|
if not remaining_str:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
h, m, s = remaining_str.split(':')
|
h, m, s = remaining_str.split(":")
|
||||||
total_s = int(h) * 3600 + int(m) * 60 + int(s)
|
total_s = int(h) * 3600 + int(m) * 60 + int(s)
|
||||||
if total_s == 0:
|
if total_s == 0:
|
||||||
return None
|
return None
|
||||||
return datetime.now(timezone.utc) + timedelta(seconds=total_s)
|
return datetime.now(UTC) + timedelta(seconds=total_s)
|
||||||
except Exception:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -113,7 +118,7 @@ def _op_minutes(op_time):
|
|||||||
if not op_time:
|
if not op_time:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
h, m, s = op_time.split(':')
|
h, m, s = op_time.split(":")
|
||||||
return int(h) * 60 + int(m) + (1 if int(s) > 0 else 0)
|
return int(h) * 60 + int(m) + (1 if int(s) > 0 else 0)
|
||||||
except Exception:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
@@ -123,11 +128,12 @@ def _op_minutes(op_time):
|
|||||||
# Options-array helpers (shared by lamp, sound, fastpreheat, naturalsteam)
|
# Options-array helpers (shared by lamp, sound, fastpreheat, naturalsteam)
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def _option_value(options, prefix):
|
def _option_value(options, prefix):
|
||||||
"""Find `<prefix>_<value>` in an options array and return <value>."""
|
"""Find `<prefix>_<value>` in an options array and return <value>."""
|
||||||
for o in (options or []):
|
for o in options or []:
|
||||||
if isinstance(o, str) and o.startswith(prefix + '_'):
|
if isinstance(o, str) and o.startswith(prefix + "_"):
|
||||||
return o.split('_', 1)[1]
|
return o.split("_", 1)[1]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@@ -149,8 +155,9 @@ def _has_option(prefix):
|
|||||||
a first chance to bind, since exists_fn runs before that first real
|
a first chance to bind, since exists_fn runs before that first real
|
||||||
fetch lands.
|
fetch lands.
|
||||||
"""
|
"""
|
||||||
return lambda rep, resources: is_stub_rep(rep) or _option_value(
|
return lambda rep, resources: (
|
||||||
rep.get('x.com.samsung.da.options'), prefix) is not None
|
is_stub_rep(rep) or _option_value(rep.get("x.com.samsung.da.options"), prefix) is not None
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _option_write(prefix, new_value):
|
def _option_write(prefix, new_value):
|
||||||
@@ -163,13 +170,14 @@ def _option_write(prefix, new_value):
|
|||||||
replaces the field outright instead of merging would drop every other
|
replaces the field outright instead of merging would drop every other
|
||||||
option in it (Sound/fastpreheat/etc.) on the next write -- revisit if a
|
option in it (Sound/fastpreheat/etc.) on the next write -- revisit if a
|
||||||
real device report surfaces that."""
|
real device report surfaces that."""
|
||||||
return [f'{prefix}_{new_value}']
|
return [f"{prefix}_{new_value}"]
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Write functions
|
# Write functions
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def _oven_setpoint_write(p, rep, href=None):
|
def _oven_setpoint_write(p, rep, href=None):
|
||||||
"""RMW write to /temperatures/vs/0 items array."""
|
"""RMW write to /temperatures/vs/0 items array."""
|
||||||
try:
|
try:
|
||||||
@@ -180,27 +188,27 @@ def _oven_setpoint_write(p, rep, href=None):
|
|||||||
temp_i = int(round(temp / step_v) * step_v)
|
temp_i = int(round(temp / step_v) * step_v)
|
||||||
if not (min_v <= temp_i <= max_v):
|
if not (min_v <= temp_i <= max_v):
|
||||||
return None
|
return None
|
||||||
items = rep.get('x.com.samsung.da.items')
|
items = rep.get("x.com.samsung.da.items")
|
||||||
if not items:
|
if not items:
|
||||||
return None
|
return None
|
||||||
items = [dict(it) for it in items]
|
items = [dict(it) for it in items]
|
||||||
items[0]['x.com.samsung.da.desired'] = str(temp_i)
|
items[0]["x.com.samsung.da.desired"] = str(temp_i)
|
||||||
return ['temperatures', 'vs', '0'], {'x.com.samsung.da.items': items}
|
return ["temperatures", "vs", "0"], {"x.com.samsung.da.items": items}
|
||||||
|
|
||||||
|
|
||||||
def _cook_time_write(p, rep, href=None):
|
def _cook_time_write(p, rep, href=None):
|
||||||
"""Write operationTime + remainingTime (H:MM:SS) from minutes."""
|
"""Write operationTime + remainingTime (H:MM:SS) from minutes."""
|
||||||
try:
|
try:
|
||||||
minutes = int(round(float(p)))
|
minutes = round(float(p))
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
return None
|
return None
|
||||||
if not (0 <= minutes <= 1439):
|
if not (0 <= minutes <= 1439):
|
||||||
return None
|
return None
|
||||||
h, m = divmod(minutes, 60)
|
h, m = divmod(minutes, 60)
|
||||||
hms = f"{h:02d}:{m:02d}:00"
|
hms = f"{h:02d}:{m:02d}:00"
|
||||||
return ['operational', 'state', 'vs', '0'], {
|
return ["operational", "state", "vs", "0"], {
|
||||||
'x.com.samsung.da.operationTime': hms,
|
"x.com.samsung.da.operationTime": hms,
|
||||||
'x.com.samsung.da.remainingTime': hms,
|
"x.com.samsung.da.remainingTime": hms,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -210,30 +218,32 @@ def _oven_mode_options(resources):
|
|||||||
laundry.py's options_field pattern (buzzer_sound/finish_sound), but
|
laundry.py's options_field pattern (buzzer_sound/finish_sound), but
|
||||||
needs the callable form rather than options_field because a static
|
needs the callable form rather than options_field because a static
|
||||||
fallback has to kick in when the device's own field is absent."""
|
fallback has to kick in when the device's own field is absent."""
|
||||||
rep = resources.get('/mode/vs/0') or {}
|
rep = resources.get("/mode/vs/0") or {}
|
||||||
live = rep.get('x.com.samsung.da.supportedModes')
|
live = rep.get("x.com.samsung.da.supportedModes")
|
||||||
return list(live) if live else list(_OVEN_MODES)
|
return list(live) if live else list(_OVEN_MODES)
|
||||||
|
|
||||||
|
|
||||||
def _oven_mode_write(p, rep, href=None):
|
def _oven_mode_write(p, rep, href=None):
|
||||||
valid = rep.get('x.com.samsung.da.supportedModes') or _OVEN_MODES
|
valid = rep.get("x.com.samsung.da.supportedModes") or _OVEN_MODES
|
||||||
if p not in valid:
|
if p not in valid:
|
||||||
return None
|
return None
|
||||||
return ['mode', 'vs', '0'], {'x.com.samsung.da.modes': [p]}
|
return ["mode", "vs", "0"], {"x.com.samsung.da.modes": [p]}
|
||||||
|
|
||||||
|
|
||||||
def _option_switch_write(prefix):
|
def _option_switch_write(prefix):
|
||||||
"""Factory for a single-token on/off options-array write -- lamp, sound,
|
"""Factory for a single-token on/off options-array write -- lamp, sound,
|
||||||
fast_preheat, natural_steam, energy_saving, and cooktop_on_alert were all
|
fast_preheat, natural_steam, energy_saving, and cooktop_on_alert were all
|
||||||
a byte-for-byte copy of this same shape, one per prefix."""
|
a byte-for-byte copy of this same shape, one per prefix."""
|
||||||
|
|
||||||
def write(p, rep, href=None):
|
def write(p, rep, href=None):
|
||||||
if p not in ('On', 'Off'):
|
if p not in ("On", "Off"):
|
||||||
return None
|
return None
|
||||||
if not rep.get('x.com.samsung.da.options'):
|
if not rep.get("x.com.samsung.da.options"):
|
||||||
return None
|
return None
|
||||||
return ['mode', 'vs', '0'], {
|
return ["mode", "vs", "0"], {
|
||||||
'x.com.samsung.da.options': _option_write(prefix, p),
|
"x.com.samsung.da.options": _option_write(prefix, p),
|
||||||
}
|
}
|
||||||
|
|
||||||
return write
|
return write
|
||||||
|
|
||||||
|
|
||||||
@@ -242,44 +252,71 @@ def _option_switch_write(prefix):
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
OVEN_OPERATIONAL_STATE = Capability(
|
OVEN_OPERATIONAL_STATE = Capability(
|
||||||
href='/operational/state/vs/0',
|
href="/operational/state/vs/0",
|
||||||
poll_tier='hot',
|
poll_tier="hot",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='machine_state', field='x.com.samsung.da.state',
|
SensorDesc(
|
||||||
icon='mdi:stove',
|
key="machine_state",
|
||||||
device_class='enum', options=('idle', 'active', 'pause'),
|
field="x.com.samsung.da.state",
|
||||||
translation_key='machine_state', value_fn=_to_ocf),
|
icon="mdi:stove",
|
||||||
BinarySensorDesc(key='cycle_active', field='x.com.samsung.da.state',
|
device_class="enum",
|
||||||
device_class='running',
|
options=("idle", "active", "pause"),
|
||||||
value_fn=lambda v: _SAMSUNG_STATE_TO_OCF.get(v) == 'active'),
|
translation_key="machine_state",
|
||||||
SensorDesc(key='progress_percentage',
|
value_fn=_to_ocf,
|
||||||
field='x.com.samsung.da.progressPercentage',
|
),
|
||||||
unit='%', state_class='measurement',
|
BinarySensorDesc(
|
||||||
value_fn=_int),
|
key="cycle_active",
|
||||||
SensorDesc(key='operation_time_minutes',
|
field="x.com.samsung.da.state",
|
||||||
field='x.com.samsung.da.operationTime',
|
device_class="running",
|
||||||
unit='min',
|
value_fn=lambda v: _SAMSUNG_STATE_TO_OCF.get(v) == "active",
|
||||||
state_class='measurement', value_fn=_op_minutes),
|
),
|
||||||
SensorDesc(key='finish_time', field='x.com.samsung.da.remainingTime',
|
SensorDesc(
|
||||||
device_class='timestamp',
|
key="progress_percentage",
|
||||||
value_fn=_finish_time),
|
field="x.com.samsung.da.progressPercentage",
|
||||||
NumberDesc(key='cook_time', field='x.com.samsung.da.operationTime',
|
unit="%",
|
||||||
unit='min', native_min=0, native_max=1439,
|
state_class="measurement",
|
||||||
step=1.0, icon='mdi:timer', value_fn=_op_minutes,
|
value_fn=_int,
|
||||||
write_fn=_cook_time_write),
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="operation_time_minutes",
|
||||||
|
field="x.com.samsung.da.operationTime",
|
||||||
|
unit="min",
|
||||||
|
state_class="measurement",
|
||||||
|
value_fn=_op_minutes,
|
||||||
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="finish_time",
|
||||||
|
field="x.com.samsung.da.remainingTime",
|
||||||
|
device_class="timestamp",
|
||||||
|
value_fn=_finish_time,
|
||||||
|
),
|
||||||
|
NumberDesc(
|
||||||
|
key="cook_time",
|
||||||
|
field="x.com.samsung.da.operationTime",
|
||||||
|
unit="min",
|
||||||
|
native_min=0,
|
||||||
|
native_max=1439,
|
||||||
|
step=1.0,
|
||||||
|
icon="mdi:timer",
|
||||||
|
value_fn=_op_minutes,
|
||||||
|
write_fn=_cook_time_write,
|
||||||
|
),
|
||||||
STOP_BUTTON,
|
STOP_BUTTON,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
OVEN_CAVITY = Capability(
|
OVEN_CAVITY = Capability(
|
||||||
href='/oven/vs/0',
|
href="/oven/vs/0",
|
||||||
poll_tier='hot',
|
poll_tier="hot",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='oven_state', field='x.com.samsung.da.state',
|
SensorDesc(
|
||||||
),
|
key="oven_state",
|
||||||
|
field="x.com.samsung.da.state",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _oven_temp_unit(rep):
|
def _oven_temp_unit(rep):
|
||||||
"""Same shape/risk as fridge.py's TEMPERATURES_FALLBACK: this is the
|
"""Same shape/risk as fridge.py's TEMPERATURES_FALLBACK: this is the
|
||||||
same aggregate `/temperatures/vs/0` items[] resource type, which on
|
same aggregate `/temperatures/vs/0` items[] resource type, which on
|
||||||
@@ -288,9 +325,9 @@ def _oven_temp_unit(rep):
|
|||||||
Keeps the verified '°C' default when the field is absent (the original
|
Keeps the verified '°C' default when the field is absent (the original
|
||||||
NV7000BS-class dump this module was written against), but reads it live
|
NV7000BS-class dump this module was written against), but reads it live
|
||||||
-- issue #44's range dump is the first to report 'Fahrenheit' here."""
|
-- issue #44's range dump is the first to report 'Fahrenheit' here."""
|
||||||
items = rep.get('x.com.samsung.da.items') or []
|
items = rep.get("x.com.samsung.da.items") or []
|
||||||
unit = items[0].get('x.com.samsung.da.unit') if items else None
|
unit = items[0].get("x.com.samsung.da.unit") if items else None
|
||||||
return normalize_temp_unit(unit, default='°C')
|
return normalize_temp_unit(unit, default="°C")
|
||||||
|
|
||||||
|
|
||||||
def _setpoint_bounds(rep):
|
def _setpoint_bounds(rep):
|
||||||
@@ -298,54 +335,72 @@ def _setpoint_bounds(rep):
|
|||||||
constants above for provenance. Bounds must track the unit shown by
|
constants above for provenance. Bounds must track the unit shown by
|
||||||
unit_fn (both read the same live rep), or the HA slider's range would
|
unit_fn (both read the same live rep), or the HA slider's range would
|
||||||
silently mismatch its own displayed unit."""
|
silently mismatch its own displayed unit."""
|
||||||
if _oven_temp_unit(rep) == '°F':
|
if _oven_temp_unit(rep) == "°F":
|
||||||
return SETPOINT_MIN_F, SETPOINT_MAX_F, SETPOINT_STEP_F
|
return SETPOINT_MIN_F, SETPOINT_MAX_F, SETPOINT_STEP_F
|
||||||
return SETPOINT_MIN_C, SETPOINT_MAX_C, SETPOINT_STEP_C
|
return SETPOINT_MIN_C, SETPOINT_MAX_C, SETPOINT_STEP_C
|
||||||
|
|
||||||
|
|
||||||
OVEN_SETPOINT = Capability(
|
OVEN_SETPOINT = Capability(
|
||||||
href='/temperatures/vs/0',
|
href="/temperatures/vs/0",
|
||||||
poll_tier='hot',
|
poll_tier="hot",
|
||||||
entities=(
|
entities=(
|
||||||
# NumberDesc first — test_oven_setpoint_write_is_read_modify_write uses entities[0]
|
# NumberDesc first — test_oven_setpoint_write_is_read_modify_write uses entities[0]
|
||||||
NumberDesc(key='oven_setpoint', field='x.com.samsung.da.items',
|
NumberDesc(
|
||||||
device_class='temperature', unit_fn=_oven_temp_unit,
|
key="oven_setpoint",
|
||||||
native_min=float(SETPOINT_MIN_C), native_max=float(SETPOINT_MAX_C),
|
field="x.com.samsung.da.items",
|
||||||
step=float(SETPOINT_STEP_C), icon='mdi:thermometer-chevron-up',
|
device_class="temperature",
|
||||||
native_min_fn=lambda rep: float(_setpoint_bounds(rep)[0]),
|
unit_fn=_oven_temp_unit,
|
||||||
native_max_fn=lambda rep: float(_setpoint_bounds(rep)[1]),
|
native_min=float(SETPOINT_MIN_C),
|
||||||
step_fn=lambda rep: float(_setpoint_bounds(rep)[2]),
|
native_max=float(SETPOINT_MAX_C),
|
||||||
value_fn=lambda items: _int(
|
step=float(SETPOINT_STEP_C),
|
||||||
(items[0].get('x.com.samsung.da.desired') if items else None)),
|
icon="mdi:thermometer-chevron-up",
|
||||||
write_fn=_oven_setpoint_write),
|
native_min_fn=lambda rep: float(_setpoint_bounds(rep)[0]),
|
||||||
SensorDesc(key='current_temp_c', field='x.com.samsung.da.items',
|
native_max_fn=lambda rep: float(_setpoint_bounds(rep)[1]),
|
||||||
device_class='temperature',
|
step_fn=lambda rep: float(_setpoint_bounds(rep)[2]),
|
||||||
state_class='measurement', unit_fn=_oven_temp_unit,
|
value_fn=lambda items: _int(
|
||||||
value_fn=lambda items: _int(
|
items[0].get("x.com.samsung.da.desired") if items else None
|
||||||
(items[0].get('x.com.samsung.da.current') if items else None))),
|
),
|
||||||
|
write_fn=_oven_setpoint_write,
|
||||||
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="current_temp_c",
|
||||||
|
field="x.com.samsung.da.items",
|
||||||
|
device_class="temperature",
|
||||||
|
state_class="measurement",
|
||||||
|
unit_fn=_oven_temp_unit,
|
||||||
|
value_fn=lambda items: _int(
|
||||||
|
items[0].get("x.com.samsung.da.current") if items else None
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
OVEN_DOOR = Capability(
|
OVEN_DOOR = Capability(
|
||||||
href='/doors/vs/0',
|
href="/doors/vs/0",
|
||||||
poll_tier='hot',
|
poll_tier="hot",
|
||||||
entities=(
|
entities=(
|
||||||
BinarySensorDesc(key='door_open', field='x.com.samsung.da.items',
|
BinarySensorDesc(
|
||||||
device_class='door',
|
key="door_open",
|
||||||
value_fn=lambda items: (
|
field="x.com.samsung.da.items",
|
||||||
items[0].get('x.com.samsung.da.openState') == 'Open'
|
device_class="door",
|
||||||
if items else None)),
|
value_fn=lambda items: (
|
||||||
|
items[0].get("x.com.samsung.da.openState") == "Open" if items else None
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
OVEN_CONNECTED = Capability(
|
OVEN_CONNECTED = Capability(
|
||||||
href='/connected/vs/0',
|
href="/connected/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
BinarySensorDesc(key='cloud_connected', field='x.com.samsung.da.connected',
|
BinarySensorDesc(
|
||||||
device_class='connectivity',
|
key="cloud_connected",
|
||||||
entity_category='diagnostic',
|
field="x.com.samsung.da.connected",
|
||||||
value_fn=lambda v: v == 'On'),
|
device_class="connectivity",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
value_fn=lambda v: v == "On",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -354,59 +409,82 @@ OVEN_CONNECTED = Capability(
|
|||||||
# range: single cavity, no supportedFeatureList entries). Bound with no
|
# range: single cavity, no supportedFeatureList entries). Bound with no
|
||||||
# entities purely for coverage; revisit if a multi-cavity dump surfaces
|
# entities purely for coverage; revisit if a multi-cavity dump surfaces
|
||||||
# fields worth exposing.
|
# fields worth exposing.
|
||||||
OVEN_SPEC = Capability(href='/oven/spec/vs/0')
|
OVEN_SPEC = Capability(href="/oven/spec/vs/0")
|
||||||
|
|
||||||
# Quick-recipe display blob (combi microwave, issue #121) -- a JSON-encoded
|
# Quick-recipe display blob (combi microwave, issue #121) -- a JSON-encoded
|
||||||
# string (language/menu/servingSize/option) with every field blank on the
|
# string (language/menu/servingSize/option) with every field blank on the
|
||||||
# only dump seen, and no documented write contract. No entity to bind per
|
# only dump seen, and no documented write contract. No entity to bind per
|
||||||
# the 'don't guess' rule; a bare Capability still marks the href covered.
|
# the 'don't guess' rule; a bare Capability still marks the href covered.
|
||||||
OVEN_RECIPE_COOK = Capability(href='/recipe/cook/vs/0')
|
OVEN_RECIPE_COOK = Capability(href="/recipe/cook/vs/0")
|
||||||
|
|
||||||
OVEN_MODE = Capability(
|
OVEN_MODE = Capability(
|
||||||
href='/mode/vs/0',
|
href="/mode/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
# SelectDesc first — test_oven_mode_options_nonempty uses entities[0]
|
# SelectDesc first — test_oven_mode_options_nonempty uses entities[0]
|
||||||
SelectDesc(key='oven_mode', field='x.com.samsung.da.modes',
|
SelectDesc(
|
||||||
icon='mdi:tune',
|
key="oven_mode",
|
||||||
options=_oven_mode_options,
|
field="x.com.samsung.da.modes",
|
||||||
value_fn=lambda v: v[0] if v else None,
|
icon="mdi:tune",
|
||||||
write_fn=_oven_mode_write),
|
options=_oven_mode_options,
|
||||||
SwitchDesc(key='lamp', field='x.com.samsung.da.options',
|
value_fn=lambda v: v[0] if v else None,
|
||||||
icon='mdi:track-light',
|
write_fn=_oven_mode_write,
|
||||||
value_fn=lambda opts: _option_value(opts, 'UpperLamp') == 'On',
|
),
|
||||||
write_fn=_option_switch_write('UpperLamp')),
|
SwitchDesc(
|
||||||
SwitchDesc(key='sound', field='x.com.samsung.da.options',
|
key="lamp",
|
||||||
icon='mdi:volume-high',
|
field="x.com.samsung.da.options",
|
||||||
entity_category='config',
|
icon="mdi:track-light",
|
||||||
value_fn=lambda opts: _option_value(opts, 'Sound') == 'On',
|
value_fn=lambda opts: _option_value(opts, "UpperLamp") == "On",
|
||||||
write_fn=_option_switch_write('Sound')),
|
write_fn=_option_switch_write("UpperLamp"),
|
||||||
SwitchDesc(key='fast_preheat', field='x.com.samsung.da.options',
|
),
|
||||||
icon='mdi:fire',
|
SwitchDesc(
|
||||||
exists_fn=_has_option('fastpreheat'),
|
key="sound",
|
||||||
value_fn=lambda opts: _option_value(opts, 'fastpreheat') == 'On',
|
field="x.com.samsung.da.options",
|
||||||
write_fn=_option_switch_write('fastpreheat')),
|
icon="mdi:volume-high",
|
||||||
SwitchDesc(key='natural_steam', field='x.com.samsung.da.options',
|
entity_category="config",
|
||||||
icon='mdi:kettle-steam',
|
value_fn=lambda opts: _option_value(opts, "Sound") == "On",
|
||||||
exists_fn=_has_option('NaturalSteam'),
|
write_fn=_option_switch_write("Sound"),
|
||||||
value_fn=lambda opts: _option_value(opts, 'NaturalSteam') == 'On',
|
),
|
||||||
write_fn=_option_switch_write('NaturalSteam')),
|
SwitchDesc(
|
||||||
|
key="fast_preheat",
|
||||||
|
field="x.com.samsung.da.options",
|
||||||
|
icon="mdi:fire",
|
||||||
|
exists_fn=_has_option("fastpreheat"),
|
||||||
|
value_fn=lambda opts: _option_value(opts, "fastpreheat") == "On",
|
||||||
|
write_fn=_option_switch_write("fastpreheat"),
|
||||||
|
),
|
||||||
|
SwitchDesc(
|
||||||
|
key="natural_steam",
|
||||||
|
field="x.com.samsung.da.options",
|
||||||
|
icon="mdi:kettle-steam",
|
||||||
|
exists_fn=_has_option("NaturalSteam"),
|
||||||
|
value_fn=lambda opts: _option_value(opts, "NaturalSteam") == "On",
|
||||||
|
write_fn=_option_switch_write("NaturalSteam"),
|
||||||
|
),
|
||||||
# 120-hour energy-saving standby (issue #183): confirmed present in
|
# 120-hour energy-saving standby (issue #183): confirmed present in
|
||||||
# this unit's options[] (EnergySaving_On) and directly requested --
|
# this unit's options[] (EnergySaving_On) and directly requested --
|
||||||
# unlike fast_preheat/natural_steam above, this token is real on this
|
# unlike fast_preheat/natural_steam above, this token is real on this
|
||||||
# hardware, just previously unbound entirely.
|
# hardware, just previously unbound entirely.
|
||||||
SwitchDesc(key='energy_saving', field='x.com.samsung.da.options',
|
SwitchDesc(
|
||||||
icon='mdi:leaf', entity_category='config',
|
key="energy_saving",
|
||||||
exists_fn=_has_option('EnergySaving'),
|
field="x.com.samsung.da.options",
|
||||||
value_fn=lambda opts: _option_value(opts, 'EnergySaving') == 'On',
|
icon="mdi:leaf",
|
||||||
write_fn=_option_switch_write('EnergySaving')),
|
entity_category="config",
|
||||||
|
exists_fn=_has_option("EnergySaving"),
|
||||||
|
value_fn=lambda opts: _option_value(opts, "EnergySaving") == "On",
|
||||||
|
write_fn=_option_switch_write("EnergySaving"),
|
||||||
|
),
|
||||||
# Cooktop-on alert (issue #183): also confirmed present
|
# Cooktop-on alert (issue #183): also confirmed present
|
||||||
# (BurnerOnAlert_Off) though the reporter noted it mainly matters for
|
# (BurnerOnAlert_Off) though the reporter noted it mainly matters for
|
||||||
# the SmartThings app's own alerting, not local automation.
|
# the SmartThings app's own alerting, not local automation.
|
||||||
SwitchDesc(key='cooktop_on_alert', field='x.com.samsung.da.options',
|
SwitchDesc(
|
||||||
icon='mdi:alert-circle-outline', entity_category='config',
|
key="cooktop_on_alert",
|
||||||
exists_fn=_has_option('BurnerOnAlert'),
|
field="x.com.samsung.da.options",
|
||||||
value_fn=lambda opts: _option_value(opts, 'BurnerOnAlert') == 'On',
|
icon="mdi:alert-circle-outline",
|
||||||
write_fn=_option_switch_write('BurnerOnAlert')),
|
entity_category="config",
|
||||||
|
exists_fn=_has_option("BurnerOnAlert"),
|
||||||
|
value_fn=lambda opts: _option_value(opts, "BurnerOnAlert") == "On",
|
||||||
|
write_fn=_option_switch_write("BurnerOnAlert"),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -23,6 +23,7 @@ caveat as oven.py's RMW writes) -- power level uses the same read-modify-
|
|||||||
write pattern already proven safe elsewhere in this codebase (oven setpoint,
|
write pattern already proven safe elsewhere in this codebase (oven setpoint,
|
||||||
icemaker toggles).
|
icemaker toggles).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
from ..entities import BinarySensorDesc, SelectDesc, SensorDesc, SwitchDesc
|
from ..entities import BinarySensorDesc, SelectDesc, SensorDesc, SwitchDesc
|
||||||
from .common import normalize_temp_unit
|
from .common import normalize_temp_unit
|
||||||
@@ -34,14 +35,14 @@ MAX_BURNERS = 6
|
|||||||
|
|
||||||
|
|
||||||
def _burner(burner_list, i):
|
def _burner(burner_list, i):
|
||||||
for b in (burner_list or []):
|
for b in burner_list or []:
|
||||||
if b.get('burnerNumber') == i:
|
if b.get("burnerNumber") == i:
|
||||||
return b
|
return b
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _burner_exists(i):
|
def _burner_exists(i):
|
||||||
return lambda rep, resources: _burner(rep.get('burnerList'), i) is not None
|
return lambda rep, resources: _burner(rep.get("burnerList"), i) is not None
|
||||||
|
|
||||||
|
|
||||||
def _burner_field_fn(i, field):
|
def _burner_field_fn(i, field):
|
||||||
@@ -49,35 +50,36 @@ def _burner_field_fn(i, field):
|
|||||||
|
|
||||||
|
|
||||||
def _burner_hot_surface_fn(i):
|
def _burner_hot_surface_fn(i):
|
||||||
get_state = _burner_field_fn(i, 'hotSurfaceState')
|
get_state = _burner_field_fn(i, "hotSurfaceState")
|
||||||
return lambda burner_list: get_state(burner_list) not in (None, 'normal')
|
return lambda burner_list: get_state(burner_list) not in (None, "normal")
|
||||||
|
|
||||||
|
|
||||||
def _burner_pan_detection_fn(i):
|
def _burner_pan_detection_fn(i):
|
||||||
return lambda burner_list: bool(_burner_field_fn(i, 'panDetection')(burner_list))
|
return lambda burner_list: bool(_burner_field_fn(i, "panDetection")(burner_list))
|
||||||
|
|
||||||
|
|
||||||
def _power_level_options(resources):
|
def _power_level_options(resources):
|
||||||
spec = resources.get('/cooktop/spec/vs/0') or {}
|
spec = resources.get("/cooktop/spec/vs/0") or {}
|
||||||
return list(spec.get('supportedPowerLevelList') or [])
|
return list(spec.get("supportedPowerLevelList") or [])
|
||||||
|
|
||||||
|
|
||||||
def _burner_power_level_write(i):
|
def _burner_power_level_write(i):
|
||||||
def write(p, rep, href=None):
|
def write(p, rep, href=None):
|
||||||
burner_list = rep.get('burnerList')
|
burner_list = rep.get("burnerList")
|
||||||
if not burner_list:
|
if not burner_list:
|
||||||
return None
|
return None
|
||||||
new_list = []
|
new_list = []
|
||||||
found = False
|
found = False
|
||||||
for b in burner_list:
|
for b in burner_list:
|
||||||
if b.get('burnerNumber') == i:
|
if b.get("burnerNumber") == i:
|
||||||
b = dict(b)
|
b = dict(b)
|
||||||
b['powerLevel'] = p
|
b["powerLevel"] = p
|
||||||
found = True
|
found = True
|
||||||
new_list.append(b)
|
new_list.append(b)
|
||||||
if not found:
|
if not found:
|
||||||
return None
|
return None
|
||||||
return ['cooktop', 'status', 'vs', '0'], {'burnerList': new_list}
|
return ["cooktop", "status", "vs", "0"], {"burnerList": new_list}
|
||||||
|
|
||||||
return write
|
return write
|
||||||
|
|
||||||
|
|
||||||
@@ -85,64 +87,83 @@ def _burner_entities(i):
|
|||||||
exists = _burner_exists(i)
|
exists = _burner_exists(i)
|
||||||
n = i + 1
|
n = i + 1
|
||||||
return (
|
return (
|
||||||
SelectDesc(key=f'burner_{i}_power_level', field='burnerList',
|
SelectDesc(
|
||||||
icon='mdi:knob',
|
key=f"burner_{i}_power_level",
|
||||||
translation_key='range_burner_power_level',
|
field="burnerList",
|
||||||
translation_placeholders={'number': str(n)},
|
icon="mdi:knob",
|
||||||
options=_power_level_options,
|
translation_key="range_burner_power_level",
|
||||||
exists_fn=exists,
|
translation_placeholders={"number": str(n)},
|
||||||
value_fn=_burner_field_fn(i, 'powerLevel'),
|
options=_power_level_options,
|
||||||
write_fn=_burner_power_level_write(i)),
|
exists_fn=exists,
|
||||||
SensorDesc(key=f'burner_{i}_state', field='burnerList',
|
value_fn=_burner_field_fn(i, "powerLevel"),
|
||||||
icon='mdi:stove',
|
write_fn=_burner_power_level_write(i),
|
||||||
translation_key='burner_state',
|
),
|
||||||
translation_placeholders={'number': str(n)},
|
SensorDesc(
|
||||||
exists_fn=exists,
|
key=f"burner_{i}_state",
|
||||||
value_fn=_burner_field_fn(i, 'operationState')),
|
field="burnerList",
|
||||||
BinarySensorDesc(key=f'burner_{i}_hot_surface', field='burnerList',
|
icon="mdi:stove",
|
||||||
device_class='heat',
|
translation_key="burner_state",
|
||||||
translation_key='burner_hot_surface',
|
translation_placeholders={"number": str(n)},
|
||||||
translation_placeholders={'number': str(n)},
|
exists_fn=exists,
|
||||||
exists_fn=exists,
|
value_fn=_burner_field_fn(i, "operationState"),
|
||||||
value_fn=_burner_hot_surface_fn(i)),
|
),
|
||||||
BinarySensorDesc(key=f'burner_{i}_pan_detected', field='burnerList',
|
BinarySensorDesc(
|
||||||
icon='mdi:pot',
|
key=f"burner_{i}_hot_surface",
|
||||||
translation_key='burner_pan_detected',
|
field="burnerList",
|
||||||
translation_placeholders={'number': str(n)},
|
device_class="heat",
|
||||||
entity_category='diagnostic',
|
translation_key="burner_hot_surface",
|
||||||
exists_fn=exists,
|
translation_placeholders={"number": str(n)},
|
||||||
value_fn=_burner_pan_detection_fn(i)),
|
exists_fn=exists,
|
||||||
|
value_fn=_burner_hot_surface_fn(i),
|
||||||
|
),
|
||||||
|
BinarySensorDesc(
|
||||||
|
key=f"burner_{i}_pan_detected",
|
||||||
|
field="burnerList",
|
||||||
|
icon="mdi:pot",
|
||||||
|
translation_key="burner_pan_detected",
|
||||||
|
translation_placeholders={"number": str(n)},
|
||||||
|
entity_category="diagnostic",
|
||||||
|
exists_fn=exists,
|
||||||
|
value_fn=_burner_pan_detection_fn(i),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _child_lock_write(p, rep, href=None):
|
def _child_lock_write(p, rep, href=None):
|
||||||
if p not in ('On', 'Off'):
|
if p not in ("On", "Off"):
|
||||||
return None
|
return None
|
||||||
return ['cooktop', 'status', 'vs', '0'], {'childLock': p.lower()}
|
return ["cooktop", "status", "vs", "0"], {"childLock": p.lower()}
|
||||||
|
|
||||||
|
|
||||||
COOKTOP_STATUS = Capability(
|
COOKTOP_STATUS = Capability(
|
||||||
href='/cooktop/status/vs/0',
|
href="/cooktop/status/vs/0",
|
||||||
poll_tier='hot',
|
poll_tier="hot",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='cooktop_state', field='operationState',
|
SensorDesc(key="cooktop_state", field="operationState", icon="mdi:pot-steam"),
|
||||||
icon='mdi:pot-steam'),
|
|
||||||
# The cooktop section's own on/off (issue #86) -- distinct from
|
# The cooktop section's own on/off (issue #86) -- distinct from
|
||||||
# common.POWER's /power/0 or /power/vs/0, which some boards in this
|
# common.POWER's /power/0 or /power/vs/0, which some boards in this
|
||||||
# family (the range combo) additionally carry for the whole
|
# family (the range combo) additionally carry for the whole
|
||||||
# appliance. Read-only: no live device to confirm remotely turning
|
# appliance. Read-only: no live device to confirm remotely turning
|
||||||
# a cooktop on wouldn't leave a burner active unattended.
|
# a cooktop on wouldn't leave a burner active unattended.
|
||||||
BinarySensorDesc(key='cooktop_power', field='power',
|
BinarySensorDesc(
|
||||||
device_class='power', icon='mdi:pot-steam',
|
key="cooktop_power",
|
||||||
value_fn=lambda v: str(v).lower() == 'on'),
|
field="power",
|
||||||
|
device_class="power",
|
||||||
|
icon="mdi:pot-steam",
|
||||||
|
value_fn=lambda v: str(v).lower() == "on",
|
||||||
|
),
|
||||||
# Safe to write -- a lock toggle, not a heat control -- via a
|
# Safe to write -- a lock toggle, not a heat control -- via a
|
||||||
# direct single-field PUT (no RMW needed; unlike burnerList this
|
# direct single-field PUT (no RMW needed; unlike burnerList this
|
||||||
# is a lone scalar, not an array of siblings to preserve).
|
# is a lone scalar, not an array of siblings to preserve).
|
||||||
SwitchDesc(key='cooktop_child_lock', field='childLock',
|
SwitchDesc(
|
||||||
device_class='lock', entity_category='config',
|
key="cooktop_child_lock",
|
||||||
icon='mdi:lock',
|
field="childLock",
|
||||||
value_fn=lambda v: str(v).lower() == 'on',
|
device_class="lock",
|
||||||
write_fn=_child_lock_write),
|
entity_category="config",
|
||||||
|
icon="mdi:lock",
|
||||||
|
value_fn=lambda v: str(v).lower() == "on",
|
||||||
|
write_fn=_child_lock_write,
|
||||||
|
),
|
||||||
*[e for i in range(MAX_BURNERS) for e in _burner_entities(i)],
|
*[e for i in range(MAX_BURNERS) for e in _burner_entities(i)],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -151,7 +172,7 @@ COOKTOP_STATUS = Capability(
|
|||||||
# COOKTOP_STATUS's power-level select (options=_power_level_options) rather
|
# COOKTOP_STATUS's power-level select (options=_power_level_options) rather
|
||||||
# than exposed through its own entity -- same "informs another capability,
|
# than exposed through its own entity -- same "informs another capability,
|
||||||
# no entity of its own" pattern as /wm/editcourse/vs/0 (ignored.py).
|
# no entity of its own" pattern as /wm/editcourse/vs/0 (ignored.py).
|
||||||
COOKTOP_SPEC = Capability(href='/cooktop/spec/vs/0')
|
COOKTOP_SPEC = Capability(href="/cooktop/spec/vs/0")
|
||||||
|
|
||||||
# settingTime (seconds) is the hot-surface auto-shutoff timer's configured
|
# settingTime (seconds) is the hot-surface auto-shutoff timer's configured
|
||||||
# duration (1200s = 20 min in issue #44's dump); state on/off is whether the
|
# duration (1200s = 20 min in issue #44's dump); state on/off is whether the
|
||||||
@@ -159,12 +180,15 @@ COOKTOP_SPEC = Capability(href='/cooktop/spec/vs/0')
|
|||||||
# (that's COOKTOP_STATUS's per-burner hot_surface). No write contract
|
# (that's COOKTOP_STATUS's per-burner hot_surface). No write contract
|
||||||
# verified, so read-only for now.
|
# verified, so read-only for now.
|
||||||
COOKTOP_SAFETY = Capability(
|
COOKTOP_SAFETY = Capability(
|
||||||
href='/cooktop/settings/status/vs/0',
|
href="/cooktop/settings/status/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
BinarySensorDesc(key='cooktop_safety_shutoff_enabled', field='safetyAlert',
|
BinarySensorDesc(
|
||||||
entity_category='config',
|
key="cooktop_safety_shutoff_enabled",
|
||||||
value_fn=lambda v: (v or {}).get('state') == 'on'),
|
field="safetyAlert",
|
||||||
|
entity_category="config",
|
||||||
|
value_fn=lambda v: (v or {}).get("state") == "on",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -174,21 +198,37 @@ COOKTOP_SAFETY = Capability(
|
|||||||
# showing a disconnected accessory's fields plainly rather than hiding the
|
# showing a disconnected accessory's fields plainly rather than hiding the
|
||||||
# whole capability.
|
# whole capability.
|
||||||
PROBE_STATUS = Capability(
|
PROBE_STATUS = Capability(
|
||||||
href='/bluetooth/probe/status/vs/0',
|
href="/bluetooth/probe/status/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
BinarySensorDesc(key='probe_connected', field='connectionState',
|
BinarySensorDesc(
|
||||||
device_class='connectivity',
|
key="probe_connected",
|
||||||
value_fn=lambda v: str(v).lower() == 'connected'),
|
field="connectionState",
|
||||||
SensorDesc(key='probe_battery', field='batteryPercentage',
|
device_class="connectivity",
|
||||||
device_class='battery', state_class='measurement',
|
value_fn=lambda v: str(v).lower() == "connected",
|
||||||
unit='%', entity_category='diagnostic'),
|
),
|
||||||
SensorDesc(key='probe_temperature', field='currentTemperature',
|
SensorDesc(
|
||||||
device_class='temperature', state_class='measurement',
|
key="probe_battery",
|
||||||
unit_fn=lambda rep: normalize_temp_unit(rep.get('temperatureUnit'), '°C')),
|
field="batteryPercentage",
|
||||||
SensorDesc(key='probe_target_temperature', field='targetTemperature',
|
device_class="battery",
|
||||||
device_class='temperature', entity_category='diagnostic',
|
state_class="measurement",
|
||||||
unit_fn=lambda rep: normalize_temp_unit(rep.get('temperatureUnit'), '°C')),
|
unit="%",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="probe_temperature",
|
||||||
|
field="currentTemperature",
|
||||||
|
device_class="temperature",
|
||||||
|
state_class="measurement",
|
||||||
|
unit_fn=lambda rep: normalize_temp_unit(rep.get("temperatureUnit"), "°C"),
|
||||||
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="probe_target_temperature",
|
||||||
|
field="targetTemperature",
|
||||||
|
device_class="temperature",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
unit_fn=lambda rep: normalize_temp_unit(rep.get("temperatureUnit"), "°C"),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -201,12 +241,19 @@ PROBE_STATUS = Capability(
|
|||||||
# `supportedHoodLampStateList` has no corresponding live-state field on
|
# `supportedHoodLampStateList` has no corresponding live-state field on
|
||||||
# this resource, so nothing to bind it to yet.
|
# this resource, so nothing to bind it to yet.
|
||||||
COOKTOP_MONITORING = Capability(
|
COOKTOP_MONITORING = Capability(
|
||||||
href='/cooktopmonitoring/vs/0',
|
href="/cooktopmonitoring/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='cooktop_running_state', field='x.com.samsung.da.cooktopRunningState',
|
SensorDesc(
|
||||||
icon='mdi:pot-steam-outline'),
|
key="cooktop_running_state",
|
||||||
SensorDesc(key='warming_center_state', field='x.com.samsung.da.warmingCenterState',
|
field="x.com.samsung.da.cooktopRunningState",
|
||||||
icon='mdi:heat-wave', entity_category='diagnostic'),
|
icon="mdi:pot-steam-outline",
|
||||||
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="warming_center_state",
|
||||||
|
field="x.com.samsung.da.warmingCenterState",
|
||||||
|
icon="mdi:heat-wave",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -7,7 +7,7 @@ brightness remain separate controls because the device advertises them as two
|
|||||||
independent fields.
|
independent fields.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from datetime import datetime, timezone
|
from datetime import UTC, datetime
|
||||||
|
|
||||||
from ..batch import is_stub_rep
|
from ..batch import is_stub_rep
|
||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
@@ -24,7 +24,7 @@ from .common import int_or_none, sensor_item_value
|
|||||||
|
|
||||||
def _timestamp(value):
|
def _timestamp(value):
|
||||||
try:
|
try:
|
||||||
return datetime.fromtimestamp(float(value), tz=timezone.utc)
|
return datetime.fromtimestamp(float(value), tz=UTC)
|
||||||
except (TypeError, ValueError, OSError):
|
except (TypeError, ValueError, OSError):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -39,23 +39,23 @@ def _active_alarm_codes(items):
|
|||||||
for item in items or ():
|
for item in items or ():
|
||||||
if not isinstance(item, dict):
|
if not isinstance(item, dict):
|
||||||
continue
|
continue
|
||||||
if str(item.get('x.com.samsung.da.state', '')).lower() == 'deleted':
|
if str(item.get("x.com.samsung.da.state", "")).lower() == "deleted":
|
||||||
continue
|
continue
|
||||||
code = item.get('x.com.samsung.da.code')
|
code = item.get("x.com.samsung.da.code")
|
||||||
if code and str(code).lower() != 'errorcode_off':
|
if code and str(code).lower() != "errorcode_off":
|
||||||
codes.append(code)
|
codes.append(code)
|
||||||
return ', '.join(codes) if codes else 'none'
|
return ", ".join(codes) if codes else "none"
|
||||||
|
|
||||||
|
|
||||||
HOOD_ALARMS = Capability(
|
HOOD_ALARMS = Capability(
|
||||||
href='/alarms/vs/0',
|
href="/alarms/vs/0",
|
||||||
poll_tier='hot',
|
poll_tier="hot",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='alarm_code',
|
key="alarm_code",
|
||||||
field='x.com.samsung.da.items',
|
field="x.com.samsung.da.items",
|
||||||
icon='mdi:alert',
|
icon="mdi:alert",
|
||||||
entity_category='diagnostic',
|
entity_category="diagnostic",
|
||||||
value_fn=_active_alarm_codes,
|
value_fn=_active_alarm_codes,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -64,49 +64,56 @@ HOOD_ALARMS = Capability(
|
|||||||
|
|
||||||
def _hood_fan_write(payload, rep, href=None):
|
def _hood_fan_write(payload, rep, href=None):
|
||||||
kind, value, *args = payload
|
kind, value, *args = payload
|
||||||
if kind == 'power':
|
if kind == "power":
|
||||||
power_href = args[0] if args else '/power/0'
|
power_href = args[0] if args else "/power/0"
|
||||||
if power_href == '/power/0':
|
if power_href == "/power/0":
|
||||||
return ['power', '0'], {'value': bool(value)}
|
return ["power", "0"], {"value": bool(value)}
|
||||||
if power_href == '/power/vs/0':
|
if power_href == "/power/vs/0":
|
||||||
return ['power', 'vs', '0'], {
|
return ["power", "vs", "0"], {
|
||||||
'x.com.samsung.da.power': 'On' if value else 'Off',
|
"x.com.samsung.da.power": "On" if value else "Off",
|
||||||
}
|
}
|
||||||
return None
|
return None
|
||||||
if kind == 'speed':
|
if kind == "speed":
|
||||||
value = str(value)
|
value = str(value)
|
||||||
supported = [
|
supported = [str(code) for code in rep.get("x.com.samsung.da.hood.supportedFanSpeed", ())]
|
||||||
str(code)
|
if not supported:
|
||||||
for code in rep.get('x.com.samsung.da.hood.supportedFanSpeed', ())
|
min_s = rep.get("x.com.samsung.da.hood.settableMinFanSpeed")
|
||||||
]
|
max_s = rep.get("x.com.samsung.da.hood.settableMaxFanSpeed")
|
||||||
|
if min_s is not None and max_s is not None:
|
||||||
|
try:
|
||||||
|
mn, mx = int(min_s), int(max_s)
|
||||||
|
supported = [str(i) for i in range(mn, mx + 1)]
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
pass
|
||||||
if value not in supported:
|
if value not in supported:
|
||||||
return None
|
return None
|
||||||
return ['hood', 'fanspeed', 'vs', '0'], {
|
return ["hood", "fanspeed", "vs", "0"], {
|
||||||
'x.com.samsung.da.hood.fanSpeed': value,
|
"x.com.samsung.da.hood.fanSpeed": value,
|
||||||
}
|
}
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
HOOD_FAN = Capability(
|
HOOD_FAN = Capability(
|
||||||
href='/hood/fanspeed/vs/0',
|
href="/hood/fanspeed/vs/0",
|
||||||
poll_tier='hot',
|
poll_tier="hot",
|
||||||
entities=(
|
entities=(
|
||||||
FanDesc(
|
FanDesc(
|
||||||
key='fan',
|
key="fan",
|
||||||
field='x.com.samsung.da.hood.fanSpeed',
|
field="x.com.samsung.da.hood.fanSpeed",
|
||||||
write_fn=_hood_fan_write,
|
write_fn=_hood_fan_write,
|
||||||
),
|
),
|
||||||
BinarySensorDesc(
|
BinarySensorDesc(
|
||||||
key='automatic_operation',
|
key="automatic_operation",
|
||||||
field='x.com.samsung.da.hood.autoOperation',
|
field="x.com.samsung.da.hood.autoOperation",
|
||||||
icon='mdi:fan-auto',
|
icon="mdi:fan-auto",
|
||||||
entity_category='diagnostic',
|
entity_category="diagnostic",
|
||||||
# Absent on the microwave family's built-in vent fan (issue
|
# Absent on the microwave family's built-in vent fan (issue
|
||||||
# #137) -- this board has no auto-ventilation mode, unlike the
|
# #137) -- this board has no auto-ventilation mode, unlike the
|
||||||
# standalone range hood this capability was written for.
|
# standalone range hood this capability was written for.
|
||||||
exists_fn=lambda rep, resources: (
|
exists_fn=lambda rep, resources: (
|
||||||
is_stub_rep(rep) or 'x.com.samsung.da.hood.autoOperation' in rep),
|
is_stub_rep(rep) or "x.com.samsung.da.hood.autoOperation" in rep
|
||||||
value_fn=lambda value: str(value).lower() == 'on',
|
),
|
||||||
|
value_fn=lambda value: str(value).lower() == "on",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -114,34 +121,34 @@ HOOD_FAN = Capability(
|
|||||||
|
|
||||||
def _lamp_level_write(value, rep, href=None):
|
def _lamp_level_write(value, rep, href=None):
|
||||||
code = str(value)
|
code = str(value)
|
||||||
supported = [str(level) for level in rep.get('x.com.samsung.lamp.range', ())]
|
supported = [str(level) for level in rep.get("x.com.samsung.lamp.range", ())]
|
||||||
if code not in supported:
|
if code not in supported:
|
||||||
return None
|
return None
|
||||||
return ['hood', 'lamp', 'vs', '0'], {
|
return ["hood", "lamp", "vs", "0"], {
|
||||||
'x.com.samsung.lamp.current': code,
|
"x.com.samsung.lamp.current": code,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HOOD_LAMP = Capability(
|
HOOD_LAMP = Capability(
|
||||||
href='/hood/lamp/vs/0',
|
href="/hood/lamp/vs/0",
|
||||||
poll_tier='hot',
|
poll_tier="hot",
|
||||||
entities=(
|
entities=(
|
||||||
SwitchDesc(
|
SwitchDesc(
|
||||||
key='lamp',
|
key="lamp",
|
||||||
field='x.com.samsung.lamp.power',
|
field="x.com.samsung.lamp.power",
|
||||||
icon='mdi:range-hood',
|
icon="mdi:range-hood",
|
||||||
value_fn=lambda value: str(value).lower() == 'on',
|
value_fn=lambda value: str(value).lower() == "on",
|
||||||
write_fn=lambda payload, rep, href=None: (
|
write_fn=lambda payload, rep, href=None: (
|
||||||
['hood', 'lamp', 'vs', '0'],
|
["hood", "lamp", "vs", "0"],
|
||||||
{'x.com.samsung.lamp.power': 'On' if payload == 'On' else 'Off'},
|
{"x.com.samsung.lamp.power": "On" if payload == "On" else "Off"},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SelectDesc(
|
SelectDesc(
|
||||||
key='lamp_brightness',
|
key="lamp_brightness",
|
||||||
field='x.com.samsung.lamp.current',
|
field="x.com.samsung.lamp.current",
|
||||||
icon='mdi:brightness-6',
|
icon="mdi:brightness-6",
|
||||||
translation_key='range_hood_lamp_brightness',
|
translation_key="range_hood_lamp_brightness",
|
||||||
options_field='x.com.samsung.lamp.range',
|
options_field="x.com.samsung.lamp.range",
|
||||||
write_fn=_lamp_level_write,
|
write_fn=_lamp_level_write,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -149,36 +156,34 @@ HOOD_LAMP = Capability(
|
|||||||
|
|
||||||
|
|
||||||
HOOD_FILTER = Capability(
|
HOOD_FILTER = Capability(
|
||||||
href='/filter/hoodfilter/vs/0',
|
href="/filter/hoodfilter/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='hood_filter_usage',
|
key="hood_filter_usage",
|
||||||
field='x.com.samsung.da.filterUsage',
|
field="x.com.samsung.da.filterUsage",
|
||||||
unit='%',
|
unit="%",
|
||||||
state_class='measurement',
|
state_class="measurement",
|
||||||
icon='mdi:air-filter',
|
icon="mdi:air-filter",
|
||||||
entity_category='diagnostic',
|
entity_category="diagnostic",
|
||||||
value_fn=int_or_none,
|
value_fn=int_or_none,
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='hood_filter_status',
|
key="hood_filter_status",
|
||||||
field='x.com.samsung.da.filterStatus',
|
field="x.com.samsung.da.filterStatus",
|
||||||
icon='mdi:air-filter',
|
icon="mdi:air-filter",
|
||||||
entity_category='diagnostic',
|
entity_category="diagnostic",
|
||||||
device_class='enum',
|
device_class="enum",
|
||||||
options=('normal', 'wash', 'replace'),
|
options=("normal", "wash", "replace"),
|
||||||
translation_key='filter_status',
|
translation_key="filter_status",
|
||||||
value_fn=lambda value: (
|
value_fn=lambda value: value.lower() if isinstance(value, str) else value,
|
||||||
value.lower() if isinstance(value, str) else value
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='hood_filter_capacity',
|
key="hood_filter_capacity",
|
||||||
field='x.com.samsung.da.filterCapacity',
|
field="x.com.samsung.da.filterCapacity",
|
||||||
unit='h',
|
unit="h",
|
||||||
icon='mdi:timer-outline',
|
icon="mdi:timer-outline",
|
||||||
entity_category='diagnostic',
|
entity_category="diagnostic",
|
||||||
enabled_default=False,
|
enabled_default=False,
|
||||||
value_fn=int_or_none,
|
value_fn=int_or_none,
|
||||||
),
|
),
|
||||||
@@ -199,31 +204,31 @@ HOOD_FILTER = Capability(
|
|||||||
# left an opaque passthrough -- unlike activationState/runningCancel, there's
|
# left an opaque passthrough -- unlike activationState/runningCancel, there's
|
||||||
# no ambiguous field name or missing-write-contract question here to hedge on.
|
# no ambiguous field name or missing-write-contract question here to hedge on.
|
||||||
AFTER_RUN = Capability(
|
AFTER_RUN = Capability(
|
||||||
href='/afterrun/vs/0',
|
href="/afterrun/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
BinarySensorDesc(
|
BinarySensorDesc(
|
||||||
key='after_run_active',
|
key="after_run_active",
|
||||||
field='x.com.samsung.da.activationState',
|
field="x.com.samsung.da.activationState",
|
||||||
icon='mdi:fan-clock',
|
icon="mdi:fan-clock",
|
||||||
value_fn=lambda value: str(value).lower() == 'on',
|
value_fn=lambda value: str(value).lower() == "on",
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='after_run_progress',
|
key="after_run_progress",
|
||||||
field='x.com.samsung.da.runningProgress',
|
field="x.com.samsung.da.runningProgress",
|
||||||
unit='%',
|
unit="%",
|
||||||
state_class='measurement',
|
state_class="measurement",
|
||||||
icon='mdi:fan-clock',
|
icon="mdi:fan-clock",
|
||||||
value_fn=int_or_none,
|
value_fn=int_or_none,
|
||||||
),
|
),
|
||||||
ButtonDesc(
|
ButtonDesc(
|
||||||
key='after_run_cancel',
|
key="after_run_cancel",
|
||||||
field='',
|
field="",
|
||||||
payload='Cancel',
|
payload="Cancel",
|
||||||
icon='mdi:fan-off',
|
icon="mdi:fan-off",
|
||||||
write_fn=lambda p, rep, href=None: (
|
write_fn=lambda p, rep, href=None: (
|
||||||
['afterrun', 'vs', '0'],
|
["afterrun", "vs", "0"],
|
||||||
{'x.com.samsung.da.runningCancel': p},
|
{"x.com.samsung.da.runningCancel": p},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -231,82 +236,82 @@ AFTER_RUN = Capability(
|
|||||||
|
|
||||||
|
|
||||||
AIR_QUALITY = Capability(
|
AIR_QUALITY = Capability(
|
||||||
href='/sensors/vs/0',
|
href="/sensors/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='clean_level',
|
key="clean_level",
|
||||||
field='x.com.samsung.da.items',
|
field="x.com.samsung.da.items",
|
||||||
icon='mdi:air-filter',
|
icon="mdi:air-filter",
|
||||||
value_fn=lambda items: sensor_item_value(items, 'CleanLevel'),
|
value_fn=lambda items: sensor_item_value(items, "CleanLevel"),
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='dust',
|
key="dust",
|
||||||
field='x.com.samsung.da.items',
|
field="x.com.samsung.da.items",
|
||||||
value_fn=lambda items: sensor_item_value(items, 'Dust'),
|
value_fn=lambda items: sensor_item_value(items, "Dust"),
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='fine_dust',
|
key="fine_dust",
|
||||||
field='x.com.samsung.da.items',
|
field="x.com.samsung.da.items",
|
||||||
value_fn=lambda items: sensor_item_value(items, 'FineDust'),
|
value_fn=lambda items: sensor_item_value(items, "FineDust"),
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='super_fine_dust',
|
key="super_fine_dust",
|
||||||
field='x.com.samsung.da.items',
|
field="x.com.samsung.da.items",
|
||||||
value_fn=lambda items: sensor_item_value(items, 'SuperFineDust'),
|
value_fn=lambda items: sensor_item_value(items, "SuperFineDust"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
AIR_LEVEL_CHECK = Capability(
|
AIR_LEVEL_CHECK = Capability(
|
||||||
href='/airlevelcheck/vs/0',
|
href="/airlevelcheck/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
BinarySensorDesc(
|
BinarySensorDesc(
|
||||||
key='periodic_air_sensing',
|
key="periodic_air_sensing",
|
||||||
field='x.com.samsung.da.periodicSensingActivationState',
|
field="x.com.samsung.da.periodicSensingActivationState",
|
||||||
icon='mdi:radar',
|
icon="mdi:radar",
|
||||||
entity_category='diagnostic',
|
entity_category="diagnostic",
|
||||||
value_fn=lambda value: str(value).lower() == 'on',
|
value_fn=lambda value: str(value).lower() == "on",
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='air_sensing_state',
|
key="air_sensing_state",
|
||||||
field='x.com.samsung.da.sensingState',
|
field="x.com.samsung.da.sensingState",
|
||||||
icon='mdi:radar',
|
icon="mdi:radar",
|
||||||
entity_category='diagnostic',
|
entity_category="diagnostic",
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='last_air_sensing_time',
|
key="last_air_sensing_time",
|
||||||
field='x.com.samsung.da.lastSensingTime',
|
field="x.com.samsung.da.lastSensingTime",
|
||||||
device_class='timestamp',
|
device_class="timestamp",
|
||||||
entity_category='diagnostic',
|
entity_category="diagnostic",
|
||||||
value_fn=_timestamp,
|
value_fn=_timestamp,
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='last_air_sensing_level',
|
key="last_air_sensing_level",
|
||||||
field='x.com.samsung.da.lastSensingLevel',
|
field="x.com.samsung.da.lastSensingLevel",
|
||||||
icon='mdi:air-filter',
|
icon="mdi:air-filter",
|
||||||
entity_category='diagnostic',
|
entity_category="diagnostic",
|
||||||
),
|
),
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='automatic_ventilation_state',
|
key="automatic_ventilation_state",
|
||||||
field='x.com.samsung.da.autoExeState',
|
field="x.com.samsung.da.autoExeState",
|
||||||
icon='mdi:fan-auto',
|
icon="mdi:fan-auto",
|
||||||
entity_category='diagnostic',
|
entity_category="diagnostic",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
AUTO_VENTILATION = Capability(
|
AUTO_VENTILATION = Capability(
|
||||||
href='/autoventilation/vs/0',
|
href="/autoventilation/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(
|
SensorDesc(
|
||||||
key='auto_ventilation_action',
|
key="auto_ventilation_action",
|
||||||
field='action',
|
field="action",
|
||||||
icon='mdi:fan-auto',
|
icon="mdi:fan-auto",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -317,11 +322,11 @@ AUTO_VENTILATION = Capability(
|
|||||||
COVERAGE = [
|
COVERAGE = [
|
||||||
Capability(href=href)
|
Capability(href=href)
|
||||||
for href in (
|
for href in (
|
||||||
'/power/0',
|
"/power/0",
|
||||||
'/power/vs/0',
|
"/power/vs/0",
|
||||||
'/mode/vs/0',
|
"/mode/vs/0",
|
||||||
'/personality/presence/vs/0',
|
"/personality/presence/vs/0",
|
||||||
'/availablecontrolsets/vs/0',
|
"/availablecontrolsets/vs/0",
|
||||||
'/da/softreset/vs/0',
|
"/da/softreset/vs/0",
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
@@ -15,19 +15,23 @@ docstring for that rule).
|
|||||||
|
|
||||||
Resources verified against the issue #131 diagnostics dump.
|
Resources verified against the issue #131 diagnostics dump.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
from ..entities import BinarySensorDesc, SelectDesc, SensorDesc, SwitchDesc
|
from ..entities import BinarySensorDesc, SelectDesc, SensorDesc, SwitchDesc
|
||||||
from .common import int_or_none, parse_iso_utc as _parse_iso_utc
|
from .common import int_or_none
|
||||||
|
from .common import parse_iso_utc as _parse_iso_utc
|
||||||
|
|
||||||
DUSTBAG = Capability(
|
DUSTBAG = Capability(
|
||||||
href='/component/station/dustbag/vs/0',
|
href="/component/station/dustbag/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
BinarySensorDesc(key='dustbag_full', field='x.com.samsung.da.status',
|
BinarySensorDesc(
|
||||||
device_class='problem',
|
key="dustbag_full",
|
||||||
icon='mdi:bag-personal',
|
field="x.com.samsung.da.status",
|
||||||
value_fn=lambda v: v == 'full'),
|
device_class="problem",
|
||||||
|
icon="mdi:bag-personal",
|
||||||
|
value_fn=lambda v: v == "full",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -36,40 +40,57 @@ DUSTBAG = Capability(
|
|||||||
# families' filterUsage, which always ships filterCapacity) -- exposed as a
|
# families' filterUsage, which always ships filterCapacity) -- exposed as a
|
||||||
# plain diagnostic count rather than guessing a unit.
|
# plain diagnostic count rather than guessing a unit.
|
||||||
DUSTBAG_USAGE = Capability(
|
DUSTBAG_USAGE = Capability(
|
||||||
href='/component/station/dustbagusage/vs/0',
|
href="/component/station/dustbagusage/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='dustbag_usage', field='x.com.samsung.da.dustbagUsage',
|
SensorDesc(
|
||||||
icon='mdi:counter', entity_category='diagnostic',
|
key="dustbag_usage",
|
||||||
state_class='total_increasing', value_fn=int_or_none),
|
field="x.com.samsung.da.dustbagUsage",
|
||||||
|
icon="mdi:counter",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
state_class="total_increasing",
|
||||||
|
value_fn=int_or_none,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
DUSTBIN_SETTING = Capability(
|
DUSTBIN_SETTING = Capability(
|
||||||
href='/setting/dustbin/vs/0',
|
href="/setting/dustbin/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
SwitchDesc(key='auto_empty', field='x.com.samsung.da.autoEmpty',
|
SwitchDesc(
|
||||||
icon='mdi:delete-empty',
|
key="auto_empty",
|
||||||
entity_category='config',
|
field="x.com.samsung.da.autoEmpty",
|
||||||
value_fn=lambda v: v == 'On',
|
icon="mdi:delete-empty",
|
||||||
write_fn=lambda p, rep, href=None: (
|
entity_category="config",
|
||||||
['setting', 'dustbin', 'vs', '0'],
|
value_fn=lambda v: v == "On",
|
||||||
{'x.com.samsung.da.autoEmpty': 'On' if p == 'On' else 'Off'})),
|
write_fn=lambda p, rep, href=None: (
|
||||||
SwitchDesc(key='dustbin_auto_close', field='x.com.samsung.da.autoClose',
|
["setting", "dustbin", "vs", "0"],
|
||||||
icon='mdi:door-sliding',
|
{"x.com.samsung.da.autoEmpty": "On" if p == "On" else "Off"},
|
||||||
entity_category='config',
|
),
|
||||||
value_fn=lambda v: v == 'On',
|
),
|
||||||
write_fn=lambda p, rep, href=None: (
|
SwitchDesc(
|
||||||
['setting', 'dustbin', 'vs', '0'],
|
key="dustbin_auto_close",
|
||||||
{'x.com.samsung.da.autoClose': 'On' if p == 'On' else 'Off'})),
|
field="x.com.samsung.da.autoClose",
|
||||||
SelectDesc(key='discharging_time', field='x.com.samsung.da.desiredDischargingTime',
|
icon="mdi:door-sliding",
|
||||||
icon='mdi:timer-outline',
|
entity_category="config",
|
||||||
entity_category='config',
|
value_fn=lambda v: v == "On",
|
||||||
options_field='x.com.samsung.da.supportedDischargingTime',
|
write_fn=lambda p, rep, href=None: (
|
||||||
write_fn=lambda p, rep, href=None: (
|
["setting", "dustbin", "vs", "0"],
|
||||||
['setting', 'dustbin', 'vs', '0'],
|
{"x.com.samsung.da.autoClose": "On" if p == "On" else "Off"},
|
||||||
{'x.com.samsung.da.desiredDischargingTime': p})),
|
),
|
||||||
|
),
|
||||||
|
SelectDesc(
|
||||||
|
key="discharging_time",
|
||||||
|
field="x.com.samsung.da.desiredDischargingTime",
|
||||||
|
icon="mdi:timer-outline",
|
||||||
|
entity_category="config",
|
||||||
|
options_field="x.com.samsung.da.supportedDischargingTime",
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["setting", "dustbin", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.desiredDischargingTime": p},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -78,32 +99,60 @@ DUSTBIN_SETTING = Capability(
|
|||||||
# rather than a binary_sensor, so no polarity/semantic is asserted that
|
# rather than a binary_sensor, so no polarity/semantic is asserted that
|
||||||
# might be wrong.
|
# might be wrong.
|
||||||
CLEANSTATION_STATUS = Capability(
|
CLEANSTATION_STATUS = Capability(
|
||||||
href='/status/cleanstation/vs/0',
|
href="/status/cleanstation/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='cleanstation_status', field='x.com.samsung.da.status',
|
SensorDesc(
|
||||||
icon='mdi:home-lightning-bolt', entity_category='diagnostic'),
|
key="cleanstation_status",
|
||||||
SensorDesc(key='stick_status', field='x.com.samsung.da.stickStatus',
|
field="x.com.samsung.da.status",
|
||||||
icon='mdi:broom', entity_category='diagnostic'),
|
icon="mdi:home-lightning-bolt",
|
||||||
SwitchDesc(key='uvc_intensive_mode', field='x.com.samsung.da.uvcIntensive',
|
entity_category="diagnostic",
|
||||||
icon='mdi:lightbulb-on-outline',
|
),
|
||||||
entity_category='config',
|
SensorDesc(
|
||||||
value_fn=lambda v: v == 'On',
|
key="stick_status",
|
||||||
write_fn=lambda p, rep, href=None: (
|
field="x.com.samsung.da.stickStatus",
|
||||||
['status', 'cleanstation', 'vs', '0'],
|
icon="mdi:broom",
|
||||||
{'x.com.samsung.da.uvcIntensive': 'On' if p == 'On' else 'Off'})),
|
entity_category="diagnostic",
|
||||||
SensorDesc(key='uvc_operation_time', field='x.com.samsung.da.uvcOperationTime',
|
),
|
||||||
icon='mdi:timer-sand', entity_category='diagnostic',
|
SwitchDesc(
|
||||||
value_fn=int_or_none),
|
key="uvc_intensive_mode",
|
||||||
SensorDesc(key='uvc_total_operation_time',
|
field="x.com.samsung.da.uvcIntensive",
|
||||||
field='x.com.samsung.da.uvcTotalOperationTime',
|
icon="mdi:lightbulb-on-outline",
|
||||||
icon='mdi:timer-sand', entity_category='diagnostic',
|
entity_category="config",
|
||||||
state_class='total_increasing', value_fn=int_or_none),
|
value_fn=lambda v: v == "On",
|
||||||
SensorDesc(key='uvc_finished_time', field='x.com.samsung.da.uvcFinishedTime',
|
write_fn=lambda p, rep, href=None: (
|
||||||
device_class='timestamp', entity_category='diagnostic',
|
["status", "cleanstation", "vs", "0"],
|
||||||
value_fn=_parse_iso_utc),
|
{"x.com.samsung.da.uvcIntensive": "On" if p == "On" else "Off"},
|
||||||
SensorDesc(key='uvc_emitted_time', field='x.com.samsung.da.emittedTime',
|
),
|
||||||
device_class='timestamp', entity_category='diagnostic',
|
),
|
||||||
value_fn=_parse_iso_utc),
|
SensorDesc(
|
||||||
|
key="uvc_operation_time",
|
||||||
|
field="x.com.samsung.da.uvcOperationTime",
|
||||||
|
icon="mdi:timer-sand",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
value_fn=int_or_none,
|
||||||
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="uvc_total_operation_time",
|
||||||
|
field="x.com.samsung.da.uvcTotalOperationTime",
|
||||||
|
icon="mdi:timer-sand",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
state_class="total_increasing",
|
||||||
|
value_fn=int_or_none,
|
||||||
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="uvc_finished_time",
|
||||||
|
field="x.com.samsung.da.uvcFinishedTime",
|
||||||
|
device_class="timestamp",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
value_fn=_parse_iso_utc,
|
||||||
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="uvc_emitted_time",
|
||||||
|
field="x.com.samsung.da.emittedTime",
|
||||||
|
device_class="timestamp",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
value_fn=_parse_iso_utc,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -14,12 +14,18 @@ specific controls (wash settings, drum-clean tracking, dispenser dosing) are
|
|||||||
here; they read washer-only fields off the same shared /course/vs/0 options
|
here; they read washer-only fields off the same shared /course/vs/0 options
|
||||||
array.
|
array.
|
||||||
"""
|
"""
|
||||||
from datetime import datetime, timezone
|
|
||||||
|
from datetime import UTC, datetime
|
||||||
|
|
||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
from ..entities import BinarySensorDesc, SelectDesc, SensorDesc
|
from ..entities import BinarySensorDesc, SelectDesc, SensorDesc
|
||||||
from .laundry import (
|
from .laundry import (
|
||||||
bool_option_exists, bool_option_switch, cycle_options, cycle_select, hex_pairs, option_value,
|
bool_option_exists,
|
||||||
|
bool_option_switch,
|
||||||
|
cycle_options,
|
||||||
|
cycle_select,
|
||||||
|
hex_pairs,
|
||||||
|
option_value,
|
||||||
option_write,
|
option_write,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -81,39 +87,58 @@ from .laundry import (
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
WASHER_SETTINGS = Capability(
|
WASHER_SETTINGS = Capability(
|
||||||
href='/washer/vs/0',
|
href="/washer/vs/0",
|
||||||
entities=(
|
entities=(
|
||||||
SelectDesc(key='wash_temperature', field='x.com.samsung.da.waterTemperature',
|
SelectDesc(
|
||||||
icon='mdi:thermometer-water',
|
key="wash_temperature",
|
||||||
entity_category='config',
|
field="x.com.samsung.da.waterTemperature",
|
||||||
options_field='x.com.samsung.da.supportedWaterTemperature',
|
icon="mdi:thermometer-water",
|
||||||
write_fn=lambda p, rep, href=None: (
|
entity_category="config",
|
||||||
['washer', 'vs', '0'], {'x.com.samsung.da.waterTemperature': p})),
|
options_field="x.com.samsung.da.supportedWaterTemperature",
|
||||||
SelectDesc(key='spin_speed', field='x.com.samsung.da.spinLevel',
|
write_fn=lambda p, rep, href=None: (
|
||||||
icon='mdi:sync',
|
["washer", "vs", "0"],
|
||||||
entity_category='config',
|
{"x.com.samsung.da.waterTemperature": p},
|
||||||
options_field='x.com.samsung.da.supportedSpinLevel',
|
),
|
||||||
write_fn=lambda p, rep, href=None: (
|
),
|
||||||
['washer', 'vs', '0'], {'x.com.samsung.da.spinLevel': p})),
|
SelectDesc(
|
||||||
SelectDesc(key='rinse_cycles', field='x.com.samsung.da.rinseCycles',
|
key="spin_speed",
|
||||||
icon='mdi:water-sync',
|
field="x.com.samsung.da.spinLevel",
|
||||||
entity_category='config',
|
icon="mdi:sync",
|
||||||
options_field='x.com.samsung.da.supportedRinseCycles',
|
entity_category="config",
|
||||||
write_fn=lambda p, rep, href=None: (
|
options_field="x.com.samsung.da.supportedSpinLevel",
|
||||||
['washer', 'vs', '0'], {'x.com.samsung.da.rinseCycles': p})),
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["washer", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.spinLevel": p},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SelectDesc(
|
||||||
|
key="rinse_cycles",
|
||||||
|
field="x.com.samsung.da.rinseCycles",
|
||||||
|
icon="mdi:water-sync",
|
||||||
|
entity_category="config",
|
||||||
|
options_field="x.com.samsung.da.supportedRinseCycles",
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["washer", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.rinseCycles": p},
|
||||||
|
),
|
||||||
|
),
|
||||||
# Washer/dryer combo units carry a dryLevel field on the wash
|
# Washer/dryer combo units carry a dryLevel field on the wash
|
||||||
# resource itself (no separate dryer device/course) -- see issue
|
# resource itself (no separate dryer device/course) -- see issue
|
||||||
# #22. Self-gates off on plain washers, which never report
|
# #22. Self-gates off on plain washers, which never report
|
||||||
# supportedDryLevel.
|
# supportedDryLevel.
|
||||||
SelectDesc(key='dry_level', field='x.com.samsung.da.dryLevel',
|
SelectDesc(
|
||||||
icon='mdi:tumble-dryer',
|
key="dry_level",
|
||||||
entity_category='config',
|
field="x.com.samsung.da.dryLevel",
|
||||||
translation_key='washer_dry_level',
|
icon="mdi:tumble-dryer",
|
||||||
options_field='x.com.samsung.da.supportedDryLevel',
|
entity_category="config",
|
||||||
exists_fn=lambda rep, resources: bool(
|
translation_key="washer_dry_level",
|
||||||
rep.get('x.com.samsung.da.supportedDryLevel')),
|
options_field="x.com.samsung.da.supportedDryLevel",
|
||||||
write_fn=lambda p, rep, href=None: (
|
exists_fn=lambda rep, resources: bool(rep.get("x.com.samsung.da.supportedDryLevel")),
|
||||||
['washer', 'vs', '0'], {'x.com.samsung.da.dryLevel': p})),
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["washer", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.dryLevel": p},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -135,9 +160,9 @@ WASHER_SETTINGS = Capability(
|
|||||||
# so it's treated as UTC, matching this integration's convention for other
|
# so it's treated as UTC, matching this integration's convention for other
|
||||||
# bare ISO datetime fields (see fridge.py's night-light schedule comment).
|
# bare ISO datetime fields (see fridge.py's night-light schedule comment).
|
||||||
def _drum_clean_cycles_remaining(rep):
|
def _drum_clean_cycles_remaining(rep):
|
||||||
opts = rep.get('x.com.samsung.da.options') or []
|
opts = rep.get("x.com.samsung.da.options") or []
|
||||||
proposal = option_value(opts, 'DrumCleanProposal')
|
proposal = option_value(opts, "DrumCleanProposal")
|
||||||
washed = option_value(opts, 'WashingTimes')
|
washed = option_value(opts, "WashingTimes")
|
||||||
if proposal is None or washed is None:
|
if proposal is None or washed is None:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
@@ -147,11 +172,11 @@ def _drum_clean_cycles_remaining(rep):
|
|||||||
|
|
||||||
|
|
||||||
def _drum_clean_last_cleaned(rep):
|
def _drum_clean_last_cleaned(rep):
|
||||||
raw = option_value(rep.get('x.com.samsung.da.options'), 'DrumCleanLog')
|
raw = option_value(rep.get("x.com.samsung.da.options"), "DrumCleanLog")
|
||||||
if not raw:
|
if not raw:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
return datetime.fromisoformat(raw).replace(tzinfo=timezone.utc)
|
return datetime.fromisoformat(raw).replace(tzinfo=UTC)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -183,8 +208,8 @@ def _drum_clean_last_cleaned(rep):
|
|||||||
# otherwise identical in shape to the detergent side. Revisit if a second
|
# otherwise identical in shape to the detergent side. Revisit if a second
|
||||||
# device's dump contradicts this.
|
# device's dump contradicts this.
|
||||||
def _supported_level_options(resources, prefix):
|
def _supported_level_options(resources, prefix):
|
||||||
rep = resources.get('/course/vs/0') or {}
|
rep = resources.get("/course/vs/0") or {}
|
||||||
raw = option_value(rep.get('x.com.samsung.da.options'), f'Supported{prefix}')
|
raw = option_value(rep.get("x.com.samsung.da.options"), f"Supported{prefix}")
|
||||||
return hex_pairs(raw) if raw else []
|
return hex_pairs(raw) if raw else []
|
||||||
|
|
||||||
|
|
||||||
@@ -202,12 +227,13 @@ def _dosing_level(prefix):
|
|||||||
outside the select's own option list, so HA renders it 'unknown' (issue #9).
|
outside the select's own option list, so HA renders it 'unknown' (issue #9).
|
||||||
Resolve it to the supported code with the same integer value so
|
Resolve it to the supported code with the same integer value so
|
||||||
current_option matches an option (and its translation)."""
|
current_option matches an option (and its translation)."""
|
||||||
|
|
||||||
def fn(rep):
|
def fn(rep):
|
||||||
opts = rep.get('x.com.samsung.da.options')
|
opts = rep.get("x.com.samsung.da.options")
|
||||||
raw = option_value(opts, prefix)
|
raw = option_value(opts, prefix)
|
||||||
if raw is None:
|
if raw is None:
|
||||||
return None
|
return None
|
||||||
supported_raw = option_value(opts, f'Supported{prefix}')
|
supported_raw = option_value(opts, f"Supported{prefix}")
|
||||||
try:
|
try:
|
||||||
target = int(raw, 16)
|
target = int(raw, 16)
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
@@ -219,29 +245,32 @@ def _dosing_level(prefix):
|
|||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
continue
|
continue
|
||||||
return raw
|
return raw
|
||||||
|
|
||||||
return fn
|
return fn
|
||||||
|
|
||||||
|
|
||||||
def _level_write(prefix):
|
def _level_write(prefix):
|
||||||
def write(p, rep, href=None):
|
def write(p, rep, href=None):
|
||||||
if not rep.get('x.com.samsung.da.options'):
|
if not rep.get("x.com.samsung.da.options"):
|
||||||
return None
|
return None
|
||||||
# `p` is the zero-padded supported code the UI selected (e.g. '03');
|
# `p` is the zero-padded supported code the UI selected (e.g. '03');
|
||||||
# the device stores the level un-padded (e.g. '3'), matching how it
|
# the device stores the level un-padded (e.g. '3'), matching how it
|
||||||
# reports it, so write it back in that native shape.
|
# reports it, so write it back in that native shape.
|
||||||
try:
|
try:
|
||||||
native = format(int(p, 16), 'X')
|
native = format(int(p, 16), "X")
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
native = p
|
native = p
|
||||||
return ['course', 'vs', '0'], {
|
return ["course", "vs", "0"], {
|
||||||
'x.com.samsung.da.options': option_write(prefix, native),
|
"x.com.samsung.da.options": option_write(prefix, native),
|
||||||
}
|
}
|
||||||
|
|
||||||
return write
|
return write
|
||||||
|
|
||||||
|
|
||||||
def _dosing_low(prefix):
|
def _dosing_low(prefix):
|
||||||
return lambda rep: option_value(
|
return lambda rep: (
|
||||||
rep.get('x.com.samsung.da.options'), prefix) not in (None, 'Off')
|
option_value(rep.get("x.com.samsung.da.options"), prefix) not in (None, "Off")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# Bubble soak / pre-wash / intensive-wash toggles, from the same options[]
|
# Bubble soak / pre-wash / intensive-wash toggles, from the same options[]
|
||||||
@@ -276,10 +305,10 @@ def _bool_option_switch(key, icon, prefix, availability_field):
|
|||||||
resolved (unrecognized course, missing/mismatched-length bitmap)
|
resolved (unrecognized course, missing/mismatched-length bitmap)
|
||||||
rather than guessing -- a false rejection is worse than an
|
rather than guessing -- a false rejection is worse than an
|
||||||
occasional no-op write."""
|
occasional no-op write."""
|
||||||
if p != 'On':
|
if p != "On":
|
||||||
return None
|
return None
|
||||||
opts = rep.get('x.com.samsung.da.options') or []
|
opts = rep.get("x.com.samsung.da.options") or []
|
||||||
current = option_value(opts, 'Course')
|
current = option_value(opts, "Course")
|
||||||
courses = cycle_options(resources)
|
courses = cycle_options(resources)
|
||||||
if not current or current not in courses:
|
if not current or current not in courses:
|
||||||
return None
|
return None
|
||||||
@@ -289,75 +318,99 @@ def _bool_option_switch(key, icon, prefix, availability_field):
|
|||||||
pairs = hex_pairs(raw)
|
pairs = hex_pairs(raw)
|
||||||
if len(pairs) != len(courses):
|
if len(pairs) != len(courses):
|
||||||
return None
|
return None
|
||||||
if pairs[courses.index(current)] != 'F0':
|
if pairs[courses.index(current)] != "F0":
|
||||||
return f"{key}_unavailable_for_cycle"
|
return f"{key}_unavailable_for_cycle"
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return bool_option_switch(
|
return bool_option_switch(
|
||||||
key, icon, prefix,
|
key, icon, prefix, entity_category="config", gate_on_presence=True, validate_fn=validate
|
||||||
entity_category='config', gate_on_presence=True, validate_fn=validate)
|
)
|
||||||
|
|
||||||
|
|
||||||
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(
|
||||||
table_href='/st/washercourse/vs/0'),
|
translation_key="washer_cycle",
|
||||||
SensorDesc(key='drum_clean_cycles_remaining', unit='cycles',
|
icon="mdi:washing-machine",
|
||||||
icon='mdi:washing-machine-alert',
|
table_href="/st/washercourse/vs/0",
|
||||||
state_class='measurement',
|
),
|
||||||
exists_fn=lambda rep, resources: _drum_clean_cycles_remaining(rep) is not None,
|
SensorDesc(
|
||||||
rep_fn=_drum_clean_cycles_remaining),
|
key="drum_clean_cycles_remaining",
|
||||||
SensorDesc(key='drum_clean_last_cleaned', device_class='timestamp',
|
unit="cycles",
|
||||||
icon='mdi:calendar-clock',
|
icon="mdi:washing-machine-alert",
|
||||||
entity_category='diagnostic',
|
state_class="measurement",
|
||||||
exists_fn=lambda rep, resources: _drum_clean_last_cleaned(rep) is not None,
|
exists_fn=lambda rep, resources: _drum_clean_cycles_remaining(rep) is not None,
|
||||||
rep_fn=_drum_clean_last_cleaned),
|
rep_fn=_drum_clean_cycles_remaining,
|
||||||
SelectDesc(key='detergent_quantity', icon='mdi:cup-water',
|
),
|
||||||
translation_key='detergent_quantity',
|
SensorDesc(
|
||||||
entity_category='config',
|
key="drum_clean_last_cleaned",
|
||||||
options=_level_options('DetergentLevelCtrl'),
|
device_class="timestamp",
|
||||||
exists_fn=lambda rep, resources: bool(
|
icon="mdi:calendar-clock",
|
||||||
_level_options('DetergentLevelCtrl')(resources)),
|
entity_category="diagnostic",
|
||||||
rep_fn=_dosing_level('DetergentLevelCtrl'),
|
exists_fn=lambda rep, resources: _drum_clean_last_cleaned(rep) is not None,
|
||||||
write_fn=_level_write('DetergentLevelCtrl')),
|
rep_fn=_drum_clean_last_cleaned,
|
||||||
SelectDesc(key='detergent_water_hardness', icon='mdi:water-opacity',
|
),
|
||||||
translation_key='detergent_water_hardness',
|
SelectDesc(
|
||||||
entity_category='config',
|
key="detergent_quantity",
|
||||||
options=_level_options('DetergentLevel2Ctrl'),
|
icon="mdi:cup-water",
|
||||||
exists_fn=lambda rep, resources: bool(
|
translation_key="detergent_quantity",
|
||||||
_level_options('DetergentLevel2Ctrl')(resources)),
|
entity_category="config",
|
||||||
rep_fn=_dosing_level('DetergentLevel2Ctrl'),
|
options=_level_options("DetergentLevelCtrl"),
|
||||||
write_fn=_level_write('DetergentLevel2Ctrl')),
|
exists_fn=lambda rep, resources: bool(_level_options("DetergentLevelCtrl")(resources)),
|
||||||
SelectDesc(key='softener_quantity', icon='mdi:flask-outline',
|
rep_fn=_dosing_level("DetergentLevelCtrl"),
|
||||||
translation_key='softener_quantity',
|
write_fn=_level_write("DetergentLevelCtrl"),
|
||||||
entity_category='config',
|
),
|
||||||
options=_level_options('SoftenerLevelCtrl'),
|
SelectDesc(
|
||||||
exists_fn=lambda rep, resources: bool(
|
key="detergent_water_hardness",
|
||||||
_level_options('SoftenerLevelCtrl')(resources)),
|
icon="mdi:water-opacity",
|
||||||
rep_fn=_dosing_level('SoftenerLevelCtrl'),
|
translation_key="detergent_water_hardness",
|
||||||
write_fn=_level_write('SoftenerLevelCtrl')),
|
entity_category="config",
|
||||||
SelectDesc(key='softener_concentration', icon='mdi:flask-plus-outline',
|
options=_level_options("DetergentLevel2Ctrl"),
|
||||||
translation_key='softener_concentration',
|
exists_fn=lambda rep, resources: bool(_level_options("DetergentLevel2Ctrl")(resources)),
|
||||||
entity_category='config',
|
rep_fn=_dosing_level("DetergentLevel2Ctrl"),
|
||||||
options=_level_options('SoftenerLevel2Ctrl'),
|
write_fn=_level_write("DetergentLevel2Ctrl"),
|
||||||
exists_fn=lambda rep, resources: bool(
|
),
|
||||||
_level_options('SoftenerLevel2Ctrl')(resources)),
|
SelectDesc(
|
||||||
rep_fn=_dosing_level('SoftenerLevel2Ctrl'),
|
key="softener_quantity",
|
||||||
write_fn=_level_write('SoftenerLevel2Ctrl')),
|
icon="mdi:flask-outline",
|
||||||
BinarySensorDesc(key='detergent_low', device_class='problem',
|
translation_key="softener_quantity",
|
||||||
icon='mdi:alert-circle-outline',
|
entity_category="config",
|
||||||
exists_fn=bool_option_exists('DetergentAlarm'),
|
options=_level_options("SoftenerLevelCtrl"),
|
||||||
rep_fn=_dosing_low('DetergentAlarm')),
|
exists_fn=lambda rep, resources: bool(_level_options("SoftenerLevelCtrl")(resources)),
|
||||||
BinarySensorDesc(key='softener_low', device_class='problem',
|
rep_fn=_dosing_level("SoftenerLevelCtrl"),
|
||||||
icon='mdi:alert-circle-outline',
|
write_fn=_level_write("SoftenerLevelCtrl"),
|
||||||
exists_fn=bool_option_exists('SoftenerAlarm'),
|
),
|
||||||
rep_fn=_dosing_low('SoftenerAlarm')),
|
SelectDesc(
|
||||||
_bool_option_switch('bubble_soak', 'mdi:chart-bubble',
|
key="softener_concentration",
|
||||||
'BubbleSoak', 'BubbleSoakSet'),
|
icon="mdi:flask-plus-outline",
|
||||||
_bool_option_switch('pre_wash', 'mdi:washing-machine',
|
translation_key="softener_concentration",
|
||||||
'PreWashSetting', 'PreWashAvailableSet'),
|
entity_category="config",
|
||||||
_bool_option_switch('intensive', 'mdi:washing-machine',
|
options=_level_options("SoftenerLevel2Ctrl"),
|
||||||
'IntensiveSetting', 'IntensiveAvailableSet'),
|
exists_fn=lambda rep, resources: bool(_level_options("SoftenerLevel2Ctrl")(resources)),
|
||||||
|
rep_fn=_dosing_level("SoftenerLevel2Ctrl"),
|
||||||
|
write_fn=_level_write("SoftenerLevel2Ctrl"),
|
||||||
|
),
|
||||||
|
BinarySensorDesc(
|
||||||
|
key="detergent_low",
|
||||||
|
device_class="problem",
|
||||||
|
icon="mdi:alert-circle-outline",
|
||||||
|
exists_fn=bool_option_exists("DetergentAlarm"),
|
||||||
|
rep_fn=_dosing_low("DetergentAlarm"),
|
||||||
|
),
|
||||||
|
BinarySensorDesc(
|
||||||
|
key="softener_low",
|
||||||
|
device_class="problem",
|
||||||
|
icon="mdi:alert-circle-outline",
|
||||||
|
exists_fn=bool_option_exists("SoftenerAlarm"),
|
||||||
|
rep_fn=_dosing_low("SoftenerAlarm"),
|
||||||
|
),
|
||||||
|
_bool_option_switch("bubble_soak", "mdi:chart-bubble", "BubbleSoak", "BubbleSoakSet"),
|
||||||
|
_bool_option_switch(
|
||||||
|
"pre_wash", "mdi:washing-machine", "PreWashSetting", "PreWashAvailableSet"
|
||||||
|
),
|
||||||
|
_bool_option_switch(
|
||||||
|
"intensive", "mdi:washing-machine", "IntensiveSetting", "IntensiveAvailableSet"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -4,22 +4,27 @@ issue #196, model RWP70F15ANW/AILITE_WATERPURIFIER_25K).
|
|||||||
|
|
||||||
Resources verified against the issue #90 and #196 diagnostics dumps.
|
Resources verified against the issue #90 and #196 diagnostics dumps.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..batch import is_stub_rep
|
from ..batch import is_stub_rep
|
||||||
from ..capability import Capability
|
from ..capability import Capability
|
||||||
from ..entities import BinarySensorDesc, NumberDesc, SelectDesc, SensorDesc, SwitchDesc
|
from ..entities import BinarySensorDesc, NumberDesc, SelectDesc, SensorDesc, SwitchDesc
|
||||||
from .common import int_or_none, parse_iso_utc as _parse_iso_utc
|
from .common import int_or_none
|
||||||
|
from .common import parse_iso_utc as _parse_iso_utc
|
||||||
|
|
||||||
DISPENSE = Capability(
|
DISPENSE = Capability(
|
||||||
href='/setting/waterpurifier/vs/0',
|
href="/setting/waterpurifier/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
SelectDesc(key='dispense_type', field='x.com.samsung.da.desiredType',
|
SelectDesc(
|
||||||
icon='mdi:cup-water',
|
key="dispense_type",
|
||||||
options_field='x.com.samsung.da.supportedTypes',
|
field="x.com.samsung.da.desiredType",
|
||||||
write_fn=lambda p, rep, href=None: (
|
icon="mdi:cup-water",
|
||||||
['setting', 'waterpurifier', 'vs', '0'],
|
options_field="x.com.samsung.da.supportedTypes",
|
||||||
{'x.com.samsung.da.desiredType': p})),
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["setting", "waterpurifier", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.desiredType": p},
|
||||||
|
),
|
||||||
|
),
|
||||||
# Only a handful of discrete temperatures are selectable (not a
|
# Only a handful of discrete temperatures are selectable (not a
|
||||||
# continuous range) -- a select over the live-reported set, not a
|
# continuous range) -- a select over the live-reported set, not a
|
||||||
# number with invented bounds.
|
# number with invented bounds.
|
||||||
@@ -33,16 +38,20 @@ DISPENSE = Capability(
|
|||||||
# list and renders as "unknown" -- the exact symptom reported. Gate
|
# list and renders as "unknown" -- the exact symptom reported. Gate
|
||||||
# the entity off entirely when the board doesn't report a supported
|
# the entity off entirely when the board doesn't report a supported
|
||||||
# list, rather than guess at hotwaterRange/hotwaterLevel's meaning.
|
# list, rather than guess at hotwaterRange/hotwaterLevel's meaning.
|
||||||
SelectDesc(key='hot_water_temperature', field='x.com.samsung.da.tempDesiredHotWater',
|
SelectDesc(
|
||||||
icon='mdi:thermometer',
|
key="hot_water_temperature",
|
||||||
entity_category='config',
|
field="x.com.samsung.da.tempDesiredHotWater",
|
||||||
options_field='x.com.samsung.da.supportedHotTemperatures',
|
icon="mdi:thermometer",
|
||||||
exists_fn=lambda rep, resources: (
|
entity_category="config",
|
||||||
is_stub_rep(rep)
|
options_field="x.com.samsung.da.supportedHotTemperatures",
|
||||||
or 'x.com.samsung.da.supportedHotTemperatures' in rep),
|
exists_fn=lambda rep, resources: (
|
||||||
write_fn=lambda p, rep, href=None: (
|
is_stub_rep(rep) or "x.com.samsung.da.supportedHotTemperatures" in rep
|
||||||
['setting', 'waterpurifier', 'vs', '0'],
|
),
|
||||||
{'x.com.samsung.da.tempDesiredHotWater': p})),
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["setting", "waterpurifier", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.tempDesiredHotWater": p},
|
||||||
|
),
|
||||||
|
),
|
||||||
# Bounds and step come live from the device's own
|
# Bounds and step come live from the device's own
|
||||||
# desiredCapacityRange/capacityResolution fields, not a hardcoded
|
# desiredCapacityRange/capacityResolution fields, not a hardcoded
|
||||||
# constant -- see the adding-device-support skill's "never hard-code
|
# constant -- see the adding-device-support skill's "never hard-code
|
||||||
@@ -50,70 +59,103 @@ DISPENSE = Capability(
|
|||||||
# "C" on this dump, which can't be right for a volume field, so per
|
# "C" on this dump, which can't be right for a volume field, so per
|
||||||
# the 'don't guess' rule the unit is left unset rather than assumed
|
# the 'don't guess' rule the unit is left unset rather than assumed
|
||||||
# to be mL.
|
# to be mL.
|
||||||
NumberDesc(key='dispense_capacity', field='x.com.samsung.da.desiredCapacity',
|
NumberDesc(
|
||||||
icon='mdi:cup-water',
|
key="dispense_capacity",
|
||||||
value_fn=int_or_none,
|
field="x.com.samsung.da.desiredCapacity",
|
||||||
range_field='x.com.samsung.da.desiredCapacityRange',
|
icon="mdi:cup-water",
|
||||||
step_fn=lambda rep: int_or_none(
|
value_fn=int_or_none,
|
||||||
rep.get('x.com.samsung.da.capacityResolution')) or 1,
|
range_field="x.com.samsung.da.desiredCapacityRange",
|
||||||
write_fn=lambda p, rep, href=None: (
|
step_fn=lambda rep: int_or_none(rep.get("x.com.samsung.da.capacityResolution")) or 1,
|
||||||
['setting', 'waterpurifier', 'vs', '0'],
|
write_fn=lambda p, rep, href=None: (
|
||||||
{'x.com.samsung.da.desiredCapacity': str(int(round(float(p))))})),
|
["setting", "waterpurifier", "vs", "0"],
|
||||||
BinarySensorDesc(key='pouring', field='x.com.samsung.da.pourStatus',
|
{"x.com.samsung.da.desiredCapacity": str(round(float(p)))},
|
||||||
icon='mdi:cup-water',
|
),
|
||||||
value_fn=lambda v: v == 'On'),
|
),
|
||||||
|
BinarySensorDesc(
|
||||||
|
key="pouring",
|
||||||
|
field="x.com.samsung.da.pourStatus",
|
||||||
|
icon="mdi:cup-water",
|
||||||
|
value_fn=lambda v: v == "On",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
STATUS = Capability(
|
STATUS = Capability(
|
||||||
href='/status/waterpurifier/vs/0',
|
href="/status/waterpurifier/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='waterpurifier_status', field='x.com.samsung.da.status',
|
SensorDesc(
|
||||||
icon='mdi:water-pump',
|
key="waterpurifier_status",
|
||||||
entity_category='diagnostic'),
|
field="x.com.samsung.da.status",
|
||||||
BinarySensorDesc(key='filter_door_status', field='x.com.samsung.da.filterDoorStatus',
|
icon="mdi:water-pump",
|
||||||
device_class='door',
|
entity_category="diagnostic",
|
||||||
entity_category='diagnostic',
|
),
|
||||||
value_fn=lambda v: v == 'Open'),
|
BinarySensorDesc(
|
||||||
SensorDesc(key='sterilize_period', field='x.com.samsung.da.sterilizePeriod',
|
key="filter_door_status",
|
||||||
icon='mdi:calendar-sync',
|
field="x.com.samsung.da.filterDoorStatus",
|
||||||
entity_category='diagnostic'),
|
device_class="door",
|
||||||
SensorDesc(key='sterilize_run_time', field='x.com.samsung.da.sterilizeRunTime',
|
entity_category="diagnostic",
|
||||||
icon='mdi:timer-outline',
|
value_fn=lambda v: v == "Open",
|
||||||
entity_category='diagnostic'),
|
),
|
||||||
SensorDesc(key='sterilize_last_time', device_class='timestamp',
|
SensorDesc(
|
||||||
entity_category='diagnostic',
|
key="sterilize_period",
|
||||||
rep_fn=lambda rep: _parse_iso_utc(
|
field="x.com.samsung.da.sterilizePeriod",
|
||||||
rep.get('x.com.samsung.da.sterilizeLastTime'))),
|
icon="mdi:calendar-sync",
|
||||||
SensorDesc(key='sterilize_plan_time', device_class='timestamp',
|
entity_category="diagnostic",
|
||||||
entity_category='diagnostic',
|
),
|
||||||
rep_fn=lambda rep: _parse_iso_utc(
|
SensorDesc(
|
||||||
rep.get('x.com.samsung.da.sterilizePlanTime'))),
|
key="sterilize_run_time",
|
||||||
SensorDesc(key='filter_clean_remain_time', field='x.com.samsung.da.filterCleanRemainTime',
|
field="x.com.samsung.da.sterilizeRunTime",
|
||||||
icon='mdi:timer-sand',
|
icon="mdi:timer-outline",
|
||||||
entity_category='diagnostic'),
|
entity_category="diagnostic",
|
||||||
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="sterilize_last_time",
|
||||||
|
device_class="timestamp",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
rep_fn=lambda rep: _parse_iso_utc(rep.get("x.com.samsung.da.sterilizeLastTime")),
|
||||||
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="sterilize_plan_time",
|
||||||
|
device_class="timestamp",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
rep_fn=lambda rep: _parse_iso_utc(rep.get("x.com.samsung.da.sterilizePlanTime")),
|
||||||
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="filter_clean_remain_time",
|
||||||
|
field="x.com.samsung.da.filterCleanRemainTime",
|
||||||
|
icon="mdi:timer-sand",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
FAVORITE_CAPACITY = Capability(
|
FAVORITE_CAPACITY = Capability(
|
||||||
href='/favorite/capacity/vs/0',
|
href="/favorite/capacity/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
SwitchDesc(key='favorite_capacity_enabled', field='x.com.samsung.da.switchCapacity',
|
SwitchDesc(
|
||||||
icon='mdi:star-outline',
|
key="favorite_capacity_enabled",
|
||||||
entity_category='config',
|
field="x.com.samsung.da.switchCapacity",
|
||||||
value_fn=lambda v: v == 'On',
|
icon="mdi:star-outline",
|
||||||
write_fn=lambda p, rep, href=None: (
|
entity_category="config",
|
||||||
['favorite', 'capacity', 'vs', '0'],
|
value_fn=lambda v: v == "On",
|
||||||
{'x.com.samsung.da.switchCapacity': 'On' if p == 'On' else 'Off'})),
|
write_fn=lambda p, rep, href=None: (
|
||||||
SelectDesc(key='favorite_capacity', field='x.com.samsung.da.defaultCapacity',
|
["favorite", "capacity", "vs", "0"],
|
||||||
icon='mdi:cup-water',
|
{"x.com.samsung.da.switchCapacity": "On" if p == "On" else "Off"},
|
||||||
entity_category='config',
|
),
|
||||||
options_field='x.com.samsung.da.capacityList',
|
),
|
||||||
write_fn=lambda p, rep, href=None: (
|
SelectDesc(
|
||||||
['favorite', 'capacity', 'vs', '0'],
|
key="favorite_capacity",
|
||||||
{'x.com.samsung.da.defaultCapacity': p})),
|
field="x.com.samsung.da.defaultCapacity",
|
||||||
|
icon="mdi:cup-water",
|
||||||
|
entity_category="config",
|
||||||
|
options_field="x.com.samsung.da.capacityList",
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["favorite", "capacity", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.defaultCapacity": p},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -135,17 +177,17 @@ def _status_lock_definitely_lacks_hotwater_field(resources: dict) -> bool:
|
|||||||
too would register both descriptors -- as SwitchDescs sharing one key,
|
too would register both descriptors -- as SwitchDescs sharing one key,
|
||||||
with identical unique_ids -- until the next poll resolves it.
|
with identical unique_ids -- until the next poll resolves it.
|
||||||
- href present and fetched -> the real answer."""
|
- href present and fetched -> the real answer."""
|
||||||
rep = resources.get('/status/lock/vs/0')
|
rep = resources.get("/status/lock/vs/0")
|
||||||
if rep is None:
|
if rep is None:
|
||||||
return True
|
return True
|
||||||
if not rep:
|
if not rep:
|
||||||
return False
|
return False
|
||||||
return 'x.com.samsung.da.hotwaterLock' not in rep
|
return "x.com.samsung.da.hotwaterLock" not in rep
|
||||||
|
|
||||||
|
|
||||||
FAVORITE_HOTWATER = Capability(
|
FAVORITE_HOTWATER = Capability(
|
||||||
href='/favorite/hotwater/vs/0',
|
href="/favorite/hotwater/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
# Despite the resource/field naming, switchHotwater's value domain is
|
# Despite the resource/field naming, switchHotwater's value domain is
|
||||||
# Locked/Unlocked, not an enable flag (issue #144) -- it's the same
|
# Locked/Unlocked, not an enable flag (issue #144) -- it's the same
|
||||||
@@ -165,43 +207,70 @@ FAVORITE_HOTWATER = Capability(
|
|||||||
# also re-asserts its own field's presence (switchHotwater), the
|
# also re-asserts its own field's presence (switchHotwater), the
|
||||||
# gate a bare `field=` used to get for free before it had to share a
|
# gate a bare `field=` used to get for free before it had to share a
|
||||||
# key with LOCK's descriptor.
|
# key with LOCK's descriptor.
|
||||||
SwitchDesc(key='hotwater_lock', field='x.com.samsung.da.switchHotwater',
|
SwitchDesc(
|
||||||
device_class='lock',
|
key="hotwater_lock",
|
||||||
entity_category='config',
|
field="x.com.samsung.da.switchHotwater",
|
||||||
value_fn=lambda v: v != 'Unlocked',
|
device_class="lock",
|
||||||
exists_fn=lambda rep, resources: (
|
entity_category="config",
|
||||||
'x.com.samsung.da.switchHotwater' in rep
|
value_fn=lambda v: v != "Unlocked",
|
||||||
and _status_lock_definitely_lacks_hotwater_field(resources)),
|
exists_fn=lambda rep, resources: (
|
||||||
write_fn=lambda p, rep, href=None: (
|
"x.com.samsung.da.switchHotwater" in rep
|
||||||
['favorite', 'hotwater', 'vs', '0'],
|
and _status_lock_definitely_lacks_hotwater_field(resources)
|
||||||
{'x.com.samsung.da.switchHotwater': 'Locked' if p == 'On' else 'Unlocked'})),
|
),
|
||||||
SelectDesc(key='favorite_hotwater_temperature',
|
write_fn=lambda p, rep, href=None: (
|
||||||
field='x.com.samsung.da.favorite.defaultTemperature',
|
["favorite", "hotwater", "vs", "0"],
|
||||||
icon='mdi:thermometer',
|
{"x.com.samsung.da.switchHotwater": "Locked" if p == "On" else "Unlocked"},
|
||||||
entity_category='config',
|
),
|
||||||
options_field='x.com.samsung.da.favorite.supportedList',
|
),
|
||||||
write_fn=lambda p, rep, href=None: (
|
# Issue #196: `supportedList` is only the four *fixed* presets
|
||||||
['favorite', 'hotwater', 'vs', '0'],
|
# (e.g. ['40', '75', '85', '90']) -- the SmartThings app also lets
|
||||||
{'x.com.samsung.da.favorite.defaultTemperature': p})),
|
# the user add one custom value to their own display list via its
|
||||||
|
# "temperatures to display" editor (a wheel picker bounded by
|
||||||
|
# /setting/waterpurifier/vs/0's hotwaterRange, separate resource),
|
||||||
|
# and that custom value shows up in `showList`
|
||||||
|
# (['40', '50', '75', '85', '90'] here) but never in
|
||||||
|
# `supportedList`. Reading options from `supportedList` meant a
|
||||||
|
# unit whose current default *was* that custom value rendered as
|
||||||
|
# "unknown" -- not a coverage gap, just the wrong field. `showList`
|
||||||
|
# is a superset of `supportedList` that always includes whatever
|
||||||
|
# the current default actually is, custom or not.
|
||||||
|
SelectDesc(
|
||||||
|
key="favorite_hotwater_temperature",
|
||||||
|
field="x.com.samsung.da.favorite.defaultTemperature",
|
||||||
|
icon="mdi:thermometer",
|
||||||
|
entity_category="config",
|
||||||
|
options_field="x.com.samsung.da.favorite.showList",
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["favorite", "hotwater", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.favorite.defaultTemperature": p},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Coffee-capable variant (issue #107). No 'x.com.samsung.da.' field prefix
|
# Coffee-capable variant (issue #107). No 'x.com.samsung.da.' field prefix
|
||||||
# on this resource, unlike the rest of the water-purifier surface.
|
# on this resource, unlike the rest of the water-purifier surface.
|
||||||
COFFEE = Capability(
|
COFFEE = Capability(
|
||||||
href='/favorite/coffee/vs/0',
|
href="/favorite/coffee/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
SwitchDesc(key='favorite_coffee_enabled', field='favorite.activate',
|
SwitchDesc(
|
||||||
icon='mdi:coffee-outline',
|
key="favorite_coffee_enabled",
|
||||||
entity_category='config',
|
field="favorite.activate",
|
||||||
value_fn=lambda v: v == 'On',
|
icon="mdi:coffee-outline",
|
||||||
write_fn=lambda p, rep, href=None: (
|
entity_category="config",
|
||||||
['favorite', 'coffee', 'vs', '0'],
|
value_fn=lambda v: v == "On",
|
||||||
{'favorite.activate': 'On' if p == 'On' else 'Off'})),
|
write_fn=lambda p, rep, href=None: (
|
||||||
SensorDesc(key='coffee_brew_status', field='brew.status',
|
["favorite", "coffee", "vs", "0"],
|
||||||
icon='mdi:coffee-outline',
|
{"favorite.activate": "On" if p == "On" else "Off"},
|
||||||
entity_category='diagnostic'),
|
),
|
||||||
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="coffee_brew_status",
|
||||||
|
field="brew.status",
|
||||||
|
icon="mdi:coffee-outline",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -209,11 +278,15 @@ COFFEE = Capability(
|
|||||||
# the full state domain isn't confirmed, so this stays a plain diagnostic
|
# the full state domain isn't confirmed, so this stays a plain diagnostic
|
||||||
# sensor rather than an enum with an invented state table.
|
# sensor rather than an enum with an invented state table.
|
||||||
CUP_STATE = Capability(
|
CUP_STATE = Capability(
|
||||||
href='/cup/state/vs/0',
|
href="/cup/state/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='cup_state', field='water.cup.state',
|
SensorDesc(
|
||||||
icon='mdi:cup-outline', entity_category='diagnostic'),
|
key="cup_state",
|
||||||
|
field="water.cup.state",
|
||||||
|
icon="mdi:cup-outline",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -224,48 +297,64 @@ CUP_STATE = Capability(
|
|||||||
# reject a live-supported value, so these read the device's own supported
|
# reject a live-supported value, so these read the device's own supported
|
||||||
# list/range like air_purifier's versions do.
|
# list/range like air_purifier's versions do.
|
||||||
SOUND_MODE = Capability(
|
SOUND_MODE = Capability(
|
||||||
href='/settings/sound/mode/vs/0',
|
href="/settings/sound/mode/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
SelectDesc(key='sound_mode', translation_key='water_purifier_sound_mode',
|
SelectDesc(
|
||||||
field='mode',
|
key="sound_mode",
|
||||||
icon='mdi:volume-high',
|
translation_key="water_purifier_sound_mode",
|
||||||
entity_category='config',
|
field="mode",
|
||||||
options_field='supportedModes',
|
icon="mdi:volume-high",
|
||||||
write_fn=lambda p, rep, href=None: (
|
entity_category="config",
|
||||||
['settings', 'sound', 'mode', 'vs', '0'], {'mode': p})),
|
options_field="supportedModes",
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["settings", "sound", "mode", "vs", "0"],
|
||||||
|
{"mode": p},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
SOUND_OUTPUT = Capability(
|
SOUND_OUTPUT = Capability(
|
||||||
href='/settings/sound/output/vs/0',
|
href="/settings/sound/output/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='sound_output', field='deviceType',
|
SensorDesc(
|
||||||
icon='mdi:volume-high', entity_category='diagnostic'),
|
key="sound_output",
|
||||||
|
field="deviceType",
|
||||||
|
icon="mdi:volume-high",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
),
|
||||||
# No confirmed write contract (no sibling field advertising this as
|
# No confirmed write contract (no sibling field advertising this as
|
||||||
# user-settable) -- surfaced read-only per the 'don't guess' rule.
|
# user-settable) -- surfaced read-only per the 'don't guess' rule.
|
||||||
BinarySensorDesc(key='alarm_in_mute', field='alarmInMute',
|
BinarySensorDesc(
|
||||||
icon='mdi:volume-mute',
|
key="alarm_in_mute",
|
||||||
entity_category='diagnostic',
|
field="alarmInMute",
|
||||||
value_fn=lambda v: str(v).lower() == 'true'),
|
icon="mdi:volume-mute",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
value_fn=lambda v: str(v).lower() == "true",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
SOUND_VOLUME = Capability(
|
SOUND_VOLUME = Capability(
|
||||||
href='/settings/sound/volume/vs/0',
|
href="/settings/sound/volume/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
NumberDesc(key='sound_volume', field='level',
|
NumberDesc(
|
||||||
icon='mdi:volume-medium',
|
key="sound_volume",
|
||||||
entity_category='config',
|
field="level",
|
||||||
native_min_fn=lambda rep: int_or_none(rep.get('minLevel')) or 0,
|
icon="mdi:volume-medium",
|
||||||
native_max_fn=lambda rep: int_or_none(rep.get('maxLevel')) or 0,
|
entity_category="config",
|
||||||
step_fn=lambda rep: int_or_none(rep.get('resolution')) or 1,
|
native_min_fn=lambda rep: int_or_none(rep.get("minLevel")) or 0,
|
||||||
value_fn=int_or_none,
|
native_max_fn=lambda rep: int_or_none(rep.get("maxLevel")) or 0,
|
||||||
write_fn=lambda p, rep, href=None: (
|
step_fn=lambda rep: int_or_none(rep.get("resolution")) or 1,
|
||||||
['settings', 'sound', 'volume', 'vs', '0'],
|
value_fn=int_or_none,
|
||||||
{'level': str(int(p))})),
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["settings", "sound", "volume", "vs", "0"],
|
||||||
|
{"level": str(int(p))},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -274,20 +363,28 @@ SOUND_VOLUME = Capability(
|
|||||||
# which at least has an -- albeit suspect -- capacityUnit) so it's left
|
# which at least has an -- albeit suspect -- capacityUnit) so it's left
|
||||||
# unitless rather than assumed to be mL.
|
# unitless rather than assumed to be mL.
|
||||||
STATISTIC_POUR = Capability(
|
STATISTIC_POUR = Capability(
|
||||||
href='/statistic/pour/vs/0',
|
href="/statistic/pour/vs/0",
|
||||||
poll_tier='cold',
|
poll_tier="cold",
|
||||||
entities=(
|
entities=(
|
||||||
SensorDesc(key='last_pour_type', field='last.type',
|
SensorDesc(
|
||||||
icon='mdi:cup-water', entity_category='diagnostic'),
|
key="last_pour_type",
|
||||||
SensorDesc(key='last_pour_capacity', field='last.capacity',
|
field="last.type",
|
||||||
icon='mdi:cup-water', entity_category='diagnostic',
|
icon="mdi:cup-water",
|
||||||
value_fn=int_or_none),
|
entity_category="diagnostic",
|
||||||
|
),
|
||||||
|
SensorDesc(
|
||||||
|
key="last_pour_capacity",
|
||||||
|
field="last.capacity",
|
||||||
|
icon="mdi:cup-water",
|
||||||
|
entity_category="diagnostic",
|
||||||
|
value_fn=int_or_none,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
LOCK = Capability(
|
LOCK = Capability(
|
||||||
href='/status/lock/vs/0',
|
href="/status/lock/vs/0",
|
||||||
poll_tier='warm',
|
poll_tier="warm",
|
||||||
entities=(
|
entities=(
|
||||||
# Shares its key with FAVORITE_HOTWATER's switchHotwater fallback
|
# Shares its key with FAVORITE_HOTWATER's switchHotwater fallback
|
||||||
# above (issue #144); see the comment there for why this half also
|
# above (issue #144); see the comment there for why this half also
|
||||||
@@ -296,29 +393,40 @@ LOCK = Capability(
|
|||||||
# "present" here (matches entity.py's own default for a field-less
|
# "present" here (matches entity.py's own default for a field-less
|
||||||
# gate) since the alternative -- treating an unfetched resource as
|
# gate) since the alternative -- treating an unfetched resource as
|
||||||
# confirmed-absent -- is what let both descriptors register at once.
|
# confirmed-absent -- is what let both descriptors register at once.
|
||||||
SwitchDesc(key='hotwater_lock', field='x.com.samsung.da.hotwaterLock',
|
SwitchDesc(
|
||||||
device_class='lock',
|
key="hotwater_lock",
|
||||||
entity_category='config',
|
field="x.com.samsung.da.hotwaterLock",
|
||||||
value_fn=lambda v: v != 'Unlocked',
|
device_class="lock",
|
||||||
exists_fn=lambda rep, resources: (
|
entity_category="config",
|
||||||
not rep or 'x.com.samsung.da.hotwaterLock' in rep),
|
value_fn=lambda v: v != "Unlocked",
|
||||||
write_fn=lambda p, rep, href=None: (
|
exists_fn=lambda rep, resources: not rep or "x.com.samsung.da.hotwaterLock" in rep,
|
||||||
['status', 'lock', 'vs', '0'],
|
write_fn=lambda p, rep, href=None: (
|
||||||
{'x.com.samsung.da.hotwaterLock': 'Locked' if p == 'On' else 'Unlocked'})),
|
["status", "lock", "vs", "0"],
|
||||||
SwitchDesc(key='coldwater_lock', field='x.com.samsung.da.coldwaterLock',
|
{"x.com.samsung.da.hotwaterLock": "Locked" if p == "On" else "Unlocked"},
|
||||||
device_class='lock',
|
),
|
||||||
entity_category='config',
|
),
|
||||||
value_fn=lambda v: v != 'Unlocked',
|
SwitchDesc(
|
||||||
write_fn=lambda p, rep, href=None: (
|
key="coldwater_lock",
|
||||||
['status', 'lock', 'vs', '0'],
|
field="x.com.samsung.da.coldwaterLock",
|
||||||
{'x.com.samsung.da.coldwaterLock': 'Locked' if p == 'On' else 'Unlocked'})),
|
device_class="lock",
|
||||||
SwitchDesc(key='buzz_lock', field='x.com.samsung.da.buzzLock',
|
entity_category="config",
|
||||||
device_class='lock',
|
value_fn=lambda v: v != "Unlocked",
|
||||||
entity_category='config',
|
write_fn=lambda p, rep, href=None: (
|
||||||
value_fn=lambda v: v != 'Unlocked',
|
["status", "lock", "vs", "0"],
|
||||||
write_fn=lambda p, rep, href=None: (
|
{"x.com.samsung.da.coldwaterLock": "Locked" if p == "On" else "Unlocked"},
|
||||||
['status', 'lock', 'vs', '0'],
|
),
|
||||||
{'x.com.samsung.da.buzzLock': 'Locked' if p == 'On' else 'Unlocked'})),
|
),
|
||||||
|
SwitchDesc(
|
||||||
|
key="buzz_lock",
|
||||||
|
field="x.com.samsung.da.buzzLock",
|
||||||
|
device_class="lock",
|
||||||
|
entity_category="config",
|
||||||
|
value_fn=lambda v: v != "Unlocked",
|
||||||
|
write_fn=lambda p, rep, href=None: (
|
||||||
|
["status", "lock", "vs", "0"],
|
||||||
|
{"x.com.samsung.da.buzzLock": "Locked" if p == "On" else "Unlocked"},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -334,18 +442,18 @@ _WP_IGNORED = [
|
|||||||
# select. OCF-standard /mode/0 mirrors the same vendor resource but is
|
# select. OCF-standard /mode/0 mirrors the same vendor resource but is
|
||||||
# already covered by the global ignored.IGNORED (fridge's OCF-native
|
# already covered by the global ignored.IGNORED (fridge's OCF-native
|
||||||
# vacation-mode flag shares that href).
|
# vacation-mode flag shares that href).
|
||||||
'/mode/vs/0',
|
"/mode/vs/0",
|
||||||
# Static support-flags blob (automation.supported.modes/options) -- no
|
# Static support-flags blob (automation.supported.modes/options) -- no
|
||||||
# live "current automation setting" field to expose.
|
# live "current automation setting" field to expose.
|
||||||
'/automation/waterpurifier/vs/0',
|
"/automation/waterpurifier/vs/0",
|
||||||
# Coffee-capable variant (issue #107). All four are static
|
# Coffee-capable variant (issue #107). All four are static
|
||||||
# capability-advertisement blobs or empty -- no live "current recipe" /
|
# capability-advertisement blobs or empty -- no live "current recipe" /
|
||||||
# "current custom slot" field to expose, unlike /favorite/coffee/vs/0
|
# "current custom slot" field to expose, unlike /favorite/coffee/vs/0
|
||||||
# (COFFEE above), which does carry live brew status.
|
# (COFFEE above), which does carry live brew status.
|
||||||
'/brand/recipe/info/vs/0', # revision + max-brand-count metadata
|
"/brand/recipe/info/vs/0", # revision + max-brand-count metadata
|
||||||
'/coffee/custom/recipe/vs/0', # publisher.support: allowed custom-recipe slot IDs
|
"/coffee/custom/recipe/vs/0", # publisher.support: allowed custom-recipe slot IDs
|
||||||
'/recipe/coffee/vs/0', # same publisher.support shape, no per-recipe content
|
"/recipe/coffee/vs/0", # same publisher.support shape, no per-recipe content
|
||||||
'/recipe/coffee/deletion/vs/0', # empty {} on this dump
|
"/recipe/coffee/deletion/vs/0", # empty {} on this dump
|
||||||
]
|
]
|
||||||
|
|
||||||
COVERAGE = [Capability(href=h) for h in _WP_IGNORED]
|
COVERAGE = [Capability(href=h) for h in _WP_IGNORED]
|
||||||
@@ -1,26 +1,27 @@
|
|||||||
"""A Capability binds one OCF resource href to the entities it produces."""
|
"""A Capability binds one OCF resource href to the entities it produces."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Callable, Optional
|
|
||||||
|
|
||||||
from .entities import SamsungEntityDescription
|
from .entities import SamsungEntityDescription
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class Capability:
|
class Capability:
|
||||||
href: Optional[str] = None
|
href: str | None = None
|
||||||
entities: tuple[SamsungEntityDescription, ...] = ()
|
entities: tuple[SamsungEntityDescription, ...] = ()
|
||||||
poll_tier: str = 'cold' # 'hot' | 'warm' | 'cold'
|
poll_tier: str = "cold" # 'hot' | 'warm' | 'cold'
|
||||||
rt_filter: Optional[str] = None # bind only if rt_filter in rep.get('rt', ())
|
rt_filter: str | None = None # bind only if rt_filter in rep.get('rt', ())
|
||||||
href_prefix: Optional[str] = None # pattern caps only: bind only if href starts with this
|
href_prefix: str | None = None # pattern caps only: bind only if href starts with this
|
||||||
strip_prefix_in_key: bool = False # strip href_prefix segs before building key_override
|
strip_prefix_in_key: bool = False # strip href_prefix segs before building key_override
|
||||||
# Rep field holding this instance's device-given name (e.g. an ice
|
# Rep field holding this instance's device-given name (e.g. an ice
|
||||||
# maker's "CUBED_ICE"/"ICE_BITES"), normalized and used as the display
|
# maker's "CUBED_ICE"/"ICE_BITES"), normalized and used as the display
|
||||||
# name prefix in place of the href-derived instance label. Does not
|
# name prefix in place of the href-derived instance label. Does not
|
||||||
# affect key_override/unique_id -- only what's shown in the UI.
|
# affect key_override/unique_id -- only what's shown in the UI.
|
||||||
name_field: Optional[str] = None
|
name_field: str | None = None
|
||||||
match_fn: Optional[Callable[[dict, dict], bool]] = None # match_fn(rep, resources) -> bool
|
match_fn: Callable[[dict, dict], bool] | None = None # match_fn(rep, resources) -> bool
|
||||||
# Rare optional hook — only operational-state-style resources use this.
|
# Rare optional hook — only operational-state-style resources use this.
|
||||||
on_observation: Optional[Callable[[dict, dict], None]] = None
|
on_observation: Callable[[dict, dict], None] | None = None
|
||||||
project: Optional[Callable[[dict, dict], dict]] = None
|
project: Callable[[dict, dict], dict] | None = None
|
||||||
@@ -11,10 +11,11 @@ doesn't have that filter) is *not* a gap — a maintainer already looked at
|
|||||||
that href and decided how to handle it. Only hrefs absent from the registry
|
that href and decided how to handle it. Only hrefs absent from the registry
|
||||||
entirely are reported.
|
entirely are reported.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from collections.abc import Callable, Iterable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Callable, Iterable, Optional
|
|
||||||
|
|
||||||
from .capability import Capability
|
from .capability import Capability
|
||||||
from .entities import SamsungEntityDescription
|
from .entities import SamsungEntityDescription
|
||||||
@@ -26,9 +27,9 @@ class BoundEntity:
|
|||||||
href: str
|
href: str
|
||||||
capability: Capability
|
capability: Capability
|
||||||
desc: SamsungEntityDescription
|
desc: SamsungEntityDescription
|
||||||
instance: str = ''
|
instance: str = ""
|
||||||
key_override: Optional[str] = None
|
key_override: str | None = None
|
||||||
instance_name: Optional[str] = None
|
instance_name: str | None = None
|
||||||
# Which logical indoor subdevice (issue #177) this entity belongs to.
|
# Which logical indoor subdevice (issue #177) this entity belongs to.
|
||||||
# `href` above is always the *actual*, on-the-wire href for that
|
# `href` above is always the *actual*, on-the-wire href for that
|
||||||
# subdevice -- MAIN's
|
# subdevice -- MAIN's
|
||||||
@@ -40,10 +41,10 @@ class BoundEntity:
|
|||||||
def _snake_to_title(s: str) -> str:
|
def _snake_to_title(s: str) -> str:
|
||||||
"""'CUBED_ICE'/'cubed_ice' -> 'Cubed Ice'. Shared with entity.py's
|
"""'CUBED_ICE'/'cubed_ice' -> 'Cubed Ice'. Shared with entity.py's
|
||||||
_derive_name, which applies the same transform to an href-derived key."""
|
_derive_name, which applies the same transform to an href-derived key."""
|
||||||
return s.replace('_', ' ').title()
|
return s.replace("_", " ").title()
|
||||||
|
|
||||||
|
|
||||||
def _instance_name(cap: Capability, rep: dict) -> Optional[str]:
|
def _instance_name(cap: Capability, rep: dict) -> str | None:
|
||||||
"""Normalize `cap.name_field`'s raw value ("CUBED_ICE" -> "Cubed Ice")
|
"""Normalize `cap.name_field`'s raw value ("CUBED_ICE" -> "Cubed Ice")
|
||||||
for use as a display-name prefix, or None if the cap doesn't declare
|
for use as a display-name prefix, or None if the cap doesn't declare
|
||||||
one or the device didn't report it."""
|
one or the device didn't report it."""
|
||||||
@@ -57,15 +58,20 @@ def _instance_name(cap: Capability, rep: dict) -> Optional[str]:
|
|||||||
|
|
||||||
def instance_suffix(href: str) -> str:
|
def instance_suffix(href: str) -> str:
|
||||||
"""'' for the index-0 instance, else '_<n>' from the trailing segment."""
|
"""'' for the index-0 instance, else '_<n>' from the trailing segment."""
|
||||||
tail = href.rstrip('/').rsplit('/', 1)[-1]
|
tail = href.rstrip("/").rsplit("/", 1)[-1]
|
||||||
if tail.isdigit() and tail != '0':
|
if tail.isdigit() and tail != "0":
|
||||||
return f'_{tail}'
|
return f"_{tail}"
|
||||||
return ''
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def _bind(cap: Capability, href: str, inst: str, inst_name: Optional[str],
|
def _bind(
|
||||||
key_prefix: Optional[str] = None,
|
cap: Capability,
|
||||||
subdevice: Subdevice = MAIN) -> list[BoundEntity]:
|
href: str,
|
||||||
|
inst: str,
|
||||||
|
inst_name: str | None,
|
||||||
|
key_prefix: str | None = None,
|
||||||
|
subdevice: Subdevice = MAIN,
|
||||||
|
) -> list[BoundEntity]:
|
||||||
"""Build one BoundEntity per entity on `cap`, sharing the instance/
|
"""Build one BoundEntity per entity on `cap`, sharing the instance/
|
||||||
key-prefix/instance-name computed once by the caller.
|
key-prefix/instance-name computed once by the caller.
|
||||||
|
|
||||||
@@ -74,10 +80,15 @@ def _bind(cap: Capability, href: str, inst: str, inst_name: Optional[str],
|
|||||||
actually reads/writes (identity for MAIN, so single-subdevice devices are
|
actually reads/writes (identity for MAIN, so single-subdevice devices are
|
||||||
unaffected -- see subdevices.py)."""
|
unaffected -- see subdevices.py)."""
|
||||||
return [
|
return [
|
||||||
BoundEntity(href=subdevice.to_actual(href), capability=cap, desc=desc,
|
BoundEntity(
|
||||||
instance=inst,
|
href=subdevice.to_actual(href),
|
||||||
key_override=f'{key_prefix}_{desc.key}' if key_prefix else None,
|
capability=cap,
|
||||||
instance_name=inst_name, subdevice=subdevice)
|
desc=desc,
|
||||||
|
instance=inst,
|
||||||
|
key_override=f"{key_prefix}_{desc.key}" if key_prefix else None,
|
||||||
|
instance_name=inst_name,
|
||||||
|
subdevice=subdevice,
|
||||||
|
)
|
||||||
for desc in cap.entities
|
for desc in cap.entities
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -86,8 +97,8 @@ def discover(
|
|||||||
resources: dict[str, dict],
|
resources: dict[str, dict],
|
||||||
registry: dict[str, list[Capability]],
|
registry: dict[str, list[Capability]],
|
||||||
pattern_caps: Iterable[Capability] = (),
|
pattern_caps: Iterable[Capability] = (),
|
||||||
log: Optional[Callable[[str], None]] = None,
|
log: Callable[[str], None] | None = None,
|
||||||
tier_log: Optional[Callable[[str, str], None]] = None,
|
tier_log: Callable[[str, str], None] | None = None,
|
||||||
subdevice: Subdevice = MAIN,
|
subdevice: Subdevice = MAIN,
|
||||||
) -> list[BoundEntity]:
|
) -> list[BoundEntity]:
|
||||||
"""`tier_log(href, poll_tier)` fires for every href a capability actually
|
"""`tier_log(href, poll_tier)` fires for every href a capability actually
|
||||||
@@ -114,7 +125,7 @@ def discover(
|
|||||||
for href, rep in resources.items():
|
for href, rep in resources.items():
|
||||||
if not isinstance(rep, dict):
|
if not isinstance(rep, dict):
|
||||||
continue
|
continue
|
||||||
rts = rep.get('rt') or ()
|
rts = rep.get("rt") or ()
|
||||||
caps = registry.get(href) or []
|
caps = registry.get(href) or []
|
||||||
matched = False
|
matched = False
|
||||||
|
|
||||||
@@ -142,10 +153,17 @@ def discover(
|
|||||||
continue
|
continue
|
||||||
inst = instance_suffix(href)
|
inst = instance_suffix(href)
|
||||||
# Auto-derive key prefix from href segments (skip digits and 'vs')
|
# Auto-derive key prefix from href segments (skip digits and 'vs')
|
||||||
src = href[len(cap.href_prefix):] if (cap.strip_prefix_in_key and cap.href_prefix) else href
|
src = (
|
||||||
segs = [s for s in src.strip('/').split('/') if s and not s.isdigit() and s != 'vs']
|
href[len(cap.href_prefix) :]
|
||||||
out.extend(_bind(cap, href, inst, _instance_name(cap, rep), '_'.join(segs),
|
if (cap.strip_prefix_in_key and cap.href_prefix)
|
||||||
subdevice=subdevice))
|
else href
|
||||||
|
)
|
||||||
|
segs = [s for s in src.strip("/").split("/") if s and not s.isdigit() and s != "vs"]
|
||||||
|
out.extend(
|
||||||
|
_bind(
|
||||||
|
cap, href, inst, _instance_name(cap, rep), "_".join(segs), subdevice=subdevice
|
||||||
|
)
|
||||||
|
)
|
||||||
matched = True
|
matched = True
|
||||||
if tier_log is not None:
|
if tier_log is not None:
|
||||||
tier_log(subdevice.to_actual(href), cap.poll_tier)
|
tier_log(subdevice.to_actual(href), cap.poll_tier)
|
||||||
|
|||||||
@@ -6,17 +6,19 @@ presence gating in exists_fn; write logic in write_fn on command platforms;
|
|||||||
pre-write rejection (surfaced to the user, not just logged) in validate_fn
|
pre-write rejection (surfaced to the user, not just logged) in validate_fn
|
||||||
where a description declares one.
|
where a description declares one.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from collections.abc import Callable, Mapping
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any, Callable, Mapping, Optional
|
from typing import Any
|
||||||
|
|
||||||
WriteFn = Optional[Callable[[Any, dict], "tuple[list[str], dict] | None"]]
|
WriteFn = Callable[[Any, dict], "tuple[list[str], dict] | None"] | None
|
||||||
# (payload, rep, resources) -> a translation key, or None to allow the
|
# (payload, rep, resources) -> a translation key, or None to allow the
|
||||||
# write. resources is the coordinator's full href->rep snapshot, for the same
|
# write. resources is the coordinator's full href->rep snapshot, for the same
|
||||||
# cross-resource lookups exists_fn needs (e.g. reading a sibling href's live
|
# cross-resource lookups exists_fn needs (e.g. reading a sibling href's live
|
||||||
# option list).
|
# option list).
|
||||||
ValidateFn = Optional[Callable[[Any, dict, dict], "str | None"]]
|
ValidateFn = Callable[[Any, dict, dict], "str | None"] | None
|
||||||
|
|
||||||
|
|
||||||
def _identity(v: Any) -> Any:
|
def _identity(v: Any) -> Any:
|
||||||
@@ -26,7 +28,7 @@ def _identity(v: Any) -> Any:
|
|||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class SamsungEntityDescription:
|
class SamsungEntityDescription:
|
||||||
key: str
|
key: str
|
||||||
field: str = ''
|
field: str = ""
|
||||||
# Defaults to `key`: entity names and states live in translations/, never
|
# Defaults to `key`: entity names and states live in translations/, never
|
||||||
# here, so a descriptor only sets this to share one catalog entry across
|
# here, so a descriptor only sets this to share one catalog entry across
|
||||||
# several descriptors, or to point at a differently-named one.
|
# several descriptors, or to point at a differently-named one.
|
||||||
@@ -35,74 +37,79 @@ class SamsungEntityDescription:
|
|||||||
# snapshot and returns the key to use -- for a descriptor shared across
|
# snapshot and returns the key to use -- for a descriptor shared across
|
||||||
# board generations whose state-code meaning isn't guaranteed consistent
|
# board generations whose state-code meaning isn't guaranteed consistent
|
||||||
# between them; see laundry.cycle_select's table-id-gated resolver.
|
# between them; see laundry.cycle_select's table-id-gated resolver.
|
||||||
translation_placeholders: Optional[Mapping[str, str]] = None
|
translation_placeholders: Mapping[str, str] | None = None
|
||||||
# Dynamic resources such as fridge compartments and ice makers use a
|
# Dynamic resources such as fridge compartments and ice makers use a
|
||||||
# device-provided or href-derived instance label inside a translated name.
|
# device-provided or href-derived instance label inside a translated name.
|
||||||
use_instance_name: bool = False
|
use_instance_name: bool = False
|
||||||
icon: Optional[str] = None
|
icon: str | None = None
|
||||||
entity_category: Optional[str] = None # 'diagnostic' | 'config' | None
|
entity_category: str | None = None # 'diagnostic' | 'config' | None
|
||||||
enabled_default: bool = True
|
enabled_default: bool = True
|
||||||
value_fn: Callable[[Any], Any] = _identity
|
value_fn: Callable[[Any], Any] = _identity
|
||||||
rep_fn: Optional[Callable[[dict], Any]] = None # replaces field+value_fn; receives full rep
|
rep_fn: Callable[[dict], Any] | None = None # replaces field+value_fn; receives full rep
|
||||||
# (rep, resources): rep is this entity's own href's representation;
|
# (rep, resources): rep is this entity's own href's representation;
|
||||||
# resources is the coordinator's full href->rep snapshot, for gating
|
# resources is the coordinator's full href->rep snapshot, for gating
|
||||||
# presence on a sibling resource (e.g. laundry.cycle_options's source).
|
# presence on a sibling resource (e.g. laundry.cycle_options's source).
|
||||||
exists_fn: Optional[Callable[[dict, dict], bool]] = None
|
exists_fn: Callable[[dict, dict], bool] | None = None
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class SensorDesc(SamsungEntityDescription):
|
class SensorDesc(SamsungEntityDescription):
|
||||||
device_class: Optional[str] = None
|
device_class: str | None = None
|
||||||
state_class: Optional[str] = None
|
state_class: str | None = None
|
||||||
unit: Optional[str] = None
|
unit: str | None = None
|
||||||
unit_fn: Optional[Callable[[dict], str]] = None # overrides `unit` from the live rep, when set
|
unit_fn: Callable[[dict], str] | None = None # overrides `unit` from the live rep, when set
|
||||||
options: Optional[tuple] = None # required by HA when device_class == 'enum'
|
options: tuple | None = None # required by HA when device_class == 'enum'
|
||||||
|
# Opt-in: gate this sensor's reported value behind the user-configurable
|
||||||
|
# CONF_FINISH_TIME_HYSTERESIS_MINUTES threshold (see sensor.py). Only for
|
||||||
|
# values that are expected to jitter around their "true" value between
|
||||||
|
# device-side revisions -- not a general-purpose flag every sensor should set.
|
||||||
|
hysteresis: bool = False
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class BinarySensorDesc(SamsungEntityDescription):
|
class BinarySensorDesc(SamsungEntityDescription):
|
||||||
device_class: Optional[str] = None # value_fn must return bool
|
device_class: str | None = None # value_fn must return bool
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class SelectDesc(SamsungEntityDescription):
|
class SelectDesc(SamsungEntityDescription):
|
||||||
options: Any = () # tuple[str,...] | Callable[[dict[str, dict]], list[str]]
|
options: Any = () # tuple[str,...] | Callable[[dict[str, dict]], list[str]]
|
||||||
# callable form receives the coordinator's full href->rep resource
|
# callable form receives the coordinator's full href->rep resource
|
||||||
# snapshot (not just this entity's own href) and returns raw device
|
# snapshot (not just this entity's own href) and returns raw device
|
||||||
# option values; see select.py's LocalThingsSelect._raw_options().
|
# option values; see select.py's LocalThingsSelect._raw_options().
|
||||||
options_field: Optional[str] = None # resource field that contains the live options list
|
options_field: str | None = None # resource field that contains the live options list
|
||||||
write_fn: WriteFn = None
|
write_fn: WriteFn = None
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class SwitchDesc(SamsungEntityDescription):
|
class SwitchDesc(SamsungEntityDescription):
|
||||||
device_class: Optional[str] = None
|
device_class: str | None = None
|
||||||
write_fn: WriteFn = None
|
write_fn: WriteFn = None
|
||||||
validate_fn: ValidateFn = None
|
validate_fn: ValidateFn = None
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class ButtonDesc(SamsungEntityDescription):
|
class ButtonDesc(SamsungEntityDescription):
|
||||||
payload: str = ''
|
payload: str = ""
|
||||||
write_fn: WriteFn = None
|
write_fn: WriteFn = None
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class NumberDesc(SamsungEntityDescription):
|
class NumberDesc(SamsungEntityDescription):
|
||||||
device_class: Optional[str] = None
|
device_class: str | None = None
|
||||||
unit: Optional[str] = None
|
unit: str | None = None
|
||||||
unit_fn: Optional[Callable[[dict], str]] = None # overrides `unit` from the live rep, when set
|
unit_fn: Callable[[dict], str] | None = None # overrides `unit` from the live rep, when set
|
||||||
native_min: Optional[float] = None
|
native_min: float | None = None
|
||||||
native_max: Optional[float] = None
|
native_max: float | None = None
|
||||||
step: Optional[float] = None
|
step: float | None = None
|
||||||
# Override native_min/native_max/step from the live rep, when set --
|
# Override native_min/native_max/step from the live rep, when set --
|
||||||
# same "static default, live override" shape as unit_fn, for resources
|
# same "static default, live override" shape as unit_fn, for resources
|
||||||
# whose sane bounds depend on a per-device value (e.g. a temperature
|
# whose sane bounds depend on a per-device value (e.g. a temperature
|
||||||
# setpoint reported in Celsius on one device, Fahrenheit on another).
|
# setpoint reported in Celsius on one device, Fahrenheit on another).
|
||||||
native_min_fn: Optional[Callable[[dict], float]] = None
|
native_min_fn: Callable[[dict], float] | None = None
|
||||||
native_max_fn: Optional[Callable[[dict], float]] = None
|
native_max_fn: Callable[[dict], float] | None = None
|
||||||
step_fn: Optional[Callable[[dict], float]] = None
|
step_fn: Callable[[dict], float] | None = None
|
||||||
range_field: Optional[str] = None # resource field containing [min, max] list
|
range_field: str | None = None # resource field containing [min, max] list
|
||||||
write_fn: WriteFn = None
|
write_fn: WriteFn = None
|
||||||
|
|
||||||
|
|
||||||
@@ -128,14 +135,25 @@ class FanDesc(SamsungEntityDescription):
|
|||||||
write_fn: WriteFn = None
|
write_fn: WriteFn = None
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(frozen=True, kw_only=True)
|
||||||
|
class WaterHeaterDesc(SamsungEntityDescription):
|
||||||
|
# Composite water_heater entity: binds one primary resource (its href,
|
||||||
|
# typically an operation-mode resource) but the water_heater platform
|
||||||
|
# reads sibling resources (power, temperature) from the coordinator
|
||||||
|
# snapshot and writes to several of them. Same (kind, value) -> (path_segs,
|
||||||
|
# body) write_fn shape as ClimateDesc/FanDesc.
|
||||||
|
write_fn: WriteFn = None
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_OF: dict[type, str] = {
|
PLATFORM_OF: dict[type, str] = {
|
||||||
SensorDesc: 'sensor',
|
SensorDesc: "sensor",
|
||||||
BinarySensorDesc: 'binary_sensor',
|
BinarySensorDesc: "binary_sensor",
|
||||||
SelectDesc: 'select',
|
SelectDesc: "select",
|
||||||
SwitchDesc: 'switch',
|
SwitchDesc: "switch",
|
||||||
ButtonDesc: 'button',
|
ButtonDesc: "button",
|
||||||
NumberDesc: 'number',
|
NumberDesc: "number",
|
||||||
TimeDesc: 'time',
|
TimeDesc: "time",
|
||||||
ClimateDesc: 'climate',
|
ClimateDesc: "climate",
|
||||||
FanDesc: 'fan',
|
FanDesc: "fan",
|
||||||
|
WaterHeaterDesc: "water_heater",
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
"""Read device identity from standard OCF resources (/oic/p, /oic/d, /oic/res)."""
|
"""Read device identity from standard OCF resources (/oic/p, /oic/d, /oic/res)."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
import cbor2
|
import cbor2
|
||||||
|
|
||||||
@@ -12,9 +12,9 @@ class DeviceIdentity:
|
|||||||
manufacturer: str
|
manufacturer: str
|
||||||
model: str
|
model: str
|
||||||
name: str
|
name: str
|
||||||
serial: Optional[str]
|
serial: str | None
|
||||||
device_types: tuple[str, ...] = ()
|
device_types: tuple[str, ...] = ()
|
||||||
raw: dict[str, dict] = field(default_factory=dict)
|
raw: dict[str, dict | list] = field(default_factory=dict)
|
||||||
|
|
||||||
|
|
||||||
def _get(sess, path) -> dict:
|
def _get(sess, path) -> dict:
|
||||||
@@ -47,15 +47,15 @@ def _device_types(d: dict) -> tuple[str, ...]:
|
|||||||
|
|
||||||
In OCF this is the one standardized "what am I" field: alongside the
|
In OCF this is the one standardized "what am I" field: alongside the
|
||||||
generic 'oic.wk.d' it carries a concrete type such as 'oic.d.airconditioner'
|
generic 'oic.wk.d' it carries a concrete type such as 'oic.d.airconditioner'
|
||||||
or a Samsung 'x.com.samsung.da.*' equivalent. Nothing routes on it yet --
|
or a SmartThings 'x.com.st.d.*' equivalent. `registry/by_type/resolve()`
|
||||||
device-type detection currently parses board part numbers out of
|
now consults this first, ahead of board-part-number parsing, via
|
||||||
/information/vs/0's modelNum instead (see registry/by_type/__init__.py) --
|
`for_device_by_oic_type` and its `_OIC_TYPE_TO_KEY` table -- but only a
|
||||||
because no captured dump has ever included it: /device/0 batch responses
|
minority of dumps populate it, so the modelNum/description path stays
|
||||||
don't carry /oic/d, and diagnostics didn't report it. It's surfaced in
|
load-bearing for everything else. It's also kept whole in diagnostics
|
||||||
diagnostics so incoming issue reports can tell us whether real hardware
|
(see `raw` below) so incoming issue reports keep surfacing types that
|
||||||
populates it usefully enough to route on.
|
table doesn't know about yet.
|
||||||
"""
|
"""
|
||||||
rt = d.get('rt')
|
rt = d.get("rt")
|
||||||
if isinstance(rt, str):
|
if isinstance(rt, str):
|
||||||
rt = [rt]
|
rt = [rt]
|
||||||
if not isinstance(rt, (list, tuple)):
|
if not isinstance(rt, (list, tuple)):
|
||||||
@@ -63,9 +63,9 @@ def _device_types(d: dict) -> tuple[str, ...]:
|
|||||||
return tuple(t for t in rt if isinstance(t, str))
|
return tuple(t for t in rt if isinstance(t, str))
|
||||||
|
|
||||||
|
|
||||||
def read_identity(sess, serial: Optional[str]) -> DeviceIdentity:
|
def read_identity(sess, serial: str | None) -> DeviceIdentity:
|
||||||
p = _get(sess, ['oic', 'p'])
|
p = _get(sess, ["oic", "p"])
|
||||||
d = _get(sess, ['oic', 'd'])
|
d = _get(sess, ["oic", "d"])
|
||||||
# /oic/res is OCF's baseline resource-discovery endpoint: a unicast
|
# /oic/res is OCF's baseline resource-discovery endpoint: a unicast
|
||||||
# RETRIEVE on it returns every Resource/Collection href this endpoint
|
# RETRIEVE on it returns every Resource/Collection href this endpoint
|
||||||
# hosts, not just the one /device/0 seed path the coordinator polls.
|
# hosts, not just the one /device/0 seed path the coordinator polls.
|
||||||
@@ -78,15 +78,15 @@ def read_identity(sess, serial: Optional[str]) -> DeviceIdentity:
|
|||||||
# /device/2 speculative fallback it used to run right here on every
|
# /device/2 speculative fallback it used to run right here on every
|
||||||
# _connect_session (including every reconnect), moved to that module so
|
# _connect_session (including every reconnect), moved to that module so
|
||||||
# it only runs once, at first discovery, instead of on every reconnect.
|
# it only runs once, at first discovery, instead of on every reconnect.
|
||||||
res = _get_links(sess, ['oic', 'res'])
|
res = _get_links(sess, ["oic", "res"])
|
||||||
return DeviceIdentity(
|
return DeviceIdentity(
|
||||||
manufacturer=p.get('mnmn') or 'Samsung',
|
manufacturer=p.get("mnmn") or "Samsung",
|
||||||
model=p.get('mnmo') or '',
|
model=p.get("mnmo") or "",
|
||||||
name=d.get('n') or '',
|
name=d.get("n") or "",
|
||||||
serial=serial,
|
serial=serial,
|
||||||
device_types=_device_types(d),
|
device_types=_device_types(d),
|
||||||
# Kept whole rather than field-by-field: these resources are outside
|
# Kept whole rather than field-by-field: these resources are outside
|
||||||
# the /device/0 dump diagnostics already captures, and we don't yet
|
# the /device/0 dump diagnostics already captures, and we don't yet
|
||||||
# know which of their fields will turn out to identify a device type.
|
# know which of their fields will turn out to identify a device type.
|
||||||
raw={'/oic/p': p, '/oic/d': d, '/oic/res': res},
|
raw={"/oic/p": p, "/oic/d": d, "/oic/res": res},
|
||||||
)
|
)
|
||||||
@@ -10,13 +10,24 @@ under — new device types will have unknown-shaped data we can't fully
|
|||||||
enumerate in advance, so this errs on catching the field by name rather
|
enumerate in advance, so this errs on catching the field by name rather
|
||||||
than only redacting inside hrefs we already recognize.
|
than only redacting inside hrefs we already recognize.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
REDACTED = "**REDACTED**"
|
REDACTED = "**REDACTED**"
|
||||||
|
|
||||||
_SENSITIVE_SUBSTRINGS = (
|
_SENSITIVE_SUBSTRINGS = (
|
||||||
'mac', 'serial', 'token', 'login', 'account', 'email',
|
"mac",
|
||||||
'userid', 'deviceid', 'uuid', 'duid', 'password', 'secret',
|
"serial",
|
||||||
|
"token",
|
||||||
|
"login",
|
||||||
|
"account",
|
||||||
|
"email",
|
||||||
|
"userid",
|
||||||
|
"deviceid",
|
||||||
|
"uuid",
|
||||||
|
"duid",
|
||||||
|
"password",
|
||||||
|
"secret",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Matched whole, not as substrings. OCF's /oic/d and /oic/p identify the unit
|
# Matched whole, not as substrings. OCF's /oic/d and /oic/p identify the unit
|
||||||
@@ -32,7 +43,7 @@ _SENSITIVE_SUBSTRINGS = (
|
|||||||
# reachable when diagnostics started reporting /oic/d, and the
|
# reachable when diagnostics started reporting /oic/d, and the
|
||||||
# device-type signal we actually want from that resource is `rt`,
|
# device-type signal we actually want from that resource is `rt`,
|
||||||
# which is not redacted.
|
# which is not redacted.
|
||||||
_SENSITIVE_EXACT = frozenset({'di', 'pi', 'n'})
|
_SENSITIVE_EXACT = frozenset({"di", "pi", "n"})
|
||||||
|
|
||||||
|
|
||||||
def _is_sensitive_key(key: str) -> bool:
|
def _is_sensitive_key(key: str) -> bool:
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ Raises ValueError at import if any href group contains an unfiltered cap
|
|||||||
alongside other caps (i.e., a cap with neither rt_filter nor match_fn set
|
alongside other caps (i.e., a cap with neither rt_filter nor match_fn set
|
||||||
in a group with multiple caps).
|
in a group with multiple caps).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .capabilities import ALL
|
from .capabilities import ALL
|
||||||
from .capability import Capability
|
from .capability import Capability
|
||||||
|
|
||||||
@@ -32,8 +33,7 @@ def _build() -> dict[str, list[Capability]]:
|
|||||||
# Validate: every group with >1 cap must have all caps filtered
|
# Validate: every group with >1 cap must have all caps filtered
|
||||||
for href, caps in out.items():
|
for href, caps in out.items():
|
||||||
if len(caps) > 1:
|
if len(caps) > 1:
|
||||||
unfiltered = [c for c in caps
|
unfiltered = [c for c in caps if c.rt_filter is None and c.match_fn is None]
|
||||||
if c.rt_filter is None and c.match_fn is None]
|
|
||||||
if unfiltered:
|
if unfiltered:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"duplicate capability href {href!r} has unfiltered cap(s); "
|
f"duplicate capability href {href!r} has unfiltered cap(s); "
|
||||||
|
|||||||
@@ -30,13 +30,50 @@ second subdevice exists at that prefix, but not evidence that `GET
|
|||||||
around) itself returns anything. Issue #205, the same unit on a later
|
around) itself returns anything. Issue #205, the same unit on a later
|
||||||
version, is that assumption failing: `/<uuid>/device/0` comes back empty.
|
version, is that assumption failing: `/<uuid>/device/0` comes back empty.
|
||||||
So `enumerate_subdevices` tries it first (a future board might genuinely
|
So `enumerate_subdevices` tries it first (a future board might genuinely
|
||||||
expose it) and falls back, when it's empty, to probing every href the
|
expose it) and, when it's empty, assumes the sibling shares the master's
|
||||||
master itself answered this cycle individually under the UUID prefix --
|
resource surface outright rather than trying to confirm it href by href.
|
||||||
the only thing ever actually confirmed to work for this pattern -- on the
|
|
||||||
assumption that a composite device's siblings share the master's resource
|
|
||||||
surface. See `Subdevice.flat_hrefs`.
|
|
||||||
|
|
||||||
Both are "the same thing wearing different clothes": a logical subdevice is a
|
That per-href confirmation is what this module did originally, and issue
|
||||||
|
#265 is why it doesn't anymore: `ARTIK051_FAC_TIME_21K`'s firmware doesn't
|
||||||
|
4.04 an href it doesn't recognize under a foreign prefix, it drops the
|
||||||
|
packet -- so probing the ~30 hrefs a real AC dump carries, each waiting out
|
||||||
|
the full 10s RETRIEVE timeout before moving on, took close enough to five
|
||||||
|
minutes to trip Home Assistant's own bootstrap-stage timeout and fail the
|
||||||
|
whole config entry, main unit included, before a single entity existed.
|
||||||
|
A device naming this UUID in its own `subdeviceIdList` (or `/oic/res` link
|
||||||
|
prefix, Pattern C) is already the device's own claim that a real subdevice
|
||||||
|
lives there; spending an unbounded, firmware-dependent amount of RETRIEVEs
|
||||||
|
trying to re-confirm that claim one href at a time bought unreliable
|
||||||
|
confirmation at a cost that could take the integration down with it. So the
|
||||||
|
fallback now trusts the claim and clones the master's current hrefs *and*
|
||||||
|
values verbatim under the prefix as this cycle's assumed state for the
|
||||||
|
sibling, with one bounded exception: it still retries a single individual
|
||||||
|
`GET /<uuid>/information/vs/0` -- the one href this pattern has ever
|
||||||
|
actually confirmed to answer on its own, per the paragraph above -- so the
|
||||||
|
sibling's HA device shows its own model/serial rather than the master's
|
||||||
|
cloned ones (identical model/serial across two otherwise-distinct devices
|
||||||
|
reads as a duplicate, even though their device-registry identifiers are
|
||||||
|
genuinely different). That's one extra RETRIEVE per candidate, not the ~30
|
||||||
|
that caused issue #265. `coordinator._poll_subdevice_flat_hrefs` still
|
||||||
|
re-GETs every cloned href individually, under the prefix, on every later
|
||||||
|
summary poll (unchanged by this), correcting the assumption toward the
|
||||||
|
sibling's real values as responses arrive; an href the firmware never
|
||||||
|
answers under that prefix just keeps mirroring the master indefinitely --
|
||||||
|
which, for a board proven not to expose that href at all, is what "assume
|
||||||
|
it exists" has to mean in practice. See `Subdevice.flat_hrefs`.
|
||||||
|
|
||||||
|
Pattern C -- UUID prefix advertised only via `/oic/res`
|
||||||
|
(`AWM-WW-AID-26-ONEBODY` washer+dryer combo, issue #241). The board answers
|
||||||
|
`numofsubdevice='2'` on `/multidevice/vs/0` but has no `/subdevices/vs/0`
|
||||||
|
(no `subdeviceIdList`) and 4.04s `/device/1`/`/device/2`; the washer
|
||||||
|
subdevice's UUID appears nowhere except as the path prefix of the
|
||||||
|
`x.com.samsung.da.multidevice` link in `/oic/res`, and
|
||||||
|
`GET /<uuid>/device/0` answers the washer's own full Collection batch
|
||||||
|
(model `..._WF80H` vs. the master's `..._DV80H27H`) -- Pattern B's
|
||||||
|
transform with the UUID sourced from the link prefix instead of
|
||||||
|
`subdeviceIdList`.
|
||||||
|
|
||||||
|
All of these are "the same thing wearing different clothes": a logical subdevice is a
|
||||||
seed collection path to poll, plus an href transform between the canonical
|
seed collection path to poll, plus an href transform between the canonical
|
||||||
href the registry knows (`/mode/vs/0`) and the actual on-the-wire href. The
|
href the registry knows (`/mode/vs/0`) and the actual on-the-wire href. The
|
||||||
detection signals don't overlap on either captured board (the Pattern A
|
detection signals don't overlap on either captured board (the Pattern A
|
||||||
@@ -60,25 +97,40 @@ fridge's second compartment, ...) baked into a registry field before any
|
|||||||
of those families could use this module at all. `discover_partitioned`
|
of those families could use this module at all. `discover_partitioned`
|
||||||
instead gates at the *entity* layer, after discovery+flattening: a
|
instead gates at the *entity* layer, after discovery+flattening: a
|
||||||
candidate is only kept if it produced at least one *primary* (no
|
candidate is only kept if it produced at least one *primary* (no
|
||||||
`entity_category`) bound entity whose flattened value isn't `None` -- e.g.
|
`entity_category`), non-meter bound entity whose flattened value isn't
|
||||||
the Pattern A reporter's /device/2 does flatten to an `alarm_code` value, but
|
`None` -- e.g. the Pattern A reporter's /device/2 does flatten to an
|
||||||
that entity is diagnostic-category and derived from an empty /alarms/vs/2,
|
`alarm_code` value, but that entity is diagnostic-category and derived from
|
||||||
so it doesn't count. This reuses the same primary/config/diagnostic
|
an empty /alarms/vs/2, so it doesn't count. This reuses the same
|
||||||
taxonomy every registry already declares (see the adding-device-support
|
primary/config/diagnostic taxonomy every registry already declares (see the
|
||||||
skill's entity-taxonomy section) instead of adding a second, parallel
|
adding-device-support skill's entity-taxonomy section) instead of adding a
|
||||||
domain-knowledge mechanism.
|
second, parallel domain-knowledge mechanism.
|
||||||
|
|
||||||
|
The meter carve-out is issue #214, and it's the same "an unused slot still
|
||||||
|
answers *something*" problem one layer further in: that reporter's
|
||||||
|
single-split ARTIK051_KRAC_18K has a /device/1 whose operational reps are
|
||||||
|
all empty {} -- the /device/2 shape above -- but which also reports a
|
||||||
|
populated /energy/consumption/vs/1, a whole-appliance lifetime kWh counter
|
||||||
|
that materialized the slot as a phantom second air conditioner. See
|
||||||
|
`_has_live_primary_entity`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
from collections.abc import Callable, Sequence
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Callable, Optional
|
|
||||||
|
|
||||||
import cbor2
|
import cbor2
|
||||||
|
|
||||||
from .batch import parse_device0_batch
|
from .batch import parse_device0_batch
|
||||||
|
from .by_type._base import DeviceRegistry
|
||||||
|
|
||||||
_INDEXED_HREF_RE = re.compile(r'^/device/(\d+)$')
|
_INDEXED_HREF_RE = re.compile(r"^/device/(\d+)$")
|
||||||
|
|
||||||
|
# A UUID as the first path segment of an /oic/res link href -- Pattern C's
|
||||||
|
# discovery signal (issue #241): a subdevice tree whose UUID is advertised
|
||||||
|
# nowhere except as this prefix (no subdeviceIdList, no /device/<n>).
|
||||||
|
_UUID_PREFIX_RE = re.compile(r"^/([0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12})/")
|
||||||
|
|
||||||
# Speculative /device/<n> siblings probed when /oic/res doesn't reveal a
|
# Speculative /device/<n> siblings probed when /oic/res doesn't reveal a
|
||||||
# second logical subdevice's Collection on this board (moved here from
|
# second logical subdevice's Collection on this board (moved here from
|
||||||
@@ -108,21 +160,25 @@ class Subdevice:
|
|||||||
`flat_hrefs` is non-empty only for a 'prefixed' subdevice that doesn't
|
`flat_hrefs` is non-empty only for a 'prefixed' subdevice that doesn't
|
||||||
expose its own Collection at `seed_path` (issue #205 -- not even
|
expose its own Collection at `seed_path` (issue #205 -- not even
|
||||||
TP2X_FAC_BORA_21K, the board this pattern was built against, always
|
TP2X_FAC_BORA_21K, the board this pattern was built against, always
|
||||||
does). When set, `seed_path` is meaningless (left as `()`) and this
|
does). When set, `seed_path` is meaningless (left as `()`); enumeration
|
||||||
subdevice's state comes from GETting each of these canonical hrefs
|
seeds this subdevice's initial state by cloning the master's own current
|
||||||
individually under its prefix instead of one Collection batch -- see
|
hrefs/values under its prefix rather than confirming them live (issue
|
||||||
enumerate_subdevices' fallback and coordinator._poll_subdevice_seed.
|
#265 -- see enumerate_subdevices' fallback), and from then on
|
||||||
|
coordinator._poll_subdevice_seed refreshes it by GETting each of these
|
||||||
|
canonical hrefs individually under its prefix instead of one Collection
|
||||||
|
batch, correcting the clone toward real values as responses arrive.
|
||||||
"""
|
"""
|
||||||
kind: str # 'main' | 'indexed' | 'prefixed'
|
|
||||||
key: str # '' | '1' | '6c2dff6d-ee5c-dad1-6a5e-000000000001'
|
kind: str # 'main' | 'indexed' | 'prefixed'
|
||||||
|
key: str # '' | '1' | '6c2dff6d-ee5c-dad1-6a5e-000000000001'
|
||||||
seed_path: tuple[str, ...]
|
seed_path: tuple[str, ...]
|
||||||
flat_hrefs: tuple[str, ...] = ()
|
flat_hrefs: tuple[str, ...] = ()
|
||||||
|
|
||||||
def to_actual(self, canonical: str) -> str:
|
def to_actual(self, canonical: str) -> str:
|
||||||
"""Canonical registry href (e.g. '/mode/vs/0') -> the real,
|
"""Canonical registry href (e.g. '/mode/vs/0') -> the real,
|
||||||
on-the-wire href for this subdevice."""
|
on-the-wire href for this subdevice."""
|
||||||
if self.kind == 'indexed':
|
if self.kind == "indexed":
|
||||||
head, sep, tail = canonical.rpartition('/')
|
head, sep, tail = canonical.rpartition("/")
|
||||||
# Only the index-0 trailing segment is ours to rewrite --
|
# Only the index-0 trailing segment is ours to rewrite --
|
||||||
# deliberately not a "replace any trailing digit" rule, which
|
# deliberately not a "replace any trailing digit" rule, which
|
||||||
# would misread a genuine multi-instance resource (the fridge's
|
# would misread a genuine multi-instance resource (the fridge's
|
||||||
@@ -130,24 +186,24 @@ class Subdevice:
|
|||||||
# registry declares a non-zero trailing index today and no
|
# registry declares a non-zero trailing index today and no
|
||||||
# fixture in the corpus contains one (verified across the whole
|
# fixture in the corpus contains one (verified across the whole
|
||||||
# corpus), so the strict rule costs nothing.
|
# corpus), so the strict rule costs nothing.
|
||||||
if tail == '0':
|
if tail == "0":
|
||||||
return f'{head}{sep}{self.key}'
|
return f"{head}{sep}{self.key}"
|
||||||
return canonical
|
return canonical
|
||||||
if self.kind == 'prefixed':
|
if self.kind == "prefixed":
|
||||||
return f'/{self.key}{canonical}'
|
return f"/{self.key}{canonical}"
|
||||||
return canonical
|
return canonical
|
||||||
|
|
||||||
def to_canonical(self, actual: str) -> Optional[str]:
|
def to_canonical(self, actual: str) -> str | None:
|
||||||
"""Inverse of to_actual, or None when `actual` isn't this subdevice's."""
|
"""Inverse of to_actual, or None when `actual` isn't this subdevice's."""
|
||||||
if self.kind == 'indexed':
|
if self.kind == "indexed":
|
||||||
head, sep, tail = actual.rpartition('/')
|
head, sep, tail = actual.rpartition("/")
|
||||||
if tail == self.key:
|
if tail == self.key:
|
||||||
return f'{head}{sep}0'
|
return f"{head}{sep}0"
|
||||||
return None
|
return None
|
||||||
if self.kind == 'prefixed':
|
if self.kind == "prefixed":
|
||||||
prefix = f'/{self.key}'
|
prefix = f"/{self.key}"
|
||||||
if actual.startswith(prefix + '/'):
|
if actual.startswith(prefix + "/"):
|
||||||
return actual[len(prefix):]
|
return actual[len(prefix) :]
|
||||||
return None
|
return None
|
||||||
return actual
|
return actual
|
||||||
|
|
||||||
@@ -155,7 +211,7 @@ class Subdevice:
|
|||||||
"""True if `actual` belongs to this subdevice's namespace. MAIN never
|
"""True if `actual` belongs to this subdevice's namespace. MAIN never
|
||||||
"owns" anything by this definition -- it gets whatever's left after
|
"owns" anything by this definition -- it gets whatever's left after
|
||||||
every other subdevice's hrefs are excluded (see canonical_view)."""
|
every other subdevice's hrefs are excluded (see canonical_view)."""
|
||||||
if self.kind == 'main':
|
if self.kind == "main":
|
||||||
return False
|
return False
|
||||||
return self.to_canonical(actual) is not None
|
return self.to_canonical(actual) is not None
|
||||||
|
|
||||||
@@ -172,19 +228,21 @@ class Subdevice:
|
|||||||
(see DESIGN-177.md section 6): HA derives the visible entity_id from
|
(see DESIGN-177.md section 6): HA derives the visible entity_id from
|
||||||
the device name + entity name, not from unique_id.
|
the device name + entity name, not from unique_id.
|
||||||
"""
|
"""
|
||||||
if self.kind == 'indexed':
|
if self.kind == "indexed":
|
||||||
return f'subdevice{self.key}_'
|
return f"subdevice{self.key}_"
|
||||||
if self.kind == 'prefixed':
|
if self.kind == "prefixed":
|
||||||
slug = re.sub(r'[^a-zA-Z0-9]', '', self.key)
|
slug = re.sub(r"[^a-zA-Z0-9]", "", self.key)
|
||||||
return f'subdevice_{slug}_'
|
return f"subdevice_{slug}_"
|
||||||
return ''
|
return ""
|
||||||
|
|
||||||
|
|
||||||
MAIN = Subdevice(kind='main', key='', seed_path=('device', '0'))
|
MAIN = Subdevice(kind="main", key="", seed_path=("device", "0"))
|
||||||
|
|
||||||
|
|
||||||
def canonical_view(
|
def canonical_view(
|
||||||
subdevice: Subdevice, resources: dict[str, dict], subdevices: list['Subdevice'],
|
subdevice: Subdevice,
|
||||||
|
resources: dict[str, dict],
|
||||||
|
subdevices: list[Subdevice],
|
||||||
) -> dict[str, dict]:
|
) -> dict[str, dict]:
|
||||||
"""Rewrite `resources` (real, on-the-wire hrefs) into `subdevice`'s own
|
"""Rewrite `resources` (real, on-the-wire hrefs) into `subdevice`'s own
|
||||||
canonical namespace -- what discover()/exists_fn/rep_fn/is_legacy_board
|
canonical namespace -- what discover()/exists_fn/rep_fn/is_legacy_board
|
||||||
@@ -201,11 +259,8 @@ def canonical_view(
|
|||||||
`subdevices` may or may not include MAIN itself -- MAIN.owns() is always
|
`subdevices` may or may not include MAIN itself -- MAIN.owns() is always
|
||||||
False, so including it is harmless.
|
False, so including it is harmless.
|
||||||
"""
|
"""
|
||||||
if subdevice.kind == 'main':
|
if subdevice.kind == "main":
|
||||||
owned_elsewhere = {
|
owned_elsewhere = {href for href in resources if any(su.owns(href) for su in subdevices)}
|
||||||
href for href in resources
|
|
||||||
if any(su.owns(href) for su in subdevices)
|
|
||||||
}
|
|
||||||
return {h: r for h, r in resources.items() if h not in owned_elsewhere}
|
return {h: r for h, r in resources.items() if h not in owned_elsewhere}
|
||||||
return {
|
return {
|
||||||
canon: resources[actual]
|
canon: resources[actual]
|
||||||
@@ -225,11 +280,11 @@ def normalize_seed_batch(subdevice: Subdevice, batch: dict[str, dict]) -> dict[s
|
|||||||
reporter's board was never probed live before the subdevice id was
|
reporter's board was never probed live before the subdevice id was
|
||||||
known), so it's added when missing.
|
known), so it's added when missing.
|
||||||
"""
|
"""
|
||||||
if subdevice.kind != 'prefixed':
|
if subdevice.kind != "prefixed":
|
||||||
return batch
|
return batch
|
||||||
prefix = f'/{subdevice.key}'
|
prefix = f"/{subdevice.key}"
|
||||||
return {
|
return {
|
||||||
(href if href.startswith(prefix + '/') else f'{prefix}{href}'): rep
|
(href if href.startswith(prefix + "/") else f"{prefix}{href}"): rep
|
||||||
for href, rep in batch.items()
|
for href, rep in batch.items()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,14 +298,14 @@ def _iter_oic_res_hrefs(oic_res):
|
|||||||
rules it out, and _get_links' own posture already treats any list-shaped
|
rules it out, and _get_links' own posture already treats any list-shaped
|
||||||
body as possible) and of anything else by yielding nothing.
|
body as possible) and of anything else by yielding nothing.
|
||||||
"""
|
"""
|
||||||
for entry in (oic_res or []):
|
for entry in oic_res or []:
|
||||||
if not isinstance(entry, dict):
|
if not isinstance(entry, dict):
|
||||||
continue
|
continue
|
||||||
if 'links' in entry:
|
if "links" in entry:
|
||||||
for link in entry.get('links') or []:
|
for link in entry.get("links") or []:
|
||||||
if isinstance(link, dict):
|
if isinstance(link, dict):
|
||||||
yield link
|
yield link
|
||||||
elif 'href' in entry:
|
elif "href" in entry:
|
||||||
yield entry
|
yield entry
|
||||||
|
|
||||||
|
|
||||||
@@ -258,7 +313,7 @@ def _seed_href(path_segs: tuple[str, ...]) -> str:
|
|||||||
"""('device', '1') -> '/device/1' -- the leading-slash href form
|
"""('device', '1') -> '/device/1' -- the leading-slash href form
|
||||||
`probe_log` and diagnostics report, built from the path-segment form
|
`probe_log` and diagnostics report, built from the path-segment form
|
||||||
`sess.get` takes."""
|
`sess.get` takes."""
|
||||||
return '/' + '/'.join(path_segs)
|
return "/" + "/".join(path_segs)
|
||||||
|
|
||||||
|
|
||||||
def _get_raw(sess, path_segs: tuple[str, ...]):
|
def _get_raw(sess, path_segs: tuple[str, ...]):
|
||||||
@@ -297,8 +352,8 @@ def enumerate_subdevices(
|
|||||||
sess,
|
sess,
|
||||||
resources: dict[str, dict],
|
resources: dict[str, dict],
|
||||||
oic_res_links,
|
oic_res_links,
|
||||||
probe_log: Optional[Callable[[str, bool], None]] = None,
|
probe_log: Callable[[str, bool], None] | None = None,
|
||||||
) -> tuple[list['Subdevice'], dict[str, dict]]:
|
) -> tuple[list[Subdevice], dict[str, dict]]:
|
||||||
"""Discover every sibling indoor subdevice reachable over `sess`'s
|
"""Discover every sibling indoor subdevice reachable over `sess`'s
|
||||||
connection.
|
connection.
|
||||||
|
|
||||||
@@ -325,14 +380,96 @@ def enumerate_subdevices(
|
|||||||
"""
|
"""
|
||||||
subdevices: list[Subdevice] = []
|
subdevices: list[Subdevice] = []
|
||||||
fetched: dict[str, dict] = {}
|
fetched: dict[str, dict] = {}
|
||||||
|
# Case-insensitive -- the same UUID can reach here once from
|
||||||
|
# subdeviceIdList and once from an /oic/res link prefix with different
|
||||||
|
# casing (Samsung's own fields disagree on this elsewhere too, e.g. the
|
||||||
|
# redaction-prone subdeviceIdList handling below), and probing it twice
|
||||||
|
# would materialize the same physical subdevice as two Subdevice
|
||||||
|
# candidates under two different keys.
|
||||||
|
probed_ids: set[str] = set()
|
||||||
|
|
||||||
def _probed(seed_href: str, batch: dict) -> None:
|
def _probed(seed_href: str, batch: dict) -> None:
|
||||||
if probe_log is not None:
|
if probe_log is not None:
|
||||||
probe_log(seed_href, bool(batch))
|
probe_log(seed_href, bool(batch))
|
||||||
|
|
||||||
|
def _probe_prefixed(sub_id: str) -> None:
|
||||||
|
"""Materialize one UUID-prefixed subdevice candidate -- shared by
|
||||||
|
Pattern B (ids from subdeviceIdList) and Pattern C (ids from
|
||||||
|
/oic/res link prefixes) below, which differ only in where the UUID
|
||||||
|
came from."""
|
||||||
|
if sub_id.lower() in probed_ids:
|
||||||
|
return
|
||||||
|
probed_ids.add(sub_id.lower())
|
||||||
|
seed = (sub_id, "device", "0")
|
||||||
|
batch = _get_batch(sess, seed)
|
||||||
|
_probed(_seed_href(seed), batch)
|
||||||
|
if batch:
|
||||||
|
subdevice = Subdevice(kind="prefixed", key=sub_id, seed_path=seed)
|
||||||
|
fetched.update(normalize_seed_batch(subdevice, batch))
|
||||||
|
subdevices.append(subdevice)
|
||||||
|
return
|
||||||
|
# Fallback (issue #265, superseding the per-href probe issue #205
|
||||||
|
# originally added here): TP2X_FAC_BORA_21K itself -- the board this
|
||||||
|
# pattern was built against -- turns out not to always expose its own
|
||||||
|
# `/<uuid>/device/0` Collection either, so "every prefixed subdevice
|
||||||
|
# has one" doesn't hold even on the reference hardware. This used to
|
||||||
|
# respond by probing every href the master itself answered this
|
||||||
|
# cycle, individually, under this UUID's prefix, keeping whichever
|
||||||
|
# ones answered -- but issue #265's ARTIK051_FAC_TIME_21K drops
|
||||||
|
# packets for hrefs it doesn't recognize under a foreign prefix
|
||||||
|
# instead of 4.04ing them, so that loop's ~30 RETRIEVEs (a real AC
|
||||||
|
# dump's href count) each ran out the full 10s timeout, took close
|
||||||
|
# to five minutes, and tripped Home Assistant's own bootstrap-stage
|
||||||
|
# timeout -- failing the whole config entry, main unit included,
|
||||||
|
# before a single entity existed. The device already named this
|
||||||
|
# UUID in its own subdeviceIdList (or an /oic/res link prefix,
|
||||||
|
# Pattern C) -- that's the device's own claim a real subdevice lives
|
||||||
|
# there, so trust it outright rather than spend an unbounded,
|
||||||
|
# firmware-dependent number of RETRIEVEs re-confirming it href by
|
||||||
|
# href: clone the master's current hrefs and values verbatim under
|
||||||
|
# this prefix as the sibling's assumed state, no per-href probing
|
||||||
|
# loop at all. coordinator._poll_subdevice_flat_hrefs re-GETs each of
|
||||||
|
# these hrefs individually, under the prefix, on every later summary
|
||||||
|
# poll (unchanged by this), correcting the clone toward the
|
||||||
|
# sibling's real values as responses arrive; an href the firmware
|
||||||
|
# never answers under this prefix just keeps mirroring the master
|
||||||
|
# indefinitely -- the necessary meaning of "assume it exists" for a
|
||||||
|
# board already proven not to expose that href at all.
|
||||||
|
flat_hrefs = tuple(sorted(resources))
|
||||||
|
if not flat_hrefs:
|
||||||
|
return
|
||||||
|
for href in flat_hrefs:
|
||||||
|
fetched[f"/{sub_id}{href}"] = resources[href]
|
||||||
|
# One exception, worth its own bounded RETRIEVE rather than trusting
|
||||||
|
# the clone: /information/vs/0 is what device_info_for() reads for
|
||||||
|
# this subdevice's own model/serial. Left cloned from the master,
|
||||||
|
# the sibling's HA device page would show the *master's* model and
|
||||||
|
# serial verbatim -- distinct device-registry identifiers (derived
|
||||||
|
# from this UUID, see device_info_for), but reading as a duplicate
|
||||||
|
# of the master to anyone looking at the two devices' info. This is
|
||||||
|
# also the one href ever actually confirmed to answer under this
|
||||||
|
# pattern's prefix on real hardware (issue #177 comment 5113518087),
|
||||||
|
# so it's worth retrying here even though the rest of the fallback
|
||||||
|
# no longer probes anything -- one extra RETRIEVE per candidate,
|
||||||
|
# not the ~30 that caused issue #265.
|
||||||
|
info_seed = (sub_id, "information", "vs", "0")
|
||||||
|
info = _get_property(sess, info_seed)
|
||||||
|
_probed(_seed_href(info_seed), info)
|
||||||
|
if info:
|
||||||
|
fetched[f"/{sub_id}/information/vs/0"] = info
|
||||||
|
if "/information/vs/0" not in flat_hrefs:
|
||||||
|
flat_hrefs = tuple(sorted({*flat_hrefs, "/information/vs/0"}))
|
||||||
|
subdevices.append(
|
||||||
|
Subdevice(
|
||||||
|
kind="prefixed",
|
||||||
|
key=sub_id,
|
||||||
|
seed_path=(),
|
||||||
|
flat_hrefs=flat_hrefs,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
# --- Pattern B: UUID-prefixed tree (TP2X_FAC_BORA_21K) ------------------
|
# --- Pattern B: UUID-prefixed tree (TP2X_FAC_BORA_21K) ------------------
|
||||||
raw_ids = (resources.get('/subdevices/vs/0') or {}).get(
|
raw_ids = (resources.get("/subdevices/vs/0") or {}).get("x.com.samsung.da.subdeviceIdList")
|
||||||
'x.com.samsung.da.subdeviceIdList')
|
|
||||||
# Tolerate anything but a list of strings -- this field is redaction-prone
|
# Tolerate anything but a list of strings -- this field is redaction-prone
|
||||||
# (it matches the 'deviceid' substring rule in redact.py) and the existing
|
# (it matches the 'deviceid' substring rule in redact.py) and the existing
|
||||||
# airconditioner_fac_bora fixture carries the literal string
|
# airconditioner_fac_bora fixture carries the literal string
|
||||||
@@ -340,64 +477,48 @@ def enumerate_subdevices(
|
|||||||
# crash -- issue #177 is additive, it must never break an already-working
|
# crash -- issue #177 is additive, it must never break an already-working
|
||||||
# single-climate-entity device.
|
# single-climate-entity device.
|
||||||
ids = raw_ids if isinstance(raw_ids, list) else []
|
ids = raw_ids if isinstance(raw_ids, list) else []
|
||||||
for sub_id in sorted(i for i in ids if isinstance(i, str) and i):
|
listed = sorted(i for i in ids if isinstance(i, str) and i)
|
||||||
seed = (sub_id, 'device', '0')
|
for sub_id in listed:
|
||||||
batch = _get_batch(sess, seed)
|
_probe_prefixed(sub_id)
|
||||||
_probed(_seed_href(seed), batch)
|
|
||||||
if batch:
|
# --- Pattern C: UUID prefix advertised only via /oic/res ----------------
|
||||||
subdevice = Subdevice(kind='prefixed', key=sub_id, seed_path=seed)
|
# (AWM-WW-AID-26-ONEBODY washer+dryer combo, issue #241.) A third
|
||||||
fetched.update(normalize_seed_batch(subdevice, batch))
|
# multidevice shape: the board answers numofsubdevice='2' on
|
||||||
subdevices.append(subdevice)
|
# /multidevice/vs/0, but carries no /subdevices/vs/0 (no subdeviceIdList
|
||||||
continue
|
# -- Pattern B's signal) and 4.04s /device/1 and /device/2 (Pattern A's).
|
||||||
# Fallback (issue #205): TP2X_FAC_BORA_21K itself -- the board this
|
# The only trace of the sibling is a UUID-prefixed link in /oic/res
|
||||||
# pattern was built against -- turns out not to always expose its own
|
# itself: the x.com.samsung.da.multidevice link,
|
||||||
# `/<uuid>/device/0` Collection either, so "every prefixed subdevice
|
# '/<uuid>/multidevice/vs/0' on the reporting board. Its washer tree
|
||||||
# has one" doesn't hold even on the reference hardware. With no
|
# answers a full Collection at /<uuid>/device/0, exactly Pattern B's
|
||||||
# Collection to seed from and no per-UUID entry in `/oic/res` to
|
# transform -- so treat every UUID path prefix seen in /oic/res as a
|
||||||
# enumerate hrefs from, the only signal left is that a composite
|
# prefixed-subdevice candidate. Probing is the same tolerated-404
|
||||||
# device's siblings are the same physical board family as the
|
# RETRIEVE as everything else here, and discover_partitioned's
|
||||||
# subdevice this config entry already talks to -- so probe every
|
# entity-level liveness gate still decides materialization, so a board
|
||||||
# href the master itself answered this cycle, individually, under
|
# that advertises a UUID link without a live sibling behind it
|
||||||
# this UUID's prefix, and keep whichever ones answer. Each is a
|
# contributes nothing. _probe_prefixed's probed_ids guard -- not a set
|
||||||
# plain tolerated-404 RETRIEVE, same posture as every other probe in
|
# difference against `listed` here -- is what keeps an id already named
|
||||||
# this function.
|
# by subdeviceIdList from being probed and materialized a second time,
|
||||||
#
|
# since the two sources can disagree on that UUID's case.
|
||||||
# Known gap, not yet guarded against: a firmware that answers *any*
|
linked = sorted(
|
||||||
# request under an unrecognized prefix (echoing the master's own
|
{
|
||||||
# state back rather than 4.04ing) would pass every one of these
|
m.group(1)
|
||||||
# probes and, if the echoed state also clears discover_partitioned's
|
for link in _iter_oic_res_hrefs(oic_res_links)
|
||||||
# liveness gate, materialize a phantom duplicate of the master
|
for m in [_UUID_PREFIX_RE.match(link.get("href", ""))]
|
||||||
# rather than a real sibling. Every board seen so far genuinely
|
if m
|
||||||
# 4.04s on paths it doesn't own (issue #205's own unit answered only
|
}
|
||||||
# 1 of 31 probes), so this hasn't been built -- the one place it
|
)
|
||||||
# could hook in later is comparing a candidate's confirmed reps
|
for sub_id in linked:
|
||||||
# against the master's own values for those same canonical hrefs.
|
_probe_prefixed(sub_id)
|
||||||
flat_hrefs = []
|
|
||||||
first = True
|
|
||||||
for href in sorted(resources):
|
|
||||||
if not first:
|
|
||||||
sess.pace()
|
|
||||||
first = False
|
|
||||||
actual = f'/{sub_id}{href}'
|
|
||||||
rep = _get_property(sess, tuple(actual.strip('/').split('/')))
|
|
||||||
_probed(actual, bool(rep))
|
|
||||||
if rep:
|
|
||||||
flat_hrefs.append(href)
|
|
||||||
fetched[actual] = rep
|
|
||||||
if not flat_hrefs:
|
|
||||||
continue
|
|
||||||
subdevices.append(Subdevice(
|
|
||||||
kind='prefixed', key=sub_id, seed_path=(),
|
|
||||||
flat_hrefs=tuple(flat_hrefs),
|
|
||||||
))
|
|
||||||
|
|
||||||
# --- Pattern A: indexed siblings (ARTIK051_DONGLE_FAC_18K) --------------
|
# --- Pattern A: indexed siblings (ARTIK051_DONGLE_FAC_18K) --------------
|
||||||
indices = sorted({
|
indices = sorted(
|
||||||
int(m.group(1))
|
{
|
||||||
for link in _iter_oic_res_hrefs(oic_res_links)
|
int(m.group(1))
|
||||||
for m in [_INDEXED_HREF_RE.match(link.get('href', ''))]
|
for link in _iter_oic_res_hrefs(oic_res_links)
|
||||||
if m and int(m.group(1)) >= 1
|
for m in [_INDEXED_HREF_RE.match(link.get("href", ""))]
|
||||||
})
|
if m and int(m.group(1)) >= 1
|
||||||
|
}
|
||||||
|
)
|
||||||
if not indices:
|
if not indices:
|
||||||
# A board that hides its whole tree from /oic/res (Pattern B's
|
# A board that hides its whole tree from /oic/res (Pattern B's
|
||||||
# reporter board does this too, but it has no /device/<n> to find
|
# reporter board does this too, but it has no /device/<n> to find
|
||||||
@@ -405,12 +526,12 @@ def enumerate_subdevices(
|
|||||||
# bounded speculative probe this replaces from identity.py.
|
# bounded speculative probe this replaces from identity.py.
|
||||||
indices = list(_SPECULATIVE_DEVICE_INDICES)
|
indices = list(_SPECULATIVE_DEVICE_INDICES)
|
||||||
for n in indices:
|
for n in indices:
|
||||||
seed = ('device', str(n))
|
seed = ("device", str(n))
|
||||||
batch = _get_batch(sess, seed)
|
batch = _get_batch(sess, seed)
|
||||||
_probed(_seed_href(seed), batch)
|
_probed(_seed_href(seed), batch)
|
||||||
if not batch:
|
if not batch:
|
||||||
continue
|
continue
|
||||||
subdevice = Subdevice(kind='indexed', key=str(n), seed_path=seed)
|
subdevice = Subdevice(kind="indexed", key=str(n), seed_path=seed)
|
||||||
fetched.update(batch) # already real /x/<n> hrefs, no normalization needed
|
fetched.update(batch) # already real /x/<n> hrefs, no normalization needed
|
||||||
subdevices.append(subdevice)
|
subdevices.append(subdevice)
|
||||||
|
|
||||||
@@ -427,11 +548,11 @@ def enumerate_subdevices(
|
|||||||
# with the number of subdevices actually materialized is the
|
# with the number of subdevices actually materialized is the
|
||||||
# coordinator's call to log (it owns the logger; this module doesn't),
|
# coordinator's call to log (it owns the logger; this module doesn't),
|
||||||
# not this function's.
|
# not this function's.
|
||||||
multidevice_seed = ('multidevice', 'vs', '0')
|
multidevice_seed = ("multidevice", "vs", "0")
|
||||||
multidevice = _get_property(sess, multidevice_seed)
|
multidevice = _get_property(sess, multidevice_seed)
|
||||||
_probed(_seed_href(multidevice_seed), multidevice)
|
_probed(_seed_href(multidevice_seed), multidevice)
|
||||||
if multidevice:
|
if multidevice:
|
||||||
fetched['/multidevice/vs/0'] = multidevice
|
fetched["/multidevice/vs/0"] = multidevice
|
||||||
|
|
||||||
return subdevices, fetched
|
return subdevices, fetched
|
||||||
|
|
||||||
@@ -443,37 +564,80 @@ class SkippedSubdevice:
|
|||||||
unused SmartThings slot (the Pattern A reporter's `/device/2`), not a
|
unused SmartThings slot (the Pattern A reporter's `/device/2`), not a
|
||||||
real second subdevice. Kept around (rather than silently dropped) so a
|
real second subdevice. Kept around (rather than silently dropped) so a
|
||||||
caller can log/report what was skipped and why."""
|
caller can log/report what was skipped and why."""
|
||||||
|
|
||||||
subdevice: Subdevice
|
subdevice: Subdevice
|
||||||
hrefs: tuple[str, ...]
|
hrefs: tuple[str, ...]
|
||||||
|
|
||||||
|
|
||||||
|
# Sensor kinds whose value is a running total the *appliance* keeps rather
|
||||||
|
# than a reading of the subdevice's own hardware -- excluded from the
|
||||||
|
# liveness gate below (issue #214). HA's own running-total state classes
|
||||||
|
# cover most of them; the consumption device classes catch the rest, since a
|
||||||
|
# descriptor may deliberately declare no state_class (common.ENERGY_METER's
|
||||||
|
# monthly totals reset at each billing boundary, so they aren't
|
||||||
|
# `total_increasing`).
|
||||||
|
_METER_STATE_CLASSES = frozenset({"total", "total_increasing"})
|
||||||
|
_METER_DEVICE_CLASSES = frozenset({"energy", "water", "gas"})
|
||||||
|
|
||||||
|
|
||||||
|
def _is_meter(desc) -> bool:
|
||||||
|
"""True for a cumulative consumption/counter descriptor -- see the two
|
||||||
|
constants above. Only SensorDesc carries either attribute; everything
|
||||||
|
else answers False through the getattr defaults."""
|
||||||
|
return (
|
||||||
|
getattr(desc, "state_class", None) in _METER_STATE_CLASSES
|
||||||
|
or getattr(desc, "device_class", None) in _METER_DEVICE_CLASSES
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _has_live_primary_entity(bound, state: dict) -> bool:
|
def _has_live_primary_entity(bound, state: dict) -> bool:
|
||||||
"""True if flattening `bound` (one candidate subdevice's BoundEntity
|
"""True if flattening `bound` (one candidate subdevice's BoundEntity
|
||||||
list) produced at least one non-`None` value for a *primary* entity --
|
list) produced at least one non-`None` value for a *primary* entity --
|
||||||
`entity_category` unset, HA's own "the user acts on or watches this"
|
`entity_category` unset, HA's own "the user acts on or watches this"
|
||||||
tier (see the adding-device-support skill's entity-taxonomy section).
|
tier (see the adding-device-support skill's entity-taxonomy section) --
|
||||||
|
that isn't a cumulative meter (`_is_meter`).
|
||||||
|
|
||||||
This is the materialization gate itself (see this module's docstring):
|
This is the materialization gate itself (see this module's docstring).
|
||||||
the Pattern A reporter's `/device/2` does flatten to one non-`None` value
|
Two exclusions, both for the same reason -- the question this answers is
|
||||||
(`alarm_code`), but that entity is `diagnostic`-category and derived
|
"is a physical subdevice installed at this slot?", and neither kind of
|
||||||
from an empty `/alarms/vs/2` -- a config/diagnostic entity reading
|
value can speak to it:
|
||||||
"something" proves nothing about whether a physical subdevice is actually
|
|
||||||
installed there, so it's deliberately excluded from this check.
|
- **Non-primary entities.** The Pattern A reporter's `/device/2` does
|
||||||
|
flatten to one non-`None` value (`alarm_code`), but that entity is
|
||||||
|
`diagnostic`-category and derived from an empty `/alarms/vs/2` -- a
|
||||||
|
config/diagnostic entity reading "something" proves nothing about
|
||||||
|
whether hardware is there.
|
||||||
|
- **Cumulative meters** (issue #214). An unused slot on the issue #214
|
||||||
|
reporter's ARTIK051_KRAC_18K reports `/energy/consumption/vs/1` with a
|
||||||
|
populated `cumulativePower` while every operational rep on it
|
||||||
|
(`/power/1`, `/mode/1`, `/mode/vs/1`, `/temperature/current/1`,
|
||||||
|
`/temperature/desired/1`, `/airflow/1`, `/humidity/1`) is empty `{}` --
|
||||||
|
i.e. exactly the Pattern A `/device/2` shape plus a lifetime kWh
|
||||||
|
counter. That counter got the slot materialized as a phantom second
|
||||||
|
air conditioner. A single-split AC has one compressor and one energy
|
||||||
|
meter, so a whole-appliance total showing up under a second index is
|
||||||
|
the appliance's own bookkeeping, not evidence of a second indoor unit.
|
||||||
|
A genuinely installed subdevice reports its own operational state too
|
||||||
|
(the Pattern A reporter's real `/device/1` reports power, mode, both
|
||||||
|
temperatures and airflow), and that state is what still passes this
|
||||||
|
gate.
|
||||||
"""
|
"""
|
||||||
from .adapter import _key # see discover_partitioned's deferred-import note
|
from .adapter import _key # see discover_partitioned's deferred-import note
|
||||||
|
|
||||||
return any(
|
return any(
|
||||||
not b.desc.entity_category and state.get(_key(b)) is not None
|
not b.desc.entity_category and not _is_meter(b.desc) and state.get(_key(b)) is not None
|
||||||
for b in bound
|
for b in bound
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def discover_partitioned(
|
def discover_partitioned(
|
||||||
resources: dict[str, dict],
|
resources: dict[str, dict],
|
||||||
subdevices: list['Subdevice'],
|
subdevices: list[Subdevice],
|
||||||
resolve_registry: Callable[[dict], object],
|
resolve_registry: Callable[..., DeviceRegistry | None],
|
||||||
fallback_capabilities: dict,
|
fallback_capabilities: dict,
|
||||||
log: Optional[Callable[[str], None]] = None,
|
log: Callable[[str], None] | None = None,
|
||||||
tier_log: Optional[Callable[[str, str], None]] = None,
|
tier_log: Callable[[str, str], None] | None = None,
|
||||||
|
oic_device_types: Sequence[str] = (),
|
||||||
):
|
):
|
||||||
"""Bind every href in `resources` (the merged, real-href snapshot -- main
|
"""Bind every href in `resources` (the merged, real-href snapshot -- main
|
||||||
plus every enumerated subdevice's seed) to entities, partitioned by which
|
plus every enumerated subdevice's seed) to entities, partitioned by which
|
||||||
@@ -502,6 +666,15 @@ def discover_partitioned(
|
|||||||
first-discovery time only is a non-issue; getting a phantom subdevice
|
first-discovery time only is a non-issue; getting a phantom subdevice
|
||||||
silently counted into unbound_hrefs or hot/warm tiers is not.
|
silently counted into unbound_hrefs or hot/warm tiers is not.
|
||||||
|
|
||||||
|
`oic_device_types` (from the master's own `/oic/d`, see
|
||||||
|
registry/identity.py) is passed only to the *master's* resolution --
|
||||||
|
subdevices have no `/oic/d` of their own read today (they resolve from
|
||||||
|
their own `/information/vs/0` or fall back to the master's whole
|
||||||
|
registry, as documented above), and blindly applying the master's OCF
|
||||||
|
device type to every subdevice's own model-based resolution would be
|
||||||
|
wrong the moment a composite appliance ever pairs two genuinely
|
||||||
|
different device types under one connection.
|
||||||
|
|
||||||
Returns `(bound, device_type_name, materialized, skipped)`:
|
Returns `(bound, device_type_name, materialized, skipped)`:
|
||||||
- `bound`: the concatenated BoundEntity list (main + every materialized
|
- `bound`: the concatenated BoundEntity list (main + every materialized
|
||||||
subdevice).
|
subdevice).
|
||||||
@@ -526,9 +699,10 @@ def discover_partitioned(
|
|||||||
# owned_elsewhere here too.
|
# owned_elsewhere here too.
|
||||||
main_view = canonical_view(MAIN, resources, subdevices)
|
main_view = canonical_view(MAIN, resources, subdevices)
|
||||||
|
|
||||||
reg = resolve_registry(main_view)
|
reg = resolve_registry(main_view, device_types=oic_device_types)
|
||||||
caps, pats = (
|
caps, pats = (
|
||||||
(reg.capabilities, reg.pattern_capabilities) if reg is not None
|
(reg.capabilities, reg.pattern_capabilities)
|
||||||
|
if reg is not None
|
||||||
else (fallback_capabilities, [])
|
else (fallback_capabilities, [])
|
||||||
)
|
)
|
||||||
# MAIN is never gated -- the config entry's own physical connection
|
# MAIN is never gated -- the config entry's own physical connection
|
||||||
@@ -543,7 +717,8 @@ def discover_partitioned(
|
|||||||
view = canonical_view(su, resources, subdevices)
|
view = canonical_view(su, resources, subdevices)
|
||||||
su_reg = resolve_registry(view) or reg
|
su_reg = resolve_registry(view) or reg
|
||||||
su_caps, su_pats = (
|
su_caps, su_pats = (
|
||||||
(su_reg.capabilities, su_reg.pattern_capabilities) if su_reg is not None
|
(su_reg.capabilities, su_reg.pattern_capabilities)
|
||||||
|
if su_reg is not None
|
||||||
else (fallback_capabilities, [])
|
else (fallback_capabilities, [])
|
||||||
)
|
)
|
||||||
probe_bound = discover(view, su_caps, su_pats, subdevice=su)
|
probe_bound = discover(view, su_caps, su_pats, subdevice=su)
|
||||||
@@ -551,12 +726,19 @@ def discover_partitioned(
|
|||||||
if _has_live_primary_entity(probe_bound, probe_state):
|
if _has_live_primary_entity(probe_bound, probe_state):
|
||||||
materialized.append(su)
|
materialized.append(su)
|
||||||
bound = bound + discover(
|
bound = bound + discover(
|
||||||
view, su_caps, su_pats, log=log, tier_log=tier_log, subdevice=su,
|
view,
|
||||||
|
su_caps,
|
||||||
|
su_pats,
|
||||||
|
log=log,
|
||||||
|
tier_log=tier_log,
|
||||||
|
subdevice=su,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
skipped.append(SkippedSubdevice(
|
skipped.append(
|
||||||
subdevice=su,
|
SkippedSubdevice(
|
||||||
hrefs=tuple(sorted({b.href for b in probe_bound})),
|
subdevice=su,
|
||||||
))
|
hrefs=tuple(sorted({b.href for b in probe_bound})),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
return bound, device_type_name, materialized, skipped
|
return bound, device_type_name, materialized, skipped
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
"""Select platform for Local Things."""
|
"""Select platform for Local Things."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from typing import Optional
|
from typing import cast
|
||||||
|
|
||||||
from homeassistant.components.select import SelectEntity
|
from homeassistant.components.select import SelectEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .registry.entities import SelectDesc
|
|
||||||
|
|
||||||
from .catalog import translated_states
|
from .catalog import translated_states
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import LocalThingsCoordinator
|
from .coordinator import LocalThingsCoordinator
|
||||||
from .entity import LocalThingsEntity, _is_included
|
from .entity import LocalThingsEntity, _is_included
|
||||||
|
from .registry.entities import SelectDesc
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@@ -30,7 +30,7 @@ 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 _translation_state(value: str, known: frozenset[str]) -> str | None:
|
def _translation_state(value: str, known: frozenset[str]) -> str | None:
|
||||||
@@ -42,14 +42,14 @@ def _translation_state(value: str, known: frozenset[str]) -> str | None:
|
|||||||
knows are normalized -- an unrecognized (or future) vendor value keeps
|
knows are normalized -- an unrecognized (or future) vendor value keeps
|
||||||
its own readable form rather than becoming an untranslatable slug.
|
its own readable form rather than becoming an untranslatable slug.
|
||||||
"""
|
"""
|
||||||
direct = value.lower().replace(' ', '_')
|
direct = value.lower().replace(" ", "_")
|
||||||
if direct in known:
|
if direct in known:
|
||||||
return direct
|
return direct
|
||||||
snake = _CAMEL_BOUNDARY_RE.sub('_', value).lower().replace(' ', '_')
|
snake = _CAMEL_BOUNDARY_RE.sub("_", value).lower().replace(" ", "_")
|
||||||
return snake if snake in known else None
|
return snake if snake in known else None
|
||||||
|
|
||||||
|
|
||||||
def _display(value, translation_key: Optional[str]):
|
def _display(value, translation_key: str | None):
|
||||||
"""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` is the entity's already-resolved key (SelectDesc.
|
||||||
@@ -74,7 +74,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 translation_key:
|
||||||
known = translated_states('select', translation_key)
|
known = translated_states("select", translation_key)
|
||||||
if not known:
|
if not known:
|
||||||
# No state table for this key: either the entity isn't translated
|
# No state table for this key: either the entity isn't translated
|
||||||
# at all, or its name is translated but its options deliberately
|
# at all, or its name is translated but its options deliberately
|
||||||
@@ -84,20 +84,19 @@ def _display(value, translation_key: Optional[str]):
|
|||||||
if translated := _translation_state(value, known):
|
if translated := _translation_state(value, known):
|
||||||
return translated
|
return translated
|
||||||
if value.islower():
|
if value.islower():
|
||||||
return value.replace('_', ' ').title()
|
return value.replace("_", " ").title()
|
||||||
return _CAMEL_BOUNDARY_RE.sub(' ', value)
|
return _CAMEL_BOUNDARY_RE.sub(" ", value)
|
||||||
|
|
||||||
|
|
||||||
class LocalThingsSelect(LocalThingsEntity, SelectEntity):
|
class LocalThingsSelect(LocalThingsEntity, SelectEntity):
|
||||||
|
|
||||||
def __init__(self, coordinator: LocalThingsCoordinator, bound) -> None:
|
def __init__(self, coordinator: LocalThingsCoordinator, bound) -> None:
|
||||||
super().__init__(coordinator, bound)
|
super().__init__(coordinator, bound)
|
||||||
desc: SelectDesc = bound.desc
|
desc = cast(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, self.translation_key) for o in desc.options]
|
||||||
|
|
||||||
def _raw_options(self) -> list[str]:
|
def _raw_options(self) -> list[str]:
|
||||||
desc: SelectDesc = self._bound.desc
|
desc = cast(SelectDesc, self._bound.desc)
|
||||||
if callable(desc.options):
|
if callable(desc.options):
|
||||||
# Per-device option list computed from the full resource
|
# Per-device option list computed from the full resource
|
||||||
# snapshot (not just this entity's own href) -- e.g. a course
|
# snapshot (not just this entity's own href) -- e.g. a course
|
||||||
@@ -114,7 +113,7 @@ class LocalThingsSelect(LocalThingsEntity, SelectEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def options(self) -> list[str]:
|
def options(self) -> list[str]:
|
||||||
desc: SelectDesc = self._bound.desc
|
desc = cast(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, self.translation_key) for o in self._raw_options()]
|
||||||
return self._attr_options
|
return self._attr_options
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
"""Sensor platform for Local Things."""
|
"""Sensor platform for Local Things."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity, SensorDeviceClass, SensorStateClass
|
from datetime import timedelta
|
||||||
|
from typing import cast
|
||||||
|
|
||||||
|
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity, SensorStateClass
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import EntityCategory
|
from homeassistant.const import EntityCategory
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@@ -9,12 +13,15 @@ from homeassistant.helpers.device_registry import DeviceInfo
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
from .observe import MODE_OBSERVE, MODE_POLL
|
from .const import (
|
||||||
from .registry.entities import SensorDesc
|
CONF_FINISH_TIME_HYSTERESIS_MINUTES,
|
||||||
|
DEFAULT_FINISH_TIME_HYSTERESIS_MINUTES,
|
||||||
from .const import DOMAIN
|
DOMAIN,
|
||||||
|
)
|
||||||
from .coordinator import LocalThingsCoordinator
|
from .coordinator import LocalThingsCoordinator
|
||||||
from .entity import LocalThingsEntity, _is_included
|
from .entity import LocalThingsEntity, _is_included
|
||||||
|
from .observe import MODE_OBSERVE, MODE_POLL
|
||||||
|
from .registry.entities import SensorDesc
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@@ -23,7 +30,7 @@ async def async_setup_entry(
|
|||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
coordinator: LocalThingsCoordinator = hass.data[DOMAIN][entry.entry_id]
|
coordinator: LocalThingsCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
entities = [
|
entities: list[SensorEntity] = [
|
||||||
LocalThingsSensor(coordinator, b)
|
LocalThingsSensor(coordinator, b)
|
||||||
for b in coordinator.bound
|
for b in coordinator.bound
|
||||||
if isinstance(b.desc, SensorDesc) and _is_included(b, coordinator)
|
if isinstance(b.desc, SensorDesc) and _is_included(b, coordinator)
|
||||||
@@ -33,26 +40,61 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
|
|
||||||
class LocalThingsSensor(LocalThingsEntity, SensorEntity):
|
class LocalThingsSensor(LocalThingsEntity, SensorEntity):
|
||||||
|
|
||||||
def __init__(self, coordinator: LocalThingsCoordinator, bound) -> None:
|
def __init__(self, coordinator: LocalThingsCoordinator, bound) -> None:
|
||||||
super().__init__(coordinator, bound)
|
super().__init__(coordinator, bound)
|
||||||
desc: SensorDesc = bound.desc
|
desc = cast(SensorDesc, bound.desc)
|
||||||
self._attr_native_unit_of_measurement = desc.unit
|
self._attr_native_unit_of_measurement = desc.unit
|
||||||
self._attr_device_class = desc.device_class
|
self._attr_device_class = (
|
||||||
self._attr_state_class = desc.state_class
|
SensorDeviceClass(desc.device_class) if desc.device_class else None
|
||||||
|
)
|
||||||
|
self._attr_state_class = SensorStateClass(desc.state_class) if desc.state_class else None
|
||||||
if desc.options:
|
if desc.options:
|
||||||
self._attr_options = list(desc.options)
|
self._attr_options = list(desc.options)
|
||||||
|
self._hysteresis_value = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_unit_of_measurement(self):
|
def native_unit_of_measurement(self):
|
||||||
desc: SensorDesc = self._bound.desc
|
desc = cast(SensorDesc, self._bound.desc)
|
||||||
if desc.unit_fn is not None:
|
if desc.unit_fn is not None:
|
||||||
return desc.unit_fn(self.coordinator.resource(self._bound.href))
|
return desc.unit_fn(self.coordinator.resource(self._bound.href))
|
||||||
return self._attr_native_unit_of_measurement
|
return self._attr_native_unit_of_measurement
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
return (self.coordinator.data or {}).get(self._state_key)
|
raw = (self.coordinator.data or {}).get(self._state_key)
|
||||||
|
desc = cast(SensorDesc, self._bound.desc)
|
||||||
|
if not desc.hysteresis:
|
||||||
|
return raw
|
||||||
|
return self._apply_hysteresis(raw)
|
||||||
|
|
||||||
|
def _apply_hysteresis(self, raw):
|
||||||
|
"""Hold the last value this entity actually reported until a new one
|
||||||
|
differs by at least the configured threshold, regardless of how long
|
||||||
|
that difference has been building up (this is a deadband, not a
|
||||||
|
time-based debounce).
|
||||||
|
|
||||||
|
Values like finish_time are `now() + remaining`, recomputed from
|
||||||
|
scratch every poll -- both wall-clock drift between the device's own
|
||||||
|
remaining-time updates and the device revising its own estimate mid-
|
||||||
|
cycle produce a stream of small, real changes that are individually
|
||||||
|
meaningless but each trigger a recorder/logbook entry. A cycle
|
||||||
|
ending (raw is None) or starting (cache empty) always passes through
|
||||||
|
immediately -- only in-between jitter while a value already exists
|
||||||
|
on both sides gets held back.
|
||||||
|
"""
|
||||||
|
assert self.coordinator.config_entry is not None
|
||||||
|
threshold_min = self.coordinator.config_entry.options.get(
|
||||||
|
CONF_FINISH_TIME_HYSTERESIS_MINUTES, DEFAULT_FINISH_TIME_HYSTERESIS_MINUTES
|
||||||
|
)
|
||||||
|
if (
|
||||||
|
threshold_min
|
||||||
|
and raw is not None
|
||||||
|
and self._hysteresis_value is not None
|
||||||
|
and abs(raw - self._hysteresis_value) < timedelta(minutes=threshold_min)
|
||||||
|
):
|
||||||
|
return self._hysteresis_value
|
||||||
|
self._hysteresis_value = raw
|
||||||
|
return raw
|
||||||
|
|
||||||
|
|
||||||
class LocalThingsConnectionModeSensor(CoordinatorEntity[LocalThingsCoordinator], SensorEntity):
|
class LocalThingsConnectionModeSensor(CoordinatorEntity[LocalThingsCoordinator], SensorEntity):
|
||||||
@@ -61,11 +103,11 @@ class LocalThingsConnectionModeSensor(CoordinatorEntity[LocalThingsCoordinator],
|
|||||||
Disabled by default — it's for troubleshooting, not everyday use."""
|
Disabled by default — it's for troubleshooting, not everyday use."""
|
||||||
|
|
||||||
_attr_has_entity_name = True
|
_attr_has_entity_name = True
|
||||||
_attr_translation_key = 'connection_mode'
|
_attr_translation_key = "connection_mode"
|
||||||
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||||
_attr_entity_registry_enabled_default = False
|
_attr_entity_registry_enabled_default = False
|
||||||
_attr_device_class = SensorDeviceClass.ENUM
|
_attr_device_class = SensorDeviceClass.ENUM
|
||||||
_attr_options = [MODE_OBSERVE, MODE_POLL]
|
_attr_options = [MODE_OBSERVE, MODE_POLL] # noqa: RUF012 -- HA `_attr_*` convention
|
||||||
|
|
||||||
def __init__(self, coordinator: LocalThingsCoordinator) -> None:
|
def __init__(self, coordinator: LocalThingsCoordinator) -> None:
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
"""Switch platform for Local Things."""
|
"""Switch platform for Local Things."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchEntity
|
from homeassistant.components.switch import SwitchDeviceClass, SwitchEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .registry.entities import SwitchDesc
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import LocalThingsCoordinator
|
from .coordinator import LocalThingsCoordinator
|
||||||
from .entity import LocalThingsEntity, _is_included
|
from .entity import LocalThingsEntity, _is_included
|
||||||
|
from .registry.entities import SwitchDesc
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@@ -27,18 +27,19 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
|
|
||||||
class LocalThingsSwitch(LocalThingsEntity, SwitchEntity):
|
class LocalThingsSwitch(LocalThingsEntity, SwitchEntity):
|
||||||
|
|
||||||
def __init__(self, coordinator: LocalThingsCoordinator, bound) -> None:
|
def __init__(self, coordinator: LocalThingsCoordinator, bound) -> None:
|
||||||
super().__init__(coordinator, bound)
|
super().__init__(coordinator, bound)
|
||||||
desc: SwitchDesc = bound.desc
|
desc: SwitchDesc = bound.desc
|
||||||
self._attr_device_class = desc.device_class
|
self._attr_device_class = (
|
||||||
|
SwitchDeviceClass(desc.device_class) if desc.device_class else None
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
return (self.coordinator.data or {}).get(self._state_key)
|
return (self.coordinator.data or {}).get(self._state_key)
|
||||||
|
|
||||||
async def async_turn_on(self, **kwargs) -> None:
|
async def async_turn_on(self, **kwargs) -> None:
|
||||||
await self.coordinator.async_send_command(self._bound, 'On')
|
await self.coordinator.async_send_command(self._bound, "On")
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs) -> None:
|
async def async_turn_off(self, **kwargs) -> None:
|
||||||
await self.coordinator.async_send_command(self._bound, 'Off')
|
await self.coordinator.async_send_command(self._bound, "Off")
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
"""Time platform for Local Things."""
|
"""Time platform for Local Things."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
@@ -8,11 +9,10 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .registry.entities import TimeDesc
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import LocalThingsCoordinator
|
from .coordinator import LocalThingsCoordinator
|
||||||
from .entity import LocalThingsEntity, _is_included
|
from .entity import LocalThingsEntity, _is_included
|
||||||
|
from .registry.entities import TimeDesc
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@@ -29,7 +29,6 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
|
|
||||||
class LocalThingsTime(LocalThingsEntity, TimeEntity):
|
class LocalThingsTime(LocalThingsEntity, TimeEntity):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> datetime.time | None:
|
def native_value(self) -> datetime.time | None:
|
||||||
return (self.coordinator.data or {}).get(self._state_key)
|
return (self.coordinator.data or {}).get(self._state_key)
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"entity": {
|
"entity": {
|
||||||
"binary_sensor": {
|
"binary_sensor": {
|
||||||
|
"auto_clean_running": {
|
||||||
|
"name": "Auto clean running"
|
||||||
|
},
|
||||||
"after_run_active": {
|
"after_run_active": {
|
||||||
"name": "After run active"
|
"name": "After run active"
|
||||||
},
|
},
|
||||||
@@ -10,12 +13,18 @@
|
|||||||
"automatic_operation": {
|
"automatic_operation": {
|
||||||
"name": "Automatic operation"
|
"name": "Automatic operation"
|
||||||
},
|
},
|
||||||
|
"battery_charging": {
|
||||||
|
"name": "Charging"
|
||||||
|
},
|
||||||
"burner_hot_surface": {
|
"burner_hot_surface": {
|
||||||
"name": "Burner {number} hot surface"
|
"name": "Burner {number} hot surface"
|
||||||
},
|
},
|
||||||
"burner_pan_detected": {
|
"burner_pan_detected": {
|
||||||
"name": "Burner {number} pan detected"
|
"name": "Burner {number} pan detected"
|
||||||
},
|
},
|
||||||
|
"child_lock": {
|
||||||
|
"name": "Child lock"
|
||||||
|
},
|
||||||
"cloud_connected": {
|
"cloud_connected": {
|
||||||
"name": "Cloud connected"
|
"name": "Cloud connected"
|
||||||
},
|
},
|
||||||
@@ -34,6 +43,9 @@
|
|||||||
"overload_protection_active": {
|
"overload_protection_active": {
|
||||||
"name": "Overload protection active"
|
"name": "Overload protection active"
|
||||||
},
|
},
|
||||||
|
"odor_controller_active": {
|
||||||
|
"name": "Odor controller active"
|
||||||
|
},
|
||||||
"cycle_active": {
|
"cycle_active": {
|
||||||
"name": "Running"
|
"name": "Running"
|
||||||
},
|
},
|
||||||
@@ -190,6 +202,9 @@
|
|||||||
},
|
},
|
||||||
"tropical_night_mode": {
|
"tropical_night_mode": {
|
||||||
"name": "Tropical night mode"
|
"name": "Tropical night mode"
|
||||||
|
},
|
||||||
|
"zone_target_temperature": {
|
||||||
|
"name": "Zone target temperature"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"select": {
|
"select": {
|
||||||
@@ -292,19 +307,25 @@
|
|||||||
"01": "Normal",
|
"01": "Normal",
|
||||||
"06": "Time dry",
|
"06": "Time dry",
|
||||||
"16": "Cotton",
|
"16": "Cotton",
|
||||||
|
"17": "Super Speed",
|
||||||
"18": "Synthetics",
|
"18": "Synthetics",
|
||||||
"19": "Delicates",
|
"19": "Delicates",
|
||||||
"20": "Iron dry",
|
"20": "Iron dry",
|
||||||
"23": "Quick Dry 35",
|
"21": "Hygiene Care",
|
||||||
|
"22": "Silent Dry",
|
||||||
|
"23": "Quick Dry 35'",
|
||||||
"24": "Cool air",
|
"24": "Cool air",
|
||||||
"25": "Warm air",
|
"25": "Warm air",
|
||||||
"27": "Time dry",
|
"27": "Time dry",
|
||||||
|
"29": "AI Dry",
|
||||||
"1a": "Wool",
|
"1a": "Wool",
|
||||||
"1b": "Bedding",
|
"1b": "Bedding",
|
||||||
"1c": "Shirts",
|
"1c": "Shirts",
|
||||||
"1d": "Towels",
|
"1d": "Towels",
|
||||||
"1e": "Outdoor",
|
"1e": "Outdoor",
|
||||||
"1f": "Mixed load"
|
"1f": "Mixed load",
|
||||||
|
"2b": "Self Tub Dry",
|
||||||
|
"4c": "Air Refresh"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"favorite_capacity": {
|
"favorite_capacity": {
|
||||||
@@ -313,6 +334,15 @@
|
|||||||
"favorite_hotwater_temperature": {
|
"favorite_hotwater_temperature": {
|
||||||
"name": "Favorite hot water temperature"
|
"name": "Favorite hot water temperature"
|
||||||
},
|
},
|
||||||
|
"filter_alarm_time": {
|
||||||
|
"name": "Filter alarm interval",
|
||||||
|
"state": {
|
||||||
|
"180": "180 hours",
|
||||||
|
"300": "300 hours",
|
||||||
|
"500": "500 hours",
|
||||||
|
"700": "700 hours"
|
||||||
|
}
|
||||||
|
},
|
||||||
"finish_sound": {
|
"finish_sound": {
|
||||||
"name": "Finish sound",
|
"name": "Finish sound",
|
||||||
"state": {
|
"state": {
|
||||||
@@ -588,9 +618,15 @@
|
|||||||
"none": "Off",
|
"none": "Off",
|
||||||
"cupboard": "Cupboard"
|
"cupboard": "Cupboard"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"zone_mode": {
|
||||||
|
"name": "Zone mode"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sensor": {
|
"sensor": {
|
||||||
|
"auto_clean_progress": {
|
||||||
|
"name": "Auto clean progress"
|
||||||
|
},
|
||||||
"after_run_progress": {
|
"after_run_progress": {
|
||||||
"name": "After run progress"
|
"name": "After run progress"
|
||||||
},
|
},
|
||||||
@@ -600,6 +636,9 @@
|
|||||||
"air_filter_usage_hours": {
|
"air_filter_usage_hours": {
|
||||||
"name": "Filter usage hours"
|
"name": "Filter usage hours"
|
||||||
},
|
},
|
||||||
|
"air_quality_standard": {
|
||||||
|
"name": "Air quality standard"
|
||||||
|
},
|
||||||
"air_sensing_state": {
|
"air_sensing_state": {
|
||||||
"name": "Air sensing state"
|
"name": "Air sensing state"
|
||||||
},
|
},
|
||||||
@@ -612,12 +651,18 @@
|
|||||||
"automatic_ventilation_state": {
|
"automatic_ventilation_state": {
|
||||||
"name": "Automatic ventilation state"
|
"name": "Automatic ventilation state"
|
||||||
},
|
},
|
||||||
|
"battery": {
|
||||||
|
"name": "Battery"
|
||||||
|
},
|
||||||
"burner_state": {
|
"burner_state": {
|
||||||
"name": "Burner {number} state"
|
"name": "Burner {number} state"
|
||||||
},
|
},
|
||||||
"clean_level": {
|
"clean_level": {
|
||||||
"name": "Clean level"
|
"name": "Clean level"
|
||||||
},
|
},
|
||||||
|
"co2": {
|
||||||
|
"name": "CO2"
|
||||||
|
},
|
||||||
"coffee_brew_status": {
|
"coffee_brew_status": {
|
||||||
"name": "Coffee brew status"
|
"name": "Coffee brew status"
|
||||||
},
|
},
|
||||||
@@ -646,6 +691,9 @@
|
|||||||
"outdoor_temperature": {
|
"outdoor_temperature": {
|
||||||
"name": "Outdoor temperature"
|
"name": "Outdoor temperature"
|
||||||
},
|
},
|
||||||
|
"odor_controller_progress": {
|
||||||
|
"name": "Odor controller progress"
|
||||||
|
},
|
||||||
"panel_status": {
|
"panel_status": {
|
||||||
"name": "Panel status"
|
"name": "Panel status"
|
||||||
},
|
},
|
||||||
@@ -918,6 +966,9 @@
|
|||||||
"icestatus_stop": "Idle",
|
"icestatus_stop": "Idle",
|
||||||
"icestatus_run": "Making ice"
|
"icestatus_run": "Making ice"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"zone_temperature": {
|
||||||
|
"name": "Zone temperature"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"switch": {
|
"switch": {
|
||||||
@@ -996,6 +1047,9 @@
|
|||||||
"display_light": {
|
"display_light": {
|
||||||
"name": "Display light"
|
"name": "Display light"
|
||||||
},
|
},
|
||||||
|
"dnd": {
|
||||||
|
"name": "Do not disturb"
|
||||||
|
},
|
||||||
"fast_preheat": {
|
"fast_preheat": {
|
||||||
"name": "Fast preheat"
|
"name": "Fast preheat"
|
||||||
},
|
},
|
||||||
@@ -1076,9 +1130,21 @@
|
|||||||
},
|
},
|
||||||
"wrinkle_prevent": {
|
"wrinkle_prevent": {
|
||||||
"name": "Wrinkle prevent"
|
"name": "Wrinkle prevent"
|
||||||
|
},
|
||||||
|
"zone_power": {
|
||||||
|
"name": "Zone power"
|
||||||
|
},
|
||||||
|
"away_mode": {
|
||||||
|
"name": "Away mode"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"time": {
|
"time": {
|
||||||
|
"dnd_end": {
|
||||||
|
"name": "Do not disturb end"
|
||||||
|
},
|
||||||
|
"dnd_start": {
|
||||||
|
"name": "Do not disturb start"
|
||||||
|
},
|
||||||
"led_night_end": {
|
"led_night_end": {
|
||||||
"name": "Door LED night end"
|
"name": "Door LED night end"
|
||||||
},
|
},
|
||||||
@@ -1091,6 +1157,11 @@
|
|||||||
"night_start": {
|
"night_start": {
|
||||||
"name": "Night light start"
|
"name": "Night light start"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"water_heater": {
|
||||||
|
"dhw": {
|
||||||
|
"name": "Hot water"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
@@ -1138,15 +1209,16 @@
|
|||||||
"init": {
|
"init": {
|
||||||
"title": "LocalThings options",
|
"title": "LocalThings options",
|
||||||
"menu_options": {
|
"menu_options": {
|
||||||
"settings": "Remote control write settings",
|
"settings": "Device settings",
|
||||||
"debug_write": "Debug: write to a resource"
|
"debug_write": "Debug: write to a resource"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"title": "Remote control write settings",
|
"title": "Device settings",
|
||||||
"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.",
|
"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.\n\nEstimated finish time is recomputed from the device's remaining-time estimate on every poll, which can drift or get revised by a minute or two between updates. Raise the minimum-change value below to hold the sensor at its last reported value until the estimate moves by at least that many minutes, cutting down on history/logbook noise. Set it to 0 to report every computed change.",
|
||||||
"data": {
|
"data": {
|
||||||
"bypass_remote_control_lock": "Allow writes even when remote control is reported off"
|
"bypass_remote_control_lock": "Allow writes even when remote control is reported off",
|
||||||
|
"finish_time_hysteresis_minutes": "Estimated finish -- minimum change (minutes)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"debug_write": {
|
"debug_write": {
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"entity": {
|
"entity": {
|
||||||
"binary_sensor": {
|
"binary_sensor": {
|
||||||
|
"auto_clean_running": {
|
||||||
|
"name": "Auto clean actief"
|
||||||
|
},
|
||||||
"after_run_active": {
|
"after_run_active": {
|
||||||
"name": "Nadraaien actief"
|
"name": "Nadraaien actief"
|
||||||
},
|
},
|
||||||
@@ -10,11 +13,17 @@
|
|||||||
"automatic_operation": {
|
"automatic_operation": {
|
||||||
"name": "Automatische werking"
|
"name": "Automatische werking"
|
||||||
},
|
},
|
||||||
|
"battery_charging": {
|
||||||
|
"name": "Opladen"
|
||||||
|
},
|
||||||
"burner_hot_surface": {
|
"burner_hot_surface": {
|
||||||
"name": "Brander {number} heet oppervlak"
|
"name": "Brander {number} heet oppervlak"
|
||||||
},
|
},
|
||||||
"burner_pan_detected": {
|
"burner_pan_detected": {
|
||||||
"name": "Brander {number} pan gedetecteerd"
|
"name": "Pan gedetecteerd op brander {number}"
|
||||||
|
},
|
||||||
|
"child_lock": {
|
||||||
|
"name": "Kinderslot"
|
||||||
},
|
},
|
||||||
"cloud_connected": {
|
"cloud_connected": {
|
||||||
"name": "Verbonden met cloud"
|
"name": "Verbonden met cloud"
|
||||||
@@ -23,7 +32,7 @@
|
|||||||
"name": "Stofzak vol"
|
"name": "Stofzak vol"
|
||||||
},
|
},
|
||||||
"cooktop_power": {
|
"cooktop_power": {
|
||||||
"name": "Kookplaat voeding"
|
"name": "Voeding kookplaat"
|
||||||
},
|
},
|
||||||
"cooktop_safety_shutoff_enabled": {
|
"cooktop_safety_shutoff_enabled": {
|
||||||
"name": "Automatische uitschakeling heet oppervlak ingeschakeld"
|
"name": "Automatische uitschakeling heet oppervlak ingeschakeld"
|
||||||
@@ -34,6 +43,9 @@
|
|||||||
"overload_protection_active": {
|
"overload_protection_active": {
|
||||||
"name": "Overbelastingsbeveiliging actief"
|
"name": "Overbelastingsbeveiliging actief"
|
||||||
},
|
},
|
||||||
|
"odor_controller_active": {
|
||||||
|
"name": "Geurbeheersing actief"
|
||||||
|
},
|
||||||
"cycle_active": {
|
"cycle_active": {
|
||||||
"name": "Actief"
|
"name": "Actief"
|
||||||
},
|
},
|
||||||
@@ -74,7 +86,7 @@
|
|||||||
"name": "Schenken"
|
"name": "Schenken"
|
||||||
},
|
},
|
||||||
"alarm_in_mute": {
|
"alarm_in_mute": {
|
||||||
"name": "Alarm bij dempen"
|
"name": "Alarmdemping"
|
||||||
},
|
},
|
||||||
"power_state": {
|
"power_state": {
|
||||||
"name": "Voedingsstatus"
|
"name": "Voedingsstatus"
|
||||||
@@ -190,6 +202,9 @@
|
|||||||
},
|
},
|
||||||
"tropical_night_mode": {
|
"tropical_night_mode": {
|
||||||
"name": "Tropische nachtmodus"
|
"name": "Tropische nachtmodus"
|
||||||
|
},
|
||||||
|
"zone_target_temperature": {
|
||||||
|
"name": "Doeltemperatuur zone"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"select": {
|
"select": {
|
||||||
@@ -215,7 +230,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cooler_temperature_setpoint": {
|
"cooler_temperature_setpoint": {
|
||||||
"name": "Koeler temperatuur"
|
"name": "Temperatuur koelgedeelte"
|
||||||
},
|
},
|
||||||
"day_brightness": {
|
"day_brightness": {
|
||||||
"name": "Helderheid kast",
|
"name": "Helderheid kast",
|
||||||
@@ -292,19 +307,25 @@
|
|||||||
"01": "Normaal",
|
"01": "Normaal",
|
||||||
"06": "Tijdprogramma",
|
"06": "Tijdprogramma",
|
||||||
"16": "Katoen",
|
"16": "Katoen",
|
||||||
|
"17": "Super Speed",
|
||||||
"18": "Synthetisch",
|
"18": "Synthetisch",
|
||||||
"19": "Fijne was",
|
"19": "Fijne was",
|
||||||
"20": "Strijkdroog",
|
"20": "Strijkdroog",
|
||||||
|
"21": "Hygiënisch drogen",
|
||||||
|
"22": "Stil drogen",
|
||||||
"23": "Snel drogen 35'",
|
"23": "Snel drogen 35'",
|
||||||
"24": "Koude lucht",
|
"24": "Koude lucht",
|
||||||
"25": "Warme lucht",
|
"25": "Warme lucht",
|
||||||
"27": "Tijdprogramma",
|
"27": "Tijdprogramma",
|
||||||
|
"29": "AI drogen",
|
||||||
"1a": "Wol",
|
"1a": "Wol",
|
||||||
"1b": "Beddengoed",
|
"1b": "Beddengoed",
|
||||||
"1c": "Overhemden",
|
"1c": "Overhemden",
|
||||||
"1d": "Handdoeken",
|
"1d": "Handdoeken",
|
||||||
"1e": "Outdoor",
|
"1e": "Outdoor",
|
||||||
"1f": "Gemengde was"
|
"1f": "Gemengde was",
|
||||||
|
"2b": "Zelf trommel drogen",
|
||||||
|
"4c": "Opfrissen"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"favorite_capacity": {
|
"favorite_capacity": {
|
||||||
@@ -313,6 +334,15 @@
|
|||||||
"favorite_hotwater_temperature": {
|
"favorite_hotwater_temperature": {
|
||||||
"name": "Favoriete temperatuur warm water"
|
"name": "Favoriete temperatuur warm water"
|
||||||
},
|
},
|
||||||
|
"filter_alarm_time": {
|
||||||
|
"name": "Filteralarminterval",
|
||||||
|
"state": {
|
||||||
|
"180": "180 uur",
|
||||||
|
"300": "300 uur",
|
||||||
|
"500": "500 uur",
|
||||||
|
"700": "700 uur"
|
||||||
|
}
|
||||||
|
},
|
||||||
"finish_sound": {
|
"finish_sound": {
|
||||||
"name": "Eindgeluid",
|
"name": "Eindgeluid",
|
||||||
"state": {
|
"state": {
|
||||||
@@ -481,24 +511,24 @@
|
|||||||
"sound_mode": {
|
"sound_mode": {
|
||||||
"name": "Geluidsmodus",
|
"name": "Geluidsmodus",
|
||||||
"state": {
|
"state": {
|
||||||
"voice": "Spraak",
|
"voice": "Stem",
|
||||||
"tone": "Toon",
|
"tone": "Toon",
|
||||||
"mute": "Dempen"
|
"mute": "Stil"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"air_purifier_sound_mode": {
|
"air_purifier_sound_mode": {
|
||||||
"name": "Geluidsmodus",
|
"name": "Geluidsmodus",
|
||||||
"state": {
|
"state": {
|
||||||
"mute": "Dempen",
|
"mute": "Stil",
|
||||||
"buzzer": "Zoemer"
|
"buzzer": "Zoemer"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"water_purifier_sound_mode": {
|
"water_purifier_sound_mode": {
|
||||||
"name": "Geluidsmodus",
|
"name": "Geluidsmodus",
|
||||||
"state": {
|
"state": {
|
||||||
"voice": "Spraak",
|
"voice": "Stem",
|
||||||
"fixedtone": "Vaste toon",
|
"fixedtone": "Vaste toon",
|
||||||
"mute": "Dempen"
|
"mute": "Stil"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"spin_speed": {
|
"spin_speed": {
|
||||||
@@ -561,17 +591,17 @@
|
|||||||
"53": "Intensief",
|
"53": "Intensief",
|
||||||
"54": "Handdoeken",
|
"54": "Handdoeken",
|
||||||
"55": "Sportkleding",
|
"55": "Sportkleding",
|
||||||
"57": "Fijn",
|
"57": "Fijne was",
|
||||||
"5e": "Spoelen+centrifugeren",
|
"5e": "Spoelen+centrifugeren",
|
||||||
"60": "Zelfreinigend+",
|
"60": "Self Clean+",
|
||||||
"65": "Bonte was",
|
"65": "Bonte was",
|
||||||
"66": "Spijkergoed",
|
"66": "Spijkergoed",
|
||||||
"7c": "Witte was",
|
"7c": "Witte was",
|
||||||
"7d": "Beddengoed/Waterdicht",
|
"7d": "Beddengoed/waterdicht",
|
||||||
"7e": "Zelfreinigend",
|
"7e": "Self Clean",
|
||||||
"7f": "Wol/Fijn",
|
"7f": "Wol/fijne was",
|
||||||
"86": "Diep wassen",
|
"86": "Diep wassen",
|
||||||
"87": "Downloaden",
|
"87": "Gedownload",
|
||||||
"8f": "Intensief koud",
|
"8f": "Intensief koud",
|
||||||
"96": "Minder microvezels"
|
"96": "Minder microvezels"
|
||||||
}
|
}
|
||||||
@@ -588,9 +618,15 @@
|
|||||||
"none": "Uit",
|
"none": "Uit",
|
||||||
"cupboard": "Kastdroog"
|
"cupboard": "Kastdroog"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"zone_mode": {
|
||||||
|
"name": "Zonemodus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sensor": {
|
"sensor": {
|
||||||
|
"auto_clean_progress": {
|
||||||
|
"name": "Auto clean voortgang"
|
||||||
|
},
|
||||||
"after_run_progress": {
|
"after_run_progress": {
|
||||||
"name": "Voortgang nadraaien"
|
"name": "Voortgang nadraaien"
|
||||||
},
|
},
|
||||||
@@ -600,6 +636,9 @@
|
|||||||
"air_filter_usage_hours": {
|
"air_filter_usage_hours": {
|
||||||
"name": "Filterverbruik (uren)"
|
"name": "Filterverbruik (uren)"
|
||||||
},
|
},
|
||||||
|
"air_quality_standard": {
|
||||||
|
"name": "Luchtkwaliteitsnorm"
|
||||||
|
},
|
||||||
"air_sensing_state": {
|
"air_sensing_state": {
|
||||||
"name": "Status luchtmeting"
|
"name": "Status luchtmeting"
|
||||||
},
|
},
|
||||||
@@ -612,12 +651,18 @@
|
|||||||
"automatic_ventilation_state": {
|
"automatic_ventilation_state": {
|
||||||
"name": "Status automatische ventilatie"
|
"name": "Status automatische ventilatie"
|
||||||
},
|
},
|
||||||
|
"battery": {
|
||||||
|
"name": "Batterij"
|
||||||
|
},
|
||||||
"burner_state": {
|
"burner_state": {
|
||||||
"name": "Status brander {number}"
|
"name": "Status brander {number}"
|
||||||
},
|
},
|
||||||
"clean_level": {
|
"clean_level": {
|
||||||
"name": "Reinigingsniveau"
|
"name": "Reinigingsniveau"
|
||||||
},
|
},
|
||||||
|
"co2": {
|
||||||
|
"name": "CO2"
|
||||||
|
},
|
||||||
"coffee_brew_status": {
|
"coffee_brew_status": {
|
||||||
"name": "Koffiezetstatus"
|
"name": "Koffiezetstatus"
|
||||||
},
|
},
|
||||||
@@ -629,7 +674,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cooktop_running_state": {
|
"cooktop_running_state": {
|
||||||
"name": "Loopstatus kookplaat"
|
"name": "Bedrijfsstatus kookplaat"
|
||||||
},
|
},
|
||||||
"cooktop_state": {
|
"cooktop_state": {
|
||||||
"name": "Status kookplaat"
|
"name": "Status kookplaat"
|
||||||
@@ -646,6 +691,9 @@
|
|||||||
"outdoor_temperature": {
|
"outdoor_temperature": {
|
||||||
"name": "Buitentemperatuur"
|
"name": "Buitentemperatuur"
|
||||||
},
|
},
|
||||||
|
"odor_controller_progress": {
|
||||||
|
"name": "Voortgang geurbeheersing"
|
||||||
|
},
|
||||||
"panel_status": {
|
"panel_status": {
|
||||||
"name": "Paneelstatus"
|
"name": "Paneelstatus"
|
||||||
},
|
},
|
||||||
@@ -662,10 +710,10 @@
|
|||||||
"name": "Status steel"
|
"name": "Status steel"
|
||||||
},
|
},
|
||||||
"uvc_operation_time": {
|
"uvc_operation_time": {
|
||||||
"name": "UV-C bedrijfstijd"
|
"name": "UV-C-bedrijfstijd"
|
||||||
},
|
},
|
||||||
"uvc_total_operation_time": {
|
"uvc_total_operation_time": {
|
||||||
"name": "UV-C totale bedrijfstijd"
|
"name": "Totale UV-C-bedrijfstijd"
|
||||||
},
|
},
|
||||||
"uvc_finished_time": {
|
"uvc_finished_time": {
|
||||||
"name": "UV-C voltooid op"
|
"name": "UV-C voltooid op"
|
||||||
@@ -759,7 +807,7 @@
|
|||||||
"name": "Geschatte eindtijd"
|
"name": "Geschatte eindtijd"
|
||||||
},
|
},
|
||||||
"completion_minutes": {
|
"completion_minutes": {
|
||||||
"name": "Voltooiingstijd"
|
"name": "Resterende tijd"
|
||||||
},
|
},
|
||||||
"freezer_temperature": {
|
"freezer_temperature": {
|
||||||
"name": "Vriezertemperatuur"
|
"name": "Vriezertemperatuur"
|
||||||
@@ -840,13 +888,13 @@
|
|||||||
"name": "Vermogen"
|
"name": "Vermogen"
|
||||||
},
|
},
|
||||||
"probe_battery": {
|
"probe_battery": {
|
||||||
"name": "Sonde batterij"
|
"name": "Batterijniveau sonde"
|
||||||
},
|
},
|
||||||
"probe_target_temperature": {
|
"probe_target_temperature": {
|
||||||
"name": "Doeltemperatuur sonde"
|
"name": "Doeltemperatuur sonde"
|
||||||
},
|
},
|
||||||
"probe_temperature": {
|
"probe_temperature": {
|
||||||
"name": "Temperatuur sonde"
|
"name": "Sondetemperatuur"
|
||||||
},
|
},
|
||||||
"progress": {
|
"progress": {
|
||||||
"name": "Voortgang"
|
"name": "Voortgang"
|
||||||
@@ -888,7 +936,7 @@
|
|||||||
"name": "Status"
|
"name": "Status"
|
||||||
},
|
},
|
||||||
"cup_state": {
|
"cup_state": {
|
||||||
"name": "Kopstatus"
|
"name": "Bekerstatus"
|
||||||
},
|
},
|
||||||
"last_pour_type": {
|
"last_pour_type": {
|
||||||
"name": "Laatste schenktype"
|
"name": "Laatste schenktype"
|
||||||
@@ -918,6 +966,9 @@
|
|||||||
"icestatus_stop": "Inactief",
|
"icestatus_stop": "Inactief",
|
||||||
"icestatus_run": "IJs maken"
|
"icestatus_run": "IJs maken"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"zone_temperature": {
|
||||||
|
"name": "Zonetemperatuur"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"switch": {
|
"switch": {
|
||||||
@@ -996,6 +1047,9 @@
|
|||||||
"display_light": {
|
"display_light": {
|
||||||
"name": "Displayverlichting"
|
"name": "Displayverlichting"
|
||||||
},
|
},
|
||||||
|
"dnd": {
|
||||||
|
"name": "Niet storen"
|
||||||
|
},
|
||||||
"fast_preheat": {
|
"fast_preheat": {
|
||||||
"name": "Snel voorverwarmen"
|
"name": "Snel voorverwarmen"
|
||||||
},
|
},
|
||||||
@@ -1024,7 +1078,7 @@
|
|||||||
"name": "{instance_name} ingeschakeld"
|
"name": "{instance_name} ingeschakeld"
|
||||||
},
|
},
|
||||||
"intensive": {
|
"intensive": {
|
||||||
"name": "Intensive"
|
"name": "Intensief"
|
||||||
},
|
},
|
||||||
"lamp": {
|
"lamp": {
|
||||||
"name": "Lamp"
|
"name": "Lamp"
|
||||||
@@ -1076,9 +1130,21 @@
|
|||||||
},
|
},
|
||||||
"wrinkle_prevent": {
|
"wrinkle_prevent": {
|
||||||
"name": "Kreukpreventie"
|
"name": "Kreukpreventie"
|
||||||
|
},
|
||||||
|
"zone_power": {
|
||||||
|
"name": "Zonevoeding"
|
||||||
|
},
|
||||||
|
"away_mode": {
|
||||||
|
"name": "Afwezigheidsmodus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"time": {
|
"time": {
|
||||||
|
"dnd_end": {
|
||||||
|
"name": "Einde niet storen"
|
||||||
|
},
|
||||||
|
"dnd_start": {
|
||||||
|
"name": "Start niet storen"
|
||||||
|
},
|
||||||
"led_night_end": {
|
"led_night_end": {
|
||||||
"name": "Einde nachtverlichting deur-LED"
|
"name": "Einde nachtverlichting deur-LED"
|
||||||
},
|
},
|
||||||
@@ -1091,6 +1157,11 @@
|
|||||||
"night_start": {
|
"night_start": {
|
||||||
"name": "Start nachtverlichting"
|
"name": "Start nachtverlichting"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"water_heater": {
|
||||||
|
"dhw": {
|
||||||
|
"name": "Warm water"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
@@ -1138,15 +1209,16 @@
|
|||||||
"init": {
|
"init": {
|
||||||
"title": "LocalThings-opties",
|
"title": "LocalThings-opties",
|
||||||
"menu_options": {
|
"menu_options": {
|
||||||
"settings": "Schrijfinstellingen voor afstandsbediening",
|
"settings": "Apparaatinstellingen",
|
||||||
"debug_write": "Foutopsporing: naar een resource schrijven"
|
"debug_write": "Foutopsporing: naar een resource schrijven"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"title": "Schrijfinstellingen voor afstandsbediening",
|
"title": "Apparaatinstellingen",
|
||||||
"description": "Sommige apparaten accepteren bepaalde schrijfbewerkingen (bijvoorbeeld de standaarddosering van wasmiddel of wasverzachter op een wasmachine), ook als ze melden dat de afstandsbediening is uitgeschakeld. LocalThings blokkeert standaard elke schrijfbewerking met een duidelijke foutmelding wanneer een apparaat meldt dat de afstandsbediening is uitgeschakeld, in plaats van het apparaat de opdracht stilzwijgend te laten weigeren. Schakel deze optie alleen in als je hebt bevestigd dat schrijfbewerkingen op dit apparaat echt werken wanneer de afstandsbediening is uitgeschakeld. Anders verruil je de duidelijke foutmelding voor een stille mislukking.",
|
"description": "Sommige apparaten accepteren bepaalde schrijfbewerkingen (bijvoorbeeld de standaarddosering van wasmiddel of wasverzachter op een wasmachine), ook als ze melden dat de afstandsbediening is uitgeschakeld. LocalThings blokkeert standaard elke schrijfbewerking met een duidelijke foutmelding wanneer een apparaat meldt dat de afstandsbediening is uitgeschakeld, in plaats van het apparaat de opdracht stilzwijgend te laten weigeren. Schakel deze optie alleen in als je hebt bevestigd dat schrijfbewerkingen op dit apparaat echt werken wanneer de afstandsbediening is uitgeschakeld. Anders verruil je de duidelijke foutmelding voor een stille mislukking.\n\nDe geschatte eindtijd wordt bij elke poll opnieuw berekend op basis van de resterende tijd die het apparaat opgeeft, wat kan afwijken of met een minuut of wat worden bijgesteld tussen updates. Verhoog de minimale wijziging hieronder om de sensor op zijn laatst gerapporteerde waarde te houden totdat de schatting met minstens dat aantal minuten verandert, wat de ruis in geschiedenis/logboek vermindert. Zet op 0 om elke berekende wijziging te rapporteren.",
|
||||||
"data": {
|
"data": {
|
||||||
"bypass_remote_control_lock": "Schrijfbewerkingen toestaan wanneer afstandsbediening als uitgeschakeld wordt gemeld"
|
"bypass_remote_control_lock": "Schrijfbewerkingen toestaan wanneer afstandsbediening als uitgeschakeld wordt gemeld",
|
||||||
|
"finish_time_hysteresis_minutes": "Geschatte eindtijd -- minimale wijziging (minuten)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"debug_write": {
|
"debug_write": {
|
||||||
|
|||||||
@@ -0,0 +1,280 @@
|
|||||||
|
"""Water heater platform for Local Things.
|
||||||
|
|
||||||
|
Second composite entity in this integration (see climate.py's module
|
||||||
|
docstring for the general pattern this follows): a single HA water_heater
|
||||||
|
card for a Samsung EHS heat pump's domestic hot water (DHW) loop. It binds
|
||||||
|
the primary `WaterHeaterDesc` (the `/mode/dhw/vs/0` capability, DHW.entities
|
||||||
|
in registry/capabilities/ehs.py) so the registry still tracks it, and reads
|
||||||
|
the sibling `/power/dhw/vs/0` and `/temperatures/dhw/vs/0` resources straight
|
||||||
|
from the coordinator snapshot -- the same cross-resource read climate.py uses
|
||||||
|
for the AC's power/temperature/wind siblings.
|
||||||
|
|
||||||
|
Writes go through `coordinator.async_send_command(bound, (kind, value))`:
|
||||||
|
DHW's `write_fn` (ehs._dhw_write) maps each `(kind, value)` payload to the
|
||||||
|
right `(path_segs, body)`, and `async_send_command` POSTs to those path_segs
|
||||||
|
and applies the optimistic value/settle guard to that same href -- not the
|
||||||
|
bound `/mode/dhw/vs/0` href -- so one descriptor drives writes to, and gets
|
||||||
|
fresh state back for, power, mode and temperature alike.
|
||||||
|
|
||||||
|
Operation-mode vocabulary: the DHW loop's four device modes (Eco/Std/Force/
|
||||||
|
Power) map onto HA's own standard water_heater states -- the same mapping
|
||||||
|
Home Assistant's core `smartthings` integration uses for this exact Samsung
|
||||||
|
capability over the cloud API (`samsungce.ehsThermostat` /
|
||||||
|
`airConditionerMode`: eco/std/force/power -> STATE_ECO/STATE_HEAT_PUMP/
|
||||||
|
STATE_HIGH_DEMAND/STATE_PERFORMANCE), just title-cased to match this OCF
|
||||||
|
resource's own code spelling. Reusing HA's standard states means no *state*
|
||||||
|
translation catalog entry is needed for them (see the entity_component
|
||||||
|
fallback in homeassistant.components.water_heater.strings.json).
|
||||||
|
|
||||||
|
Naming is a separate question from that, and the answer here differs from
|
||||||
|
climate.py's: the AC *is* the device, so its climate card takes the bare
|
||||||
|
device name (`_attr_name = None`). An EHS unit has two loops, and the DHW
|
||||||
|
one is not "the device" -- its siblings are named "Zone Mode"/"Zone Target
|
||||||
|
Temperature", so a card labelled just "EHS" would misrepresent which loop
|
||||||
|
it drives. This entity is named through the catalog like every other
|
||||||
|
descriptor here, via the DHW descriptor's `translation_key='dhw'`
|
||||||
|
(entity.water_heater.dhw.name -> "Hot water").
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from homeassistant.components.water_heater import (
|
||||||
|
STATE_ECO,
|
||||||
|
STATE_HEAT_PUMP,
|
||||||
|
STATE_HIGH_DEMAND,
|
||||||
|
STATE_PERFORMANCE,
|
||||||
|
WaterHeaterEntity,
|
||||||
|
WaterHeaterEntityFeature,
|
||||||
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.const import STATE_OFF, UnitOfTemperature
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
|
from .const import DOMAIN
|
||||||
|
from .coordinator import LocalThingsCoordinator
|
||||||
|
from .entity import LocalThingsEntity, _is_included
|
||||||
|
from .registry.capabilities.common import normalize_temp_unit
|
||||||
|
from .registry.capabilities.ehs import (
|
||||||
|
HREF_DHW_MODE as MODE_HREF,
|
||||||
|
)
|
||||||
|
from .registry.capabilities.ehs import (
|
||||||
|
HREF_DHW_POWER as POWER_HREF,
|
||||||
|
)
|
||||||
|
from .registry.capabilities.ehs import (
|
||||||
|
HREF_DHW_TEMPERATURE as TEMPERATURE_HREF,
|
||||||
|
)
|
||||||
|
from .registry.entities import WaterHeaterDesc
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
_MODES_FIELD = "x.com.samsung.da.modes"
|
||||||
|
_SUPPORTED_FIELD = "x.com.samsung.da.supportedModes"
|
||||||
|
|
||||||
|
# Device mode <-> HA water_heater operation state -- see the module
|
||||||
|
# docstring above for the SmartThings-cloud precedent this mirrors.
|
||||||
|
_DEVICE_TO_STATE: dict[str, str] = {
|
||||||
|
"Eco": STATE_ECO,
|
||||||
|
"Std": STATE_HEAT_PUMP,
|
||||||
|
"Force": STATE_HIGH_DEMAND,
|
||||||
|
"Power": STATE_PERFORMANCE,
|
||||||
|
}
|
||||||
|
_STATE_TO_DEVICE = {v: k for k, v in _DEVICE_TO_STATE.items()}
|
||||||
|
|
||||||
|
# Read-side lookup, case-folded. climate.py resolves write codes from the
|
||||||
|
# unit's own supportedModes because two spellings there mean one HA value
|
||||||
|
# ('Wind'/'Fan' -> FAN_ONLY); this map is bijective, so the write side can
|
||||||
|
# use _STATE_TO_DEVICE directly. Only the read side is exposed to a board
|
||||||
|
# spelling the same code differently ('eco'/'ECO'), and case is the one
|
||||||
|
# variation worth absorbing rather than warning about.
|
||||||
|
_DEVICE_TO_STATE_CI = {k.lower(): v for k, v in _DEVICE_TO_STATE.items()}
|
||||||
|
|
||||||
|
|
||||||
|
def _to_state(code) -> str | None:
|
||||||
|
if code is None:
|
||||||
|
return None
|
||||||
|
return _DEVICE_TO_STATE_CI.get(str(code).lower())
|
||||||
|
|
||||||
|
|
||||||
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
|
coordinator: LocalThingsCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
async_add_entities(
|
||||||
|
LocalThingsWaterHeater(coordinator, b)
|
||||||
|
for b in coordinator.bound
|
||||||
|
if isinstance(b.desc, WaterHeaterDesc) and _is_included(b, coordinator)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _num(value):
|
||||||
|
try:
|
||||||
|
return float(value)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _first(value):
|
||||||
|
"""Samsung `modes` is a single-element list on this resource. Return the
|
||||||
|
first element of a list, else the value itself."""
|
||||||
|
if isinstance(value, (list, tuple)):
|
||||||
|
return value[0] if value else None
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
class LocalThingsWaterHeater(LocalThingsEntity, WaterHeaterEntity):
|
||||||
|
"""Composite water_heater entity for a Samsung EHS DHW loop."""
|
||||||
|
|
||||||
|
def __init__(self, coordinator: LocalThingsCoordinator, bound) -> None:
|
||||||
|
super().__init__(coordinator, bound)
|
||||||
|
# No _attr_name here: unlike climate.py's AC, this is one loop of a
|
||||||
|
# two-loop device and takes a catalog name ("Hot water") through the
|
||||||
|
# descriptor's translation_key -- see the module docstring.
|
||||||
|
self._attr_supported_features = (
|
||||||
|
WaterHeaterEntityFeature.TARGET_TEMPERATURE
|
||||||
|
| WaterHeaterEntityFeature.OPERATION_MODE
|
||||||
|
| WaterHeaterEntityFeature.ON_OFF
|
||||||
|
)
|
||||||
|
# Raw device codes already logged by _warn_unmapped -- these
|
||||||
|
# properties are read on every coordinator refresh, so an un-deduped
|
||||||
|
# warning would spam the log for any unit reporting a genuinely
|
||||||
|
# unrecognized code.
|
||||||
|
self._warned_unmapped: set[str] = set()
|
||||||
|
|
||||||
|
def _rep(self, href: str) -> dict:
|
||||||
|
"""`href` is one of this module's canonical HREF_* constants --
|
||||||
|
translated through this bound entity's own subdevice (issue #177),
|
||||||
|
same as climate.py's identical helper."""
|
||||||
|
return self.coordinator.resource(self._bound.subdevice.to_actual(href)) or {}
|
||||||
|
|
||||||
|
def _is_on(self) -> bool:
|
||||||
|
return str(self._rep(POWER_HREF).get("x.com.samsung.da.power", "")).lower() == "on"
|
||||||
|
|
||||||
|
def _supported(self) -> list[str]:
|
||||||
|
return list(self._rep(MODE_HREF).get(_SUPPORTED_FIELD) or [])
|
||||||
|
|
||||||
|
def _warn_unmapped(self, code: str) -> None:
|
||||||
|
if code in self._warned_unmapped:
|
||||||
|
return
|
||||||
|
self._warned_unmapped.add(code)
|
||||||
|
_LOGGER.warning(
|
||||||
|
"%s: device DHW mode %r has no HA mapping and was dropped; "
|
||||||
|
"please file an issue with your diagnostics dump",
|
||||||
|
self.entity_id,
|
||||||
|
code,
|
||||||
|
)
|
||||||
|
|
||||||
|
# -- temperature --------------------------------------------------------
|
||||||
|
|
||||||
|
@property
|
||||||
|
def temperature_unit(self) -> str:
|
||||||
|
raw = self._rep(TEMPERATURE_HREF).get("x.com.samsung.da.unit")
|
||||||
|
return (
|
||||||
|
UnitOfTemperature.FAHRENHEIT
|
||||||
|
if normalize_temp_unit(raw, "°C") == "°F"
|
||||||
|
else UnitOfTemperature.CELSIUS
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_temperature(self):
|
||||||
|
return _num(self._rep(TEMPERATURE_HREF).get("x.com.samsung.da.current"))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def target_temperature(self):
|
||||||
|
return _num(self._rep(TEMPERATURE_HREF).get("x.com.samsung.da.desired"))
|
||||||
|
|
||||||
|
def _range(self) -> list | None:
|
||||||
|
"""The device's own (minimum, maximum) pair, or None.
|
||||||
|
|
||||||
|
Both ends together or neither, deliberately -- same rule as
|
||||||
|
climate._range(). A board reporting minimum but not maximum would
|
||||||
|
otherwise pair a device minimum (40) with HA's own default maximum
|
||||||
|
(140 °F), which looks plausible and is silently wrong on a unit
|
||||||
|
that really allows 62.
|
||||||
|
"""
|
||||||
|
rep = self._rep(TEMPERATURE_HREF)
|
||||||
|
lo = _num(rep.get("x.com.samsung.da.minimum"))
|
||||||
|
hi = _num(rep.get("x.com.samsung.da.maximum"))
|
||||||
|
return [lo, hi] if (lo is not None and hi is not None) else None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def min_temp(self) -> float:
|
||||||
|
r = self._range()
|
||||||
|
return r[0] if r else super().min_temp
|
||||||
|
|
||||||
|
@property
|
||||||
|
def max_temp(self) -> float:
|
||||||
|
r = self._range()
|
||||||
|
return r[1] if r else super().max_temp
|
||||||
|
|
||||||
|
@property
|
||||||
|
def target_temperature_step(self) -> float:
|
||||||
|
# `is None`, not `or` -- see issue #160: `or` collapses a genuine 0
|
||||||
|
# into the fallback.
|
||||||
|
step = _num(self._rep(TEMPERATURE_HREF).get("x.com.samsung.da.increment"))
|
||||||
|
return 0.5 if step is None else step
|
||||||
|
|
||||||
|
# -- operation mode -------------------------------------------------------
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_operation(self) -> str | None:
|
||||||
|
if not self._is_on():
|
||||||
|
return STATE_OFF
|
||||||
|
code = _first(self._rep(MODE_HREF).get(_MODES_FIELD))
|
||||||
|
mapped = _to_state(code)
|
||||||
|
if code is not None and mapped is None:
|
||||||
|
self._warn_unmapped(code)
|
||||||
|
return mapped
|
||||||
|
|
||||||
|
@property
|
||||||
|
def operation_list(self) -> list[str]:
|
||||||
|
modes = [STATE_OFF]
|
||||||
|
for code in self._supported():
|
||||||
|
mapped = _to_state(code)
|
||||||
|
if mapped is None:
|
||||||
|
self._warn_unmapped(code)
|
||||||
|
continue
|
||||||
|
if mapped not in modes:
|
||||||
|
modes.append(mapped)
|
||||||
|
return modes
|
||||||
|
|
||||||
|
# -- writes ---------------------------------------------------------------
|
||||||
|
|
||||||
|
async def async_set_temperature(self, **kwargs) -> None:
|
||||||
|
# HA's water_heater.set_temperature service takes an optional
|
||||||
|
# operation_mode and forwards it here (SET_TEMPERATURE_SCHEMA), same
|
||||||
|
# as climate.set_temperature does with hvac_mode. Honour it, and set
|
||||||
|
# it first -- that also powers the loop on when it was off -- so a
|
||||||
|
# dashboard "boost to 55" button that carries a mode actually changes
|
||||||
|
# mode, instead of only moving the setpoint. Same fix as the AC's
|
||||||
|
# (see climate.async_set_temperature).
|
||||||
|
operation_mode = kwargs.get("operation_mode")
|
||||||
|
if operation_mode is not None:
|
||||||
|
await self.async_set_operation_mode(operation_mode)
|
||||||
|
if operation_mode == STATE_OFF:
|
||||||
|
return
|
||||||
|
temp = kwargs.get("temperature")
|
||||||
|
if temp is None:
|
||||||
|
return
|
||||||
|
await self.coordinator.async_send_command(self._bound, ("temperature", temp))
|
||||||
|
|
||||||
|
async def async_set_operation_mode(self, operation_mode: str) -> None:
|
||||||
|
if operation_mode == STATE_OFF:
|
||||||
|
await self.coordinator.async_send_command(self._bound, ("power", False))
|
||||||
|
return
|
||||||
|
device = _STATE_TO_DEVICE.get(operation_mode)
|
||||||
|
if device is None:
|
||||||
|
return
|
||||||
|
if not self._is_on():
|
||||||
|
await self.coordinator.async_send_command(self._bound, ("power", True))
|
||||||
|
await self.coordinator.async_send_command(self._bound, ("mode", device))
|
||||||
|
|
||||||
|
async def async_turn_on(self, **kwargs) -> None:
|
||||||
|
await self.coordinator.async_send_command(self._bound, ("power", True))
|
||||||
|
|
||||||
|
async def async_turn_off(self, **kwargs) -> None:
|
||||||
|
await self.coordinator.async_send_command(self._bound, ("power", False))
|
||||||
@@ -3,3 +3,36 @@ requires-python = ">=3.13"
|
|||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
asyncio_mode = "auto"
|
asyncio_mode = "auto"
|
||||||
|
|
||||||
|
[tool.ruff]
|
||||||
|
target-version = "py313"
|
||||||
|
line-length = 100
|
||||||
|
|
||||||
|
[tool.ruff.lint]
|
||||||
|
select = [
|
||||||
|
"E", # pycodestyle errors
|
||||||
|
"F", # pyflakes
|
||||||
|
"W", # pycodestyle warnings
|
||||||
|
"I", # isort
|
||||||
|
"UP", # pyupgrade
|
||||||
|
"B", # flake8-bugbear
|
||||||
|
"C4", # flake8-comprehensions
|
||||||
|
"SIM", # flake8-simplify
|
||||||
|
"RUF", # ruff-specific
|
||||||
|
"ASYNC", # flake8-async
|
||||||
|
"LOG", # flake8-logging
|
||||||
|
"G", # flake8-logging-format
|
||||||
|
"PIE", # flake8-pie
|
||||||
|
"RET", # flake8-return
|
||||||
|
"PERF", # perflint
|
||||||
|
"N", # pep8-naming
|
||||||
|
]
|
||||||
|
ignore = [
|
||||||
|
"N818", # exception name doesn't need an Error suffix in this codebase
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.ruff.lint.isort]
|
||||||
|
known-first-party = ["custom_components"]
|
||||||
|
|
||||||
|
[tool.ty.environment]
|
||||||
|
python-version = "3.13"
|
||||||
@@ -10,3 +10,7 @@ smartthings-local>=0.1.0
|
|||||||
cbor2>=5.4.6
|
cbor2>=5.4.6
|
||||||
pyOpenSSL>=23.0
|
pyOpenSSL>=23.0
|
||||||
cryptography>=41.0
|
cryptography>=41.0
|
||||||
|
|
||||||
|
# Lint / format / type-check tooling, pinned to match CI.
|
||||||
|
ruff==0.16.1
|
||||||
|
ty==0.0.65
|
||||||
+23
-19
@@ -3,16 +3,17 @@ from pathlib import Path
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
FIXTURES = Path(__file__).resolve().parent / 'fixtures'
|
FIXTURES = Path(__file__).resolve().parent / "fixtures"
|
||||||
|
|
||||||
|
|
||||||
def _resources_from_dump(dump: dict) -> dict[str, dict]:
|
def _resources_from_dump(dump: dict) -> dict[str, dict]:
|
||||||
from custom_components.localthings.registry.batch import parse_device0_batch
|
from custom_components.localthings.registry.batch import parse_device0_batch
|
||||||
return parse_device0_batch(dump['device0'])
|
|
||||||
|
return parse_device0_batch(dump["device0"])
|
||||||
|
|
||||||
|
|
||||||
def _load_device(name: str) -> dict[str, dict]:
|
def _load_device(name: str) -> dict[str, dict]:
|
||||||
data = json.loads((FIXTURES / f'{name}_device.json').read_text())
|
data = json.loads((FIXTURES / f"{name}_device.json").read_text())
|
||||||
return _resources_from_dump(data)
|
return _resources_from_dump(data)
|
||||||
|
|
||||||
|
|
||||||
@@ -33,10 +34,10 @@ def _load_device_full(name: str):
|
|||||||
ARTIK051_DONGLE_FAC_18K fixture) is folded into `seeds` here, since
|
ARTIK051_DONGLE_FAC_18K fixture) is folded into `seeds` here, since
|
||||||
FakeCoapSession answers both shapes off the same href key.
|
FakeCoapSession answers both shapes off the same href key.
|
||||||
"""
|
"""
|
||||||
data = json.loads((FIXTURES / f'{name}_device.json').read_text())
|
data = json.loads((FIXTURES / f"{name}_device.json").read_text())
|
||||||
resources = _resources_from_dump(data)
|
resources = _resources_from_dump(data)
|
||||||
seeds = {**data.get('seeds', {}), **data.get('probes', {})}
|
seeds = {**data.get("seeds", {}), **data.get("probes", {})}
|
||||||
return resources, data.get('oic_res', []), seeds
|
return resources, data.get("oic_res", []), seeds
|
||||||
|
|
||||||
|
|
||||||
class FakeCoapSession:
|
class FakeCoapSession:
|
||||||
@@ -57,11 +58,12 @@ class FakeCoapSession:
|
|||||||
self.seeds = seeds or {}
|
self.seeds = seeds or {}
|
||||||
|
|
||||||
def get(self, path, timeout=None):
|
def get(self, path, timeout=None):
|
||||||
href = '/' + '/'.join(path)
|
href = "/" + "/".join(path)
|
||||||
body = self.seeds.get(href)
|
body = self.seeds.get(href)
|
||||||
if body is None:
|
if body is None:
|
||||||
return 0x84, b'' # 4.04 not found -- tolerated absence
|
return 0x84, b"" # 4.04 not found -- tolerated absence
|
||||||
import cbor2
|
import cbor2
|
||||||
|
|
||||||
return 0x45, cbor2.dumps(body)
|
return 0x45, cbor2.dumps(body)
|
||||||
|
|
||||||
def pace(self):
|
def pace(self):
|
||||||
@@ -87,14 +89,18 @@ def _discover_full(resources: dict[str, dict], oic_res, seeds: dict[str, list]):
|
|||||||
from custom_components.localthings.registry.by_type import resolve
|
from custom_components.localthings.registry.by_type import resolve
|
||||||
from custom_components.localthings.registry.registry import CAPABILITIES
|
from custom_components.localthings.registry.registry import CAPABILITIES
|
||||||
from custom_components.localthings.registry.subdevices import (
|
from custom_components.localthings.registry.subdevices import (
|
||||||
discover_partitioned, enumerate_subdevices,
|
discover_partitioned,
|
||||||
|
enumerate_subdevices,
|
||||||
)
|
)
|
||||||
|
|
||||||
sess = FakeCoapSession(seeds)
|
sess = FakeCoapSession(seeds)
|
||||||
candidates, extra = enumerate_subdevices(sess, resources, oic_res)
|
candidates, extra = enumerate_subdevices(sess, resources, oic_res)
|
||||||
full_resources = {**resources, **extra}
|
full_resources = {**resources, **extra}
|
||||||
bound, device_type_name, materialized, skipped = discover_partitioned(
|
bound, device_type_name, materialized, skipped = discover_partitioned(
|
||||||
full_resources, candidates, resolve, CAPABILITIES,
|
full_resources,
|
||||||
|
candidates,
|
||||||
|
resolve,
|
||||||
|
CAPABILITIES,
|
||||||
)
|
)
|
||||||
return bound, materialized, skipped, full_resources, device_type_name
|
return bound, materialized, skipped, full_resources, device_type_name
|
||||||
|
|
||||||
@@ -102,8 +108,8 @@ def _discover_full(resources: dict[str, dict], oic_res, seeds: dict[str, list]):
|
|||||||
def _load_resources(ip: str) -> dict[str, dict]:
|
def _load_resources(ip: str) -> dict[str, dict]:
|
||||||
"""Legacy IP-based loader — maps known IPs to named fixtures."""
|
"""Legacy IP-based loader — maps known IPs to named fixtures."""
|
||||||
_ip_to_name = {
|
_ip_to_name = {
|
||||||
'10.0.0.129': 'dishwasher',
|
"10.0.0.129": "dishwasher",
|
||||||
'10.0.0.254': 'refrigerator',
|
"10.0.0.254": "refrigerator",
|
||||||
}
|
}
|
||||||
name = _ip_to_name.get(ip)
|
name = _ip_to_name.get(ip)
|
||||||
if name is None:
|
if name is None:
|
||||||
@@ -113,17 +119,17 @@ def _load_resources(ip: str) -> dict[str, dict]:
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def dishwasher_resources() -> dict[str, dict]:
|
def dishwasher_resources() -> dict[str, dict]:
|
||||||
return _load_device('dishwasher')
|
return _load_device("dishwasher")
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def fridge_resources() -> dict[str, dict]:
|
def fridge_resources() -> dict[str, dict]:
|
||||||
return _load_device('refrigerator')
|
return _load_device("refrigerator")
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def washer_resources() -> dict[str, dict]:
|
def washer_resources() -> dict[str, dict]:
|
||||||
return _load_device('washer')
|
return _load_device("washer")
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@@ -134,8 +140,6 @@ def all_device_fixtures() -> dict[str, dict[str, dict]]:
|
|||||||
device -- so a newly added dump exercises them automatically.
|
device -- so a newly added dump exercises them automatically.
|
||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
path.name[:-len('_device.json')]: _resources_from_dump(
|
path.name[: -len("_device.json")]: _resources_from_dump(json.loads(path.read_text()))
|
||||||
json.loads(path.read_text())
|
for path in sorted(FIXTURES.glob("*_device.json"))
|
||||||
)
|
|
||||||
for path in sorted(FIXTURES.glob('*_device.json'))
|
|
||||||
}
|
}
|
||||||
+414
@@ -0,0 +1,414 @@
|
|||||||
|
{
|
||||||
|
"device0": [
|
||||||
|
{
|
||||||
|
"rt": [
|
||||||
|
"x.com.samsung.devcol",
|
||||||
|
"oic.wk.col"
|
||||||
|
],
|
||||||
|
"if": [
|
||||||
|
"oic.if.baseline",
|
||||||
|
"oic.if.ll",
|
||||||
|
"oic.if.b"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/airdresseroption/sanitize/vs/0",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/alarms/vs/0",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/buzzersound/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"supportedBuzzerSound": [
|
||||||
|
"Off",
|
||||||
|
"On"
|
||||||
|
],
|
||||||
|
"setBuzzerSound": "On"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/configuration/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.region": "1117000000",
|
||||||
|
"x.com.samsung.da.countryCode": "KR"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/connectionconfig/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"autoReconnectionMinVersion": "1.0",
|
||||||
|
"autoReconnection": "true",
|
||||||
|
"autoReconnectionProtocolType": [
|
||||||
|
"helper_hotspot",
|
||||||
|
"ble_ocf"
|
||||||
|
],
|
||||||
|
"supportedWiFiAuthType": [
|
||||||
|
"OPEN",
|
||||||
|
"WEP",
|
||||||
|
"WPA-PSK",
|
||||||
|
"WPA2-PSK",
|
||||||
|
"SAE"
|
||||||
|
],
|
||||||
|
"supportedWiFiCryptoType": [
|
||||||
|
"TKIP",
|
||||||
|
"AES",
|
||||||
|
"WEP-64",
|
||||||
|
"WEP-128"
|
||||||
|
],
|
||||||
|
"supportedWiFiFreq": [
|
||||||
|
"2.4G"
|
||||||
|
],
|
||||||
|
"calmConnectionCare": {
|
||||||
|
"version": "1.0",
|
||||||
|
"role": [
|
||||||
|
"things"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/course/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.supportedModes": [
|
||||||
|
"HOMECARE_WIZARD_V2"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.options": [
|
||||||
|
"DeviceType_015E",
|
||||||
|
"UpdateAllow_NotAllowed",
|
||||||
|
"Course_01",
|
||||||
|
"AiOption_On",
|
||||||
|
"SteamPush_None",
|
||||||
|
"SeamlessControl_Disable",
|
||||||
|
"KidsLockBypass_On",
|
||||||
|
"FilterUsage_384001D4",
|
||||||
|
"WashingTimes_2",
|
||||||
|
"DrumCleanProposal_30",
|
||||||
|
"SpecialFunction_16",
|
||||||
|
"AvailableDelayTime_0",
|
||||||
|
"ProgressTimeSet_AA012CB20348",
|
||||||
|
"WrinklePreventRunning_Off",
|
||||||
|
"SendToDevice_Off",
|
||||||
|
"WeatherPush_On",
|
||||||
|
"GMT_12",
|
||||||
|
"DelayEndSet_0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0FF0F0F0F0F0F0F0F00F0F0F0F0F",
|
||||||
|
"EnergyLevelSet_05020404010103040301020203020101040505050503030303030303050204050405",
|
||||||
|
"WrinklePreventSet_0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0FF00F0F0F0F0F0F0F0F0F0F0FF0F0",
|
||||||
|
"SavingModeCondition_01010205272B2C2D2E0300",
|
||||||
|
"SavingMode_Off",
|
||||||
|
"UsagesDB_ok",
|
||||||
|
"DrumCleanLog_Empty"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.supportedOptions": [
|
||||||
|
"10100003500000300000E00000400000A00001300000B00001200000900000C00001000003100001400001600001700002100001900002000000F00002700003000002A00002B00002C00002D00002E00001500001A00001B00001C0000070000080000"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/cycleinterface/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.cycleInterfaceEnabled": "Off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/diagnosis/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.diagnosisStart": "Ready"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/drlc/0",
|
||||||
|
"rep": {
|
||||||
|
"DRLevel": 0,
|
||||||
|
"start": "0000-00-00T00:00:00Z",
|
||||||
|
"duration": 0,
|
||||||
|
"override": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/drlc/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.drlcLevel": "0",
|
||||||
|
"x.com.samsung.da.durationminutes": "0",
|
||||||
|
"x.com.samsung.da.start": "0000-00-00T00:00:00Z",
|
||||||
|
"x.com.samsung.da.override": "Off",
|
||||||
|
"x.com.samsung.da.realSaving": "Off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/energy/consumption/0",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/energy/consumption/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.instantaneousPower": "-500",
|
||||||
|
"x.com.samsung.da.instantaneousPowerUnit": "W",
|
||||||
|
"x.com.samsung.da.cumulativePower": "2900",
|
||||||
|
"x.com.samsung.da.cumulativeUnit": "Wh",
|
||||||
|
"x.com.samsung.da.cumulativeDate": "1785362400",
|
||||||
|
"x.com.samsung.da.cumulativeDateUTC": "1785330000",
|
||||||
|
"x.com.samsung.da.cumulativeSavedPower": "0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/file/information/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.timeoffset": "+00:00"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/information/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.modelNum": "DA_DF_TP1_21_COMMON|20313841|380101020016111F42C3000200010000",
|
||||||
|
"x.com.samsung.da.description": "DA_DF_TP1_21_COMMON_DF3000B/DC92-03252A_0002",
|
||||||
|
"x.com.samsung.da.serialNum": "REDACTED",
|
||||||
|
"x.com.samsung.da.otnDUID": "REDACTED",
|
||||||
|
"x.com.samsung.da.diagProtocolType": "BLE_OCF",
|
||||||
|
"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": "WA0",
|
||||||
|
"x.com.samsung.da.diagMinVersion": "3.0",
|
||||||
|
"x.com.samsung.da.diagTsId": "DA01",
|
||||||
|
"x.com.samsung.da.items": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "0",
|
||||||
|
"x.com.samsung.da.description": "DA_DF_TP1_21_COMMON|20313841|380101020016111F42C3000200010000",
|
||||||
|
"x.com.samsung.da.type": "Software",
|
||||||
|
"x.com.samsung.da.number": "03101A260513(A440)",
|
||||||
|
"x.com.samsung.da.newVersionAvailable": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "1",
|
||||||
|
"x.com.samsung.da.description": "Firmware_1_DB_20313841241127210FFFFF203252412402215804FFFF(015E2031384120325241_30241204)(FileDown:0)(Type:0)",
|
||||||
|
"x.com.samsung.da.type": "Firmware",
|
||||||
|
"x.com.samsung.da.number": "03138A24112721,03252A24022158",
|
||||||
|
"x.com.samsung.da.newVersionAvailable": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "2",
|
||||||
|
"x.com.samsung.da.description": "Firmware_2_DB_2031574122122007043FFF2032114122122704042FFF(015E2031574120321141_30000000)(FileDown:0)(Type:0)",
|
||||||
|
"x.com.samsung.da.type": "Firmware",
|
||||||
|
"x.com.samsung.da.number": "03157A22122007,03211A22122704"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "3",
|
||||||
|
"x.com.samsung.da.description": "Firmware_3_DB_20303242000000020AFFFFFFFFFFFFFFFFFFFFFFFFFF(015E20303242FFFFFFFF_30000000)(FileDown:0)(Type:0)",
|
||||||
|
"x.com.samsung.da.type": "Firmware",
|
||||||
|
"x.com.samsung.da.number": "03032B00000002,FFFFFFFFFFFFFF"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/kidslock/0",
|
||||||
|
"rep": {
|
||||||
|
"value": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/kidslock/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.kidsLock": "Ready"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/operational/state/0",
|
||||||
|
"rep": {
|
||||||
|
"currentMachineState": "REDACTED",
|
||||||
|
"machineStates": "REDACTED",
|
||||||
|
"jobStates": [
|
||||||
|
"None",
|
||||||
|
"Steaming",
|
||||||
|
"Airwashing",
|
||||||
|
"Drying",
|
||||||
|
"Finish"
|
||||||
|
],
|
||||||
|
"currentJobState": "None",
|
||||||
|
"remainingTime": "00:35:00",
|
||||||
|
"progressPercentage": "1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/operational/state/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.state": "Ready",
|
||||||
|
"x.com.samsung.da.remainingTime": "00:35:00",
|
||||||
|
"x.com.samsung.da.progressPercentage": "1",
|
||||||
|
"x.com.samsung.da.progress": "None",
|
||||||
|
"x.com.samsung.da.delayEndTime": "00:00:00",
|
||||||
|
"x.com.samsung.da.supportedProgress": [
|
||||||
|
"None",
|
||||||
|
"Steaming",
|
||||||
|
"Airwashing",
|
||||||
|
"Drying",
|
||||||
|
"Finish"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": "2026-07-07",
|
||||||
|
"otnList": [
|
||||||
|
{
|
||||||
|
"type": "WIFI",
|
||||||
|
"modelId": "DA_DF_TP1_21_COMMON",
|
||||||
|
"versions": [
|
||||||
|
"30260513"
|
||||||
|
],
|
||||||
|
"visVersion": "260513"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Micom",
|
||||||
|
"modelId": "015E2031384120325241",
|
||||||
|
"versions": [
|
||||||
|
"24112721",
|
||||||
|
"24022158"
|
||||||
|
],
|
||||||
|
"visVersion": "241127"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Micom",
|
||||||
|
"modelId": "015E2031574120321141",
|
||||||
|
"versions": [
|
||||||
|
"22122007",
|
||||||
|
"22122704"
|
||||||
|
],
|
||||||
|
"visVersion": "221227"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Micom",
|
||||||
|
"modelId": "015E20303242FFFFFFFF",
|
||||||
|
"versions": [
|
||||||
|
"2",
|
||||||
|
"FFFFFFFF"
|
||||||
|
],
|
||||||
|
"visVersion": "2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/power/0",
|
||||||
|
"rep": {
|
||||||
|
"value": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/power/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.power": "Off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/quickcontrol/info/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"supportedVersion": "1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/realtimenotiforclient/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.timeforshortnoti": "0",
|
||||||
|
"x.com.samsung.da.periodicnotisubscription": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/remotectrl/0",
|
||||||
|
"rep": {
|
||||||
|
"value": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/remotectrl/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.remoteControlEnabled": "false"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/st/airdressercourse/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.st.airdresserMode": "Table_00_Course_01",
|
||||||
|
"x.com.samsung.da.st.courseTable": "Table_00"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/timezone/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"timezoneid": "Asia/Seoul",
|
||||||
|
"offset": "+09:00",
|
||||||
|
"DST": "OFF"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/washer/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.wrinklePrevent": "Off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/wirelessinfo/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"macaddressWiFi": "REDACTED",
|
||||||
|
"macaddressBLE": "REDACTED"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/wm/editcourse/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.editCourseList": "EditCourseList_0135030E040A130B12090C10311416172119200F27302A2B2C2D2E151A1B1C0708",
|
||||||
|
"x.com.samsung.da.fixedCourseList": "FixedCourseList_01270F"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/wm/jobbeginingstatus/vs/0",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/wm/personalcourse/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.courses": [
|
||||||
|
"F1_00",
|
||||||
|
"F2_00",
|
||||||
|
"F3_00",
|
||||||
|
"F4_00",
|
||||||
|
"F5_00",
|
||||||
|
"F6_00",
|
||||||
|
"F7_00",
|
||||||
|
"F8_00",
|
||||||
|
"F9_00",
|
||||||
|
"FA_00"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.maxCourseNum": "10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/wm/setinfo/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.isModelSettingWithoutSC": "false",
|
||||||
|
"x.com.samsung.da.aiCourse": "false",
|
||||||
|
"x.com.samsung.da.isModelSettingPowerOnOff": "true",
|
||||||
|
"x.com.samsung.da.modelCode": "M(None),W(None)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/wm/welcomemsg/vs/0",
|
||||||
|
"rep": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
+184
@@ -0,0 +1,184 @@
|
|||||||
|
{
|
||||||
|
"device0": [
|
||||||
|
{
|
||||||
|
"rt": [
|
||||||
|
"x.com.samsung.devcol",
|
||||||
|
"oic.wk.col"
|
||||||
|
],
|
||||||
|
"if": [
|
||||||
|
"oic.if.baseline",
|
||||||
|
"oic.if.ll",
|
||||||
|
"oic.if.b"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/airqualitystandard/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.standard": "AirCleanAssociation"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/alarms/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.items": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "0",
|
||||||
|
"x.com.samsung.da.description": "Version",
|
||||||
|
"x.com.samsung.da.alarmType": "Device",
|
||||||
|
"x.com.samsung.da.code": "ErrorCode_OFF",
|
||||||
|
"x.com.samsung.da.triggeredTime": "2026-07-30T02:42:57",
|
||||||
|
"x.com.samsung.da.state": "Deleted"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rt": [
|
||||||
|
"x.com.samsung.da.alarms"
|
||||||
|
],
|
||||||
|
"if": [
|
||||||
|
"oic.if.baseline",
|
||||||
|
"oic.if.a"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/dnd/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.value": "false",
|
||||||
|
"x.com.samsung.da.startTime": "14:00:00",
|
||||||
|
"x.com.samsung.da.endTime": "22:00:00",
|
||||||
|
"x.com.samsung.da.visible": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/energy/battery/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.battery": "80",
|
||||||
|
"x.com.samsung.da.batteryResolution": "1",
|
||||||
|
"x.com.samsung.da.charging": "Off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/humidity/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.humidity": "57",
|
||||||
|
"x.com.samsung.da.validity": "Valid"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/information/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.modelNum": "ASM-KR-TP1-22-ACMB1M|10243041|75000000001611C40800020000080000",
|
||||||
|
"x.com.samsung.da.description": "ASM-KR-TP1-22-ACMB1M",
|
||||||
|
"x.com.samsung.da.serialNum": "REDACTED",
|
||||||
|
"x.com.samsung.da.otnDUID": "REDACTED",
|
||||||
|
"x.com.samsung.da.items": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "0",
|
||||||
|
"x.com.samsung.da.description": "Version",
|
||||||
|
"x.com.samsung.da.type": "Software",
|
||||||
|
"x.com.samsung.da.number": "02443A260310",
|
||||||
|
"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": "22050300",
|
||||||
|
"x.com.samsung.da.newVersionAvailable": "0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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": "AM0",
|
||||||
|
"x.com.samsung.da.diagMinVersion": "1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/keepnormalstate/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.keepnormal": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/realtimenotiforclient/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.timeforshortnoti": "0",
|
||||||
|
"x.com.samsung.da.longnotisubscription": "true",
|
||||||
|
"x.com.samsung.da.periodicnotisubscription": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/sensordatasinks/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"remove": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/sensors/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.cleanLevel": "2",
|
||||||
|
"x.com.samsung.da.refresh": "Off",
|
||||||
|
"x.com.samsung.da.lastSensingTime": "1785379376",
|
||||||
|
"x.com.samsung.da.items": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "0",
|
||||||
|
"x.com.samsung.da.description": "Sensor for CleanLevel",
|
||||||
|
"x.com.samsung.da.type": "CleanLevel",
|
||||||
|
"x.com.samsung.da.value": [
|
||||||
|
"2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "1",
|
||||||
|
"x.com.samsung.da.description": "Sensor for Odor",
|
||||||
|
"x.com.samsung.da.type": "Odor",
|
||||||
|
"x.com.samsung.da.value": [
|
||||||
|
"1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "2",
|
||||||
|
"x.com.samsung.da.description": "Sensor for Dust",
|
||||||
|
"x.com.samsung.da.type": "Dust",
|
||||||
|
"x.com.samsung.da.value": [
|
||||||
|
"31",
|
||||||
|
"2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "3",
|
||||||
|
"x.com.samsung.da.description": "Sensor for FineDust",
|
||||||
|
"x.com.samsung.da.type": "FineDust",
|
||||||
|
"x.com.samsung.da.value": [
|
||||||
|
"23",
|
||||||
|
"2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "4",
|
||||||
|
"x.com.samsung.da.description": "Sensor for SuperFineDust",
|
||||||
|
"x.com.samsung.da.type": "SuperFineDust",
|
||||||
|
"x.com.samsung.da.value": [
|
||||||
|
"18",
|
||||||
|
"2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "5",
|
||||||
|
"x.com.samsung.da.description": "Sensor for CO2",
|
||||||
|
"x.com.samsung.da.type": "CO2",
|
||||||
|
"x.com.samsung.da.value": [
|
||||||
|
"498",
|
||||||
|
"1"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,357 @@
|
|||||||
|
{
|
||||||
|
"device0": [
|
||||||
|
{
|
||||||
|
"rt": [
|
||||||
|
"x.com.samsung.devcol",
|
||||||
|
"oic.wk.col"
|
||||||
|
],
|
||||||
|
"if": [
|
||||||
|
"oic.if.baseline",
|
||||||
|
"oic.if.ll",
|
||||||
|
"oic.if.b"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/airflow/0",
|
||||||
|
"rep": {
|
||||||
|
"speed": 3,
|
||||||
|
"direction": "Fix"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/airflow/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.speedLevel": "3",
|
||||||
|
"x.com.samsung.da.direction": "Fix"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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-28T00:18:15",
|
||||||
|
"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-28T00:18:15",
|
||||||
|
"x.com.samsung.da.state": "Deleted"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/configuration/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.region": "0000000000"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/diagnosis/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.diagnosisStart": "Ready"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/energy/consumption/0",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/energy/consumption/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.cumulativePower": "0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/file/information/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.timeoffset": "+01:00",
|
||||||
|
"x.com.samsung.supprtedtype": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/humidity/0",
|
||||||
|
"rep": {
|
||||||
|
"humidity": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/humidity/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.humidity": "0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/information/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.modelNum": "ARTIK051_KRAC_18K|10193441|60010119001111110200000000000000",
|
||||||
|
"x.com.samsung.da.description": "ARTIK051_KRAC_18K",
|
||||||
|
"x.com.samsung.da.serialNum": "**REDACTED**",
|
||||||
|
"x.com.samsung.da.otnDUID": "**REDACTED**",
|
||||||
|
"x.com.samsung.da.items": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "0",
|
||||||
|
"x.com.samsung.da.description": "Version",
|
||||||
|
"x.com.samsung.da.type": "Software",
|
||||||
|
"x.com.samsung.da.number": "02016A200825",
|
||||||
|
"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": "18020800,17120500",
|
||||||
|
"x.com.samsung.da.newVersionAvailable": "0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/mode/0",
|
||||||
|
"rep": {
|
||||||
|
"supportedModes": [
|
||||||
|
"Cool",
|
||||||
|
"Dry",
|
||||||
|
"Wind",
|
||||||
|
"Auto",
|
||||||
|
"Heat",
|
||||||
|
"HOMECARE_WIZARD_V2"
|
||||||
|
],
|
||||||
|
"modes": [
|
||||||
|
"Cool"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/mode/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.supportedModes": [
|
||||||
|
"Cool",
|
||||||
|
"Dry",
|
||||||
|
"Wind",
|
||||||
|
"Auto",
|
||||||
|
"Heat",
|
||||||
|
"HOMECARE_WIZARD_V2"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.modes": [
|
||||||
|
"Cool"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.options": [
|
||||||
|
"Comode_Off",
|
||||||
|
"Sleep_0",
|
||||||
|
"OutdoorTemp_74",
|
||||||
|
"CoolCapa_25",
|
||||||
|
"WarmCapa_32",
|
||||||
|
"Spi_Off",
|
||||||
|
"Autoclean_Off",
|
||||||
|
"Light_Off",
|
||||||
|
"Volume_100",
|
||||||
|
"AirMonitoring_Off",
|
||||||
|
"AutocleanProgress_1",
|
||||||
|
"StopAutoClean_Idle",
|
||||||
|
"FilterTime_1715",
|
||||||
|
"FilterAlarmTime_500",
|
||||||
|
"OptionCode_35882",
|
||||||
|
"ExtendOptionCode_7",
|
||||||
|
"RacInfo_None",
|
||||||
|
"UpdateAllow_NotAllowed"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/personality/presence/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.items": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "",
|
||||||
|
"x.com.samsung.da.deviceId": "**REDACTED**",
|
||||||
|
"x.com.samsung.da.value": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/power/0",
|
||||||
|
"rep": {
|
||||||
|
"value": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/power/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.power": "Off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/temperature/current/0",
|
||||||
|
"rep": {
|
||||||
|
"range": [
|
||||||
|
16.0,
|
||||||
|
30.0
|
||||||
|
],
|
||||||
|
"units": "C",
|
||||||
|
"temperature": 21.0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/temperature/desired/0",
|
||||||
|
"rep": {
|
||||||
|
"range": [
|
||||||
|
16.0,
|
||||||
|
30.0
|
||||||
|
],
|
||||||
|
"units": "C",
|
||||||
|
"temperature": 20.0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": "20",
|
||||||
|
"x.com.samsung.da.current": "21",
|
||||||
|
"x.com.samsung.da.maximum": "30",
|
||||||
|
"x.com.samsung.da.minimum": "16",
|
||||||
|
"x.com.samsung.da.unit": "Celsius"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"oic_res": [],
|
||||||
|
"seeds": {
|
||||||
|
"/device/1": [
|
||||||
|
{
|
||||||
|
"rt": [
|
||||||
|
"x.com.samsung.devcol",
|
||||||
|
"oic.wk.col"
|
||||||
|
],
|
||||||
|
"if": [
|
||||||
|
"oic.if.baseline",
|
||||||
|
"oic.if.ll",
|
||||||
|
"oic.if.b"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/airflow/vs/1",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/airflow/1",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/alarms/vs/1",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/temperatures/vs/1",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.items": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "0",
|
||||||
|
"x.com.samsung.da.description": "Temperature"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/temperature/current/1",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/temperature/desired/1",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/diagnosis/vs/1",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/energy/consumption/vs/1",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.cumulativePower": "117520000",
|
||||||
|
"x.com.samsung.da.cumulativeDate": "1785420000"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/energy/consumption/1",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/mode/vs/1",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/mode/1",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/power/vs/1",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/power/1",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/information/vs/1",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.modelNum": "ARTIK051_KRAC_18K|10193441|60010119001111110200000000000000",
|
||||||
|
"x.com.samsung.da.description": "ARTIK051_KRAC_18K",
|
||||||
|
"x.com.samsung.da.serialNum": "**REDACTED**",
|
||||||
|
"x.com.samsung.da.otnDUID": "**REDACTED**",
|
||||||
|
"x.com.samsung.da.items": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "0",
|
||||||
|
"x.com.samsung.da.description": "Version",
|
||||||
|
"x.com.samsung.da.type": "Software",
|
||||||
|
"x.com.samsung.da.number": "02016A200825",
|
||||||
|
"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": "18020800,17120500",
|
||||||
|
"x.com.samsung.da.newVersionAvailable": "0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/file/information/vs/1",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.timeoffset": "+03:00",
|
||||||
|
"x.com.samsung.supprtedtype": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/configuration/vs/1",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.region": "0000000000"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/humidity/1",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/humidity/vs/1",
|
||||||
|
"rep": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"seeds_note": "device0 is the ARTIK051_KRAC_18K capture from airconditioner_artik051_krac_18k_device.json, verbatim -- a real dump, but from a different physical unit than the issue #214 reporter's AR12NXWXCWKNEU (same board family, modelNum differing only in the third segment). The reporter's own master resources were not quoted in the issue, so the master half of this fixture is that unit's stand-in. The /device/1 seed is the reporter's real slot, read off the `subdevices` block of their v0.17.0 diagnostics download (issue #214 comment 5131166356) and re-indexed from the canonical hrefs diagnostics reports back onto the real /x/1 hrefs the board answers on -- every rep is their value verbatim, including the empty {} on every operational resource and the populated /energy/consumption/vs/1, which is the whole point of this fixture. Two deliberate deviations: /information/vs/1 carries *this* fixture's master /information/vs/0 rep rather than the reporter's modelNum, because what their dump shows is the slot echoing its own master's model verbatim (ARTIK051_KRAC_18K|10193441|60010123001111110100000000000000, identical to their master's) and pasting that string against a different unit's master would misrepresent the slot as reporting a *different* model, which is what a real sibling does (see airconditioner_artik051_dongle_fac_18k_device.json's FAC_RAC subdevice); and /file/information/vs/1's +03:00 offset is the reporter's, so it doesn't match this master's +01:00 -- an artifact of the two halves coming from different units, not something the board did. oic_res is empty because the reporter's wasn't quoted either: enumeration therefore reaches /device/1 through the speculative _SPECULATIVE_DEVICE_INDICES probe, which is the path any board that doesn't advertise a sibling in /oic/res gets. Expected outcome: the candidate is found, then correctly held back by discover_partitioned's liveness gate -- a lifetime kWh counter is not evidence of a second indoor unit (issue #214)."
|
||||||
|
}
|
||||||
@@ -716,5 +716,5 @@
|
|||||||
"x.com.samsung.da.serialNum": "TEST-SUBDEVICE-SERIAL-0000"
|
"x.com.samsung.da.serialNum": "TEST-SUBDEVICE-SERIAL-0000"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"seeds_note": "device0 and oic_res are real, captured from the reporter's issue #205 report. subdeviceIdList in device0's /subdevices/vs/0 is restored to the real ['6c2dff6d-ee5c-dad1-6a5e-000000000001'] (HA's diagnostics download redacts it, matching redact.py's 'deviceid' substring rule, not because it's account data -- same restoration airconditioner_fac_bora_2in1_device.json documents for the same field), and every other value is otherwise exactly what HA's download redacts (serials/otnDUID etc.) against the same physical TP2X_FAC_BORA_21K unit as airconditioner_fac_bora_2in1_device.json -- same subdeviceIdList UUID, same wall subdevice. Filed specifically because, contrary to the assumption that fixture's seed batch was built on, this unit's /6c2dff6d-ee5c-dad1-6a5e-000000000001/device/0 does NOT answer (subdevice_probes in the report shows it False), so the Collection-batch fallback this fixture exercises (registry.subdevices.enumerate_subdevices' per-href probe, issue #205) is what has to find the subdevice instead. The one probes entry, /6c2dff6d-ee5c-dad1-6a5e-000000000001/information/vs/0, is the same real capture already used in airconditioner_fac_bora_2in1_device.json's seed batch (issue #177 comment 5113518087) -- the only href ever actually confirmed to answer under this UUID prefix. No other /6c2dff6d-ee5c-dad1-6a5e-000000000001/* href has been confirmed live yet, so none are seeded here; this fixture's expected outcome is the candidate being found by the flat-href probe but then correctly held back by discover_partitioned's liveness gate (information alone binds no entity), matching where the real issue stands -- not a materialized climate entity, which would require guessing at unconfirmed hrefs. The probe's serialNum (\"TEST-SUBDEVICE-SERIAL-0000\") is a hand-placed placeholder for the real value, not HA's own redaction output -- same placeholder airconditioner_fac_bora_2in1_device.json uses for the identical field."
|
"seeds_note": "device0 and oic_res are real, captured from the reporter's issue #205 report. subdeviceIdList in device0's /subdevices/vs/0 is restored to the real ['6c2dff6d-ee5c-dad1-6a5e-000000000001'] (HA's diagnostics download redacts it, matching redact.py's 'deviceid' substring rule, not because it's account data -- same restoration airconditioner_fac_bora_2in1_device.json documents for the same field), and every other value is otherwise exactly what HA's download redacts (serials/otnDUID etc.) against the same physical TP2X_FAC_BORA_21K unit as airconditioner_fac_bora_2in1_device.json -- same subdeviceIdList UUID, same wall subdevice. Filed specifically because this unit's /6c2dff6d-ee5c-dad1-6a5e-000000000001/device/0 does NOT answer (subdevice_probes in the report shows it False), which is what this fixture exercises: registry.subdevices.enumerate_subdevices' clone-the-master fallback (issue #265, which replaced the per-href probe loop this fixture originally exercised for issue #205). The one probes entry, /6c2dff6d-ee5c-dad1-6a5e-000000000001/information/vs/0, is the same real capture already used in airconditioner_fac_bora_2in1_device.json's seed batch (issue #177 comment 5113518087) -- the only href ever actually confirmed to answer under this UUID prefix. It's kept here as that real confirmation even though the current fallback no longer probes any href beyond /device/0 to decide whether the subdevice exists at all: since issue #265, this fixture's expected outcome is the candidate materializing immediately with the master's own device0 hrefs/values cloned under the prefix as its assumed state -- a full climate entity included -- rather than waiting on per-href confirmation this firmware may never give. The probe's serialNum (\"TEST-SUBDEVICE-SERIAL-0000\") is a hand-placed placeholder for the real value, not HA's own redaction output -- same placeholder airconditioner_fac_bora_2in1_device.json uses for the identical field."
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,575 @@
|
|||||||
|
{
|
||||||
|
"device0": [
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/alarms/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.items": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "0",
|
||||||
|
"x.com.samsung.da.alarmType": "Device",
|
||||||
|
"x.com.samsung.da.code": "ErrorCode_OFF",
|
||||||
|
"x.com.samsung.da.triggeredTime": "2026-07-31T12:54:20",
|
||||||
|
"x.com.samsung.da.state": "Deleted"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "1",
|
||||||
|
"x.com.samsung.da.alarmType": "Device",
|
||||||
|
"x.com.samsung.da.code": "FilterAlarm_OFF",
|
||||||
|
"x.com.samsung.da.triggeredTime": "2026-07-31T12:54:20",
|
||||||
|
"x.com.samsung.da.state": "Deleted"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rt": [
|
||||||
|
"x.com.samsung.da.alarms"
|
||||||
|
],
|
||||||
|
"if": [
|
||||||
|
"oic.if.baseline",
|
||||||
|
"oic.if.a"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/availablecontrolsets/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.sets": "AE3F00A0012C01610248000F0000",
|
||||||
|
"x.com.samsung.da.id": "RAC",
|
||||||
|
"x.com.samsung.da.version": "1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/configuration/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.region": "0000000000",
|
||||||
|
"x.com.samsung.da.airconOptionList": [
|
||||||
|
"PRODUCT_GLOBAL",
|
||||||
|
"AI_GLOBAL_HEATPUMP_4.0",
|
||||||
|
"AI_3.0",
|
||||||
|
"Auto_To_AI",
|
||||||
|
"AI_Heat",
|
||||||
|
"ENERGY_2.0",
|
||||||
|
"HOMECARE_WIZARD_V2",
|
||||||
|
"DR",
|
||||||
|
"SingleCommand_1"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/da/softreset/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.softwarereset": "false"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/drlc/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.start": "1970-01-01T00:00:00Z",
|
||||||
|
"x.com.samsung.da.override": "Off",
|
||||||
|
"x.com.samsung.da.durationminutes": "0",
|
||||||
|
"x.com.samsung.da.drlcLevel": "0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/electriccurrent/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"operation": "Off",
|
||||||
|
"modes": "3",
|
||||||
|
"supportedModes": [
|
||||||
|
"3",
|
||||||
|
"4",
|
||||||
|
"5",
|
||||||
|
"6",
|
||||||
|
"7",
|
||||||
|
"8",
|
||||||
|
"9"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/energy/consumption/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.cumulativeDate": "1785502435",
|
||||||
|
"x.com.samsung.da.cumulativeUnit": "Wh",
|
||||||
|
"x.com.samsung.da.instantaneousPowerUnit": "W"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/file/information/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.timeoffset": "+02:00",
|
||||||
|
"x.com.samsung.supprtedtype": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/filter/airdustfilter/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.filterUsageResolution": "1",
|
||||||
|
"x.com.samsung.da.filterCapacity": "500",
|
||||||
|
"x.com.samsung.da.filterCapacityUnit": "Hour",
|
||||||
|
"x.com.samsung.da.filterResetType": [
|
||||||
|
"replaceable",
|
||||||
|
"washable"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.filterStatus": "normal",
|
||||||
|
"x.com.samsung.da.filterUsage": "44",
|
||||||
|
"x.com.samsung.da.filterDesiredUsage": "500",
|
||||||
|
"x.com.samsung.da.supportedFilterDesiredUsage": [
|
||||||
|
"180",
|
||||||
|
"300",
|
||||||
|
"500",
|
||||||
|
"700"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/humidity/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.humidity": "0",
|
||||||
|
"x.com.samsung.da.fivepercentHumidity": "53"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/information/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.otnDUID": "**REDACTED**",
|
||||||
|
"x.com.samsung.da.modelNum": "TP1X_DA-AC-RAC-01001_0000|10267841|60010514001911010E00492200902000",
|
||||||
|
"x.com.samsung.da.description": "TP1X_DA-AC-RAC-01001_0000",
|
||||||
|
"x.com.samsung.da.serialNum": "**REDACTED**",
|
||||||
|
"x.com.samsung.da.serialNumOption": "**REDACTED**",
|
||||||
|
"x.com.samsung.da.items": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "0",
|
||||||
|
"x.com.samsung.da.description": "Version",
|
||||||
|
"x.com.samsung.da.type": "Software",
|
||||||
|
"x.com.samsung.da.number": "02762A260401",
|
||||||
|
"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.newVersionAvailable": "0",
|
||||||
|
"x.com.samsung.da.number": "02678A24092500,FFFFFFFFFFFFFF"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "2",
|
||||||
|
"x.com.samsung.da.description": "Version",
|
||||||
|
"x.com.samsung.da.type": "Firmware",
|
||||||
|
"x.com.samsung.da.newVersionAvailable": "0",
|
||||||
|
"x.com.samsung.da.number": "FFFFFFFFFFFFFF,FFFFFFFFFFFFFF"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "3",
|
||||||
|
"x.com.samsung.da.description": "Version",
|
||||||
|
"x.com.samsung.da.type": "Firmware",
|
||||||
|
"x.com.samsung.da.newVersionAvailable": "0",
|
||||||
|
"x.com.samsung.da.number": "FFFFFFFFFFFFFF,FFFFFFFFFFFFFF"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.diagDumpType": "file",
|
||||||
|
"x.com.samsung.da.diagEndPoint": "SSM",
|
||||||
|
"x.com.samsung.da.diagLogType": [
|
||||||
|
"errCode",
|
||||||
|
"dump"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.diagMnid": "0AJT",
|
||||||
|
"x.com.samsung.da.diagSetupid": "AR2",
|
||||||
|
"x.com.samsung.da.diagProtocolType": "BLE_OCF",
|
||||||
|
"x.com.samsung.da.diagMinVersion": "3.0",
|
||||||
|
"x.com.samsung.da.diagTsId": "DA01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/keepnormalstate/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.keepnormal": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/light/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"mode": "On",
|
||||||
|
"supportedModes": [
|
||||||
|
"On",
|
||||||
|
"Off"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/mds/absencemonitoring/vs/0",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/mds/absencestate/vs/0",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/mode/convenient/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.modes": "Off",
|
||||||
|
"x.com.samsung.da.supportedModes": [
|
||||||
|
"Off",
|
||||||
|
"Sleep",
|
||||||
|
"Quiet",
|
||||||
|
"Speed",
|
||||||
|
"Nano",
|
||||||
|
"NanoSleep"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/mode/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.modes": [
|
||||||
|
"Cool"
|
||||||
|
],
|
||||||
|
"workingMode": "Cool",
|
||||||
|
"x.com.samsung.da.supportedModes": [
|
||||||
|
"Auto",
|
||||||
|
"Cool",
|
||||||
|
"Dry",
|
||||||
|
"Fan",
|
||||||
|
"Heat"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.options": [
|
||||||
|
"OptionCode_35880",
|
||||||
|
"Sleep_0",
|
||||||
|
"ArtificialWorking_Off",
|
||||||
|
"ComfortAICooling_Off",
|
||||||
|
"AiTempChanged_Off",
|
||||||
|
"AiTemp_240",
|
||||||
|
"Volume_Mute",
|
||||||
|
"StopAutoClean_Idle",
|
||||||
|
"SmartCoolClean_Off",
|
||||||
|
"ProgressSmartClean_0",
|
||||||
|
"FreezeAlarmSetting_Off",
|
||||||
|
"DesiredFreezeAlarm_240",
|
||||||
|
"WashAlarm_Off",
|
||||||
|
"ExtendOptionCode_215693",
|
||||||
|
"UpdateAllow_NotAllowed",
|
||||||
|
"DurationOn_240",
|
||||||
|
"OutdoorTemp_99",
|
||||||
|
"CoolCapa_20",
|
||||||
|
"WarmCapa_22",
|
||||||
|
"Autoclean_On",
|
||||||
|
"WelcomeCoolingState_Off",
|
||||||
|
"WelcomeHeatingState_Off",
|
||||||
|
"OutdoorConnection_Connected"
|
||||||
|
],
|
||||||
|
"rt": [
|
||||||
|
"x.com.samsung.da.mode"
|
||||||
|
],
|
||||||
|
"if": [
|
||||||
|
"oic.if.baseline",
|
||||||
|
"oic.if.a"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/option/airpurify/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.modes": "Off",
|
||||||
|
"x.com.samsung.da.supportedModes": [
|
||||||
|
"On",
|
||||||
|
"Off"
|
||||||
|
],
|
||||||
|
"rt": [
|
||||||
|
"x.com.samsung.da.option.airpurify"
|
||||||
|
],
|
||||||
|
"if": [
|
||||||
|
"oic.if.baseline",
|
||||||
|
"oic.if.a"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/option/autoclean/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.status": "Stop",
|
||||||
|
"x.com.samsung.da.supportedStatus": [
|
||||||
|
"Start",
|
||||||
|
"Stop"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.progress": "0",
|
||||||
|
"x.com.samsung.da.settingStatus": "On",
|
||||||
|
"x.com.samsung.da.supportedSettingStatus": [
|
||||||
|
"On",
|
||||||
|
"Off"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/option/muteonce/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"muteonce": "Off",
|
||||||
|
"rt": [
|
||||||
|
"x.com.samsung.da.option.muteonce"
|
||||||
|
],
|
||||||
|
"if": [
|
||||||
|
"oic.if.baseline",
|
||||||
|
"oic.if.a"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/personality/presence/vs/0",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/power/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.power": "On",
|
||||||
|
"operationNumber": "4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/realtimenotiforclient/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.timeforshortnoti": "0",
|
||||||
|
"x.com.samsung.da.longnotisubscription": "false",
|
||||||
|
"x.com.samsung.da.periodicnotisubscription": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/remotedatacontrol/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.status": "Off",
|
||||||
|
"x.com.samsung.da.connectionStatus": "Disconnected"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/remotetemperature/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.temperature": "",
|
||||||
|
"x.com.samsung.da.unit": "",
|
||||||
|
"x.com.samsung.da.error": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/reserverulesets/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.sets": "AEFFFFFFFF101E121EFFFF101EFFFF000001001F00010000001F0000009C00FFFF1E00",
|
||||||
|
"x.com.samsung.da.id": "RAC",
|
||||||
|
"x.com.samsung.da.version": "1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/selfcheck/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.supportedActions": [
|
||||||
|
"Start",
|
||||||
|
"Cancel"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.error": [
|
||||||
|
"DA_ERROR_NONE"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/temperature/control/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.increment": "1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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.current": "24.0",
|
||||||
|
"x.com.samsung.da.desired": "24.0",
|
||||||
|
"x.com.samsung.da.minimum": "16",
|
||||||
|
"x.com.samsung.da.maximum": "30",
|
||||||
|
"x.com.samsung.da.increment": "1",
|
||||||
|
"x.com.samsung.da.unit": "Celsius"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/welcome/temperature/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"operatingStatus": "None",
|
||||||
|
"requestId": "0000"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/wind/direction/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.modes": "All",
|
||||||
|
"x.com.samsung.da.supportedModes": [
|
||||||
|
"Fix",
|
||||||
|
"Up_And_Low",
|
||||||
|
"Left_And_Right",
|
||||||
|
"All"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/wind/strength/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.modes": "3",
|
||||||
|
"x.com.samsung.da.supportedModes": [
|
||||||
|
"0",
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"3",
|
||||||
|
"4"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.modesName": [
|
||||||
|
"Auto",
|
||||||
|
"Low",
|
||||||
|
"Mid",
|
||||||
|
"High",
|
||||||
|
"Turbo"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/otninformation/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.target": "",
|
||||||
|
"x.com.samsung.da.newVersionAvailable": "false",
|
||||||
|
"otnStatus": "None",
|
||||||
|
"flashingProgress": "0",
|
||||||
|
"otnCompleteDate": "noHistory",
|
||||||
|
"scheduledTime": "None",
|
||||||
|
"swVersionInfo": {
|
||||||
|
"platform": "Tizen Lite",
|
||||||
|
"oneUiVersion": "7.0 Air conditioner",
|
||||||
|
"osVersion": "4.0"
|
||||||
|
},
|
||||||
|
"otnList": [
|
||||||
|
{
|
||||||
|
"type": "WIFI",
|
||||||
|
"modelId": "ARA-KR-TP1-25-ARXX00",
|
||||||
|
"versions": [
|
||||||
|
"11260401"
|
||||||
|
],
|
||||||
|
"visVersion": "260401"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Micom",
|
||||||
|
"modelId": "845210267841FFFFFFFF",
|
||||||
|
"versions": [
|
||||||
|
"24092500",
|
||||||
|
"FFFFFFFF"
|
||||||
|
],
|
||||||
|
"visVersion": "240925"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Micom",
|
||||||
|
"modelId": "045210267841FFFFFFFF",
|
||||||
|
"versions": [
|
||||||
|
"24092500",
|
||||||
|
"FFFFFFFF"
|
||||||
|
],
|
||||||
|
"visVersion": "240925"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Micom",
|
||||||
|
"modelId": "FGCAN2",
|
||||||
|
"versions": [
|
||||||
|
"",
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"visVersion": "999999"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Micom",
|
||||||
|
"modelId": "FGCAN3",
|
||||||
|
"versions": [
|
||||||
|
"",
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"visVersion": "999999"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/timezone/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"timezoneid": "Europe/Prague",
|
||||||
|
"offset": "+02:00",
|
||||||
|
"DST": "ON"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/connectionconfig/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"autoReconnectionMinVersion": "1.0",
|
||||||
|
"autoReconnection": "true",
|
||||||
|
"autoReconnectionProtocolType": [
|
||||||
|
"helper_hotspot",
|
||||||
|
"ble_ocf"
|
||||||
|
],
|
||||||
|
"supportedWiFiAuthType": [
|
||||||
|
"OPEN",
|
||||||
|
"WEP",
|
||||||
|
"WPA-PSK",
|
||||||
|
"WPA2-PSK",
|
||||||
|
"SAE"
|
||||||
|
],
|
||||||
|
"supportedWiFiCryptoType": [
|
||||||
|
"TKIP",
|
||||||
|
"AES",
|
||||||
|
"WEP-64",
|
||||||
|
"WEP-128"
|
||||||
|
],
|
||||||
|
"supportedWiFiFreq": [
|
||||||
|
"2.4G"
|
||||||
|
],
|
||||||
|
"calmConnectionCare": {
|
||||||
|
"version": "1.0",
|
||||||
|
"role": [
|
||||||
|
"things"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/wirelessinfo/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"macaddressWiFi": "**REDACTED**",
|
||||||
|
"macaddressBLE": "**REDACTED**",
|
||||||
|
"connectedApSsid": "REDACTED_SSID"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/quickcontrol/info/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"supportedVersion": "1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/dginformation/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"enrolmentstatus": "Unknown",
|
||||||
|
"devicestate": "Unknown",
|
||||||
|
"lockstatus": "Unknown",
|
||||||
|
"nextduedate": "",
|
||||||
|
"workingminutes": 0,
|
||||||
|
"paymentinfo": {
|
||||||
|
"emiplan": "Unknown",
|
||||||
|
"currency": "Unknown",
|
||||||
|
"totalemi": 0,
|
||||||
|
"totalemipaid": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Vendored
+759
@@ -0,0 +1,759 @@
|
|||||||
|
{
|
||||||
|
"device0": [
|
||||||
|
{
|
||||||
|
"rt": [
|
||||||
|
"x.com.samsung.devcol",
|
||||||
|
"oic.wk.col"
|
||||||
|
],
|
||||||
|
"if": [
|
||||||
|
"oic.if.baseline",
|
||||||
|
"oic.if.ll",
|
||||||
|
"oic.if.b"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/realtimenotiforclient/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.timeforshortnoti": "0",
|
||||||
|
"x.com.samsung.da.longnotisubscription": "false",
|
||||||
|
"x.com.samsung.da.periodicnotisubscription": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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-08-01T21:32:45",
|
||||||
|
"x.com.samsung.da.state": "Deleted"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/temperatures/indoor/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.type": "Water",
|
||||||
|
"x.com.samsung.da.desired": "5.0",
|
||||||
|
"x.com.samsung.da.current": "30.0",
|
||||||
|
"x.com.samsung.da.maximum": "25.0",
|
||||||
|
"x.com.samsung.da.minimum": "5.0",
|
||||||
|
"x.com.samsung.da.increment": "0.5",
|
||||||
|
"x.com.samsung.da.offset": "0.0",
|
||||||
|
"x.com.samsung.da.unit": "Celsius"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/temperatures/dhw/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.type": "Water",
|
||||||
|
"x.com.samsung.da.unit": "Celsius",
|
||||||
|
"x.com.samsung.da.desired": "40.0",
|
||||||
|
"x.com.samsung.da.current": "38.0",
|
||||||
|
"x.com.samsung.da.maximum": "62.0",
|
||||||
|
"x.com.samsung.da.minimum": "40.0",
|
||||||
|
"x.com.samsung.da.increment": "0.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/diagnosis/vs/0",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/energy/consumption/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.cumulativePower": "2448844",
|
||||||
|
"x.com.samsung.da.cumulativeSavedPower": "0",
|
||||||
|
"x.com.samsung.da.cumulativeUnit": "Wh",
|
||||||
|
"x.com.samsung.da.cumulativePowerType": "individual"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/mode/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.supportedModes": [
|
||||||
|
"Cool",
|
||||||
|
"Heat",
|
||||||
|
"Auto"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.modes": [
|
||||||
|
"Cool"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.options": [
|
||||||
|
"OutdoorTemp_80",
|
||||||
|
"KeyInputPermit_On",
|
||||||
|
"ModePermit_NoLimit",
|
||||||
|
"Thermostat_CoolHeat_Off"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.supportedOptions": [
|
||||||
|
"Thermostat_CoolHeat",
|
||||||
|
"DurationOn",
|
||||||
|
"KeyInputPermit",
|
||||||
|
"ModePermit",
|
||||||
|
"Volume",
|
||||||
|
"OutdoorTemp"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/mode/dhw/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.supportedModes": [
|
||||||
|
"Eco",
|
||||||
|
"Std",
|
||||||
|
"Power",
|
||||||
|
"Force"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.modes": [
|
||||||
|
"Eco"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.options": [
|
||||||
|
"Thermostat_Dhw_Off",
|
||||||
|
"KeyInputPermit_On"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.supportedOptions": [
|
||||||
|
"Thermostat_Dhw",
|
||||||
|
"KeyInputPermit"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/power/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.power": "Off",
|
||||||
|
"causeSource": "SMTS"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/power/dhw/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.power": "On",
|
||||||
|
"causeSource": "SMTS"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/information/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.modelNum": "TP1X_DA_AC_EHS_01001_0000|10250141|60070105001711034A00010000002000",
|
||||||
|
"x.com.samsung.da.description": "TP1X_DA_AC_EHS_01001_0000",
|
||||||
|
"x.com.samsung.da.serialNum": "**REDACTED**",
|
||||||
|
"x.com.samsung.da.otnDUID": "**REDACTED**",
|
||||||
|
"x.com.samsung.da.diagProtocolType": "BLE_OCF",
|
||||||
|
"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": "AE0",
|
||||||
|
"x.com.samsung.da.diagMinVersion": "3.0",
|
||||||
|
"x.com.samsung.da.diagTsId": "DA01",
|
||||||
|
"x.com.samsung.da.serialNumOption": "**REDACTED**",
|
||||||
|
"x.com.samsung.da.items": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.id": "0",
|
||||||
|
"x.com.samsung.da.description": "Version",
|
||||||
|
"x.com.samsung.da.type": "Software",
|
||||||
|
"x.com.samsung.da.number": "02504A260402",
|
||||||
|
"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": "02501A24062401,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": "02572A23081000,02549A10000800"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/file/information/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.timeoffset": "+01:00",
|
||||||
|
"x.com.samsung.supprtedtype": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/configuration/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.region": "0000000000"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/drlc/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.drlcLevel": "0",
|
||||||
|
"x.com.samsung.da.durationminutes": "0",
|
||||||
|
"x.com.samsung.da.drlcStartTime": "1970-01-01T00:00:00Z",
|
||||||
|
"x.com.samsung.da.override": "Off",
|
||||||
|
"x.com.samsung.da.realSaving": "Off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/availablecontrolsets/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.sets": "0001003200FA0B0190026C0C0000CE32",
|
||||||
|
"x.com.samsung.da.id": "EHS",
|
||||||
|
"x.com.samsung.da.version": "1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/da/softreset/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.softwarereset": "false"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": "AEH-WW-TP1-22-AE6000",
|
||||||
|
"versions": [
|
||||||
|
"17260402"
|
||||||
|
],
|
||||||
|
"visVersion": "260402"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Micom",
|
||||||
|
"modelId": "040010250141FFFFFFFF",
|
||||||
|
"versions": [
|
||||||
|
"24062401",
|
||||||
|
"FFFFFFFF"
|
||||||
|
],
|
||||||
|
"visVersion": "240624"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Micom",
|
||||||
|
"modelId": "04001025724110254941",
|
||||||
|
"versions": [
|
||||||
|
"23081000",
|
||||||
|
"10000800"
|
||||||
|
],
|
||||||
|
"visVersion": "230810"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/timezone/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"timezoneid": "Europe/London",
|
||||||
|
"offset": "+01:00",
|
||||||
|
"DST": "ON"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/option/muteonce/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"muteonce": "Off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/reserverulesets/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.sets": "0EFFFFFFFF05190F370B283E",
|
||||||
|
"x.com.samsung.da.id": "EHS",
|
||||||
|
"x.com.samsung.da.version": "1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/connectionconfig/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"autoReconnectionMinVersion": "1.0",
|
||||||
|
"autoReconnection": "true",
|
||||||
|
"autoReconnectionProtocolType": [
|
||||||
|
"helper_hotspot",
|
||||||
|
"ble_ocf"
|
||||||
|
],
|
||||||
|
"supportedWiFiAuthType": [
|
||||||
|
"OPEN",
|
||||||
|
"WEP",
|
||||||
|
"WPA-PSK",
|
||||||
|
"WPA2-PSK",
|
||||||
|
"SAE"
|
||||||
|
],
|
||||||
|
"supportedWiFiCryptoType": [
|
||||||
|
"TKIP",
|
||||||
|
"AES",
|
||||||
|
"WEP-64",
|
||||||
|
"WEP-128"
|
||||||
|
],
|
||||||
|
"supportedWiFiFreq": [
|
||||||
|
"2.4G"
|
||||||
|
],
|
||||||
|
"calmConnectionCare": {
|
||||||
|
"version": "1.0",
|
||||||
|
"role": [
|
||||||
|
"things"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/option/outgoing/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.away": "Off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/sac/installationinfo/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"installationOptions": [
|
||||||
|
{
|
||||||
|
"id": "0",
|
||||||
|
"option": "12300000000000000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "1",
|
||||||
|
"option": "20010000000000000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "2",
|
||||||
|
"option": "50000000000000000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "3",
|
||||||
|
"option": "30000000000000000000"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"installationDeviceNum": [
|
||||||
|
{
|
||||||
|
"id": "0",
|
||||||
|
"number": "01"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "1",
|
||||||
|
"number": "01"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "2",
|
||||||
|
"number": "00"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outdoorInfo": [
|
||||||
|
{
|
||||||
|
"id": "0",
|
||||||
|
"info": "02572A230810",
|
||||||
|
"serial": "**REDACTED**"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "1",
|
||||||
|
"info": "000000000000",
|
||||||
|
"serial": "**REDACTED**"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "2",
|
||||||
|
"info": "000000000000",
|
||||||
|
"serial": "**REDACTED**"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "3",
|
||||||
|
"info": "000000000000",
|
||||||
|
"serial": "**REDACTED**"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"mcuInfo": [
|
||||||
|
{
|
||||||
|
"id": "0",
|
||||||
|
"info": "000000000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "1",
|
||||||
|
"info": "000000000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "2",
|
||||||
|
"info": "000000000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "3",
|
||||||
|
"info": "000000000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "4",
|
||||||
|
"info": "000000000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "5",
|
||||||
|
"info": "000000000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "6",
|
||||||
|
"info": "000000000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "7",
|
||||||
|
"info": "000000000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "8",
|
||||||
|
"info": "000000000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "9",
|
||||||
|
"info": "000000000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10",
|
||||||
|
"info": "000000000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "11",
|
||||||
|
"info": "000000000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "12",
|
||||||
|
"info": "000000000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "13",
|
||||||
|
"info": "000000000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "14",
|
||||||
|
"info": "000000000000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "15",
|
||||||
|
"info": "000000000000"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/ehsfsv/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"setting": "0407010A01017202EE02260101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "0408010A010096017200960101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "041B010A0101F402BC026C0101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "041C010A01012C019001900101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "07DB010A01FF380032FFE20101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "07DC010A01006400C800960101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "07E5010A0100AA02EE01540101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "07E6010A0100AA02EE014A0101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "07EF010A0100AA02EE028A0101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "07F0010A0100AA02EE00AA0101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "082B0101000000000400000101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "082C0101000000000400000101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "082D0101000001000400040101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "0BC30101000000000200020101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "0BFF0101000000000100000101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "0FAB0101000000000100000101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "0FAC010A01FF6A00C800000101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "0FB50101000000000200000101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "0FCA010A010032009600640101"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setting": "0FDD0101000000000100000101"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/ehscycle/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"indoor": [
|
||||||
|
{
|
||||||
|
"cycledata": "4B055455050500000000000000000000000000000004CCA70000005D05054B",
|
||||||
|
"datetime": "2026-08-01T21:23:08"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cycledata": "4B055454050500000000000000000000000000000004CCAC0000005D05054B",
|
||||||
|
"datetime": "2026-08-01T21:28:08"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outdoor": [
|
||||||
|
{
|
||||||
|
"cycledata": "00000000555A4A53490207D000000000FFFF00480046325700000000",
|
||||||
|
"datetime": "2026-08-01T21:23:08"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cycledata": "00000000555A4952490207D000000000000000480046325600000000",
|
||||||
|
"datetime": "2026-08-01T21:28:08"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"unit": "Celsius"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/option/dhwdisplay/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.dhwdisplay": "Show"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/actions/zone1/vs/0",
|
||||||
|
"rep": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "/actions/dhw/vs/0",
|
||||||
|
"rep": {
|
||||||
|
"x.com.samsung.da.items": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.timelineId": "0",
|
||||||
|
"x.com.samsung.da.module": "DHW",
|
||||||
|
"x.com.samsung.da.temperatureType": "Water",
|
||||||
|
"x.com.samsung.da.dayofWeek": [
|
||||||
|
"Sun"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.timeblocks": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.timeblockId": "0",
|
||||||
|
"x.com.samsung.da.start": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.time": "03:00",
|
||||||
|
"x.com.samsung.da.power": "On",
|
||||||
|
"x.com.samsung.da.mode": "Std",
|
||||||
|
"x.com.samsung.da.desired": "45.0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.end": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.time": "05:00",
|
||||||
|
"x.com.samsung.da.power": "On",
|
||||||
|
"x.com.samsung.da.mode": "Eco",
|
||||||
|
"x.com.samsung.da.desired": "40.0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.timelineId": "1",
|
||||||
|
"x.com.samsung.da.module": "DHW",
|
||||||
|
"x.com.samsung.da.temperatureType": "Water",
|
||||||
|
"x.com.samsung.da.dayofWeek": [
|
||||||
|
"Mon"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.timeblocks": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.timeblockId": "0",
|
||||||
|
"x.com.samsung.da.start": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.time": "03:00",
|
||||||
|
"x.com.samsung.da.power": "On",
|
||||||
|
"x.com.samsung.da.mode": "Std",
|
||||||
|
"x.com.samsung.da.desired": "45.0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.end": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.time": "05:00",
|
||||||
|
"x.com.samsung.da.power": "On",
|
||||||
|
"x.com.samsung.da.mode": "Eco",
|
||||||
|
"x.com.samsung.da.desired": "40.0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.timelineId": "2",
|
||||||
|
"x.com.samsung.da.module": "DHW",
|
||||||
|
"x.com.samsung.da.temperatureType": "Water",
|
||||||
|
"x.com.samsung.da.dayofWeek": [
|
||||||
|
"Tue"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.timeblocks": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.timeblockId": "0",
|
||||||
|
"x.com.samsung.da.start": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.time": "03:00",
|
||||||
|
"x.com.samsung.da.power": "On",
|
||||||
|
"x.com.samsung.da.mode": "Std",
|
||||||
|
"x.com.samsung.da.desired": "45.0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.end": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.time": "05:00",
|
||||||
|
"x.com.samsung.da.power": "On",
|
||||||
|
"x.com.samsung.da.mode": "Eco",
|
||||||
|
"x.com.samsung.da.desired": "40.0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.timelineId": "3",
|
||||||
|
"x.com.samsung.da.module": "DHW",
|
||||||
|
"x.com.samsung.da.temperatureType": "Water",
|
||||||
|
"x.com.samsung.da.dayofWeek": [
|
||||||
|
"Wed"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.timeblocks": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.timeblockId": "0",
|
||||||
|
"x.com.samsung.da.start": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.time": "03:00",
|
||||||
|
"x.com.samsung.da.power": "On",
|
||||||
|
"x.com.samsung.da.mode": "Std",
|
||||||
|
"x.com.samsung.da.desired": "45.0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.end": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.time": "05:00",
|
||||||
|
"x.com.samsung.da.power": "On",
|
||||||
|
"x.com.samsung.da.mode": "Eco",
|
||||||
|
"x.com.samsung.da.desired": "40.0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.timelineId": "4",
|
||||||
|
"x.com.samsung.da.module": "DHW",
|
||||||
|
"x.com.samsung.da.temperatureType": "Water",
|
||||||
|
"x.com.samsung.da.dayofWeek": [
|
||||||
|
"Thu"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.timeblocks": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.timeblockId": "0",
|
||||||
|
"x.com.samsung.da.start": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.time": "03:00",
|
||||||
|
"x.com.samsung.da.power": "On",
|
||||||
|
"x.com.samsung.da.mode": "Std",
|
||||||
|
"x.com.samsung.da.desired": "45.0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.end": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.time": "05:00",
|
||||||
|
"x.com.samsung.da.power": "On",
|
||||||
|
"x.com.samsung.da.mode": "Eco",
|
||||||
|
"x.com.samsung.da.desired": "40.0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.timelineId": "5",
|
||||||
|
"x.com.samsung.da.module": "DHW",
|
||||||
|
"x.com.samsung.da.temperatureType": "Water",
|
||||||
|
"x.com.samsung.da.dayofWeek": [
|
||||||
|
"Fri"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.timeblocks": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.timeblockId": "0",
|
||||||
|
"x.com.samsung.da.start": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.time": "03:00",
|
||||||
|
"x.com.samsung.da.power": "On",
|
||||||
|
"x.com.samsung.da.mode": "Std",
|
||||||
|
"x.com.samsung.da.desired": "45.0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.end": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.time": "05:00",
|
||||||
|
"x.com.samsung.da.power": "On",
|
||||||
|
"x.com.samsung.da.mode": "Eco",
|
||||||
|
"x.com.samsung.da.desired": "40.0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.timelineId": "6",
|
||||||
|
"x.com.samsung.da.module": "DHW",
|
||||||
|
"x.com.samsung.da.temperatureType": "Water",
|
||||||
|
"x.com.samsung.da.dayofWeek": [
|
||||||
|
"Sat"
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.timeblocks": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.timeblockId": "0",
|
||||||
|
"x.com.samsung.da.start": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.time": "03:00",
|
||||||
|
"x.com.samsung.da.power": "On",
|
||||||
|
"x.com.samsung.da.mode": "Std",
|
||||||
|
"x.com.samsung.da.desired": "45.0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x.com.samsung.da.end": [
|
||||||
|
{
|
||||||
|
"x.com.samsung.da.time": "05:00",
|
||||||
|
"x.com.samsung.da.power": "On",
|
||||||
|
"x.com.samsung.da.mode": "Eco",
|
||||||
|
"x.com.samsung.da.desired": "40.0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"state_keys": [
|
||||||
|
"alarm_code",
|
||||||
|
"buzzer_sound",
|
||||||
|
"child_lock",
|
||||||
|
"completion_minutes",
|
||||||
|
"cycle",
|
||||||
|
"cycle_active",
|
||||||
|
"delay_start_hours",
|
||||||
|
"diagnosis_status",
|
||||||
|
"energy_kwh",
|
||||||
|
"energy_saved_kwh",
|
||||||
|
"finish_time",
|
||||||
|
"firmware_update",
|
||||||
|
"job_beginning_status",
|
||||||
|
"machine_state",
|
||||||
|
"power_switch",
|
||||||
|
"progress",
|
||||||
|
"progress_percentage",
|
||||||
|
"remote_control",
|
||||||
|
"sanitize",
|
||||||
|
"wrinkle_prevent"
|
||||||
|
]
|
||||||
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"state_keys": [
|
||||||
|
"air_quality_standard",
|
||||||
|
"alarm_code",
|
||||||
|
"battery",
|
||||||
|
"battery_charging",
|
||||||
|
"clean_level",
|
||||||
|
"co2",
|
||||||
|
"dnd",
|
||||||
|
"dnd_end",
|
||||||
|
"dnd_start",
|
||||||
|
"dust",
|
||||||
|
"fine_dust",
|
||||||
|
"humidity",
|
||||||
|
"odor",
|
||||||
|
"super_fine_dust"
|
||||||
|
]
|
||||||
|
}
|
||||||
+2
@@ -6,6 +6,8 @@
|
|||||||
"air_purify",
|
"air_purify",
|
||||||
"alarm_code",
|
"alarm_code",
|
||||||
"auto_clean",
|
"auto_clean",
|
||||||
|
"auto_clean_progress",
|
||||||
|
"auto_clean_running",
|
||||||
"beep",
|
"beep",
|
||||||
"clean_level",
|
"clean_level",
|
||||||
"climate",
|
"climate",
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
"air_filter_usage_hours",
|
"air_filter_usage_hours",
|
||||||
"alarm_code",
|
"alarm_code",
|
||||||
"auto_clean",
|
"auto_clean",
|
||||||
|
"auto_clean_progress",
|
||||||
|
"auto_clean_running",
|
||||||
"beep",
|
"beep",
|
||||||
"climate",
|
"climate",
|
||||||
"current_temperature_c",
|
"current_temperature_c",
|
||||||
@@ -14,6 +16,8 @@
|
|||||||
"firmware_update",
|
"firmware_update",
|
||||||
"humidity",
|
"humidity",
|
||||||
"mute_once",
|
"mute_once",
|
||||||
|
"odor_controller_active",
|
||||||
|
"odor_controller_progress",
|
||||||
"power_watts",
|
"power_watts",
|
||||||
"tropical_night_mode"
|
"tropical_night_mode"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"diagnosis_status",
|
"diagnosis_status",
|
||||||
"display_light",
|
"display_light",
|
||||||
"energy_kwh",
|
"energy_kwh",
|
||||||
|
"filter_alarm_time",
|
||||||
"filter_time",
|
"filter_time",
|
||||||
"good_sleep",
|
"good_sleep",
|
||||||
"humidity",
|
"humidity",
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"state_keys": [
|
||||||
|
"air_monitoring",
|
||||||
|
"alarm_code",
|
||||||
|
"auto_clean_legacy",
|
||||||
|
"beep",
|
||||||
|
"climate",
|
||||||
|
"current_temperature_c",
|
||||||
|
"diagnosis_status",
|
||||||
|
"display_light",
|
||||||
|
"energy_kwh",
|
||||||
|
"filter_alarm_time",
|
||||||
|
"filter_time",
|
||||||
|
"good_sleep",
|
||||||
|
"humidity",
|
||||||
|
"outdoor_temperature",
|
||||||
|
"spi"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
"diagnosis_status",
|
"diagnosis_status",
|
||||||
"display_light",
|
"display_light",
|
||||||
"energy_kwh",
|
"energy_kwh",
|
||||||
|
"filter_alarm_time",
|
||||||
"filter_time",
|
"filter_time",
|
||||||
"good_sleep",
|
"good_sleep",
|
||||||
"humidity",
|
"humidity",
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
"air_purify",
|
"air_purify",
|
||||||
"alarm_code",
|
"alarm_code",
|
||||||
"auto_clean",
|
"auto_clean",
|
||||||
|
"auto_clean_progress",
|
||||||
|
"auto_clean_running",
|
||||||
"clean_level",
|
"clean_level",
|
||||||
"climate",
|
"climate",
|
||||||
"current_temperature_c",
|
"current_temperature_c",
|
||||||
@@ -20,6 +22,8 @@
|
|||||||
"motion_detect_wind_active",
|
"motion_detect_wind_active",
|
||||||
"motion_detect_wind_mode",
|
"motion_detect_wind_mode",
|
||||||
"mute_once",
|
"mute_once",
|
||||||
|
"odor_controller_active",
|
||||||
|
"odor_controller_progress",
|
||||||
"power_watts",
|
"power_watts",
|
||||||
"selfcheck_error",
|
"selfcheck_error",
|
||||||
"selfcheck_result",
|
"selfcheck_result",
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
"air_filter_usage_hours",
|
"air_filter_usage_hours",
|
||||||
"alarm_code",
|
"alarm_code",
|
||||||
"auto_clean",
|
"auto_clean",
|
||||||
|
"auto_clean_progress",
|
||||||
|
"auto_clean_running",
|
||||||
"beep",
|
"beep",
|
||||||
"climate",
|
"climate",
|
||||||
"current_temperature_c",
|
"current_temperature_c",
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
"air_filter_usage_hours",
|
"air_filter_usage_hours",
|
||||||
"alarm_code",
|
"alarm_code",
|
||||||
"auto_clean",
|
"auto_clean",
|
||||||
|
"auto_clean_progress",
|
||||||
|
"auto_clean_running",
|
||||||
"beep",
|
"beep",
|
||||||
"climate",
|
"climate",
|
||||||
"current_temperature_c",
|
"current_temperature_c",
|
||||||
@@ -13,6 +15,8 @@
|
|||||||
"energy_kwh",
|
"energy_kwh",
|
||||||
"firmware_update",
|
"firmware_update",
|
||||||
"humidity",
|
"humidity",
|
||||||
|
"odor_controller_active",
|
||||||
|
"odor_controller_progress",
|
||||||
"power_energy_kwh",
|
"power_energy_kwh",
|
||||||
"power_watts",
|
"power_watts",
|
||||||
"tropical_night_mode"
|
"tropical_night_mode"
|
||||||
|
|||||||
Loaded 100 of 192 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user