Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions panels/history/ha-panel-history.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
hass='[[hass]]'
filter-type='[[_filterType]]'
start-time='[[_computeStartTime(_currentDate)]]'
end-time='[[_computeEndTime(_currentDate, _periodIndex)]]'
end-time='[[endTime]]'
data='{{stateHistoryInput}}'
is-loading='{{isLoadingData}}'
></ha-state-history-data>
Expand Down Expand Up @@ -80,8 +80,11 @@
</paper-listbox>
</paper-dropdown-menu>
</div>
<state-history-charts history-data="[[stateHistoryOutput]]"
is-loading-data="[[isLoadingData]]"></state-history-charts>
<state-history-charts
history-data="[[stateHistoryOutput]]"
is-loading-data="[[isLoadingData]]"
end-time="[[endTime]]">
</state-history-charts>
</div>
</app-header-layout>
</template>
Expand Down Expand Up @@ -126,6 +129,11 @@
value: false,
},

endTime: {
type: Object,
computed: '_computeEndTime(_currentDate, _periodIndex)',
},

// ISO8601 formatted date string
_currentDate: {
type: String,
Expand Down
11 changes: 8 additions & 3 deletions src/components/state-history-chart-line.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
observer: 'dataChanged',
},

endTime: {
type: Object,
},

chartEngine: {
type: Object,
},
Expand Down Expand Up @@ -116,9 +120,10 @@
return new Date(states[0].last_changed);
})));

endTime = new Date(Math.max.apply(null, deviceStates.map(function (states) {
return new Date(states[states.length - 1].last_changed);
})));
endTime = this.endTime ||
new Date(Math.max.apply(null, deviceStates.map(states =>
new Date(states[states.length - 1].last_changed)
)));
if (endTime > new Date()) {
endTime = new Date();
}
Expand Down
8 changes: 6 additions & 2 deletions src/components/state-history-chart-timeline.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
observer: 'dataChanged',
},

endTime: {
type: Object,
},

isAttached: {
type: Boolean,
value: false,
Expand Down Expand Up @@ -79,8 +83,8 @@
}, new Date()));

// end time is Math.max(startTime, last_event)
endTime = new Date(
stateHistory.reduce(
endTime = this.endTime ||
new Date(stateHistory.reduce(
function (maxTime, stateInfo) {
return Math.max(maxTime, new Date(stateInfo[stateInfo.length - 1].last_changed));
}, startTime));
Expand Down
19 changes: 17 additions & 2 deletions src/components/state-history-charts.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@
</template>

<state-history-chart-timeline
data='[[historyData.timeline]]'>
data='[[historyData.timeline]]'
end-time='[[_computeEndTime(endTime, upToNow)]]'>
</state-history-chart-timeline>

<template is='dom-repeat' items='[[historyData.line]]'>
<state-history-chart-line
unit='[[item.unit]]'
data='[[item.data]]'
is-single-device='[[_computeIsSingleLineChart(historyData)]]'>
is-single-device='[[_computeIsSingleLineChart(historyData)]]'
end-time='[[_computeEndTime(endTime, upToNow)]]'>
</state-history-chart-line>
</template>
</template>
Expand All @@ -68,6 +70,15 @@
value: true,
},

endTime: {
type: Object,
},

upToNow: {
type: Boolean,
value: false,
},

_apiLoaded: {
type: Boolean,
value: false,
Expand Down Expand Up @@ -101,5 +112,9 @@
historyData.timeline.length === 0 &&
historyData.line.length === 0);
},

_computeEndTime: function (endTime, upToNow) {
return upToNow ? new Date() : endTime;
},
});
</script>
7 changes: 5 additions & 2 deletions src/dialogs/more-info-dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ <h2>
data='{{stateHistory}}'
is-loading='{{stateHistoryLoading}}'
></ha-state-history-data>
<state-history-charts history-data="[[stateHistory]]"
is-loading-data="[[isLoadingHistoryData]]"></state-history-charts>
<state-history-charts
history-data="[[stateHistory]]"
is-loading-data="[[isLoadingHistoryData]]"
up-to-now>
</state-history-charts>
</div>
</template>
<paper-dialog-scrollable id='scrollable'>
Expand Down