iobroker.mywebui 1.37.66 → 1.37.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/io-package.json
CHANGED
package/package.json
CHANGED
|
@@ -878,18 +878,27 @@ export class IobrokerWebuiAppShell extends BaseCustomWebComponentConstructorAppe
|
|
|
878
878
|
['equal','='],['not_equal','≠'],['less_than','<'],['less_equal','≤'],
|
|
879
879
|
['greater_than','>'],['greater_equal','≥'],['exists','exists']
|
|
880
880
|
], ctrlCfg.condition || 'equal');
|
|
881
|
-
condSel.style.cssText += '
|
|
881
|
+
condSel.style.cssText += 'flex:1;';
|
|
882
|
+
condSel.onchange = save;
|
|
883
|
+
const condRow = document.createElement('div');
|
|
884
|
+
condRow.style.cssText = 'display:flex;align-items:center;gap:4px;margin-bottom:4px;';
|
|
885
|
+
condRow.appendChild(this._makeBindSquare('condition', ctrlCfg, designItem, 'data-animation', saveAndRefresh));
|
|
886
|
+
condRow.appendChild(condSel);
|
|
887
|
+
wrap.appendChild(condRow);
|
|
882
888
|
const valInp = document.createElement('input');
|
|
883
889
|
valInp.type = 'text'; valInp.value = ctrlCfg.value ?? 'true';
|
|
884
890
|
valInp.style.cssText = 'flex:1;padding:3px 5px;font-size:11px;border:1px solid #ccc;border-radius:3px;';
|
|
885
|
-
|
|
886
|
-
const
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
891
|
+
valInp.onchange = save;
|
|
892
|
+
const valRow = document.createElement('div');
|
|
893
|
+
valRow.style.cssText = 'display:flex;align-items:center;gap:4px;';
|
|
894
|
+
valRow.appendChild(this._makeBindSquare('value', ctrlCfg, designItem, 'data-animation', saveAndRefresh));
|
|
895
|
+
valRow.appendChild(valInp);
|
|
896
|
+
wrap.appendChild(valRow);
|
|
890
897
|
wrap._getCtrl = () => {
|
|
891
898
|
const v = { condition: condSel.value, value: valInp.value };
|
|
892
899
|
if (ctrlCfg.oid_bind) v.oid_bind = ctrlCfg.oid_bind;
|
|
900
|
+
if (ctrlCfg.condition_bind) v.condition_bind = ctrlCfg.condition_bind;
|
|
901
|
+
if (ctrlCfg.value_bind) v.value_bind = ctrlCfg.value_bind;
|
|
893
902
|
return v;
|
|
894
903
|
};
|
|
895
904
|
return wrap;
|
|
@@ -1167,10 +1176,16 @@ export class IobrokerWebuiAppShell extends BaseCustomWebComponentConstructorAppe
|
|
|
1167
1176
|
oidLabelText.textContent = 'OID';
|
|
1168
1177
|
oidLabel.appendChild(oidLabelText);
|
|
1169
1178
|
const condRowDiv = document.createElement('div');
|
|
1170
|
-
condRowDiv.style.cssText = 'display:flex;gap:
|
|
1171
|
-
condRowDiv.appendChild(
|
|
1179
|
+
condRowDiv.style.cssText = 'display:flex;align-items:center;gap:4px;margin-bottom:4px;padding-left:4px;';
|
|
1180
|
+
condRowDiv.appendChild(this._makeBindSquare('condition', cfg, designItem, 'data-effects', saveAndRefresh));
|
|
1181
|
+
condRowDiv.appendChild(condSel);
|
|
1182
|
+
const condValRowDiv = document.createElement('div');
|
|
1183
|
+
condValRowDiv.style.cssText = 'display:flex;align-items:center;gap:4px;margin-bottom:6px;padding-left:4px;';
|
|
1184
|
+
condValRowDiv.appendChild(this._makeBindSquare('conditionValue', cfg, designItem, 'data-effects', saveAndRefresh));
|
|
1185
|
+
condValRowDiv.appendChild(condValInp);
|
|
1172
1186
|
oidSection.appendChild(oidLabel);
|
|
1173
1187
|
oidSection.appendChild(condRowDiv);
|
|
1188
|
+
oidSection.appendChild(condValRowDiv);
|
|
1174
1189
|
content.appendChild(oidSection);
|
|
1175
1190
|
triggerSel.addEventListener('change', () => { oidSection.style.display = triggerSel.value === 'oid' ? '' : 'none'; });
|
|
1176
1191
|
|
|
@@ -160,30 +160,37 @@ class AnimationInstance {
|
|
|
160
160
|
const ctrl = controls[key];
|
|
161
161
|
if (!ctrl) return;
|
|
162
162
|
|
|
163
|
-
//
|
|
164
|
-
if (ctrl.
|
|
163
|
+
// condition_bind: dynamically update which condition operator to use
|
|
164
|
+
if (ctrl.condition_bind?.signal) {
|
|
165
165
|
try {
|
|
166
|
-
const s = await iobrokerHandler.connection.getState(ctrl.
|
|
167
|
-
if (s?.val != null) ctrl.
|
|
166
|
+
const s = await iobrokerHandler.connection.getState(ctrl.condition_bind.signal);
|
|
167
|
+
if (s?.val != null) ctrl.condition = String(s.val);
|
|
168
168
|
} catch (e) {}
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
const h = (id, state) => { if (state?.val != null) ctrl.condition = String(state.val); };
|
|
170
|
+
try { iobrokerHandler.connection.subscribeState(ctrl.condition_bind.signal, h); this._subs.push({ oid: ctrl.condition_bind.signal, handler: h }); } catch (e) {}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// value_bind: dynamically update the trigger value
|
|
174
|
+
if (ctrl.value_bind?.signal) {
|
|
172
175
|
try {
|
|
173
|
-
iobrokerHandler.connection.
|
|
174
|
-
|
|
176
|
+
const s = await iobrokerHandler.connection.getState(ctrl.value_bind.signal);
|
|
177
|
+
if (s?.val != null) ctrl.value = String(s.val);
|
|
175
178
|
} catch (e) {}
|
|
179
|
+
const h = (id, state) => { if (state?.val != null) ctrl.value = String(state.val); };
|
|
180
|
+
try { iobrokerHandler.connection.subscribeState(ctrl.value_bind.signal, h); this._subs.push({ oid: ctrl.value_bind.signal, handler: h }); } catch (e) {}
|
|
176
181
|
}
|
|
177
182
|
|
|
178
|
-
|
|
183
|
+
// oid_bind.signal IS the OID to watch (binding square directly holds the target OID)
|
|
184
|
+
const oid = ctrl.oid || ctrl.oid_bind?.signal;
|
|
185
|
+
if (!oid) return;
|
|
179
186
|
const handler = (id, state) => {
|
|
180
187
|
if (checkCond(state?.val, ctrl.condition || 'equal', ctrl.value ?? 'true')) action();
|
|
181
188
|
};
|
|
182
189
|
try {
|
|
183
|
-
iobrokerHandler.connection.subscribeState(
|
|
184
|
-
this._subs.push({ oid
|
|
190
|
+
iobrokerHandler.connection.subscribeState(oid, handler);
|
|
191
|
+
this._subs.push({ oid, handler });
|
|
185
192
|
} catch (e) {}
|
|
186
|
-
iobrokerHandler.connection.getState(
|
|
193
|
+
iobrokerHandler.connection.getState(oid).then(state => {
|
|
187
194
|
if (state && checkCond(state.val, ctrl.condition || 'equal', ctrl.value ?? 'true')) action();
|
|
188
195
|
}).catch(() => {});
|
|
189
196
|
};
|
|
@@ -389,24 +396,26 @@ async function _applyEffect(el, cfg) {
|
|
|
389
396
|
_clickFn = applyTween;
|
|
390
397
|
el.addEventListener('click', _clickFn);
|
|
391
398
|
} else if (cfg.trigger === 'oid') {
|
|
392
|
-
//
|
|
393
|
-
if (cfg.
|
|
394
|
-
try {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
try { iobrokerHandler.connection.
|
|
400
|
-
|
|
401
|
-
|
|
399
|
+
// condition_bind and conditionValue_bind
|
|
400
|
+
if (cfg.condition_bind?.signal) {
|
|
401
|
+
try { const s = await iobrokerHandler.connection.getState(cfg.condition_bind.signal); if (s?.val != null) cfg.condition = String(s.val); } catch (e) {}
|
|
402
|
+
const h = (id, state) => { if (state?.val != null) cfg.condition = String(state.val); };
|
|
403
|
+
try { iobrokerHandler.connection.subscribeState(cfg.condition_bind.signal, h); } catch (e) {}
|
|
404
|
+
}
|
|
405
|
+
if (cfg.conditionValue_bind?.signal) {
|
|
406
|
+
try { const s = await iobrokerHandler.connection.getState(cfg.conditionValue_bind.signal); if (s?.val != null) cfg.conditionValue = String(s.val); } catch (e) {}
|
|
407
|
+
const h = (id, state) => { if (state?.val != null) cfg.conditionValue = String(state.val); };
|
|
408
|
+
try { iobrokerHandler.connection.subscribeState(cfg.conditionValue_bind.signal, h); } catch (e) {}
|
|
402
409
|
}
|
|
403
|
-
|
|
404
|
-
|
|
410
|
+
// oid_bind.signal IS the OID to watch (same as for animation controls)
|
|
411
|
+
const oid = cfg.oid || cfg.oid_bind?.signal;
|
|
412
|
+
if (oid) {
|
|
413
|
+
_oidId = oid;
|
|
405
414
|
_oidHandler = (id, state) => {
|
|
406
415
|
if (checkCond(state?.val, cfg.condition || 'equal', cfg.conditionValue ?? 'true')) applyTween();
|
|
407
416
|
};
|
|
408
|
-
try { iobrokerHandler.connection.subscribeState(
|
|
409
|
-
iobrokerHandler.connection.getState(
|
|
417
|
+
try { iobrokerHandler.connection.subscribeState(oid, _oidHandler); } catch (e) {}
|
|
418
|
+
iobrokerHandler.connection.getState(oid).then(state => {
|
|
410
419
|
if (state && checkCond(state.val, cfg.condition || 'equal', cfg.conditionValue ?? 'true')) applyTween();
|
|
411
420
|
}).catch(() => {});
|
|
412
421
|
}
|