Why is my script not working?

So, I’m having some issues getting this script to work after replacing a doorsensor.
The script is triggered by some automations that will lock my front door (Danalock V3), but it should (of course) only lock the door if the door is closed.
I can not understand why the script is not working anymore…help?

front_door_lock:
  alias: 'Front door: LOCK'
  sequence:
  - timeout: '120'
    wait_template: '{{ is_state(''binary_sensor.entry_door_magnet_switch_sensor'',
      ''off'') }}'
  - data:
      entity_id: lock.entry_door_lock_locked
    service: lock.lock

Inside your is_state you have 2 single quotes instead of a double quote…
Same around off

Thats what I thought was a problem too, but without I get:

Error loading /home/homeassistant/.homeassistant/configuration.yaml: while parsing a block mapping
  in "/home/homeassistant/.homeassistant/scripts.yaml", line 161, column 5
expected <block end>, but found '<scalar>'
  in "/home/homeassistant/.homeassistant/scripts.yaml", line 162, column 34

Since I’m not very familiar with xml/yaml etc I dont know what it means really…

wait_template: '{{ is_state("binary_sensor.entry_door_magnet_switch_sensor",
      "off) }}'

Ah, like that.
Well, the check validates. But script is not working…

Edit…HA restart did the trick! Thanks!

However…why/when do I need to use a double quote and when do I use a single?
For my template sensors I’ve used single ones and they are working.

I don’t know exactly why, but in most cases, single quotes and double quotes can be used interchangeably for simple statements. Like this line could be:

  • timeout: ‘120’

or

  • timeout: “120”

but when you’re dealing with data templates, which are complex statements usually use both single and double quotes, you have to use quotes consistently. It’s a coding thing that you need to get used to.

Tnx, learning by doing then :wink:
And with help from experienced ppl here :wink:

You can use either. Quotes surround a string (= text as opposed to a number)
Only thing is of you need a string within a string you need to use both : one set to surround the overall string, and a different set for the inner string which was your issue here