feat: 11 more API endpoints for full UI coverage

New endpoints (total now 65+):
- clear: clear debris/POI (bottom toolbar button)
- rotate: rotate building during placement
- copy_settings: copy building config to another building
- overlay: switch overlay view (power/temp/gas/liquid/automation/rooms/decor/light/germs/materials/suits/crops/radiation/priority)
- dupe_personal_priority: set per-duplicate task priority sliders
- battery_charge: set smart battery high/low charge limits
- valve_flow: set liquid/gas valve flow rate
- vent_pressure: set vent overpressure limit
- incubator_setting: set incubator egg priority
- fridge_temp: set refrigerator temperature
- GET /api/state/overlay: current overlay + available overlays list

CLI: clear, rotate, copy_settings, overlay, dupe_personal_priority,
battery_charge, valve_flow, vent_pressure, incubator_setting, fridge_temp
This commit is contained in:
root
2026-05-22 09:53:50 +08:00
parent aa0519c1ed
commit 48dd1075ed
2 changed files with 361 additions and 0 deletions

View File

@ -1089,6 +1089,107 @@ def cmd_sensors(args):
thr = f" threshold={s.get('threshold')}" if s.get('threshold') is not None else ""
print(f" {sname:15s} at ({s.get('x', '?')},{s.get('y', '?')}){thr} {'ON' if s.get('isOperational') else 'OFF'}")
# ---------------------------------------------------------------------------
# Extended interactions
# ---------------------------------------------------------------------------
def cmd_clear(args):
"""Clear debris. Usage: clear <x> <y> [radius]"""
if len(args) < 2:
print("Usage: clear <x> <y> [radius]")
return
payload = {"x": int(args[0]), "y": int(args[1]), "radius": int(args[2]) if len(args) > 2 else 1}
result = api_post('/api/action/clear', payload)
_print_feedback(result)
def cmd_rotate(args):
"""Rotate a building. Usage: rotate <x> <y>"""
if len(args) < 2:
print("Usage: rotate <x> <y>")
return
result = api_post('/api/action/rotate', {"x": int(args[0]), "y": int(args[1])})
_print_feedback(result)
def cmd_copy_settings(args):
"""Copy building settings. Usage: copy_settings <from_x> <from_y> <to_x> <to_y>"""
if len(args) < 4:
print("Usage: copy_settings <from_x> <from_y> <to_x> <to_y>")
return
result = api_post('/api/action/copy_settings', {
"x1": int(args[0]), "y1": int(args[1]), "x2": int(args[2]), "y2": int(args[3])
})
_print_feedback(result)
def cmd_overlay(args):
"""Set overlay view. Usage: overlay <type>"""
if not args:
print("Usage: overlay <power|temp|gas|liquid|automation|rooms|decor|light|germs|materials|suits|crops|radiation|priority|none>")
return
result = api_post('/api/action/overlay', {"type": args[0]})
_print_feedback(result)
def cmd_dupe_personal_priority(args):
"""Set dupe personal priority. Usage: dupe_personal_priority <name> <taskType> <priority 1-9>"""
if len(args) < 3:
print("Usage: dupe_personal_priority <name> <taskType> <priority 1-9>")
print(" taskType: Dig, Build, Cook, Farm, Ranch, Operate, Research, Store, Tidy, LifeSupport, Supply")
return
result = api_post('/api/action/dupe_personal_priority', {
"duplicantId": args[0], "taskType": args[1], "priority": int(args[2])
})
_print_feedback(result)
def cmd_battery_charge(args):
"""Set battery charge limits. Usage: battery_charge <x> <y> <high%> <low%>"""
if len(args) < 4:
print("Usage: battery_charge <x> <y> <high_percent> <low_percent>")
return
result = api_post('/api/action/battery_charge', {
"x": int(args[0]), "y": int(args[1]),
"high": int(args[2]), "low": int(args[3])
})
_print_feedback(result)
def cmd_valve_flow(args):
"""Set valve flow limit. Usage: valve_flow <x> <y> <flow_kg>"""
if len(args) < 3:
print("Usage: valve_flow <x> <y> <flow_kg>")
return
result = api_post('/api/action/valve_flow', {
"x": int(args[0]), "y": int(args[1]), "flow": float(args[2])
})
_print_feedback(result)
def cmd_vent_pressure(args):
"""Set vent overpressure. Usage: vent_pressure <x> <y> <pressure_kg>"""
if len(args) < 3:
print("Usage: vent_pressure <x> <y> <pressure_kg>")
return
result = api_post('/api/action/vent_pressure', {
"x": int(args[0]), "y": int(args[1]), "pressure": float(args[2])
})
_print_feedback(result)
def cmd_incubator_setting(args):
"""Set incubator egg priority. Usage: incubator_setting <x> <y> <egg_type>"""
if len(args) < 3:
print("Usage: incubator_setting <x> <y> <egg_type>")
return
result = api_post('/api/action/incubator_setting', {
"x": int(args[0]), "y": int(args[1]), "egg": args[2]
})
_print_feedback(result)
def cmd_fridge_temp(args):
"""Set fridge temperature. Usage: fridge_temp <x> <y> <temp_c>"""
if len(args) < 3:
print("Usage: fridge_temp <x> <y> <temp_celsius>")
return
result = api_post('/api/action/fridge_temp', {
"x": int(args[0]), "y": int(args[1]), "temperature": float(args[2])
})
_print_feedback(result)
def cmd_sensor_threshold(args):
"""Set sensor threshold. Usage: sensor_threshold <x> <y> <value>"""
if len(args) < 3:
@ -1308,6 +1409,16 @@ COMMANDS = {
'sensor_threshold': cmd_sensor_threshold,
'sweep': cmd_sweep,
'disinfect': cmd_disinfect,
'clear': cmd_clear,
'rotate': cmd_rotate,
'copy_settings': cmd_copy_settings,
'overlay': cmd_overlay,
'dupe_personal_priority': cmd_dupe_personal_priority,
'battery_charge': cmd_battery_charge,
'valve_flow': cmd_valve_flow,
'vent_pressure': cmd_vent_pressure,
'incubator_setting': cmd_incubator_setting,
'fridge_temp': cmd_fridge_temp,
}
if __name__ == '__main__':