Looking for an automation that turns a switch on and off at specified times, only on days that I want it

I have a charging station controlled by a zigbee plug. I would like to have the plug turn on and off at a specific time (night time hours discounted by the power company) so that nothing is charging during peak hours. I also want this only enabled if I enable it with a switch on the dashboard.

In essence, if I use my vacuum, I want to put it back on it’s dock, hit a switch to ‘charge’, but not have that switch come on until 11pm, and off before 6am. I would just enable this to turn on each day, but I would rather not have the system on during days when I don’t need anything charging. Does that make sense?

Create a schedule helper called “Charging”:

And an input boolean helper called “Charge Tonight”:

Fill out the schedule for the times you want to charge.

Put the input boolean in your dashboard.

Create this automation:

trigger:
  - platform: state
    entity_id: schedule.charging
    to:
      - 'on'
      - 'off'
condition:
  - condition: state
    entity_id: input_boolean.charge_tonight
    state: 'on'
action:
    - service: "switch.turn_{{ trigger.to_state.state }}"
      target:
        entity_id: switch.your_charging_switch
    - service: input_boolean.turn_off
       target:
        entity_id: input_boolean.charge_tonight

Turn the input boolean in your dashboard on if you want to charge next time the schedule turns on. It will automatically turn off the input boolean. So you have to turn it on again next time you want to charge. If you don’t want this behaviour, delete the last action in the automation.

1 Like

Hi,
A few different ways to skin that cat. For the scheduling part you could create a Schedule helper or a Calendar event. On your dashboard you can expose your automation entity using something like the Entities card for a simple manual toggle.
Nick

Okay, the input boolean was the big piece of the puzzle that I was missing, thank you very much!

1 Like

If the times are constant you can just use time triggers instead of the schedule too.