-
As already mentioned here, I noticed that nested attributes cannot be accessed in the lambda function. For example, I want to make a plot from weather forecast data that looks like this:
Similar to this ApexCharts example, the lambda function should look something like this:
However, I found no way to make it work because |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 25 replies
-
What weather integration is this one? |
Beta Was this translation helpful? Give feedback.
-
Have you tried using lambdas? I unfortunately have no sensors with nested attributes and can therefore not test it myself |
Beta Was this translation helpful? Give feedback.
-
It was not completely clear to me what you asked me to do and post. So I hope this is what you meant. I placed a plotly graph card on one of my dashboards and configured it like so
This generated the following error in the log
I get the same error with any working plot as soon as I add the lambda you provided. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Bingo ! Thanks for your hint. It was the return statement. Now it is working as expected. Before I show my final configuration, let me answer your question why I calculate the x values myself. Hopefully I can explain it well enough :) OK, here my final configuration: Template sensor
ToDo: Find a way to have only 1 for loop in which all variables needed are created. Then use the namespace variables in the attribute_templates. Plotly Graph Card Configuration
ToDo: Come up with graph card layouts and settings for the different values. For example how to dynamically set the lower limit of the y axis for the temperature, because I don't want that to be 0 which is the default. |
Beta Was this translation helpful? Give feedback.
-
Regarding the template sensor: The output looks good in the template sandbox in the developer tools, but HA doesn't like it in the configuration.
results in
Line 188 is this one |
Beta Was this translation helpful? Give feedback.
-
For the weather forecast I would like to use bar plots, because the data points have a fix interval (every hour) and the bars make it easy to distinguish between them.
but it doesn't work. |
Beta Was this translation helpful? Give feedback.
-
Good news! Almost... it may only start working after 1 automatic update. |
Beta Was this translation helpful? Give feedback.
-
@midiwidi :) |
Beta Was this translation helpful? Give feedback.
Bingo !
Thanks for your hint. It was the return statement. Now it is working as expected.
Before I show my final configuration, let me answer your question why I calculate the x values myself. Hopefully I can explain it well enough :)
If you look at the very first post from @thomaschn or in my first post which shows the original weather data, you notice that all data points of the weather forecast is contained in the forecast attribute of a single weather entity data point.
It is not like usual sensor data which have 1 data point (usually the state) per entity which evolves over time so that the data series is contained in the history of the entity.
When I create my custom template sensor…