Around Christmas time i have some stuff around, which is powered on/off with HA. But outside this period i do not want to see these buttons etc. After some googling i found out that that ca be done with a Conditional card.
Here the result of my struggles to let this work. It took a bit of googling before i understood how to do that.
Install the Time & Date integration.
For starters you should install the Time & Date integration. (However i am wondering now if it’s really needed…)
- Go to Settings – Devices en Services – Integrations
- Search for the integratie and install it.
- Make sure you create a sensor.date entity.
Create a template binary sensor
Next step is to use the integration above to let a binary switch toggle on the correct date’s. This can be accomplished with a template binary sensor
The thing is that templates can only be added inside the configuration.yaml. You can not do this in the web Gui. The configuration.yaml is found in the root folder of yout configuration folders.
I added the following yaml code:
template:
- binary_sensor:
- unique_id: christmas_season
name: Christmas Season
state: >
{%- set today = now().date() %}
{%- set StartKerst = today.replace(month=12, day=6) %}
{%- set StopKerst = today.replace(month=1, day=9) %}
{{ today <= StopKerst or today >= StartKerst }}
attributes:
template: seasons
I you want to change stuff: you can test the {} code in the webGUI, @: Menu Developertools – Template. Here you can paste the code which is between the {}. The result will be a true or false. 🙂
Unfortunately you NEED TO RESTART home-assistant to read the new binary sensor into the configuration. Do this through: Developertools – YAML – Check en Restart – Restart – Restart Home-Assistant. (Belief me, tho option Quick Reload does not work)
Create Conditional Card
Now we can create the conditional card:
- Go to the page/dashboard where you want to place the card.
- Klick on the upper-right on Edit, and then on the lower-right on + Add Card
- Search for ‘Conditional’ Card and select.
- Below the Condition Tab klick on ‘Add Condition’, select ‘Entity State’
- Search the just created ‘Christmas Season’ sensor, and set “State equal to” to On.
- Click on the Tab “Card”, select the Card you wish to use, and configure it to your needs.
It took some time for me to find out, but i learned a lot again. 🙂
This was my first Home Assistant blog, i will do a lot more, also from projects i created earlier….😊