Turn on input_boolean

I am trying to turn on input_boolean when I get home:

config.yaml

input_boolean:
  derek:
    name: Derek
    initial: off
    icon: mdi:car

Automation.yaml

alias: Derek Home
  trigger:
  - entity_id: device_tracker.derek
    platform: state
    to: home
  condition:
  - condition: state
    entity_id: input_boolean.derek
    state: 'on'
  action: []

What am I missing. I am trying to toggle on an input_boolean in my group menus:

groups.yaml

Tracker:
   name: Trackers
   view: yes
   entities:
     - device_tracker.derek
     - input_boolean.derek

There is no action in that automation. I also believe that block under trigger and condition has to be indented. I should look like this:

alias: Derek Home
  trigger:
    - entity_id: device_tracker.derek
      platform: state
      to: home
  condition:
    - condition: state
      entity_id: input_boolean.derek
      state: 'off'
  action:
    service: homeassistant.toggle
    entity_id: input_boolean.derek

If i read the above correct, seems like he mistook the condition for the action.
So if he wants to turn on the device, the condition should either be off, or not active at all. Like this:

alias: Derek Home
  trigger:
    - entity_id: device_tracker.derek
      platform: state
      to: home
  action:
    service: input_boolean.turn_on
    entity_id: input_boolean.derek

You are right, I totally missed that. I guess I was reading too fast. I’ll edit my post to fix that

So I have made changes and checked config “No Errors” restarted Hassio and no changes. My device_trackers are registering properly and show “Home” and “Away” but the boolean-inputs are not turning “on” or “off”. Here is my code:

Group.yaml

Tracker:
   name: Trackers
   view: yes
   entities:
     - device_tracker.derek
     - input_boolean.derek

Automation.yaml

- id: '1550593708373'
  alias: Derek Home
  trigger:
  - entity_id: device_tracker.derek
    platform: state
    to: home
  action:
    service: input_boolean.turn_on
    entity_id: input_boolean.derek

I added the state from not_home to home and when I got home the input_boolean turned on. Now how do I get it to turn off when I leave? Do need to create another automation that goes for home to not_home and then toggle_off?

- id: '1550593708373'
  alias: Derek Home
  trigger:
  - entity_id: device_tracker.derek
    from: not_home
    platform: state
    to: home
  action:
  - entity_id: input_boolean.derek
    service: input_boolean.turn_on

Exactly. Another automation actioning when state to not_home.

1 Like

In my groups.yaml how do I get rid of the toggle on/off for the group name?

Are you referring to how it shows up on Lovelace frontend? If so I’m my case using an entities card with the group as entity will not make it show up with a toggle option.
If you refer to your that you do not want the input Boolean Derek to be a toggle button you might want to make it a binary sensor instead.

After diving a little deeper into this the only way I can trigger the input_boolean is to manually change the state from “not_home” to “home” or “home” to " not_home". The automation does not work. So I am guessing it has to do with my syntax “home” “not_home”. I am using Life360 as my device_tracker.

Any suggestions would be greatly appreciated.

I´m using Life360 with a group too and it works fine…
Please share your config and code to see if I can detect something wrong.

Config.yaml

input_boolean:
  derek:
    name: Derek
    initial: off
    icon: mdi:car

Automation.yaml

- id: '1550593708373'
  alias: Derek Home
  trigger:
  - entity_id: device_tracker.derek
    from: not_home
    platform: state
    to: home
  action:
    entity_id: input_boolean.derek
    service: input_boolean.turn_on

- id: '1550609969781'
  alias: Derek not_home
  trigger:
  - entity_id: device_tracker.derek
    from: home
    platform: state
    to: not_home
  action:
    service: input_boolean.turn_off
    entity_id: input_boolean.derek

groups.yaml

    
 Tracker:
   name: Trackers
   view: yes
   entities:
     - device_tracker.derek
     - input_boolean.derek
1 Like

I am still not sure why you need an input boolean.

This is what I have.
Groups.yaml.

  people_home:
    name: Everyone home
    all: true
    entities:
      - device_tracker.phone1
      - device_tracker.phone2
      - device_tracker.phone3
  people_away:
    name: Everyone away
    entities:
      - device_tracker.phone1
      - device_tracker.phone2
      - device_tracker.phone3

I defined 2 groups as I wanted to separate the groups between when everyone was home or everyone away.
Group home will have status Home when everyone is home (due to the statement all:true), but away when one person left. Group away will be away when everyone is away.
I wanted to have the logic like that so I can use automations when either everyone is home or everyone away.

Lastly I added this into the lovelace UI through an entity card.
image

entities:
  - entity: group.people_away
  - entity: group.people_home
show_header_toggle: false
title: Who is where?
type: entities

Would this not work in your case?

I added your code and was able to add group entities back to my lovelace but I have not seen where anything changes when anybody comes home or leaves. I have attached my lovelace code.

Lovelace

- cards:
      entities:
        - entity: group.people_away
        - entity: group.people_home
    badges: []
    show_header_toggle: false
    title: Who is where?
    type: entities

Groups.yaml

 people_home:
    name: Everyone home
    all: true
    entities:
     - device_tracker.derek
     - device_tracker.melissa
     - device_tracker.gybson
 people_away:
    name: Everyone away
    entities:
     - device_tracker.derek
     - device_tracker.melissa
     - device_tracker.gybson

The only difference I see is the badges statement in cards, which I am not sure if it impacts, but I doubt so.
I also see you use the lovelace.yaml, whilst I use the frontend to configure.

In my case the entity group.people_home will show status home if anyone of the 3 is home. The status of group.people_away changes to status away only if all 3 are away.

Does your group not toggle based on the tracked devices being away? have you validated with the device tracker status itself to make sure it matches?

I am also using the frontend to configure. If I look at the states for group.people_away and group.people_home both states show “not_home”

What are the individual devices’ states?

Sorry, can’t check my system now… upgrading to 0.88.1 (and looks like it’s stuck :frowning:)

device_tracker.derek - not_home
device_tracker.melissa - not_home
device-tracker.gybson - not_home

Here’s a shot in the dark, are the automations enabled?

You can add initial_state: 'on' to the automations to make sure they get enabled after each re-start.

- id: '1550593708373'
  alias: Derek Home
  initial_state: 'on'
  trigger:
  - entity_id: device_tracker.derek
    from: not_home
    platform: state
    to: home
  action:
    entity_id: input_boolean.derek
    service: input_boolean.turn_on

- id: '1550609969781'
  alias: Derek not_home
  initial_state: 'on'
  trigger:
  - entity_id: device_tracker.derek
    from: home
    platform: state
    to: not_home
  action:
    service: input_boolean.turn_off
    entity_id: input_boolean.derek

Based on this the group status is OK. If all devices show not home, both groups should also show not home.

Now if one of the devices is home, then it’s an issue with your device tracker and not this setup.
Makes sense?