Format date/time
With the now().strftime(‘XXX’), you can output the current date/time, in a certain format.
Replacing the XXX with a combination of “Format”, allows you to get a timestamp in the format your prefer. You can add multiple format tags, and also include other characters.
Format | Description |
---|---|
%a | Name of day, first 3 characters |
%A | Name of day, in full |
%d | Number of day (formatted in 2 digits) |
%B | Name of month, in full |
%m | Number of month (formatted in 2 digits) |
%Y | Number of year (formatted in 4 digits) |
%H | Hour (24-hours format) |
%I | Hour (12-hours format) |
%p | AM / PM |
%M | Minute (formatted in 2 digits) |
%S | Second (formatted in 2 digits) |
%U | Weeknumber (formatted in 2 digits) |
%j | Day count (formatted in 3 digits) |
Counters
You can use the following lines in scripting / automation, or simply put it in the templates editor,
under development.
Description | Command |
---|---|
Lights | {{ states.light | count }} |
Switches | {{ states.switch | count }} |
Binary sensors | {{ states.binary_sensor | count }} |
Sensors | {{ states.sensor | count }} |
Automations | {{ states.automation | count }} |
Entities | {{ states | count }} |
Trackers | {{ states.device_tracker | count }} |
Climate | {{ states.climate | count }} |
Media-players | {{ states.media_player | count }} |
Cameras | {{ states.camera | count }} |
Persons | {{ states.person | count }} |
Helpers-boolean | {{ states.input_boolean | count }} |
Helpers-select | {{ states.input_select | count }} |
Helpers-text | {{ states.input_text | count }} |
Helpers-counter | {{ states.counter | count }} |
Multiple spaces
Sometimes you need more then one space-character.
Due to the nature of HTML, this gets most of the time, reduced to one character.
However, there is a simple solution for it:
*Press and hold <ctrl> and <shift> together.
*next, type U 0 0 A 0
*after this, press <space> and let go the <ctrl> and <shift> key.
*You will then have a space that you can copy/paste, and you can put it multiple times on a line.
*Note that with some fonts, this gives a “visible” character 🙁