Simple timed switch

Hi there,

I have just started testing HA after using Openhab for a couple of years. I was hoping that HA would be more straight forward to setup and work with and so far it seems relatively OK.

I have hue lights working and several switches being controlled by a tellstick connected to my raspberry pi.

In Openhab I had a simple rule that switched my coffee maker switch on and off at the same time everyday, which I have been trying to replicate in HA.

I have been trying something like this:

#turns it on at 6am
  - alias: coffee maker on
    trigger:
      - platform: time
        after: '6:00'
    action:
      service: homeassistant.turn_on
      entity_id: switch.coffeeswitch

But this doesn’t work. I just get invalid config, the following components and platforms could not be setup

‘switch’

I’m pretty new to this system and still trying to get to grips with it, but if someone could point me in the right direction or share some examples that I could modify that would be amazing. To me this seems like a pretty simple function, which can surely be achieved with a very short amount of code??

Look at the “states” tab of HA’s interface. It’s the icon that looks like < > in the left sidebar. This page will list all of the entity_id’s that are set up on your system. Make sure you’ve got a “switch.coffeeswitch” to turn on. If you’ve added that coffee maker switch successfully, it should be there and this is the best way to make sure you’ve got the correct entity_id.

@ih8gates Thanks for the quick reply, that was where I got the switch.coffeeswitch from originally, as it’s listed there as the entity_ID for the particular switch I what to turn on???

Are you sure the service command shouldn’t be “switch.turn_on”? My light command is “service: light.turn_on”

Here are two of mine. First runs a script at a certain time (2am), the second turns a switch off at a specified time (2:30am):

################################
### reboot Wink Hub
################################

- alias: Wink Reboot
  hide_entity: True
  trigger:
    platform: time
    hours: 2
    minutes: 0
    seconds: 0
  action:
    - service: script.turn_on
      entity_id: script.winkreboot

################################
### Back Porch Light Off
################################

- alias: BPL Off
  hide_entity: True
  trigger:
    platform: time
    hours: 2
    minutes: 30
    seconds: 0
  action:
    - service: switch.turn_off
      entity_id: light.back_porch

thanks @Corey_Johnson I’ll give that a try

@Corey_Johnson brilliant, I’ve got it working based on your example, thanks so much, is there a way to specify which days of the the week in the time platform?

Thanks

1 Like

Hi,

Yes you can like that

  - alias: "reveil matin semaine"
    trigger:
      - platform: time
        minutes: '/1'
        seconds: 0
    condition:
      - condition: state
        entity_id: input_boolean.alarmweekon
        state: 'on'
      - condition: state
        entity_id: input_boolean.alarmweekday
        state: 'on'
      - condition: time
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
      - condition: template
        value_template: '{{ now().strftime("%H:%M") == states.sensor.alarm_time.state }}'
    action:
      service: light.turn_on
      entity_id: light.chambre
      data:
        transition: 600
        brightness: 255