Skip to content

Automation - State Condition display 'for:' in frontend#8124

Merged
bramkragten merged 2 commits intohome-assistant:devfrom
Nikfinn99:state-condition-for
Jan 11, 2021
Merged

Automation - State Condition display 'for:' in frontend#8124
bramkragten merged 2 commits intohome-assistant:devfrom
Nikfinn99:state-condition-for

Conversation

@Nikfinn99
Copy link
Copy Markdown
Contributor

Breaking change

Proposed change

The state-condition, is missing the for: configuration entry in UI mode, which can only be configured from the yaml mode.

The for: configuration is documented here (see first example):
https://www.home-assistant.io/docs/scripts/conditions/#state-condition

Old UI

state-condition-for-missing

Change from this PR

state-condition-for-added-ui

YAML mode

state-condition-for-added-yaml

Type of change

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

Example configuration

Add this to an automation and then switch to the UI mode.
In the latest release of home-assistant, the for: option will be missing from UI.

condition:
  - condition: state
    entity_id: person.somebody
    state: home
    for: '00:10:00'

Additional information

I created a feature request in the community forum first (see link below).
As i created a couple of webpages in the past also with Angular and Vue, i've decided to look into this issue myself and found the solution to be really easy, as all of the code was already present for the state trigger.

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

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

@homeassistant
Copy link
Copy Markdown
Contributor

Hi @Nikfinn99,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

let trgFor = this.condition.for;

if (
trgFor &&
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let give this variable a logical name, like for

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not exactly that, but something better, yes.
forTime?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree and the variable is now renamed

@bramkragten bramkragten merged commit aba0e1f into home-assistant:dev Jan 11, 2021
@bramkragten
Copy link
Copy Markdown
Member

Thanks! 🦁

@thomasloven
Copy link
Copy Markdown
Contributor

🎉

@Nikfinn99 Nikfinn99 deleted the state-condition-for branch January 11, 2021 18:43
@github-actions github-actions bot locked and limited conversation to collaborators Jan 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants