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
* prototype notebook
* class
* about to start integration
* last jupyter notebook
* first version that runs
* allow keys required for entity fetching to appear after a $fn if they are literals.
* fixed multiple isssues
* don't fetch non visible traces
* disable parsing of functions that return functions
* moved offset handling completely out of the cache
* Implemented observed_range clipping
* improved touch handler
* Perf
* cleanup
* Recover after config error.
* fixed filter output storage
* removed debug logs
* moved fnParams to the class
* Reordered functions in parse-config and simplified a bit
* hot reload on dev mode
* remove perf logs and put class at the top
* fixed default entity values
* pass path instead of entityIdx as fnParam
* $fn documentation
* Added the rest of plotly (from 1.1mb to 2.2mb) for advanced plots.
* Better errors and renamed/deprecated offset to time_offset
* removed no_ha_theme and no_default_layout in favour of ha_theme and raw_plotly_config
* re-fetch and autoscale on relevant config changes
* Added "do you mean" to filter name errors
* renamings
* modularization and ha_theme unaffected by raw plotly config
* docs and better css_vars for ha_theme
* improved uirevision logic
* simplifying defaults (1/2)
* modularisation and fixed types
* Warn on unknown time unit on derivative and integral
* Removed old gotcha about the plot not rendering on exceptions
* fix ha_theme default
* organised the order of functions in parse-config a bit
* new screenshot examples in readme
* fix readme glitch
Remember you can add a `console.log(the_object_you_want_to_inspect)` and see its content in the devTools console.
691
702
692
-
Deprecated. Use filters instead.
693
-
Your old lambdas should still work for now but this API will be removed in March 2023.
703
+
#### Everywhere:
704
+
705
+
- `getFromConfig: (path) => value;` Pass a path (e.g `entities.0.name`) and get back its value
706
+
- `hass: HomeAssistant object;` For example: `hass.states["sensor.garden_temperature"].state` to get its current state
707
+
- `vars: Record<string, any>;` You can communicate between functions with this. E.g `vars.temperatures = ys`
708
+
- `path: string;` The path of the current function
709
+
- `css_vars: HATheme;` The colors set by the active Home Assistant theme (see #ha_theme)
710
+
711
+
#### Only iniside entities
712
+
713
+
- `xs: Date[];` Array of timestamps
714
+
- `ys: YValue[];` Array of values of the sensor/attribute/statistic
715
+
- `statistics: StatisticValue[];` Array of statistics objects
716
+
- `states: HassEntity[];` Array of state objects
717
+
- `meta: HassEntity["attributes"];` The current attributes of the sensor
718
+
719
+
#### Gotchas
720
+
721
+
- The following entity attributes are required for fetching, so if another function needs the entity data it needs to be declared below them. `entity`,`attribute`,`offset`,`statistic`,`period`
722
+
- Functions are allowed for those properties (`entity`, `attribute`, ...) but they do not receive entity data as parameters. You can still use the `hass` parameter to get the last state of an entity if you need to.
723
+
- Functions cannot return functions for performance reasons. (feature request if you need this)
724
+
- Defaults are not applied to the subelements returned by a function. (feature request if you need this)
725
+
- You can get other values from the yaml with the `getFromConfig` parameter, but if they are functions they need to be defined before.
726
+
727
+
#### Adding the last value to the entitiy's name
728
+
729
+
```yaml
730
+
type: custom:plotly-graph
731
+
entities:
732
+
- entity: sensor.garden_temperature
733
+
name: |
734
+
$fn ({ ys,meta }) =>
735
+
meta.friendly_name + " " + ys[ys.length - 1]
736
+
```
737
+
738
+
#### Sharing data across functions
739
+
740
+
```yaml
741
+
type: custom:plotly-graph
742
+
entities:
743
+
- entity: sensor.garden_temperature
744
+
745
+
# the fn attribute has no meaning, it is just a placeholder to put a function there. It can be any name not used by plotly
746
+
fn: |
747
+
$fn ({ ys, vars }) =>
748
+
vars.title = ys[ys.length - 1]
749
+
title: $fn ({ vars }) => vars.title
750
+
```
751
+
752
+
#### Histograms
753
+
754
+
```yaml
755
+
type: custom:plotly-graph
756
+
entities:
757
+
- entity: sensor.openweathermap_temperature
758
+
x: $fn ({ys,vars}) => ys
759
+
type: histogram
760
+
title: Temperature Histogram last 10 days
761
+
hours_to_show: 240
762
+
raw_plotly_config: true
763
+
layout:
764
+
margin:
765
+
t: 0
766
+
l: 50
767
+
b: 40
768
+
height: 285
769
+
xaxis:
770
+
autorange: true
771
+
```
772
+
773
+
#### custom hover text
774
+
775
+
```yaml
776
+
type: custom:plotly-graph
777
+
title: hovertemplate
778
+
entities:
779
+
- entity: climate.living
780
+
attribute: current_temperature
781
+
customdata: |
782
+
$fn ({states}) =>
783
+
states.map( ({state, attributes}) =>({
784
+
...attributes,
785
+
state
786
+
})
787
+
)
788
+
hovertemplate: |-
789
+
<br> <b>Mode:</b> %{customdata.state}<br>
790
+
<b>Target:</b>%{y}</br>
791
+
<b>Current:</b>%{customdata.current_temperature}
792
+
<extra></extra>
793
+
hours_to_show: 24
794
+
```
694
795
695
796
## Default trace & axis styling
696
797
@@ -715,45 +816,42 @@ defaults:
715
816
To define layout aspects, like margins, title, axes names, ...
716
817
Anything from https://plotly.com/javascript/reference/layout/.
717
818
718
-
### disable default layout:
819
+
### Home Assistant theming:
820
+
821
+
Toggle Home Assistant theme colors:
719
822
720
-
Use this if you want to use plotly default layout instead. Very useful for heavy customization while following pure plotly examples.
823
+
- card-background-color
824
+
- primary-background-color
825
+
- primary-color
826
+
- primary-text-color
827
+
- secondary-text-color
721
828
722
829
```yaml
723
830
type: custom:plotly-graph
724
831
entities:
725
832
- entity: sensor.temperature_in_celsius
726
-
no_default_layout: true
833
+
ha_theme: false #defaults to true
727
834
```
728
835
729
-
### disable Home Assistant themes:
836
+
### Raw plotly config:
837
+
838
+
Toggle all in-built defaults for layout and entitites. Useful when using histograms, 3d plots, etc.
839
+
When true, the `x` and `y` properties of the traces won't be automatically filled with entity data, you need to use $fn for that.
730
840
731
841
```yaml
732
842
type: custom:plotly-graph
733
843
entities:
734
844
- entity: sensor.temperature_in_celsius
735
-
no_theme: true
845
+
x: $fn ({xs}) => xs
846
+
y: $fn ({ys}) => ys
847
+
raw_plotly_config: true # defaults to false
736
848
```
737
849
738
850
## config:
739
851
740
852
To define general configurations like enabling scroll to zoom, disabling the modebar, etc.
741
853
Anything from https://plotly.com/javascript/configuration-options/.
742
854
743
-
## significant_changes_only
744
-
745
-
When true, will tell HA to only fetch datapoints with a different state as the one before.
746
-
More here: https://developers.home-assistant.io/docs/api/rest/ under `/api/history/period/<timestamp>`
747
-
748
-
Caveats:
749
-
750
-
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).
751
-
2. This configuration will be ignored (will be true) while fetching [Attribute Values](#Attribute-Values).
752
-
753
-
```yaml
754
-
significant_changes_only: true # defaults to false
755
-
```
756
-
757
855
## disable_pinch_to_zoom
758
856
759
857
```yaml
@@ -762,19 +860,6 @@ disable_pinch_to_zoom: true # defaults to false
762
860
763
861
When true, the custom implementations of pinch-to-zoom and double-tap-drag-to-zooming will be disabled.
764
862
765
-
## minimal_response
766
-
767
-
When true, tell HA to only return last_changed and state for states other than the first and last state (much faster).
768
-
More here: https://developers.home-assistant.io/docs/api/rest/ under `/api/history/period/<timestamp>`
769
-
770
-
Caveats:
771
-
772
-
1. This configuration will be ignored (will be false) while fetching [Attribute Values](#Attribute-Values).
0 commit comments