Issue #364: several reporters got the "downloaded cycles not set up" Repair despite never meaning to use the feature -- one device appears to auto-populate a slot from a SmartThings-provided example. The two reporters who did complete setup successfully both hit the same root cause for their earlier failures: the SmartThings app has two similarly-named screens ("Cycle", which lists everything including local courses, and "Download cycles", the one that actually matters here), and nothing in our instructions said to use the second one specifically. Global disable (CONF_CLOUD_COURSES_ENABLED, entry.options, default on): - New coordinator.cloud_courses_enabled property, mirroring CONF_LEARN_MODES' shape -- off stops the Repair and stops offering already-named programs as cycles, without discarding anything already learned or named. - Deliberately does NOT stop _observe_cloud_courses' passive recording: guided/manual setup depend on live observation to detect a newly selected program at all, and leaving it running means turning the option back on immediately surfaces anything set up in the meantime instead of asking the user to redo it. Documented on the const and on the property. - New __init__.py options-update listener calls a new coordinator._on_cloud_courses_changed(), which both clears the canonical-view cache (memoized, so a stale view would otherwise keep answering with pre-toggle state -- caught by two failing tests before this) and refreshes the Repair. Nothing else needed this because every other option is read live on its own next use; cloud courses is the only one with standing Repair/cache state to refresh immediately rather than on the next unrelated change. - Toggle exposed in Device settings as "Offer downloaded cycles", alongside prose explaining why some devices show the Repair unprompted. Instructions, in every shipped locale (en/de/es/it/cs/nl/ko) -- otherwise a locale missing the new/changed strings would silently show English or the old text, the same gap issue #376 already tests for: - Every guided-setup screen, the manual edit form, and the Repair itself now say explicitly: open the SmartThings app (not the appliance), and tap "Download cycles" specifically -- a separate row from "Cycle", further down the screen -- not the general cycle picker. Also states plainly that the appliance doesn't need to be nearby or running the cycle, just powered on and connected. SmartThings' own screen names are kept in English in every locale (verified only in the English app via the reporter's screenshots; translating them without evidence of what Samsung's own localized app shows would be a guess this codebase's translations otherwise avoid). - The Repair's description now also points at the new toggle for anyone who doesn't want the feature at all. - The "cloud_courses" menu screen shows a note when the option is currently off, since guided/manual setup still work in that state but nothing named there will appear as a selectable cycle until it's turned back on. Tests: coordinator-level tests cover the option defaulting on, suppressing a new Repair, clearing an already-open one, hiding/ restoring the cycle-select entry as the option flips (which caught the canonical-cache bug above), and that passive observation keeps running regardless of the option. Options-flow tests cover the new field's default and that it persists. Translation catalog tests (test_every_language_mirrors_the_english_catalog et al.) cover every locale's topology and placeholders for the changed/added strings. Full suite (1583 tests), ruff, and `ty check custom_components tests` (CI's exact invocation) all pass.
143 lines
6.4 KiB
Python
143 lines
6.4 KiB
Python
DOMAIN = "localthings"
|
|
|
|
PLATFORMS = [
|
|
"sensor",
|
|
"binary_sensor",
|
|
"switch",
|
|
"number",
|
|
"select",
|
|
"button",
|
|
"time",
|
|
"climate",
|
|
"fan",
|
|
"water_heater",
|
|
]
|
|
|
|
CONF_HOST = "host"
|
|
CONF_PORT = "port"
|
|
CONF_CA_CERT_PEM = "ca_cert_pem"
|
|
CONF_CA_KEY_PEM = "ca_key_pem"
|
|
CONF_LEAF_CERT_PEM = "leaf_cert_pem"
|
|
CONF_LEAF_KEY_PEM = "leaf_key_pem"
|
|
|
|
# Device identity, resolved once by the config flow's probe and persisted
|
|
# on the entry (issue #236) -- what the coordinator mints registry keys
|
|
# from at __init__ time, before any poll has happened. Without them,
|
|
# anything registering before the first poll (e.g. the connection-mode
|
|
# sensor) got keyed on the IP address permanently.
|
|
#
|
|
# CONF_SERIAL is the resolved serial (registry.identity.resolve_serial's
|
|
# output, the host itself for a placeholder-serial board -- issues
|
|
# #83/#189), so it matches what _run_discovery computes on the first poll.
|
|
CONF_SERIAL = "serial"
|
|
CONF_MODEL = "model"
|
|
CONF_MANUFACTURER = "manufacturer"
|
|
CONF_DEVICE_TYPE = "device_type"
|
|
|
|
# entry.data key: modes this device reported itself in but never advertised
|
|
# in the same resource's supportedModes (issue #327). Stored on the entry
|
|
# rather than kept in memory so a mode the device only names while it is
|
|
# active survives a restart -- see learned.py. Shape:
|
|
# {actual_href: [code, ...]}.
|
|
CONF_LEARNED_MODES = "learned_modes"
|
|
|
|
# Options-flow key: whether learned modes are remembered and offered.
|
|
# Defaults to on; turning it off stops both halves at once (nothing new is
|
|
# learned, nothing already learned is offered) without discarding what was
|
|
# already remembered -- the options flow's reset step does that.
|
|
CONF_LEARN_MODES = "learn_device_modes"
|
|
DEFAULT_LEARN_MODES = True
|
|
|
|
# entry.data key: cloud "Download" programs discovered on a laundry device
|
|
# (issue #342). Same rationale as CONF_LEARNED_MODES -- a program's full
|
|
# replay payload is only ever visible while the device happens to be sitting
|
|
# on it, so it has to survive a restart -- but a richer shape, because a
|
|
# cloud program also needs a user-supplied name and the device's own
|
|
# Download course code. See cloudcourse.py, which owns the shape. Shape:
|
|
# {"download_course": "87"|null, "slots": {slot: {"blob": ..., "name": ...}}}
|
|
CONF_CLOUD_COURSES = "cloud_courses"
|
|
|
|
# Options-flow key: whether downloaded programs are offered as selectable
|
|
# cycles and nagged about via the "not set up yet" Repair (issue #364).
|
|
# Defaults to on. Unlike CONF_LEARN_MODES this does not also stop passive
|
|
# observation -- a device that merely *advertises* download slots without
|
|
# the owner ever meaning to use them (SmartThings appears to seed one from
|
|
# the cloud automatically, per #364's reporters) is exactly the case this
|
|
# exists for, and turning it off is the fix. Guided/manual setup stay
|
|
# reachable and still record what they see either way: they are a deliberate
|
|
# per-session action, not the passive background behavior this silences, and
|
|
# leaving them working means flipping the option back on immediately surfaces
|
|
# anything set up in the meantime instead of asking the user to redo it. See
|
|
# coordinator.cloud_courses_enabled for exactly what it gates.
|
|
CONF_CLOUD_COURSES_ENABLED = "cloud_courses_enabled"
|
|
DEFAULT_CLOUD_COURSES_ENABLED = True
|
|
|
|
# Options-flow key (entry.options, not entry.data): lets a user override
|
|
# the device-wide remote-control-off write block for a specific device
|
|
# (issue #54). Some devices accept certain writes even while reporting
|
|
# remote control off (e.g. a washer's default detergent dosing), so the
|
|
# blanket-block assumption doesn't hold everywhere. Defaults to False
|
|
# (block stays on).
|
|
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) reports a
|
|
# new value. Devices commonly revise their remaining-time estimate by a
|
|
# minute or two throughout a cycle, and finish_time = now() + remaining
|
|
# drifts with the poll interval between revisions -- both push a fresh
|
|
# state far more often than the estimate is meaningfully different. 0
|
|
# disables the gate.
|
|
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,
|
|
# depending on firmware (newer builds answer on 49154/49155, older ones as
|
|
# low as 49153) -- swept for a live UDP port before the expensive DTLS
|
|
# handshake.
|
|
PROBE_PORT_RANGE = list(range(49152, 49161))
|
|
|
|
# Ports we've historically seen complete a DTLS handshake; tried first when
|
|
# more than one port in the range looks live.
|
|
PREFERRED_PROBE_PORTS = [49154, 49155]
|
|
|
|
# Per-port timeout for the cheap UDP liveness sweep. Closed ports return an
|
|
# ICMP port-unreachable almost immediately; a live-but-silent port is only
|
|
# detected by this timeout elapsing, so keep it short. Only reached as the
|
|
# fallback for when the ClientHello probe below confirms nothing.
|
|
LIVENESS_PROBE_TIMEOUT_S = 1.5
|
|
|
|
# Per-port budget for the DTLS ClientHello probe (smartthings-local >=
|
|
# 0.1.2), the primary port-detection gate. A real server answers with a
|
|
# HelloVerifyRequest in ~1 RTT; the budget only bounds how long a silent
|
|
# port takes to give up. 3s covers two retransmits on a slow LAN.
|
|
CLIENTHELLO_PROBE_TIMEOUT_S = 3.0
|
|
CLIENTHELLO_PROBE_RETRIES = 2
|
|
|
|
# The whole port range is probed at once: each stateless probe is bounded
|
|
# by CLIENTHELLO_PROBE_TIMEOUT_S (unlike a full handshake's 12s), so the
|
|
# sweep costs one probe's wall clock, not the sum of the range. Capped so a
|
|
# widened PROBE_PORT_RANGE can't spawn an unbounded thread pool.
|
|
PROBE_MAX_WORKERS = 12
|
|
|
|
# Deadline for the blockwise /device/0 GET during the config-flow probe.
|
|
# The slowest device observed returns a full dump in ~8s.
|
|
PROBE_GET_TIMEOUT_S = 10.0
|
|
|
|
# Base for the local (client-side) DTLS source port, distinct from the
|
|
# destination probe ports above -- see coordinator._local_source_port for
|
|
# why a fixed per-device source port matters. Mirrors the upstream
|
|
# smartthings-local reference bridge. Requires smartthings-local >= 0.1.1.
|
|
DTLS_LOCAL_PORT_BASE = 49700
|
|
|
|
SUMMARY_INTERVAL_S = 30.0
|
|
|
|
DEVICE_SUPPORT_ISSUE_URL = (
|
|
"https://github.com/mbillow/localthings/issues/new?template=device-support.yml"
|
|
)
|
|
|
|
# Service names (services.py), shared with config_flow.py so the
|
|
# options-flow debug panel calls the exact same service a user could call
|
|
# from an automation (issue #300) -- one code path performs a raw write.
|
|
SERVICE_WRITE_RESOURCE = "write_resource"
|
|
SERVICE_READ_RESOURCE = "read_resource"
|