Can't figure out how to use conditions in script

I have a set of scripts that I’d like to make “smarter” so that they only complete when I’m awake (a test of a boolean). But I can’t work out the syntax. I can find plenty of automation examples, but no script examples.

I’ve got:

script:
  speakweather:
    alias: 'Speak weather forecast'
    sequence:
      - condition:
          condition: state
          entity_id: input_boolean.scott_awake
          state: 'on'
      - service: shell_command.speakweather

The scripts page has an example of testing a condition, but it’s just a snippet without context. Am I at least close?

You are close. This should do it:

script:
  speakweather:
    alias: 'Speak weather forecast'
    sequence:
      - condition: state
        entity_id: input_boolean.scott_awake
        state: 'on'
      - service: shell_command.speakweather

Thanks! I think that at some point I had tried using multiple conditions (both myself AND my wife are awake before speaking). With your help, I figured that out, too:

  speakweather:
    alias: 'Speak weather forecast'
    sequence:
      - condition: and
        conditions: 
        - condition: state
          entity_id: input_boolean.person1_awake
          state: 'on'
        - condition: state
          entity_id: input_boolean.person2_awake
          state: 'on'  
      - service: shell_command.speakweather
4 Likes