You could still use the Conditional card mixed with and automation script where the on state is for night time and the off state for day time. Now, the only problem at the moment is that the Conditional card is broken. It should be fixed on 0.81.4.
{{ states('sensor.battery_level') | int < 10
or states('sensor.battery_level_2') | int < 10
or states('sensor.hue_outdoor_motion_sensor_1_battery') | int < 10 }}
Hi Petro, sorry, this mathematical christmas season sensor is too hard for me to figure out. Can you please help me to understand how to convert this to a binairy sensor? I have tried:
- platform: template
sensors:
christmas_season:
friendly_name: Christmas Season (1 dec - 15 jan)
value_template: >-
{%- set month, week, day = 11, 4, 3 %}
{%- set today = now().date() %}
{%- set temp = today.replace(month=month, day=1) %}
{%- set adjust = (day - temp.weekday()) % 7 %}
{%- set temp = temp + timedelta(days=adjust) %}
{%- set thanksgiving = temp + timedelta(weeks = week - 1) %}
{%- set jan15th = temp.replace(month=1, day=15) %}
But it stayed off after 1 dec…
Can you give me a hint or maybe please point out where it could be wrong?
I am now using this and that seems to work well:
- platform: template
sensors:
christmas_time_2:
friendly_name: Christmas Season (1 dec - 15 jan) - 2
value_template: >
{% set today = states('sensor.date').split('-') %}
{% set month = today[1]|int %}
{% set day = today[2]|int %}
{{ month == 12 and day >= 1 or month == 1 and day <= 10 }}
you didn’t copy the template correctly… you’re missing the last line. As for the template itself, what does the first line of the template say? set month, week, day… so if you want December first, what month is that? and what week would the first day be in?
S rr , I d d not unders nd th t I ne d d to c py a l th c nt nt of an th r l nk. Ne t t me I will do be er.
I think you will be a good teacher! You remind me of a a professor when I was young.
@petro don’t forget that I am an overenthusiastic HA user. I do know a lot (I think) but I have major problems with the format of ymal/json coding, especially template formatting. Templates are my weak point, and I appreciate all your help (again - think I am only saying this to you since you a lecturing me as if I am at school).
@petro has some slick templating in the github repository, especially this one based on the Thanksgiving Holiday!
For anyone that needs a simple date condition for the Christmas Holiday, this is what I came up with to have a simple trigger for dates between 11/1 and 1/15.