Skip to content

Commit

Permalink
fix: always get all state changes, not only significant ones
Browse files Browse the repository at this point in the history
  • Loading branch information
RomRider committed Mar 21, 2021
1 parent 8ca0ba9 commit 3b2f9c8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
18 changes: 17 additions & 1 deletion .devcontainer/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ sensor:
unit_of_measurement: 's'
value_template: '{{ as_timestamp(now()) }}'

- platform: rest
name: counter_no_significant_update
resource: https://jsonplaceholder.typicode.com/posts/1
value_template: '{{ value_json.id | int }}'
force_update: true

input_boolean:
test_boolean:
name: Test Input Boolean
Expand All @@ -57,4 +63,14 @@ automation:
action:
- service: homeassistant.update_entity
target:
entity_id: sensor.counter
entity_id:
- sensor.counter
- alias: 'Update counter 2'
trigger:
- platform: time_pattern
seconds: '/10'
action:
- service: homeassistant.update_entity
target:
entity_id:
- sensor.counter_no_significant_update
8 changes: 8 additions & 0 deletions .devcontainer/ui-lovelace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -962,3 +962,11 @@ views:
group_by:
func: diff
duration: 10s

- type: custom:apexcharts-card
header:
show: true
title: Significant Updates
graph_span: 1m
series:
- entity: sensor.counter_no_significant_update
5 changes: 1 addition & 4 deletions src/graphEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ export default class GraphEntry {
: new Date(startHistory.getTime() + (this._config.group_by.func !== 'raw' ? 0 : -1)),
end,
this._config.attribute || this._config.transform ? false : skipInitialState,
this._config.attribute || this._config.transform ? true : false,
);
if (newHistory && newHistory[0] && newHistory[0].length > 0) {
/*
Expand Down Expand Up @@ -311,15 +310,13 @@ export default class GraphEntry {
start: Date | undefined,
end: Date | undefined,
skipInitialState: boolean,
withAttributes = false,
): Promise<HassHistory | undefined> {
let url = 'history/period';
if (start) url += `/${start.toISOString()}`;
url += `?filter_entity_id=${this._entityID}`;
if (end) url += `&end_time=${end.toISOString()}`;
if (skipInitialState) url += '&skip_initial_state';
if (!withAttributes) url += '&minimal_response';
if (withAttributes) url += '&significant_changes_only=0';
url += '&significant_changes_only=0';
return this._hass?.callApi('GET', url);
}

Expand Down

0 comments on commit 3b2f9c8

Please sign in to comment.