diff --git a/dist/irrigation-unlimited-card.js b/dist/irrigation-unlimited-card.js index 26fe334..a4029e0 100644 --- a/dist/irrigation-unlimited-card.js +++ b/dist/irrigation-unlimited-card.js @@ -454,6 +454,21 @@ class IUController extends IUEntity { return z.name; return undefined; } + sequence_status(status) { + for (const s of this.sequences) { + if (s.status === status) + return true; + } + return false; + } + pause_resume_status() { + let result = 0; + if (this.sequence_status("on")) + result |= 1; + if (this.sequence_status("paused")) + result |= 2; + return result; + } update(hass) { let result = super.update(hass); for (const z of this.zones) @@ -648,6 +663,10 @@ const styles = i$2 ` color: var(--label-badge-green, #43a047); } + .iu-timeline-history { + color: var(--secondary-text-color, #727272); + } + /* Duration colouring */ .iu-sequence.iu-on .iu-sequence-zone:not(.iu-on) .iu-duration, .iu-sequence.iu-paused .iu-sequence-zone:not(.iu-on) .iu-duration, @@ -982,7 +1001,7 @@ let IrrigationUnlimitedCard = class IrrigationUnlimitedCard extends s {
- ${this._renderMenu(isEnabled, false, true, true, 3, null, suspended)} + ${this._renderMenu(isEnabled, false, true, true, controller.pause_resume_status(), null, suspended)}
@@ -1063,7 +1082,32 @@ let IrrigationUnlimitedCard = class IrrigationUnlimitedCard extends s { if (isBlocked) classes.push("iu-blocked"); let timeline = stateObj.attributes.timeline; - if (timeline === undefined) + if (timeline !== undefined) { + // Filter items + timeline = timeline.filter((item) => { + return ((item.start !== item.end && + item.status === "history" && + (this.config.show_timeline_history === undefined || + this.config.show_timeline_history)) || + (item.status === "scheduled" && + this.config.show_timeline_scheduled) || + (item.status === "next" && this.config.show_timeline_scheduled) || + (item.status === "running" && this.config.show_timeline_scheduled)); + }); + // Sort items + timeline.sort((a, b) => { + const da = new Date(a.start).getTime(); + const db = new Date(b.start).getTime(); + if (a.status === "history" && a.status === "history") + return db - da; + return da - db; + }); + // Move first history item to head + const idx = timeline.findIndex((item) => item.status === "history"); + if (idx >= 0) + timeline.unshift(timeline.splice(idx, 1)[0]); + } + else timeline = []; return x `
- ${timeline - .filter((item) => { - return ((item.start !== item.end && - item.status === "history" && - (this.config.show_timeline_history === undefined || - this.config.show_timeline_history)) || - (item.status === "scheduled" && - this.config.show_timeline_scheduled) || - (item.status === "next" && - this.config.show_timeline_scheduled) || - (item.status === "running" && - this.config.show_timeline_scheduled)); - }) - .map((item) => this._renderZoneHistory(item))} + ${timeline.map((item) => this._renderTimeline(item))}
`; } - _renderZoneHistory(timeline) { + _renderTimeline(timeline) { const start = new Date(timeline.start); const duration = new Date(new Date(timeline.end).getTime() - start.getTime()) .toISOString()