Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix script repeat variable lifetime #38124

Merged
merged 3 commits into from Jul 24, 2020
Merged

Fix script repeat variable lifetime #38124

merged 3 commits into from Jul 24, 2020

Conversation

pnbruckner
Copy link
Contributor

Proposed change

In a script repeat action, the repeat variable was not defined while evaluating the while or until conditions. This change makes sure it is defined then.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml
my_script:
  sequence:
    - alias: Repeat the sequence AS LONG AS the conditions are true
      repeat:
        while:
          - condition: state
            entity_id: input_boolean.run_loop
            state: 'on'
          - condition: template
            value_template: "{{ repeat.index <= 20 }}"
        sequence:
          - ...

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 馃 Silver
  • 馃 Gold
  • 馃弳 Platinum

@pnbruckner
Copy link
Contributor Author

Original intent was to have repeat variable defined just within the sequence, which is how it was implemented. But later examples provided used it in while conditions, so intention changed but implementation didn't follow. This solves that problem! 馃槄

@balloob balloob merged commit 2f87da8 into dev Jul 24, 2020
@balloob balloob deleted the fix-script-repeat-var branch July 24, 2020 06:11
frenck pushed a commit that referenced this pull request Jul 24, 2020
@frenck frenck mentioned this pull request Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Script repeat action not defining repeat variable in while or until conditions
4 participants