I have a list of constants holding localized day names for different languages. I am using this list for different template sensors. Instead of recreating the list again and again for each sensor is it possible to create the list itself as template sensor or another way of storing it? I tried using the commented code, but it did not work, as state must not return a list…
States are always strings, attributes can be other data types. You can use the state and then use a split function in the subsequent sensors or you can set up an attribute.
Thanks a lot, both suggested solutions sound good!
The disadvantage of the import is that I need to write the import for every template instead of the line with the definition. So concerning length of the templates this does not improve at all, but of course I see the big benefit of code maintainability (only need to make changes in one places). It also feels like the right way to do.
Using template sensor attributes seems a bit hacky to me, but is very comfortable and would also not require another line for importing.
I will consider what I like most and which solution I will use. Thank you both for your help
PS: I really like your library for all those time calculations!