Is this the right way to write this, more so the int part?
- platform: template
value_template: "{{ state_attr('sun.sun', 'elevation') | int > -3.5 }}"
Is this the right way to write this, more so the int part?
- platform: template
value_template: "{{ state_attr('sun.sun', 'elevation') | int > -3.5 }}"
The int
filter produces an integer, in other words a whole number (no fractional values: 1, 2, 3, etc).
The sun’s elevation is an attribute. In fact, because it’s an attribute, it can have a type that is something other than a string (in contrast, an entity’s state can only be a string). In this particular case, the elevation attribute is a floating-point number (a “float”). That means you don’t need to convert it using either int
or float
.
value_template: "{{ state_attr('sun.sun', 'elevation') > -3.5 }}"