Wierd problem with javascripts and time_offset #544
Closed
henriknordgren
started this conversation in
General
Replies: 1 comment 2 replies
-
Did you try
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Ok, I have a template sensor which outputs an offset like "-24h"
Then in my plotly graph I do this
time_offset: $fn ({ hass }) => hass.states["sensor.offset_hours"].state
It doesnt show anything at all. I have confirmed that plotly can interpret the state by doing this:
It correctly output -33h or whatever the template is.
Also, I tried this:
time_offset: $fn ({ hass }) => '-33h'
and it worked perfectly with correct values in the graph.
I have spent several hours testing back and forth, and can't figure out why it doesnt work with the offset?
I tried this variant also:
time_offset: ${ states["sensor.offset_hours"].state }
and it doesnt work here, but it works for lots of other properties like:
It is funny, the problem started when I wanted to subtract a constant from the offset. I did this originally when the offset was just an input_number:
time_offset: ${ parseInt(states["input_number.offset"].state) * 24 + 'h' }
the above worked beautifully, but when I did this:
time_offset: ${ ((parseInt(states["input_number.offset"].state) * 24) -9) + 'h' }
The problems started. Then I moved to a sensor template instead, but still no joy.
I cant seem to figure out why it refuses to work, do please help...
Beta Was this translation helpful? Give feedback.
All reactions