More straightforward mapping to thermostat command

New tag "thermostat:set_param" used in JSON.
This commit is contained in:
atse 2024-07-17 16:43:42 +08:00
parent 6372e03dff
commit 487bf24ffe
2 changed files with 77 additions and 99 deletions

View File

@ -56,11 +56,10 @@
"triggerOnShow": true, "triggerOnShow": true,
"decimals": 6, "decimals": 6,
"compactHeight": false, "compactHeight": false,
"param": [ "thermostat:set_param": {
"pwm", "topic": "pwm",
"ch", "field": "i_set"
"i_set" },
],
"tip": "The set current through TEC", "tip": "The set current through TEC",
"lock": false "lock": false
}, },
@ -76,11 +75,10 @@
], ],
"format": "{value:.4f}", "format": "{value:.4f}",
"compactHeight": false, "compactHeight": false,
"param": [ "thermostat:set_param": {
"pid", "topic": "pid",
"ch", "field": "target"
"target" },
],
"tip": "The target temperature of the TEC", "tip": "The target temperature of the TEC",
"lock": false "lock": false
} }
@ -105,11 +103,10 @@
0, 0,
2000 2000
], ],
"param": [ "thermostat:set_param": {
"pwm", "topic": "pwm",
"ch", "field": "max_i_pos"
"max_i_pos" },
],
"tip": "The maximum cooling (+ve) current through the output pins", "tip": "The maximum cooling (+ve) current through the output pins",
"lock": false "lock": false
}, },
@ -125,11 +122,10 @@
0, 0,
2000 2000
], ],
"param": [ "thermostat:set_param": {
"pwm", "topic": "pwm",
"ch", "field": "max_i_neg"
"max_i_neg" },
],
"tip": "The maximum heating (-ve) current through the output pins", "tip": "The maximum heating (-ve) current through the output pins",
"lock": false "lock": false
}, },
@ -145,11 +141,10 @@
], ],
"siPrefix": true, "siPrefix": true,
"compactHeight": false, "compactHeight": false,
"param": [ "thermostat:set_param": {
"pwm", "topic": "pwm",
"ch", "field": "max_v"
"max_v" },
],
"tip": "The maximum voltage across the output pins", "tip": "The maximum voltage across the output pins",
"lock": false "lock": false
} }
@ -176,11 +171,10 @@
], ],
"format": "{value:.4f}", "format": "{value:.4f}",
"compactHeight": false, "compactHeight": false,
"param": [ "thermostat:set_param": {
"s-h", "topic": "s-h",
"ch", "field": "t0"
"t0" },
],
"tip": "The origin temperature", "tip": "The origin temperature",
"lock": false "lock": false
}, },
@ -192,11 +186,10 @@
"step": 1, "step": 1,
"siPrefix": true, "siPrefix": true,
"compactHeight": false, "compactHeight": false,
"param": [ "thermostat:set_param": {
"s-h", "topic": "s-h",
"ch", "field": "r0"
"r0" },
],
"tip": "The resistance of the thermistor at origin temperature T₀", "tip": "The resistance of the thermistor at origin temperature T₀",
"lock": false "lock": false
}, },
@ -208,11 +201,10 @@
"step": 1, "step": 1,
"decimals": 4, "decimals": 4,
"compactHeight": false, "compactHeight": false,
"param": [ "thermostat:set_param": {
"s-h", "topic": "s-h",
"ch", "field": "b"
"b" },
],
"tip": "The B (or Beta) Parameter", "tip": "The B (or Beta) Parameter",
"lock": false "lock": false
}, },
@ -221,13 +213,12 @@
"title": "Postfilter Rejection", "title": "Postfilter Rejection",
"type": "list", "type": "list",
"value": 16.67, "value": 16.67,
"param": [ "thermostat:set_param": {
"postfilter", "topic": "postfilter",
"ch", "field": "rate"
"rate" },
],
"limits": { "limits": {
"Off": null, "Off": "",
"47 dB @ 10.41 Hz": 27.0, "47 dB @ 10.41 Hz": 27.0,
"62 dB @ 9.1 Hz": 21.25, "62 dB @ 9.1 Hz": 21.25,
"86 dB @ 10 Hz": 20.0, "86 dB @ 10 Hz": 20.0,
@ -252,11 +243,10 @@
"step": 0.1, "step": 0.1,
"suffix": "", "suffix": "",
"compactHeight": false, "compactHeight": false,
"param": [ "thermostat:set_param": {
"pid", "topic": "pid",
"ch", "field": "kp"
"kp" },
],
"tip": "Proportional gain", "tip": "Proportional gain",
"lock": false "lock": false
}, },
@ -267,11 +257,10 @@
"step": 0.1, "step": 0.1,
"suffix": "Hz", "suffix": "Hz",
"compactHeight": false, "compactHeight": false,
"param": [ "thermostat:set_param": {
"pid", "topic": "pid",
"ch", "field": "ki"
"ki" },
],
"tip": "Integral gain", "tip": "Integral gain",
"lock": false "lock": false
}, },
@ -282,11 +271,10 @@
"step": 0.1, "step": 0.1,
"suffix": "s", "suffix": "s",
"compactHeight": false, "compactHeight": false,
"param": [ "thermostat:set_param": {
"pid", "topic": "pid",
"ch", "field": "kd"
"kd" },
],
"tip": "Differential gain", "tip": "Differential gain",
"lock": false "lock": false
}, },
@ -308,11 +296,10 @@
], ],
"decimals": 6, "decimals": 6,
"compactHeight": false, "compactHeight": false,
"param": [ "thermostat:set_param": {
"pid", "topic": "pid",
"ch", "field": "output_min"
"output_min" },
],
"tip": "Minimum PID output", "tip": "Minimum PID output",
"lock": false "lock": false
}, },
@ -327,11 +314,10 @@
], ],
"decimals": 6, "decimals": 6,
"compactHeight": false, "compactHeight": false,
"param": [ "thermostat:set_param": {
"pid", "topic": "pid",
"ch", "field": "output_max"
"output_max" },
],
"tip": "Maximum PID output", "tip": "Maximum PID output",
"lock": false "lock": false
} }
@ -352,10 +338,9 @@
"step": 0.1, "step": 0.1,
"format": "{value:.4f}", "format": "{value:.4f}",
"compactHeight": false, "compactHeight": false,
"pid_autotune": [ "pid_autotune": {
"target_temp", "params_name": "target_temp"
"ch" },
],
"tip": "The target temperature to autotune for" "tip": "The target temperature to autotune for"
}, },
{ {
@ -370,10 +355,9 @@
-2000, -2000,
2000 2000
], ],
"pid_autotune": [ "pid_autotune": {
"test_current", "params_name": "test_current"
"ch" },
],
"tip": "The testing current when autotuning" "tip": "The testing current when autotuning"
}, },
{ {
@ -385,10 +369,9 @@
"prefix": "±", "prefix": "±",
"format": "{value:.4f}", "format": "{value:.4f}",
"compactHeight": false, "compactHeight": false,
"pid_autotune": [ "pid_autotune": {
"temp_swing", "params_name": "temp_swing"
"ch" },
],
"tip": "The temperature swing around the target" "tip": "The temperature swing around the target"
}, },
{ {
@ -399,10 +382,9 @@
"step": 0.1, "step": 0.1,
"format": "{value:.4f}", "format": "{value:.4f}",
"compactHeight": false, "compactHeight": false,
"pid_autotune": [ "pid_autotune": {
"lookback", "params_name": "lookback"
"ch" },
],
"tip": "Amount of time to lookback" "tip": "Amount of time to lookback"
}, },
{ {

View File

@ -273,23 +273,19 @@ class MainWindow(QtWidgets.QMainWindow):
if inner_param.opts.get("title", None).endswith(" (mA)"): if inner_param.opts.get("title", None).endswith(" (mA)"):
new_value /= 1000 # Given in mA new_value /= 1000 # Given in mA
thermostat_param = inner_param.opts["param"] if inner_param.name() == "rate" and new_value == "":
if thermostat_param[1] == "ch": thermostat_param = thermostat_param.copy()
thermostat_param[1] = ch thermostat_param["field"] = "off"
if inner_param.name() == "rate" and new_value is None:
set_param_args = (*thermostat_param[:2], "off")
else:
set_param_args = (*thermostat_param, new_value)
inner_param.setOpts(lock=True) inner_param.setOpts(lock=True)
await self.client.set_param(*set_param_args) await self.client.set_param(
channel=ch, value=new_value, **thermostat_param
)
inner_param.setOpts(lock=False) inner_param.setOpts(lock=False)
if "pid_autotune" in inner_param.opts: if "pid_autotune" in inner_param.opts:
autotuner_param = inner_param.opts["pid_autotune"][0] autotuner_param = inner_param.opts["pid_autotune"]
if inner_param.opts["pid_autotune"][1] != "ch": self.autotuners.set_params(ch=ch, val=new_value, **autotuner_param)
ch = inner_param.opts["pid_autotune"][1]
self.autotuners.set_params(autotuner_param, ch, data)
if "activaters" in inner_param.opts: if "activaters" in inner_param.opts:
activater = inner_param.opts["activaters"][ activater = inner_param.opts["activaters"][