-
-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Labels
enhancementNew feature or requestNew feature or request
Description
possible solution for #24 , #47 , #55
I have made a small modification to the energy-period-selector-plus.js file
TIP: when changing a HACS .js file you also need to change the .js.gz file
Otherwise it seems you have a caching problem, But it is the original .js.gz file that is still used
The modification loads the start and end date into two helpers, every time the period selector plus changes.
Then the helpers can be used in any other card of HA
- Add code to energy-period-selector-plus.js
- Create the altered energy-period-selector-plus.js.gz file
- Add helper input_datetime.energy_start_date
- Add helper input_datetime.energy_end_date
- (optional) For use with apex-chart-card I added 2 extra helpers to calculate the span and offset out of the energy_start_date and energy_end_date
add following code to _setDate(t, e) in energy-period-selector-plus.js
// === BEGIN MODIFICATIONS ===
// Debugging logs
console.log("Updating start_date:", t.toISOString().split('T')[0]);
console.log("Updating end_date:", n ? n.toISOString().split('T')[0] : "No end date");
// Update Home Assistant helpers
try {
this.hass.callService('input_datetime', 'set_datetime', {
entity_id: 'input_datetime.energy_start_date',
date: t.toISOString().split('T')[0], // Extract date in YYYY-MM-DD format
});
if (n) {
this.hass.callService('input_datetime', 'set_datetime', {
entity_id: 'input_datetime.energy_end_date',
date: n.toISOString().split('T')[0], // Extract date in YYYY-MM-DD format
});
}
} catch (error) {
console.error("Error updating input_datetime helpers:", error);
}
// === END MODIFICATIONS ===
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request