@@ -353,8 +353,8 @@ entities:
353353 width: 1
354354 dash: dot
355355 color: deepskyblue
356- x: $fn () => [Date.now(), Date.now()]
357- y: $fn () => [0,1]
356+ x: $ex [Date.now(), Date.now()]
357+ y: [0, 1]
358358layout:
359359 yaxis9:
360360 visible: false
@@ -749,13 +749,29 @@ The returned value will be used as value for the property where it is found. E.g
749749name: $fn ({ hass }) => hass.states["sensor.garden_temperature"].state
750750` ` `
751751
752+ or a universal expression `$ex` (the parameters and arrow are added automatically) :
753+
754+ ` ` ` js
755+ name: $ex hass.states["sensor.garden_temperature"].state
756+ ` ` `
757+
758+ which can also take a block :
759+
760+ ` ` ` js
761+ name: |
762+ $ex {
763+ return hass.states["sensor.garden_temperature"].state
764+ }
765+ ` ` `
766+
752767# ## Available parameters:
753768
754769Remember you can add a `console.log(the_object_you_want_to_inspect)` and see its content in the devTools console.
755770
756771# ### Everywhere:
757772
758773- `getFromConfig : (path) => value;` Pass a path (e.g `entities.0.name`) and get back its value
774+ - `get : (path) => value;` same as `getFromConfig`
759775- `hass : HomeAssistant object;` For example: `hass.states["sensor.garden_temperature"].state` to get its current state
760776- `vars : Record<string, any>;` You can communicate between functions with this. E.g `vars.temperatures = ys`
761777- `path : string;` The path of the current function
@@ -784,8 +800,7 @@ type: custom:plotly-graph
784800entities:
785801 - entity: sensor.garden_temperature
786802 name: |
787- $fn ({ ys,meta }) =>
788- meta.friendly_name + " " + ys[ys.length - 1]
803+ $ex meta.friendly_name + " " + ys[ys.length - 1]
789804` ` `
790805
791806# ### Sharing data across functions
@@ -796,10 +811,8 @@ entities:
796811 - entity: sensor.garden_temperature
797812
798813 # 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
799- fn: |
800- $fn ({ ys, vars }) =>
801- vars.title = ys[ys.length - 1]
802- title: $fn ({ vars }) => vars.title
814+ fn: $ex vars.title = ys[ys.length - 1];
815+ title: $ex vars.title
803816` ` `
804817
805818# ### Histograms
@@ -808,7 +821,7 @@ title: $fn ({ vars }) => vars.title
808821type: custom:plotly-graph
809822entities:
810823 - entity: sensor.openweathermap_temperature
811- x: $fn ({ys,vars}) => ys
824+ x: $ex ys
812825 type: histogram
813826title: Temperature Histogram last 10 days
814827hours_to_show: 10d
@@ -895,8 +908,8 @@ When true, the `x` and `y` properties of the traces won't be automatically fille
895908type: custom:plotly-graph
896909entities:
897910 - entity: sensor.temperature_in_celsius
898- x: $fn ({xs}) => xs
899- y: $fn ({ys}) => ys
911+ x: $ex xs
912+ y: $ex ys
900913raw_plotly_config: true # defaults to false
901914` ` `
902915
0 commit comments