This is a daily schedule card that I’m using to turn my heating on and off, although it could be used to schedule anything. It isn’t a very elegant solution to a problem but it works and I’ve seen other community members wanting a weekday scheduler, so I thought I’d post this project and welcome any suggestions for improvement. I did have some great suggestions from @petro and @finity, from a different thread, but this is working so I decided to post. In fact @petro has made some new suggestions while I’m writing this, so an updated version could be on the cards (excuse the pun!). I’ll update any code once I’ve successfully implemented it. Hopefully this is of use to some members.
Here’s a screenshot of the lovelace card: -
This is a picture entity card and the background-picture is a table that I made in PowerPoint (10cm x 16cm) and then saved as a png. In order to customise the colour, you’d need to make your own, or I probably could have selected a transparent background but the headers and weekdays are part of the background image, so would need to be redone to change the colour. The coloured circles are, once again, just circles made in PowerPoint (0.5cm x 0.5cm). Those images are saved in the normal ‘www folder’ in config.
Here’s the lovelace code: -
elements:
- entity: input_datetime.mon_on_morning
style:
color: white
font-size: 10px
left: 39.5%
top: 16%
type: state-label
- entity: input_datetime.mon_off_morning
style:
color: white
font-size: 10px
left: 52.5%
top: 16%
type: state-label
- entity: input_datetime.mon_on_evening
style:
color: white
font-size: 10px
left: 80%
top: 16%
type: state-label
- entity: input_datetime.mon_off_evening
style:
color: white
font-size: 10px
left: 93%
top: 16%
type: state-label
- entity: input_datetime.tue_on_morning
style:
color: white
font-size: 10px
left: 39.5%
top: 29%
type: state-label
- entity: input_datetime.tue_off_morning
style:
color: white
font-size: 10px
left: 52.5%
top: 29%
type: state-label
- entity: input_datetime.tue_on_evening
style:
color: white
font-size: 10px
left: 80%
top: 29%
type: state-label
- entity: input_datetime.tue_off_evening
style:
color: white
font-size: 10px
left: 93%
top: 29%
type: state-label
- entity: input_datetime.wed_on_morning
style:
color: white
font-size: 10px
left: 39.5%
top: 42%
type: state-label
- entity: input_datetime.wed_off_morning
style:
color: white
font-size: 10px
left: 52.5%
top: 42%
type: state-label
- entity: input_datetime.wed_on_evening
style:
color: white
font-size: 10px
left: 80%
top: 42%
type: state-label
- entity: input_datetime.wed_off_evening
style:
color: white
font-size: 10px
left: 93%
top: 42%
type: state-label
- entity: input_datetime.thur_on_morning
style:
color: white
font-size: 10px
left: 39.5%
top: 55%
type: state-label
- entity: input_datetime.thur_off_morning
style:
color: white
font-size: 10px
left: 52.5%
top: 55%
type: state-label
- entity: input_datetime.thur_on_evening
style:
color: white
font-size: 10px
left: 80%
top: 55%
type: state-label
- entity: input_datetime.thur_off_evening
style:
color: white
font-size: 10px
left: 93%
top: 55%
type: state-label
- entity: input_datetime.fri_on_morning
style:
color: white
font-size: 10px
left: 39.5%
top: 68%
type: state-label
- entity: input_datetime.fri_off_morning
style:
color: white
font-size: 10px
left: 52.5%
top: 68%
type: state-label
- entity: input_datetime.fri_on_evening
style:
color: white
font-size: 10px
left: 80%
top: 68%
type: state-label
- entity: input_datetime.fri_off_evening
style:
color: white
font-size: 10px
left: 93%
top: 68%
type: state-label
- entity: input_datetime.sat_on_morning
style:
color: white
font-size: 10px
left: 39.5%
top: 81%
type: state-label
- entity: input_datetime.sat_off_morning
style:
color: white
font-size: 10px
left: 52.5%
top: 81%
type: state-label
- entity: input_datetime.sat_on_evening
style:
color: white
font-size: 10px
left: 80%
top: 81%
type: state-label
- entity: input_datetime.sat_off_evening
style:
color: white
font-size: 10px
left: 93%
top: 81%
type: state-label
- entity: input_datetime.sun_on_morning
style:
color: white
font-size: 10px
left: 39.5%
top: 94%
type: state-label
- entity: input_datetime.sun_off_morning
style:
color: white
font-size: 10px
left: 52.5%
top: 94%
type: state-label
- entity: input_datetime.sun_on_evening
style:
color: white
font-size: 10px
left: 80%
top: 94%
type: state-label
- entity: input_datetime.sun_off_evening
style:
color: white
font-size: 10px
left: 93%
top: 94%
type: state-label
- entity: input_boolean.timer_mon_morning
state_image:
'off': /local/TimerOff.png
'on': /local/TimerOn.png
style:
left: 22.7%
top: 10%
transform: scale(0.6)
tap_action:
action: toggle
type: image
- entity: input_boolean.timer_tue_morning
state_image:
'off': /local/TimerOff.png
'on': /local/TimerOn.png
style:
left: 22.7%
top: 23%
transform: scale(0.6)
tap_action:
action: toggle
type: image
- entity: input_boolean.timer_wed_morning
state_image:
'off': /local/TimerOff.png
'on': /local/TimerOn.png
style:
left: 22.7%
top: 36%
transform: scale(0.6)
tap_action:
action: toggle
type: image
- entity: input_boolean.timer_thur_morning
state_image:
'off': /local/TimerOff.png
'on': /local/TimerOn.png
style:
left: 22.7%
top: 49%
transform: scale(0.6)
tap_action:
action: toggle
type: image
- entity: input_boolean.timer_fri_morning
state_image:
'off': /local/TimerOff.png
'on': /local/TimerOn.png
style:
left: 22.7%
top: 62%
transform: scale(0.6)
tap_action:
action: toggle
type: image
- entity: input_boolean.timer_sat_morning
state_image:
'off': /local/TimerOff.png
'on': /local/TimerOn.png
style:
left: 22.7%
top: 75%
transform: scale(0.6)
tap_action:
action: toggle
type: image
- entity: input_boolean.timer_sun_morning
state_image:
'off': /local/TimerOff.png
'on': /local/TimerOn.png
style:
left: 22.7%
top: 88%
transform: scale(0.6)
tap_action:
action: toggle
type: image
- entity: input_boolean.timer_mon_evening
state_image:
'off': /local/TimerOff.png
'on': /local/TimerOn.png
style:
left: 63.5%
top: 10%
transform: scale(0.6)
tap_action:
action: toggle
type: image
- entity: input_boolean.timer_tue_evening
state_image:
'off': /local/TimerOff.png
'on': /local/TimerOn.png
style:
left: 63.5%
top: 23%
transform: scale(0.6)
tap_action:
action: toggle
type: image
- entity: input_boolean.timer_wed_evening
state_image:
'off': /local/TimerOff.png
'on': /local/TimerOn.png
style:
left: 63.5%
top: 36%
transform: scale(0.6)
tap_action:
action: toggle
type: image
- entity: input_boolean.timer_thur_evening
state_image:
'off': /local/TimerOff.png
'on': /local/TimerOn.png
style:
left: 63.5%
top: 49%
transform: scale(0.6)
tap_action:
action: toggle
type: image
- entity: input_boolean.timer_fri_evening
state_image:
'off': /local/TimerOff.png
'on': /local/TimerOn.png
style:
left: 63.5%
top: 62%
transform: scale(0.6)
tap_action:
action: toggle
type: image
- entity: input_boolean.timer_sat_evening
state_image:
'off': /local/TimerOff.png
'on': /local/TimerOn.png
style:
left: 63.5%
top: 75%
transform: scale(0.6)
tap_action:
action: toggle
type: image
- entity: input_boolean.timer_sun_evening
state_image:
'off': /local/TimerOff.png
'on': /local/TimerOn.png
style:
left: 63.5%
top: 88%
transform: scale(0.6)
tap_action:
action: toggle
type: image
image: /local/Schedule.png
type: picture-elements
Here’s the different input_datetime’s: -
mon_on_morning:
name: Mon on morning
has_time: true
mon_off_morning:
name: Mon off morning
has_time: true
mon_on_evening:
name: Mon on evening
has_time: true
mon_off_evening:
name: Mon off evening
has_time: true
tue_on_morning:
name: Tue on morning
has_time: true
tue_off_morning:
name: Tue off morning
has_time: true
tue_on_evening:
name: Tue on evening
has_time: true
tue_off_evening:
name: Tue off evening
has_time: true
wed_on_morning:
name: Wed on morning
has_time: true
wed_off_morning:
name: Wed off morning
has_time: true
wed_on_evening:
name: Wed on evening
has_time: true
wed_off_evening:
name: Wed off evening
has_time: true
thur_on_morning:
name: Thur on morning
has_time: true
thur_off_morning:
name: Thur off morning
has_time: true
thur_on_evening:
name: Thur on evening
has_time: true
thur_off_evening:
name: Thur off evening
has_time: true
fri_on_morning:
name: Fri on morning
has_time: true
fri_off_morning:
name: Fri off morning
has_time: true
fri_on_evening:
name: Fri on evening
has_time: true
fri_off_evening:
name: Fri off evening
has_time: true
sat_on_morning:
name: Sat on morning
has_time: true
sat_off_morning:
name: Sat off morning
has_time: true
sat_on_evening:
name: Sat on evening
has_time: true
sat_off_evening:
name: Sat off evening
has_time: true
sun_on_morning:
name: Sun on morning
has_time: true
sun_off_morning:
name: Sun off morning
has_time: true
sun_on_evening:
name: Sun on evening
has_time: true
sun_off_evening:
name: Sun off evening
has_time: true
These are the input_booleans for selecting if the timer comes on in the morning or evening: -
timer_mon_morning:
timer_mon_evening:
timer_tue_morning:
timer_tue_evening:
timer_wed_morning:
timer_wed_evening:
timer_thur_morning:
timer_thur_evening:
timer_fri_morning:
timer_fri_evening:
timer_sat_morning:
timer_sat_evening:
timer_sun_morning:
timer_sun_evening:
And here’s the automation: -
##########################
## Schedule Automations ##
##########################
## Monday ##
- id: mon_on_morning
alias: Mon On Morning
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.mon_on_morning', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_mon_morning
state: 'on'
- condition: time
weekday:
- mon
action:
- service: input_boolean.turn_on
entity_id: input_boolean.heating_switch
- id: mon_off_morning
alias: Mon Off Morning
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.mon_off_morning', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_mon_morning
state: 'on'
- condition: time
weekday:
- mon
action:
- service: input_boolean.turn_off
entity_id: input_boolean.heating_switch
- id: mon_on_evening
alias: Mon On Evening
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.mon_on_evening', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_mon_evening
state: 'on'
- condition: time
weekday:
- mon
action:
- service: input_boolean.turn_on
entity_id: input_boolean.heating_switch
- id: mon_off_evening
alias: Mon Off Evening
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.mon_off_evening', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: time
weekday:
- mon
action:
- service: input_boolean.turn_off
entity_id: input_boolean.heating_switch
## Tuesday ##
- id: tue_on_morning
alias: Tue On Morning
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.tue_on_morning', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_tue_morning
state: 'on'
- condition: time
weekday:
- tue
action:
- service: input_boolean.turn_on
entity_id: input_boolean.heating_switch
- id: tue_off_morning
alias: Tue Off Morning
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.tue_off_morning', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_tue_morning
state: 'on'
- condition: time
weekday:
- tue
action:
- service: input_boolean.turn_off
entity_id: input_boolean.heating_switch
- id: tue_on_evening
alias: Tue On Evening
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.tue_on_evening', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_tue_evening
state: 'on'
- condition: time
weekday:
- tue
action:
- service: input_boolean.turn_on
entity_id: input_boolean.heating_switch
- id: tue_off_evening
alias: Tue Off Evening
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.tue_off_evening', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: time
weekday:
- tue
action:
- service: input_boolean.turn_off
entity_id: input_boolean.heating_switch
## Wednesday ##
- id: wed_on_morning
alias: Wed On Morning
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.wed_on_morning', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_wed_morning
state: 'on'
- condition: time
weekday:
- wed
action:
- service: input_boolean.turn_on
entity_id: input_boolean.heating_switch
- id: wed_off_morning
alias: Wed Off Morning
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.wed_off_morning', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_wed_morning
state: 'on'
- condition: time
weekday:
- wed
action:
- service: input_boolean.turn_off
entity_id: input_boolean.heating_switch
- id: wed_on_evening
alias: Wed On Evening
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.wed_on_evening', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_wed_evening
state: 'on'
- condition: time
weekday:
- wed
action:
- service: input_boolean.turn_on
entity_id: input_boolean.heating_switch
- id: wed_off_evening
alias: Wed Off Evening
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.wed_off_evening', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: time
weekday:
- wed
action:
- service: input_boolean.turn_off
entity_id: input_boolean.heating_switch
## Thursday ##
- id: thur_on_morning
alias: Thur On Morning
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.thur_on_morning', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_thur_morning
state: 'on'
- condition: time
weekday:
- thu
action:
- service: input_boolean.turn_on
entity_id: input_boolean.heating_switch
- id: thur_off_morning
alias: Thur Off Morning
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.thur_off_morning', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_thur_morning
state: 'on'
- condition: time
weekday:
- thu
action:
- service: input_boolean.turn_off
entity_id: input_boolean.heating_switch
- id: thur_on_evening
alias: Thur On Evening
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.thur_on_evening', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_thur_evening
state: 'on'
- condition: time
weekday:
- thu
action:
- service: input_boolean.turn_on
entity_id: input_boolean.heating_switch
- id: thur_off_evening
alias: Thur Off Evening
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.thur_off_evening', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: time
weekday:
- thu
action:
- service: input_boolean.turn_off
entity_id: input_boolean.heating_switch
## Friday ##
- id: fri_on_morning
alias: Fri On Morning
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.fri_on_morning', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_fri_morning
state: 'on'
- condition: time
weekday:
- fri
action:
- service: input_boolean.turn_on
entity_id: input_boolean.heating_switch
- id: fri_off_morning
alias: Fri Off Morning
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.fri_off_morning', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_fri_morning
state: 'on'
- condition: time
weekday:
- fri
action:
- service: input_boolean.turn_off
entity_id: input_boolean.heating_switch
- id: fri_on_evening
alias: Fri On Evening
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.fri_on_evening', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_fri_evening
state: 'on'
- condition: time
weekday:
- fri
action:
- service: input_boolean.turn_on
entity_id: input_boolean.heating_switch
- id: fri_off_evening
alias: Fri Off Evening
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.fri_off_evening', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: time
weekday:
- fri
action:
- service: input_boolean.turn_off
entity_id: input_boolean.heating_switch
## Saturday ##
- id: sat_on_morning
alias: Sat On Morning
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.sat_on_morning', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_sat_morning
state: 'on'
- condition: time
weekday:
- sat
action:
- service: input_boolean.turn_on
entity_id: input_boolean.heating_switch
- id: sat_off_morning
alias: Sat Off Morning
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.sat_off_morning', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_sat_morning
state: 'on'
- condition: time
weekday:
- sat
action:
- service: input_boolean.turn_off
entity_id: input_boolean.heating_switch
- id: sat_on_evening
alias: Sat On Evening
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.sat_on_evening', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_sat_evening
state: 'on'
- condition: time
weekday:
- sat
action:
- service: input_boolean.turn_on
entity_id: input_boolean.heating_switch
- id: sat_off_evening
alias: Sat Off Evening
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.sat_off_evening', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: time
weekday:
- sat
action:
- service: input_boolean.turn_off
entity_id: input_boolean.heating_switch
## Sunday ##
- id: sun_on_morning
alias: Sun On Morning
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.sun_on_morning', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_sun_morning
state: 'on'
- condition: time
weekday:
- sun
action:
- service: input_boolean.turn_on
entity_id: input_boolean.heating_switch
- id: sun_off_morning
alias: Sun Off Morning
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.sun_off_morning', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_sun_morning
state: 'on'
- condition: time
weekday:
- sun
action:
- service: input_boolean.turn_off
entity_id: input_boolean.heating_switch
- id: sun_on_evening
alias: Sun On Evening
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.sun_on_evening', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: state
entity_id: input_boolean.timer_sun_evening
state: 'on'
- condition: time
weekday:
- sun
action:
- service: input_boolean.turn_on
entity_id: input_boolean.heating_switch
- id: sun_off_evening
alias: Sun Off Evening
initial_state: 'true'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.sun_off_evening', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
- condition: time
weekday:
- sun
action:
- service: input_boolean.turn_off
entity_id: input_boolean.heating_switch
Obviously you’d just change the action to suit your needs. It could be switching lights on/off