R2: git = source de vérité — src/nodes/ + build/extract intégrés au push
- src/nodes/*.js (6 nodes + template snapshot) = source de vérité unique. - n8n-push.mjs reconstruit le JSON depuis src/ avant syntaxe+golden+PUT (src gagne toujours; n8n-extract.mjs pour resynchroniser si édition UI). - n8n-build.mjs --check pour vérifier la synchro. - Copies historiques déplacées dans archive/ (mortes, dérivées de la prod). - .gitignore: backups locaux de rollback. - AGENTS.md: règle R2 pour toutes les futures sessions (dont Qwen local). - Validé: idempotence, mutation/restauration, pipeline push complet en réel.
This commit is contained in:
86
archive/decoupesurplus/V2/gridhystact.js
Normal file
86
archive/decoupesurplus/V2/gridhystact.js
Normal file
@@ -0,0 +1,86 @@
|
||||
const root = $input.first().json;
|
||||
const actions = [];
|
||||
|
||||
// Toujours mettre à jour état + raison
|
||||
actions.push({
|
||||
json: {
|
||||
action: 'helper_state',
|
||||
...root.ha_service_calls.helper_state
|
||||
}
|
||||
});
|
||||
|
||||
actions.push({
|
||||
json: {
|
||||
action: 'helper_reason',
|
||||
...root.ha_service_calls.helper_reason
|
||||
}
|
||||
});
|
||||
|
||||
// Action réseau si nécessaire
|
||||
if (root.decision.grid_action !== 'none') {
|
||||
actions.push({
|
||||
json: {
|
||||
action: 'grid',
|
||||
...root.ha_service_calls.grid
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Action latch si nécessaire
|
||||
if (root.decision.latch_action !== 'none') {
|
||||
actions.push({
|
||||
json: {
|
||||
action: 'helper_latch',
|
||||
...root.ha_service_calls.helper_latch
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Timestamps si nécessaire
|
||||
if (root.decision.set_last_on_at) {
|
||||
actions.push({
|
||||
json: {
|
||||
action: 'helper_last_on_at',
|
||||
...root.ha_service_calls.helper_last_on_at
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (root.decision.set_last_off_at) {
|
||||
actions.push({
|
||||
json: {
|
||||
action: 'helper_last_off_at',
|
||||
...root.ha_service_calls.helper_last_off_at
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Signature + logbook si changement
|
||||
if (root.decision.signature_changed) {
|
||||
actions.push({
|
||||
json: {
|
||||
action: 'helper_signature',
|
||||
...root.ha_service_calls.helper_signature
|
||||
}
|
||||
});
|
||||
|
||||
actions.push({
|
||||
json: {
|
||||
action: 'logbook',
|
||||
...root.ha_service_calls.logbook
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Notification si utile
|
||||
if (root.decision.should_notify) {
|
||||
actions.push({
|
||||
json: {
|
||||
action: 'mobile_notification',
|
||||
...root.ha_service_calls.mobile_notification
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return actions;
|
||||
|
||||
Reference in New Issue
Block a user