SDB : capteur muet et garde batterie (workflow sous controle du depot) ; alertes de piles des capteurs

This commit is contained in:
Tallagrand Thierry
2026-10-10 00:30:06 +02:00
parent 1bbb54ae6e
commit 16658304c7
12 changed files with 1970 additions and 1 deletions

159
src/sdb/BUILD_ACTIONS.js Normal file
View File

@@ -0,0 +1,159 @@
const root = $input.first().json || {};
const calls = root.ha_service_calls || {};
const decision = root.decision || {};
const actions = [];
function pushAction(action, call, enabled = true) {
if (!enabled) return;
if (!call) return;
if (call.execute === false) return;
const { execute, ...rest } = call;
actions.push({
json: {
action,
...rest
}
});
}
// =====================================================
// HELPERS TOUJOURS MIS A JOUR
// =====================================================
pushAction('helper_state', calls.helper_state, true);
pushAction('helper_reason', calls.helper_reason, true);
// =====================================================
// OFF ENFANTS D'ABORD
// =====================================================
pushAction(
'deshumide',
calls.deshumide,
decision.deshumide_action === 'turn_off'
);
pushAction(
'radiator',
calls.radiator,
decision.radiator_action === 'turn_off'
);
// =====================================================
// PUIS OFF MASTER SI NECESSAIRE
// =====================================================
pushAction(
'master_power',
calls.master_power,
decision.master_action === 'turn_off'
);
// =====================================================
// ON MASTER D'ABORD
// =====================================================
pushAction(
'master_power',
calls.master_power,
decision.master_action === 'turn_on'
);
// =====================================================
// PUIS ON ENFANTS
// =====================================================
pushAction(
'deshumide',
calls.deshumide,
decision.deshumide_action === 'turn_on'
);
pushAction(
'radiator',
calls.radiator,
decision.radiator_action === 'turn_on'
);
// =====================================================
// LATCHES
// =====================================================
pushAction(
'helper_master_latch',
calls.helper_master_latch,
decision.master_latch_action !== 'none'
);
pushAction(
'helper_deshumide_latch',
calls.helper_deshumide_latch,
decision.deshumide_latch_action !== 'none'
);
pushAction(
'helper_radiator_latch',
calls.helper_radiator_latch,
decision.radiator_latch_action !== 'none'
);
// =====================================================
// TIMESTAMPS
// =====================================================
pushAction(
'helper_master_last_on_at',
calls.helper_master_last_on_at,
!!decision.set_master_last_on_at
);
pushAction(
'helper_master_last_off_at',
calls.helper_master_last_off_at,
!!decision.set_master_last_off_at
);
pushAction(
'helper_deshumide_last_on_at',
calls.helper_deshumide_last_on_at,
!!decision.set_deshumide_last_on_at
);
pushAction(
'helper_deshumide_last_off_at',
calls.helper_deshumide_last_off_at,
!!decision.set_deshumide_last_off_at
);
pushAction(
'helper_radiator_last_on_at',
calls.helper_radiator_last_on_at,
!!decision.set_radiator_last_on_at
);
pushAction(
'helper_radiator_last_off_at',
calls.helper_radiator_last_off_at,
!!decision.set_radiator_last_off_at
);
// =====================================================
// SIGNATURE + LOGBOOK SI CHANGEMENT
// =====================================================
pushAction(
'helper_signature',
calls.helper_signature,
!!decision.signature_changed
);
pushAction(
'logbook',
calls.logbook,
!!decision.signature_changed
);
// =====================================================
// NOTIFICATION
// =====================================================
pushAction(
'mobile_notification',
calls.mobile_notification,
!!decision.should_notify
);
return actions;

1058
src/sdb/COMPUTE.js Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,68 @@
{{ {
"soc_percent": states("sensor.victron_battery_soc"),
"battery_current_a": states("sensor.victron_battery_current"),
"pv_power_w": states("sensor.victron_pv_power_system"),
"pv_power_10m_avg_w": states("sensor.victron_pv_power_10m_avg"),
"house_ac_power_w": states("sensor.victron_consumption_power_l1"),
"grid_power_w": states("sensor.victron_grid_power_l1"),
"grid_state": states("switch.edf_general_ok_switch"),
"victron_acin1_available": states("sensor.victron_ac_in1_available"),
"sdb_master_power": states("switch.sdb_prise_socket_1"),
"sdb_master_energy_total": states("sensor.sdb_prise_energie_totale"),
"deshumide_switch": states("switch.deshumide_sdb_socket_1"),
"deshumide_energy_total": states("sensor.deshumide_sdb_energie_totale"),
"radiator_switch": states("switch.sdb_radiateur_socket_1"),
"radiator_energy_total": states("sensor.sdb_radiateur_energie_totale"),
"sdb_temperature_c": states("sensor.sdb_temp_hygro_temperature"),
"sdb_humidity_pct": states("sensor.sdb_temp_hygro_humidite"),
"sdb_humidity_age_min": ((as_timestamp(now()) - as_timestamp(states.sensor.sdb_temp_hygro_humidite.last_reported or states.sensor.sdb_temp_hygro_humidite.last_changed)) / 60) | round(0) if states.sensor.sdb_temp_hygro_humidite is not none else -1,
"balance_required_soc_prudent": states("input_number.evcs_balance_required_soc_prudent"),
"balance_status": states("input_text.evcs_balance_status"),
"auto_enabled": states("input_boolean.sdb_climate_surplus_auto_enabled"),
"notifications_enabled": states("input_boolean.sdb_climate_surplus_notifications"),
"manual_adopt_enabled": states("input_boolean.sdb_master_manual_adopt_enabled"),
"master_power_latch": states("input_boolean.sdb_master_power_latch"),
"deshumide_latch": states("input_boolean.sdb_deshumide_latch"),
"radiator_latch": states("input_boolean.sdb_radiator_latch"),
"temp_on_min_c": states("input_number.sdb_temp_on_min_c"),
"temp_off_max_c": states("input_number.sdb_temp_off_max_c"),
"humidity_on_pct": states("input_number.sdb_humidity_on_pct"),
"humidity_off_pct": states("input_number.sdb_humidity_off_pct"),
"deshumide_min_on_minutes": states("input_number.sdb_deshumide_min_on_minutes"),
"deshumide_min_off_minutes": states("input_number.sdb_deshumide_min_off_minutes"),
"radiator_auto_enabled": states("input_boolean.sdb_radiator_surplus_auto_enabled"),
"radiator_soc_on": states("input_number.sdb_radiator_soc_on"),
"radiator_soc_off": states("input_number.sdb_radiator_soc_off"),
"radiator_pv_on_w": states("input_number.sdb_radiator_pv_on_w"),
"radiator_pv_off_w": states("input_number.sdb_radiator_pv_off_w"),
"radiator_battery_charge_ceiling_a": states("input_number.sdb_radiator_battery_charge_ceiling_a"),
"radiator_house_ac_max_w": states("input_number.sdb_radiator_house_ac_max_w"),
"radiator_min_on_minutes": states("input_number.sdb_radiator_min_on_minutes"),
"radiator_min_off_minutes": states("input_number.sdb_radiator_min_off_minutes"),
"day_start_time": states("input_datetime.victron_flexible_day_start_time"),
"day_stop_time": states("input_datetime.victron_flexible_day_stop_time"),
"master_last_on_at": states("input_datetime.sdb_master_last_on_at"),
"master_last_off_at": states("input_datetime.sdb_master_last_off_at"),
"deshumide_last_on_at": states("input_datetime.sdb_deshumide_last_on_at"),
"deshumide_last_off_at": states("input_datetime.sdb_deshumide_last_off_at"),
"radiator_last_on_at": states("input_datetime.sdb_radiator_last_on_at"),
"radiator_last_off_at": states("input_datetime.sdb_radiator_last_off_at"),
"evcs_priority_active": states("input_boolean.victron_evcs_priority_active"),
"energy_priority_mode": states("input_select.victron_energy_priority_mode"),
"energy_priority_reason": states("input_text.victron_energy_priority_reason"),
"evcs_priority_until": states("input_datetime.victron_evcs_priority_until"),
"last_signature": states("input_text.sdb_climate_surplus_last_signature")
} | tojson }}