It’s really already Xmas? HomeAssistant helper entity with current month used for visibility of cards in UI
Not everything is like shorts for computer science students – some other things only make sense in certain months.
Like my webscrapers for the current water temperature of the outside pool or the warning system for below 0°C degress.
To hide them in the HomeAssistant UI I created a helper that is filled with the current month as number 1 to 12 and can be nicely used for logical decisions.
Create helper:
Go to Settings > Devices and services > Helpers and “CREATE HELPER”. Choose Template > Template a sensor.
Enter a name like “Current month” and in the state template the following.
{{ now().month }}
You should see the current month as number in the preview. Press “SUBMIT” and now you have a entity with that value available.
Using the entity:
If you want it to use for a visibility condition of a card go to the view (e.g. “Overview”) and click on the pencil button to edit the cards and click “EDIT” on the desired card. Go to the tab “VISIBILITY” and then “+ ADD CONDITION” and choose “Entity numeric state”. Enter the name of the current month entity and define the logical expression like “Above” 4 and “Below” 11 to only show it from May to October. If the defined time span is e.g. from November to April, you have to create an Or-condition first and place two “Entity numeric state” conditions in there. The first is above 0 to below 5 and the other one above 10 and below 13 to cover the desired months 11 to 4.
Hope that help. Have fun tinkering around!