-
Describe the bug yaml type: custom:plotly-graph
entities:
- entity: sensor.tb_house_consumption_kw
name: Grid
fill: tozeroy
line:
color: '#77aaff'
shape: spline
show_value: false
extend_to_present: false
on_legend_click: {}
on_click: {}
on_dblclick: {}
filters:
- resample: 10m
- entity: sensor.tb_solaredge_ac_power
name: Solar
fill: tozeroy
line:
shape: spline
color: '#ff8800'
show_value: false
extend_to_present: false
on_legend_click: {}
on_click: {}
on_dblclick: {}
filters:
- resample: 10m
- entity: sensor.tb_house_solar_only_consumption_kw
name: Self
fill: tozeroy
line:
color: '#00eeee'
shape: spline
show_value: false
extend_to_present: false
on_legend_click: {}
on_click: {}
on_dblclick: {}
filters:
- resample: 10m
hours_to_show: current_day
refresh_interval: 1
config:
scrollZoom: false
displayModeBar: false
staticPlot: true Additional context |
Beta Was this translation helpful? Give feedback.
Replies: 26 comments 5 replies
-
In the console I see a lot of the following errors: |
Beta Was this translation helpful? Give feedback.
-
I clear the console, and did a refresh and this is what I see: |
Beta Was this translation helpful? Give feedback.
-
Not sure how to get the information you need to debug ? |
Beta Was this translation helpful? Give feedback.
-
Check out this section: https://github.com/dbuezas/lovelace-plotly-graph-card#debugging With it you can dump the data to the console for analysis |
Beta Was this translation helpful? Give feedback.
-
The issue may be the resample filter |
Beta Was this translation helpful? Give feedback.
-
I looked at my implementation of resampling, and it should actually add a bunch of nulls, but try without it to narrow this down :) |
Beta Was this translation helpful? Give feedback.
-
here is the graph with nofill / no resampling. This looks correct. |
Beta Was this translation helpful? Give feedback.
-
And this is nofill but with resampling. |
Beta Was this translation helpful? Give feedback.
-
I see. Maybe you can map all the null values to the number zero before resampling? |
Beta Was this translation helpful? Give feedback.
-
This would give a reasonable result after resampling, even if you use fill |
Beta Was this translation helpful? Give feedback.
-
Is there an easy way to do that, maybe with a filter ? Would that work ?
|
Beta Was this translation helpful? Give feedback.
-
Yes, Use map_y instead |
Beta Was this translation helpful? Give feedback.
-
OK, I gave it a go, but still not working. Here is a simplified graph with various options. Any option used in filters: seems to mess up the line / fill. |
Beta Was this translation helpful? Give feedback.
-
Try map_y: isNaN(+y) ? 0 : y Maybe y is "unavailable" or something like that. BTW, map_y_numbers is expected to remove nulls, since they are not numbers edit: fixed typo isNan => isNaN |
Beta Was this translation helpful? Give feedback.
-
I am getting this error with isNan function ? |
Beta Was this translation helpful? Give feedback.
-
I think checking against null or undefined works because the graph changes. How do you use the debugger to check further ? I looked at the debugging section but not sure what to do in the debugger (not used to it) |
Beta Was this translation helpful? Give feedback.
-
Were you able to reproduce it ? |
Beta Was this translation helpful? Give feedback.
-
just a typo, I updated my message above |
Beta Was this translation helpful? Give feedback.
-
Oh I see, you are right, it is working. So it is not that the sensor has "unavailable" datapoints, they are just missing. In this case, joining the lines is actually reasonable behaviour. What you can do is add an extra fake datapoint filters:
- fn: |-
({xs, ys}) => ({
xs: xs.flatMap((x, i) => ys[i+1] === null ? [x,x]:[x]),
ys: ys.flatMap((y, i) => ys[i+1] === null ? [y,null]:[y])
}) This will insert an extra undefined to the ys array, but set its date to that of the last known value. This should make the gap as wide as the whole missing chunk |
Beta Was this translation helpful? Give feedback.
-
I tried to add the fn above, but the syntax doesn't seem correct, and HA keeps spinning. And the multiline version not working: |
Beta Was this translation helpful? Give feedback.
-
Add an extra indentation (2 spaces) to all lines inside -fn |
Beta Was this translation helpful? Give feedback.
-
(ok, that's equivalent to the single line) |
Beta Was this translation helpful? Give feedback.
-
I tried but this is still not working as expected: |
Beta Was this translation helpful? Give feedback.
-
Interesting topic @Thlerry , I've also experimented with Plotly Graphs for SolarEdge system here: #320 |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Oh I see, you are right, it is working. So it is not that the sensor has "unavailable" datapoints, they are just missing. In this case, joining the lines is actually reasonable behaviour. What you can do is add an extra fake datapoint
This will insert an extra undefined to the ys array, but set its date to that of the last known value. This should make the gap as wide as the whole missing chunk