cobrajdm
(cobrajdm)
September 15, 2020, 4:30pm
3
Thank you for pointing that out Tom
Let me try this again
################################################################################
## Timer Input Box Information
################################################################################
input_boolean:
chicken_coop_light_timer_on_enabled:
name: "chicken_coop_light ON timer"
initial: off
icon: mdi:timer
chicken_coop_light_timer_off_enabled:
name: "chicken_coop_light OFF timer"
initial: off
icon: mdi:timer-off
cobrajdm
(cobrajdm)
September 15, 2020, 4:30pm
4
input_datetime:
turn_chicken_coop_light_on_time:
name: "Turn Chicken Coop Light on at"
has_time: true
has_date: false
initial: "06:00"
turn_chicken_coop_light_off_time:
name: "Turn Chicken Coop Light off at"
has_time: true
has_date: false
initial: "20:00"
cobrajdm
(cobrajdm)
September 15, 2020, 4:31pm
5
################################################################################
## Chicken Coop Timer Automation Information
################################################################################
#TURN CHICKEN COOP LIGHT ON AT SPECIFIC TIME
- id: 'ChickenCoopLightOn'
alias: Turn on Chicken Coop Light with Timer
trigger:
platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.turn_chicken_coop_light_on_time', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.chicken_coop_light_timer_on_enabled
state: 'on'
action:
entity_id: switch.chickencoop
service: switch.turn_on
cobrajdm
(cobrajdm)
September 15, 2020, 4:31pm
6
#TURN CHICKEN COOP LIGHT OFF AT SPECIFIC TIME
- id: 'ChickenCoopLightOff'
alias: Turn off Chicken Coop Light with Timer
trigger:
platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.turn_chicken_coop_light_on_time', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.chicken_coop_light_timer_on_enabled
state: 'on'
action:
entity_id: switch.chickencoop
service: switch.turn_off
tom_l
September 15, 2020, 4:34pm
7
See here for a solution:
BTW because the time from input_datetime has the “:00” at the end while the sensor.time.state, doesn’t, the final value template looks as follows:
value_template: "{{ states.sensor.time.state == states.input_datetime.switch_off.state[0:5] }}"
The [0:5] gets the first five characters and discards the “:00” at the end.
Though I’d do it like this:
value_template: "{{ states('sensor.time') == states('input_datetime.switch_off')[0:5] }}"
Also, have you seen this?
Scheduler integration for HA
Introduction
In my house I have quite some devices that I want to control based on the time and day. For a while I have been looking for an easy way to set up and manage the automations that control them. HA has lots of functionality, but some things (such as automations), are not as simple to use as I would like. So, I decided to create my own scheduler integration. With a mobile-friendly Lovelace card for managing it.
What is the scheduler integra…
cobrajdm
(cobrajdm)
September 15, 2020, 6:20pm
8
Hello, thank you for you reply and suggestion. I tried it and it did not work like that but I now see the issue. The input_boolean state is not turning on/off it stays off, so I adjusted that in the configuration and it is now working.
cobrajdm
(cobrajdm)
September 15, 2020, 6:20pm
9
#Input Boolean
input_boolean:
chicken_coop_light_timer_on_enabled:
name: "chicken_coop_light ON timer"
initial: off
icon: mdi:timer
chicken_coop_light_timer_off_enabled:
name: "chicken_coop_light OFF timer"
initial: off
icon: mdi:timer-off
#Input Time
input_datetime:
turn_chicken_coop_light_on_time:
name: "Turn Chicken Coop Light on at"
has_time: true
has_date: false
initial: "06:00"
turn_chicken_coop_light_off_time:
name: "Turn Chicken Coop Light off at"
has_time: true
has_date: false
initial: "20:00"
#TURN CHICKEN COOP LIGHT ON AT SPECIFIC TIME
- id: 'ChickenCoopLightOn'
alias: Turn on Chicken Coop Light with Timer
trigger:
platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.turn_chicken_coop_light_on_time', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.chicken_coop_light_timer_on_enabled
state: 'off'
action:
entity_id: switch.chickencoop
service: switch.turn_on
#TURN CHICKEN COOP LIGHT OFF AT SPECIFIC TIME
- id: 'ChickenCoopLightOff'
alias: Turn off Chicken Coop Light with Timer
trigger:
platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.turn_chicken_coop_light_off_time', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.chicken_coop_light_timer_off_enabled
state: 'off'
action:
entity_id: switch.chickencoop
service: switch.turn_off
cobrajdm
(cobrajdm)
September 15, 2020, 6:27pm
10
I do have another issue that I see. When I restart Home Assistant, the input_time, defaults to what is set in the configuration.yaml file and not with what is set on the “Turn Chicken Coop Light on at” input field in Home Assistant Card. Does anyone know how the time, that is set, in the “Turn Chicken Coop Light on at” input field in Home Assistant Card can be retained even after a restart of Home Assistant?
cobrajdm
(cobrajdm)
September 15, 2020, 6:28pm
12
input_datetime:
turn_chicken_coop_light_on_time:
name: "Turn Chicken Coop Light on at"
has_time: true
has_date: false
initial: "06:00"
turn_chicken_coop_light_off_time:
name: "Turn Chicken Coop Light off at"
has_time: true
has_date: false
initial: "20:00"
AJStubbsy
(Adam)
September 15, 2020, 7:24pm
13
If you delete the initial value, it will restore the previous state.
1 Like
cobrajdm
(cobrajdm)
September 15, 2020, 7:33pm
14
That worked. Thank you all this has been solved.
tom_l
September 15, 2020, 7:40pm
15
I used to do a similar thing with input booleans enabling my automations. Now I just turn the automations on or off. No need for the input booleans or conditions.
1 Like
peterf9
(Peter)
July 17, 2021, 8:54pm
16
@tom_l this is exactly what I’m looking to automate my water boiler. Please would you share the code? thanks
tom_l
July 18, 2021, 2:00am
17
Card (you will need the custom button card and custom hui-element cards installed):
entities:
- entity: automation.upstairs_scheduled_vacuum
state_color: true
- entity: automation.downstairs_scheduled_vacuum
state_color: true
- entity: automation.vacuum_notifications
icon: mdi:message-text
name: Enable State Notifications
state_color: true
- entity: input_datetime.vac_on_time
name: Start Time
- card_type: horizontal-stack
cards:
- entity: input_boolean.vac_mon
name: Mon
template: day_button
type: custom:button-card
- entity: input_boolean.vac_tue
name: Tue
template: day_button
type: custom:button-card
- entity: input_boolean.vac_wed
name: Wed
template: day_button
type: custom:button-card
- entity: input_boolean.vac_thu
name: Thu
template: day_button
type: custom:button-card
- entity: input_boolean.vac_fri
name: Fri
template: day_button
type: custom:button-card
- entity: input_boolean.vac_sat
name: Sat
template: day_button
type: custom:button-card
- entity: input_boolean.vac_sun
name: Sun
template: day_button
type: custom:button-card
type: custom:hui-element
type: entities
Button Template (place in top of raw edit mode):
button_card_templates:
day_button:
color_type: icon
hold_action:
action: none
show_label: false
show_name: true
show_state: false
state:
- icon: mdi:checkbox-marked-circle
styles:
card:
- border: solid 1px var(--paper-item-icon-active-color)
- box-shadow: 0px 0px 10px 3px var(--paper-item-icon-active-color)
name:
- color: var(--primary-text-color)
value: 'on'
- icon: mdi:cancel
styles: null
value: 'off'
styles:
card:
- border-radius: 10px
- border: solid 1px var(--primary-color)
- box-shadow: none
- padding: 6px 0px
- margin: 0px 0px
- '--ha-card-background': rgba(0, 0, 0, 0)
grid:
- grid-template-areas: '"i" "n"'
- grid-template-rows: 33% auto
- grid-template-columns: auto
icon:
- width: 28px
name:
- justify-self: middle
- align-self: end
- font-size: 14px
- padding: 0px 0px
- color: var(--secondary-text-color)
tap_action:
action: toggle
Automation:
- id: f8166a12-f880-4e03-b08a-6c8aa4e4bcb3
alias: Upstairs Scheduled Vacuum
trigger:
platform: time
at: input_datetime.vac_on_time
condition:
- condition: state
entity_id: binary_sensor.roborock_today
state: 'on'
action:
- service: vacuum.start
entity_id: vacuum.robovac_upstairs
Binary sensor:
- platform: template
sensors:
roborock_today:
friendly_name: "Roborock Today"
value_template: >
{% set day = states('sensor.day_today') %}
{{ is_state('input_boolean.vac_' ~ day, 'on') and ( is_state('automation.upstairs_scheduled_vacuum', 'on') or is_state('automation.downstairs_scheduled_vacuum', 'on') ) }}
Input booleans:
vac_mon:
name: Monday
icon: mdi:calendar
vac_tue:
name: Tuesday
icon: mdi:calendar
vac_wed:
name: Wednesday
icon: mdi:calendar
vac_thu:
name: Thursday
icon: mdi:calendar
vac_fri:
name: Friday
icon: mdi:calendar
vac_sat:
name: Saturday
icon: mdi:calendar
vac_sun:
name: Sunday
icon: mdi:calendar
2 Likes
Subia75
(Alessio)
July 23, 2021, 12:32pm
18
Hi @tom_l ,
I am a beginner of HA, and I ask for help if possible.
I was trying to insert this beautiful card in lovelace to schedule my vacuu.,
I entered the first part, but I don’t understand where to insert the other 4 program blocks:
Button Template
Automation (I think in a new automation) but which 'id should I enter
Binary sensor
Input booleans
thank you
CJason
May 14, 2022, 12:45am
19
Is there a how-to for beginners for implementing this kind of scheduling?
Thanks.
tom_l
May 14, 2022, 1:16am
20
Read the posts above. Or use this:
Scheduler integration for HA
Introduction
In my house I have quite some devices that I want to control based on the time and day. For a while I have been looking for an easy way to set up and manage the automations that control them. HA has lots of functionality, but some things (such as automations), are not as simple to use as I would like. So, I decided to create my own scheduler integration. With a mobile-friendly Lovelace card for managing it.
What is the scheduler integra…
CJason
May 14, 2022, 1:45am
21
Hi Tom, thanks for responding. Like Subia75 who asked the question back in July, I too found myself too new to the game to follow how to implement the listed code. Even reading through the scheduler-card install I find it requires a higher level of understanding of the system and terminology than a HA noob brings to the table.
tom_l
May 14, 2022, 1:53am
22
Start by reading the documentation . Watch some (recent) tutorials on youtube. Once you have an understanding of the basic stuff this will make more sense. There are no short-cuts to learning.