refactor: replace exact-href door/temp/icemaker caps with generic pattern caps
Delete dead: DOOR_FRIDGE, DOOR_FREEZER, TEMP_FRIDGE/FREEZER_CURRENT/SETPOINT, ICEMAKER_ONE, ICEMAKER_TWO, ICE2_MODES, temperature bounds constants. Add: TEMP_CURRENT_GENERIC (href_prefix=/temperature/current/), TEMP_SETPOINT_GENERIC (href_prefix=/temperature/desired/, write derives CoAP path from href), ICEMAKER_GENERIC (href_prefix=/icemaker/, match_fn gates on iceMaker.state field). Key derivation strips 'vs' segments alongside digits so icemaker hrefs like /icemaker/one/vs/0 produce icemaker_one_state not icemaker_one_vs_state. write_fn signature extended: adapter now passes href as 3rd positional arg; all existing write_fns updated to accept href=None. Fridge golden: old ice1_*/ice2_*/fridge_*/freezer_* keys replaced by icemaker_one_*/icemaker_two_*/temperature_current_*/temperature_desired_*.
This commit is contained in:
1 parent
9e5a169c82
commit
785154eb83
10 files changed
+116
-189
No files matched your search
@@ -119,7 +119,7 @@ def _replace_in_options(options, prefix, new_value):
|
||||
# Write functions
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def _oven_setpoint_write(p, rep):
|
||||
def _oven_setpoint_write(p, rep, href=None):
|
||||
"""RMW write to /temperatures/vs/0 items array."""
|
||||
try:
|
||||
temp = float(p)
|
||||
@@ -136,7 +136,7 @@ def _oven_setpoint_write(p, rep):
|
||||
return ['temperatures', 'vs', '0'], {'x.com.samsung.da.items': items}
|
||||
|
||||
|
||||
def _cook_time_write(p, rep):
|
||||
def _cook_time_write(p, rep, href=None):
|
||||
"""Write operationTime + remainingTime (H:MM:SS) from minutes."""
|
||||
try:
|
||||
minutes = int(round(float(p)))
|
||||
@@ -152,19 +152,19 @@ def _cook_time_write(p, rep):
|
||||
}
|
||||
|
||||
|
||||
def _stop_write(p, rep):
|
||||
def _stop_write(p, rep, href=None):
|
||||
return ['operational', 'state', 'vs', '0'], {
|
||||
'x.com.samsung.da.state': 'Ready',
|
||||
}
|
||||
|
||||
|
||||
def _oven_mode_write(p, rep):
|
||||
def _oven_mode_write(p, rep, href=None):
|
||||
if p not in _OVEN_MODES:
|
||||
return None
|
||||
return ['mode', 'vs', '0'], {'x.com.samsung.da.modes': [p]}
|
||||
|
||||
|
||||
def _lamp_write(p, rep):
|
||||
def _lamp_write(p, rep, href=None):
|
||||
if p not in ('On', 'Off'):
|
||||
return None
|
||||
opts = list(rep.get('x.com.samsung.da.options') or [])
|
||||
@@ -175,7 +175,7 @@ def _lamp_write(p, rep):
|
||||
}
|
||||
|
||||
|
||||
def _sound_write(p, rep):
|
||||
def _sound_write(p, rep, href=None):
|
||||
if p not in ('On', 'Off'):
|
||||
return None
|
||||
opts = list(rep.get('x.com.samsung.da.options') or [])
|
||||
@@ -186,7 +186,7 @@ def _sound_write(p, rep):
|
||||
}
|
||||
|
||||
|
||||
def _fastpreheat_write(p, rep):
|
||||
def _fastpreheat_write(p, rep, href=None):
|
||||
if p not in ('On', 'Off'):
|
||||
return None
|
||||
opts = list(rep.get('x.com.samsung.da.options') or [])
|
||||
@@ -197,7 +197,7 @@ def _fastpreheat_write(p, rep):
|
||||
}
|
||||
|
||||
|
||||
def _naturalsteam_write(p, rep):
|
||||
def _naturalsteam_write(p, rep, href=None):
|
||||
if p not in ('On', 'Off'):
|
||||
return None
|
||||
opts = list(rep.get('x.com.samsung.da.options') or [])
|
||||
|
||||
Reference in new issue
Block a user