Input.boolean statement when home using Life360

Try to be a little easy on the new guy. I am just starting to get me feet wet with Hassio. I am trying to create and Boolean input that has a toggle that is either “true” or “false” for when I am home. I would like to use the device_tracker with my Life360. Can anybody show me what my config.yaml should look it and my automation.yaml should look like.

Thanks in advance for any help you can provide.

So there are a few choices for Life360 integration. I believe there may even be a Hass.io add-on for this (I don’t know, I don’t use Hass.io.) But I created my own Life360 Device Tracker platform that I and at least a few others have been using successfully. Here’s a link in case you’re interested:

Again, since I don’t use Hass.io, I don’t know if this will work with it or not.

Regarding the boolean input, you could do that like this:

input_boolean:
  at_home:
    name: I am home

automation:
  - alias: Sync input_boolean.at_home with device_tracker
    trigger:
      platform: state
      entity_id: device_tracker.my_name
    action:
      service_template: >
        {% if is_state(trigger.entity_id, 'home') %}
          input_boolean.turn_on
        {% else %}
          input_boolean.turn_off
        {% endif %}
      entity_id: input_boolean.at_home

Note that the “raw” state of input_boolean.at_home will not actually be ‘true’ or ‘false’, but ‘on’ or ‘off’, which is the case for all boolean entities. However, how it displays is another thing, since that can be customized.

You can find more information about Input Booleans here:

And automations here:

Now, having said all this about the boolean input, if you just want an entity whose state reflects whether or not you’re home, you could do this instead (of the input_boolean and automation.) It’s called a Template Binary Sensor:

binary_sensor:
  - platform: template
    sensors:
      at_home:
        friendly_name: I am home
        value_template: "{{ is_state('device_tracker.my_name', 'home') }}"

You can find out more about them here:

What .yaml file do I place the binary_sensor in?

You can put everything in configuration.yaml, at least to start with. That’s what I did. It’s easier IMHO to start that way. But you can, and eventually should, split up your configuration into multiple files. How you decide to organize depends ultimately on what you’re doing, and personal choice. More info can be found here:

(Again, with the caveat that I’m not sure where Hass.io departs from the more traditional installation I’m using.)

Making some progress. Now how do I display that binary_sensor/template on a card or group in my overview page

Like any other entity. Given the example I provided, it’s entity_id would be binary_sensor.at_home.

What am I doing wrong? How do I place multiple sensors in binary_sensor. See code below
Groups.yaml
Household:
name: Household
entities:
- binary_sensor.name_house
config.yaml
binary_sensor:

  • platform: template
    sensors:
    at_home:
    friendly_name: “home”
    value_template: >-
    {{ is_state(‘device_tracker.name’, ‘Home’)
    and is_state(‘device_tracker.name’, ‘home’)
    and is_state(‘device_tracker.namer’, ‘home’) }}

Please properly format code blocks. See link at top of page that says “please use code blocks and syntax highlighting.”

I am sorry I have tried everything I can and cannot seem to get proper format code blocks. I have tried to export out of Notepad ++ and for some reason this is what it looks like.

Just precede that block of text with a line that just contains three “back-ticks” (which is the key in the upper-left corner of your keypad, left of the numeral 1, and below the ESC key, or at least that’s where it is on my keyboard.) Then add another line just like that after that block of text. Presto-magico - it will be properly formatted! :slight_smile:

It should look like this when you’re typing it:

```
XXX
```

Groups.yaml

Household:
  name: Household
  entities:
    -binary_sensor.at_home

configuration.yaml

binary_sensor:
  -platform: template
    sensors:
      at_home:
        friendly_name: “home”
        value_template: >-
         {{ is_state(‘device_tracker.name’, ‘Home’)
         and is_state(‘device_tracker.name’, ‘Home’)
         and is_state(‘device_tracker.name’, ‘Home’) }}

Close, but not quite right. You just need one line with three back-ticks, all by themselves, followed by the lines you want to have properly formatted (just enter them normally), followed by another line with three back-ticks, all by themselves. When you do this, you should see the lines properly formatted in the right pane of the reply window.

The reason this is important is YAML is very particular about spacing/indentation. Until I can see the code properly, it’s very difficult to spot what is wrong.

When you’ve done it correctly, it should look something like this:

Household:
  name: Household
  entities:
    - binary_sensor.at_home

etc.

I hope I am close and thanks for working with me.

Ok, I think you’ve got it now! :slight_smile:

So I’ve lost track of what your remaining problems are. And looking at your latest post, I’m not really sure what you’re trying to do. But, at the very least, I can tell you that fancy, curly quotes won’t work. They need to be the simple, straight, single or double quotes. Maybe this is just a side-effect of your attempts to get the code entered and formatted correctly in your post. E.g., friendly_name: “home” should be friendly_name: "home". Same goes for the others.

And speaking of the others, what are you trying to do with this:

{{ is_state(‘device_tracker.name’, ‘Home’)
         and is_state(‘device_tracker.name’, ‘Home’)
         and is_state(‘device_tracker.name’, ‘Home’) }}

Why the multiple things and’ed together that are each the same as the others?

Note that a device_tracker’s state will be 'home', not 'Home'. Even if it displays in the UI as ‘Home’, the actual state is all lowercase.

So, if you could expand a little on what you’re trying to do now, and what exactly isn’t working or right yet, I’ll be happy to continue to try and help.

Must have come from copying and pasting but anyways. What I am trying to accomplish is have (3) device_trackers shown in the group tab as either “home” or “away” with either a toggle or anything else to let me know who is home.

Dad Home
Mom Away
Son Home

Something like that.

So you can put the device_tracker entities themselves in the UI and they will display their home/away status. And if you click on one it will open a more detailed view showing the state history over the last day. Is there a reason you just don’t use them directly?

Still learning. Trying to used ideas I have seen in different videos. Thought process is if I have a on/off or true/false I can tie those into a more complex automation. For instance lets say when HA sees me get home I can have my garage door open and TV turn on or something similar to that. Does that make sense?

Yes, like this?

automation:
  - alias: I am home!
    trigger:
      platform: state
      entity_id: device_tracker.name
      to: 'home'
    action:
      - service: cover.open_cover
        entity_id: cover.my_garage
      ...

You don’t (necessarily) need a “middle man”. If you’re trying to do something more complex, like combine device_trackers, or filter events, etc., then you might need other entities. All depends on what you’re trying to do. But to just show the individual tracker entities in the UI, or to base automations off them directly, you can just use the device_tracker entities themselves.