Setting HASS to Home or Away

I’ve read some about geofencing and other presence detection, but that is a bit more than I really need to do.

I searched around, and maybe my terms weren’t quite right to get the results I’m looking for, but is there a way to set up a ‘switch’ in HASS that I can manually toggle for home or away? Basically, I’d like to have some lights doing different things if I’m home vs if I’m away, but I don’t need it automatically knowing if I’m home or away such as is done with presence detection.

Any thoughts that I missed?

You can use input_boolean for this purpose.
See details here:

Thanks - I got the ‘switch’ to show up, now to figure out how to make it work the way I want - the example there used proximity to send a message. I’ll have to put this on the back burner until I have more time to dig in and try and figure it out.

I did something similar to this - I call it Vacation Mode. It is pretty crude, but I use this variable for several switches in my automation. So before I head out, I put Hass in vacation mode and let the lights cycle. It gets the job done.

# Create variable for vacation mode
# in configuration.yaml.
input_boolean:
  vacation_mode:
    initial: off

# Vacation mode for Living Room light
- alias: 'Rule 6 Vacation Mode for Living Room ON'
  trigger:
    platform: sun
    event: sunset
    offset: "-00:38:00"
  condition:
    condition: state
    entity_id: input_boolean.vacation_mode
    state: 'on'
  action:
    service: switch.turn_on
    entity_id: switch.living_room_switch_7_0

# Vacation mode for Living Room light
- alias: 'Rule 7 Vacation Mode for Living Room OFF'
  trigger:
    platform: sun
    event: sunset
    offset: "+01:25:00"
  condition:
    condition: state
    entity_id: input_boolean.vacation_mode
    state: 'on'
  action:
    service: switch.turn_off
    entity_id: switch.living_room_switch_7_0
1 Like

Thanks Dap! That’s pretty much exactly what I’m looking to do… I’ll have to play with the random off function I was asking about in my other thread, but I think I should be able to adapt your config to work.

I might be stuck on stupid here, bit I’m not able to get this new automation to work.

I have the following added:
[/code]

  • alias: ‘Vacation Mode for Office Light ON’
    trigger:
    • platform: sun
      event: sunset
      offset: “+01:10:00”
      condition:
    • condition: state
      entity_id: input_boolean.vacation_mode
      state: ‘on’
      action:
      service: scene.turn_on
      entity_id: scene.Office_Lights_Half
      [/code]

I also had it without the ‘-’ before platform and condition, with the same problem.

Technically, I could do this without scenes, but I can’t figure out what I’d need to use for these dimmers.

I have the following that has been working until I broke the automation because it couldn’t find my Office scenes until I changed them to be how they are above.
[/code]

  • alias: Turn on driveway lights when sun sets
    trigger:
    platform: sun
    event: sunset
    offset: “-00:20:00”
    action:
    service: switch.turn_on
    entity_id: switch.leviton_unknown_type1c02_id0334_switch_4
    [/code]

Because that’s a ‘switch’, not a ‘dimmer’, the service ‘switch.turn_on’ applies, but I can’t seem to find anything for the dimmer - what would I need to use for a Leviton dimmer? Or any ideas why the scene doesn’t seem to be activating? When I activate it manually, it does what is expected, but the automation doesn’t seem to be activating it.

Noob here trying to learn as I go along and looking at a lot of post in order to do so.
What I am not understanding from the code of @dap35 is what is displayed on the screenshot. I am not seeing anything in the code that would display “Vacation Mode” maybe I just don’t know enough about HA but this puzzles me.

Basically, what his code does is looks at the state of '‘input_boolean.vacation_mode’, and if that is ‘on’,then the automation will run. If that is ‘off’, then it won’t run.

note:

condition:
condition: state
entity_id: input_boolean.vacation_mode
state: ‘on’

I’m pretty sure that I understand that part, but still can’t see how this gives me the card shown in the screenshot with the icon and switch. Guess I will have to play around with it but not seeing how this all works right now

because you need other to add group and view
something like

Network:
  entities:
    - sensor.speedtest_download
    - sensor.speedtest_upload
    - sensor.speedtest_ping

Internet:
  view: yes
  icon: mdi:speedometer
  entities:
    - group.network

note that i use this to display my speedtest bandwidth, you will have to make your own view and group

Sorry, I left a few things out… Hope this helps. I have my config split into multiple files, so my spacing may be off in a place or two in what I have pasted below.

Under the customize section of my configuration

input_boolean.vacation_mode:
  friendly_name: 'Vacation Mode'
  hidden: false
  icon: 'mdi:beach'

Under the groups section of my configuration:

group:
  default_view:
    view: yes
    entities:
      - sun.sun
      - binary_sensor.stairwell_motion_sensor_4_0
      - binary_sensor.basement_motion_sensor_5_0
      - device_tracker.iphone1
      - device_tracker.iphone2
      - group.outside
      - group.1st_floor
      - group.2nd_floor
      - group.vacation

  Entertainment:
    view: yes
    entities:
     - group.sonos

  Configuration:
    view: yes
    entities:
      - group.Automation

  vacation:
    entities:
    - input_boolean.vacation_mode

hmmm…

This is for a GE dimmer.

# Turns on lights at sunset
- alias: 'Rule 3 Welcome Home light in kitchen'
  trigger:
    platform: state
    entity_id: binary_sensor.stairwell_motion_sensor_4_0
    from: 'off'
    to: 'on'
  condition:
  - condition: state
    entity_id: binary_sensor.basement_motion_sensor_5_0
    state: 'on'
  - condition: sun
    after: sunset
  action:
    service: light.turn_on
    entity_id: light.kitchen_dimmer_level_9_0

But you might try and change the service to homeassistant and see if your Leviton dimmer will respond to that. I am using this to turn on one or more Aeotec smart outlets.

#Turn on other switches when great room light is turned on.
- alias: 'Rule 12 Slave outlets to GreatRoom On'
  trigger:
    platform: state
    entity_id: switch.great_room_lights_switch_6_0
    from: 'off'
    to: 'on'
  action:
    service: homeassistant.turn_on
    entity_id: group.gr_light_slaves

Hi all,

Tried to follow along to this and maybe because it’s late, I’m not seeing something correctly. I’ve got my front end showing the Vacation mode switch and I can toggle it on or off. I’ve made an automation to test:

- id: '1544757125460'
  alias: Vacation Test
  trigger:
  - entity_id: light.light_by_door
    from: 'off'
    platform: state
    to: 'on'
  condition:
  - condition: state
    entity_id: input_boolean.vacation_mode
    state: 'on'
  action:
  - data:
      entity_id: light.light_by_door
    service: light.turn_on

In this test I’m trying to see if when the light is off and I have vacation mode turned on, that it turns on the light, however, when I run the automation it turns the light on regardless of what the state of the switch is. What could I be missing?

Is there any good way for HA to detect you’re on vacation? Let’s automate all the things…
I don’t want to rely on me remembering to set myself in vacation mode…I might forget.

I thought about using zones to say: if my wife and I are not in #ourcity, then we’re on vacation, but then I realised we might go to #nearbycity for a meal or a show, and that would trigger the automation.

A better way to do it might be to say: if user A and user B are both >50 miles away from home, we’re probably on vacation. But at this point I came unstuck, because I don’t know how to do this calculation.

Anyone doing this, or something similar?

1 Like

Two thoughts:

  1. A very simple solution a time-based: if all person entities are not_home for more than X hours (12, 24, whatever), assume vacation mode.
  2. Use a bayesian sensor to amalgamate all of the conditions that would be likely when on vacation (i.e., people gone, lights turned off for a certain amount of time, motion not detected for a certain amount of time, etc.).

so how do you trigger to turn the lights on and off specific time

For me, it’s the “random” code here

    action:
      - service: notify.telegram
        data:
          message: House is simulating presence due to a ring on the doorbell at night
      - delay: '00:00:{{ range(10,40) | random | int }}'
      - service: light.turn_on
        entity_id: light.dave_s_room
      - delay: '00:0{{ range(9) | random | int }}:{{ range(10,58) | random | int }}'
      - service: light.turn_off
        entity_id: light.dave_s_room
2 Likes

where do i need to put this?

At the end of a relevant automation. See here if you’re new

it’s not working what is the problems…?

my setting is

input_boolean:
vacation_mode:
initial: off

  • alias: ‘Vacation Mode for Master Bedroom Room ON’
    trigger:
    platform: time
    at: ‘20:30:00’
    condition:
    condition: state
    entity_id: input_boolean.vacation_mode
    state: ‘on’
    action:
    service: light.turn_on
    entity_id: light.master_bedroom_cupboard_lights

  • alias: ‘Vacation Mode for Master Bedroom Room OFF’
    trigger:
    platform: time
    at: ‘22:30:00’
    condition:
    condition: state
    entity_id: input_boolean.vacation_mode
    state: ‘on’
    action:
    service: light.turn_off
    entity_id: light.master_bedroom_cupboard_lights