Zones & "Not Home", also single quotation marks

1 cent? :wink:

I THINK I’ve just come across an automation which hasn’t been working because of single quotations.

  - alias: Mark Steve as at work
    trigger:
      - platform: state
        entity_id: device_tracker.life360_steve
        to: 'PepsiCo'
        for:
          minutes: 30
    condition:      
      - condition: time
        after: '07:00:00'
        before: '09:00:00'
    action:
      - condition: state
        entity_id: input_boolean.stevework
        state: 'on'

hasn’t been firing. Going to update to “PepsiCo” rather than ‘PepsiCo’ and see if that does the trick. And yes, if I go to my developer tools>states, I did indeed change to PepsiCo at 08:35

I’d be surprised if switching from single to double-quotes makes a difference for delimiting a simple string like PepsiCo.

Are you using 0.89? Life360 is a custom component and requires adaptation for 0.89.

Nope - 0.87.1 - as I say, the component itself is working fine.

OK, let us know if changing to double-quotes makes it work … but I doubt that’s the cause of the automation’s failure.

In most cases, simple text to the right of to: is treated as a string (even without quotes) provided the simple text is not a key word. The addition of either single or double quotes is to ensure it is evaluated as a string.

no action defined?..

1 Like

The issue here is not quoting. In this case (as others have already pointed out) PepsiCo can be quoted with single quotes, or double quotes, or no quotes at all.

The issue is the state changed to PepsiCo at 08:35, but you have for: minutes: 30 and conditions that the time must be between 7 & 9. But 30 minutes after 08:35 is 09:05, which is not between 7 & 9!

When you use for: on a trigger, the trigger event doesn’t happen until the for: period has been satisfied. That’s the time the conditions need to be true, not when the state first changed.

1 Like

thanks and thanks also to @Mariusthvdb

I’ve amended BOTH my time condition AND my action!!

  - alias: Mark Steve as at work
    trigger:
      - platform: state
        entity_id: device_tracker.life360_steve
        to: "PepsiCo"
        for:
          minutes: 30
    condition:      
      - condition: time
        after: '07:00:00'
        before: '09:30:00'
    action:
      - service: input_boolean.turn_on
        data:
          entity_id: input_boolean.stevework

Well, hell, I thought the OP just chose to not show the balance of the action (because the focus was on quotes in trigger. But yeah, the action as shown is … no action at all!

@daneboom
This example’s failure has absolutely nothing to do with single/double/no quotes.

Now that you’ve added a valid action, and understand how for interacts with the condition's time-frame, revert "PepsiCo" to 'PepsiCo', or even just PepsiCo to prove to yourself that quotes had nothing to do with your automation’s failure.

Quote are only required in YAML when you need to clear up ambiguities. For example keywords like true, false, on, off where you need to differentiate between an actual boolean and a string or if you use certain special characters in the beginning/end of the string. Jinja templates are an entirely
different “language” with it’s own requirements.

None of these requirements has anything to do with Home Assistant, they are the result of the underlying architecture.

Some basic info on this page. http://www.thomasloven.com/blog/2018/08/YAML-For-Nonprogrammers/

1 Like