Indentation in configurator

Hi guys, sorry real noob question. I was convinced i wouldn’t struggle with the indentation but below is what i believe to be correct but configurator says its wrong.

– alias: Battery Low
  trigger:
    platform: numeric_state
    entity_id: device_tracker.life360_adam
    value_template: ‘{{ state.attributes.battery }}’
    below: 28
  action:
    service: tts.google_say
    data:
    message: “Battery Low”

Frustratingly configurator says the below is correct (yes with no indentation) and the automation didn’t work.

– alias: Battery Low
trigger:
platform: numeric_state
entity_id: device_tracker.life360_adam
value_template: ‘{{ state.attributes.battery }}’
below: 28
action:
service: tts.google_say
data:
message: “Battery Low”

Any help would be greatly appreciated

I may as well show the error from configurator

bad indentation of a mapping entry at line 3, column 10:
trigger:
^

Do you have some tabs instead of spaces?

No all manual spaces, is that correct?

Yes, use manual spaces.

1 Like

That’s what i’ve done.

OK, the last line needs indenting two spaces farther in, also I don’t know which ‘line’ you used before the word alias but it should be a hyphen, yours is somehow longer

Yours: – (copied from your post)
Correct: -

Also the quotes around your template and your message are the wrong type.

I suspect you’re using some fancy editor that is using different characters to try and look pretty. That’s not going to work.

- alias: Battery Low
  trigger:
    platform: numeric_state
    entity_id: device_tracker.life360_adam
    value_template: '{{ state.attributes.battery }}' 
    below: 28
  action:
    service: tts.google_say
    data:
      message: "Battery Low"
1 Like

@anon43302295 That worked perfectly. Not using any editor just in the configurator but i copied some of script elsewhere.

How can i manually fire that automation to check google tts works?

Yeah, whoever you copied it from has some dodgy characters then.

You can click on the automation in your states page and then click “trigger” to check your action.

Awesome! Thank you, i would never have found that.

1 Like

@anon43302295 Im stuck again :frowning: although i can manually trigger the automation and the tts works. The automation itself doesn’t run. I have ha a play around with “value template” and “platform” but i can’t get it to run. I thought i’d able to get the correct value template from the states page but it just lists all attributes.

###Adam - Battery Low###
- alias: Adam - Battery Low
  trigger:
    platform: numeric_state
    entity_id: device_tracker.life360_adam
    value_template: ‘{{ states.device_tracker.life360_adam.attributes.battery }}’
    below: 17
  action:
    service: tts.google_say
    data:
      message: “Adam's battery is low”

Any ideas? I’ll be honest i’m slightly disheartened at how difficult it is to build a very simple automation. Steep learning curve!

1 Like
###Adam - Battery Low###
- alias: Adam - Battery Low
  trigger:
    platform: template
    value_template: "{{ state_attr('device_tracker.life360_adam' , 'battery')|int < 17 }}"
  action:
    service: tts.google_say
    data:
      message: "Adam's battery is low"