You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Long-term statistics support
* Document long-term statistics support
* Add name and units to statistics. Refactor fetch statistics and states in their own files.
* Remove unused types
* change API to yaml keys for both statistics and states.
Co-authored-by: David Buezas <[email protected]>
Note that `5minute` period statistics are limited in time as normal recorder history is, contrary to other periods which keep data for years.
183
+
157
184
## Extra entity attributes:
158
185
159
186
```yaml
187
+
type: custom:plotly-graph
160
188
entities:
161
189
- entity: sensor.temperature_in_celsius
162
190
name: living temperature in Farenheit # Overrides the entity name
@@ -191,72 +219,73 @@ entities:
191
219
#### Normalisation wrt to first fetched value
192
220
193
221
```yaml
194
-
- entity: sensor.my_sensor
195
-
lambda: |-
196
-
(ys) => ys.map(y => y/ys[0])
222
+
- entity: sensor.my_sensor
223
+
lambda: |-
224
+
(ys) => ys.map(y => y/ys[0])
197
225
```
198
226
199
227
note: `ys[0]`represents the first "known" value, which is the value furthest to the past among the downloaded data. This value will change if you scroll, zoom out, change the hours_to_show, or just let time pass.
200
228
201
229
#### Accumulated value
202
230
203
231
```yaml
204
-
- entity: sensor.my_sensor
205
-
unit_of_measurement: "total pulses"
206
-
lambda: |-
207
-
(ys) => {
208
-
let accumulator = 0;
209
-
return ys.map(y => accumulator + y)
210
-
}
232
+
- entity: sensor.my_sensor
233
+
unit_of_measurement: "total pulses"
234
+
lambda: |-
235
+
(ys) => {
236
+
let accumulator = 0;
237
+
return ys.map(y => accumulator + y)
238
+
}
211
239
```
212
240
213
241
#### Derivative
214
242
215
243
```yaml
216
-
- entity: sensor.my_sensor
217
-
unit_of_measurement: "pulses / second"
218
-
lambda: |-
219
-
(ys, xs) => {
220
-
let last = {
221
-
x: new Date(),
222
-
y: 0,
223
-
}
224
-
return ys.map((y, index) => {
225
-
const x = xs[index];
226
-
const dateDelta = x - last.x;
227
-
const yDelta = (y - last.y) / dateDelta;
228
-
last = { x, y };
229
-
return yDelta;
230
-
})
244
+
- entity: sensor.my_sensor
245
+
unit_of_measurement: "pulses / second"
246
+
lambda: |-
247
+
(ys, xs) => {
248
+
let last = {
249
+
x: new Date(),
250
+
y: 0,
231
251
}
252
+
return ys.map((y, index) => {
253
+
const x = xs[index];
254
+
const dateDelta = x - last.x;
255
+
const yDelta = (y - last.y) / dateDelta;
256
+
last = { x, y };
257
+
return yDelta;
258
+
})
259
+
}
232
260
```
233
261
234
262
#### Right hand riemann integration
235
263
236
264
```yaml
237
-
- entity: sensor.my_sensor
238
-
unit_of_measurement: "kWh"
239
-
lambda: |-
240
-
(ys, xs) => {
241
-
let accumulator = 0;
242
-
let last = {
243
-
x: new Date(),
244
-
y: 0,
245
-
}
246
-
return ys.map((y, index) => {
247
-
const x = xs[index]
248
-
const dateDelta = x - last.x;
249
-
accumulator += last.y * dateDelta;
250
-
last = { x, y };
251
-
return accumulator;
252
-
})
265
+
- entity: sensor.my_sensor
266
+
unit_of_measurement: "kWh"
267
+
lambda: |-
268
+
(ys, xs) => {
269
+
let accumulator = 0;
270
+
let last = {
271
+
x: new Date(),
272
+
y: 0,
253
273
}
274
+
return ys.map((y, index) => {
275
+
const x = xs[index]
276
+
const dateDelta = x - last.x;
277
+
accumulator += last.y * dateDelta;
278
+
last = { x, y };
279
+
return accumulator;
280
+
})
281
+
}
254
282
```
255
283
256
284
#### Access all entity attributes inside lambda
257
285
258
286
```yaml
259
-
- entity: climate.wintergarten_floor::valve
287
+
- entity: climate.wintergarten_floor
288
+
attribute: valve
260
289
unit_of_measurement: °C
261
290
lambda: |-
262
291
(ys, xs, entity) =>
@@ -282,6 +311,7 @@ note: `ys[0]` represents the first "known" value, which is the value furthest to
282
311
default configurations for all entities and all yaxes (e.g yaxis, yaxis2, yaxis3, etc).
283
312
284
313
```yaml
314
+
type: custom:plotly-graph
285
315
entities:
286
316
- sensor.temperature1
287
317
- sensor.temperature2
@@ -304,6 +334,7 @@ Anything from https://plotly.com/javascript/reference/layout/.
304
334
Use this if you want to use plotly default layout instead. Very useful for heavy customization while following pure plotly examples.
305
335
306
336
```yaml
337
+
type: custom:plotly-graph
307
338
entities:
308
339
- entity: sensor.temperature_in_celsius
309
340
no_default_layout: true
@@ -312,6 +343,7 @@ no_default_layout: true
312
343
### disable Home Assistant themes:
313
344
314
345
```yaml
346
+
type: custom:plotly-graph
315
347
entities:
316
348
- entity: sensor.temperature_in_celsius
317
349
no_theme: true
@@ -328,6 +360,7 @@ When true, will tell HA to only fetch datapoints with a different state as the o
328
360
More here: https://developers.home-assistant.io/docs/api/rest/ under `/api/history/period/<timestamp>`
329
361
330
362
Caveats:
363
+
331
364
1. zana-37 repoorts that `minimal_response: false` needs to be set to get all non-significant datapoints [here](https://github.com/dbuezas/lovelace-plotly-graph-card/issues/34#issuecomment-1085083597).
332
365
2. This configuration will be ignored (will be true) while fetching [Attribute Values](#Attribute-Values).
333
366
@@ -341,6 +374,7 @@ When true, tell HA to only return last_changed and state for states other than t
341
374
More here: https://developers.home-assistant.io/docs/api/rest/ under `/api/history/period/<timestamp>`
342
375
343
376
Caveats:
377
+
344
378
1. This configuration will be ignored (will be true) while fetching [Attribute Values](#Attribute-Values).
0 commit comments