cancel
Showing results for 
Search instead for 
Did you mean: 

automation: Turn on light bulb when I'm away doesn't turn off when I'm home

gulluwing
Community Member

I created an automation that turns on the light bulb at sunset, when I'm away from home, for 30 minutes, and then turns off the light bulb for 60 minutes, and then turns on the light bulb for 30 minutes and so on. The problem is that when I arrive at home it doesn't turn them off or rather if the light bulb is activated for 30 minutes, even if I arrived home, it keeps it on until the end of the 30 minutes but I would like it to turn it off as soon as I arrive. Is there a way to get the automation done correctly?

1 Recommended Answer

salbando
Community Member

Yes, since all starters are treated as a logical "Or" just create a second starter that turns off the light when Presences triggers as "Home" If the light is on, it will turn off and if it is already off it will just stay off (no harm no foul). 

View Recommended Answer in original post

4 REPLIES 4

salbando
Community Member

Yes, since all starters are treated as a logical "Or" just create a second starter that turns off the light when Presences triggers as "Home" If the light is on, it will turn off and if it is already off it will just stay off (no harm no foul). 

I've created a new routine as you suggested, but the new problem is that if I turn on the light in the room, the routine turns it off. I think we need a routine that turns off the first one when I get home:  "when I get home deactivates the routine that turns on/off the lights when I'm away" but I don't think it's possible 

gulluwing
Community Member

Do I need to create a new starters in the same automation or in a new one? 

Can you help me? My automation is as follows:

metadata:
name: lampadina cucina accesa quando dopo il tramonto
description: Accendi lampadina dopo il tramonto
automations:
- starters:
- type: home.state.HomePresence
state: homePresenceMode
is: AWAY
condition:
type: time.between
after: SUNSET
before: SUNRISE
actions:
- type: device.command.OnOff
devices:
- lampadina cucina - cucina
on: true
- type: time.delay
for: 30min
- type: device.command.OnOff
devices:
- lampadina cucina - cucina
on: false
- type: time.delay
for: 60min
- type: device.command.OnOff
devices:
- lampadina cucina - cucina
on: true

  description: Turn on light at 2:30 PM when I'm not at home.

automations:

  - starters:

      - type: home.state.HomePresence

        state: HomePresenceMode

        is: AWAY

      - type: time.schedule

        at: sunset

    actions:

      - type: device.command.OnOff

        devices:

          - lampadina cucina - cucina

        on: true

      - type: time.delay

        for: 30min

      - type: device.command.OnOff

        devices:

          - lampadina cucina - cucina

        on: false

ImNotANestUser
Community Member

I don't think it is possible to do what you want.  However, you might be able to come close if you try something like this:

metadata:
name: Kitchen Light Control
description: Schedule on/off all day when away from home.

automations:
- starters:
- type: time.schedule
at: 6:00 AM
condition:
type: home.state.HomePresence
state: homePresenceMode
is: AWAY

actions:
- type: device.command.OnOff
on: true
devices: Kitchen Table Light - Kitchen

- starters:
- type: time.schedule
at: 8:00 PM

condition:
type: home.state.HomePresence
state: homePresenceMode
is: AWAY

actions:
- type: device.command.OnOff
on: false
devices: Kitchen Table Light - Kitchen

 

It controls the light at various times of the day but only controls them when you're away.  So, you should be able to do what you want when arriving home.