i’m a newbie, but i’m a developer in other walks of life.
my house occasionally gets power cuts, like most people’s, and my deconz doesnt connect on a system startup nicely until homeassistant itself is rebooted.
(i’ve put my code inside back ticks - why does it still pop up at me? when i post this. )
so i left it running, and i tested it by turning the rPi off , and on.
and it did what it was supposed to do. so i waked away for a few hours. came back.
but … it still was rebooting for some reason. i disabled the whole automation temporarily, and the homeassistant stopped rebooting (so i know it is this script). Re-Enabled the script, and sure enough it started rebooting HA again.
the sensor.system_up_time_seconds was well above 250, it was in the thousands (26322). but still it got past the condition.
so i’m baffled really. is it evaluating the condition as ASCII rather than a number. how do i force it to use integers.
also, separate questions, when i open those brackets in yaml… {{ am i then writing in jinja2 language? just wondered.
i’ve modified the above… just taking away the apostrophes surrounding the 250. does this make it think i’m comparing numbers now then?
i’m not an expert on this syntax. i keep seeing examples where they type " | int " in the middle of conditional statements, and i dont know what that is meant to mean. if i interpret it in c++ or javascript , in my mind, it makes no sense to me in that world.
the reason i’m not using the “simpler” numeric state condition… ultimately…, is because i’d like a unified method of defining such conditional statements (instead of sometimes data and sometimes data_template, indent this, dont indent that). there seems to be 3 different ways of doing things in hass. and i’d like to just learn one, the most complicated way, because ultimately i’m going to be doing some complicated conditional statements later, and condition: -condition: [] isn’t quite going to cut it. i’m happy to work in a programming form, and space things out, and #comment things.
so is this {{ }} notation making it interpret the inner working of those curly brackets in the jinja2 language?
the variable “system_up_time_seconds” is 63, 123, 183 (as time goes by) and the condition never evaluates to true and thus the hass does not reboot.
you’ll notice the #commented out bits (which use Numeric State in yaml speak) - this does work! (in
a separate test) but why doesn’t my Jinja2 syntax work in this test?
data_template is going away - so that’s one less thing to worry about Indenting will always be a thing to worry about while you use YAML though. The only “solution” is to jump ship to Node Red.
Yes, and that’s shown (but not explained) in the templating docs. It is explained in the linked Jinja2 docs though, since it’s a Jinja2 thing.