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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditions state_filter support #11539

Closed
wants to merge 1 commit into from

Conversation

elupus
Copy link
Contributor

@elupus elupus commented Feb 4, 2022

Proposed change

Support state_filter for conditional cards. This behaves the same as entity-filter.

I think eventually state and state_not should probably be removed, but that would be an ugly breaking change.

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

type: conditional
conditions:
  - entity: button.broadlink_mini_loxjie_display
    state_filter:
      - operator: 'in'
        value:
          - unavailable
          - jlkas
card:
  type: button
  tap_action:
    action: toggle
  entity: switch.test1

Additional information

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:

@elupus elupus changed the title Conditions state Conditions state_filter support Feb 6, 2022
@finder39
Copy link

I believe this is possible already, albeit in a slightly different syntax:

- type: conditional
  conditions:
  - entity: vacuum.roborock_vacuum_a19
    state: ["unavailable", "unknown", "docked"]

- or -

- type: conditional
  conditions:
  - entity: vacuum.roborock_vacuum_a19
    state_not: ["unavailable", "unknown", "docked"]

@Inrego
Copy link

Inrego commented Mar 28, 2022

From my testings, the above syntax for checking multiple states do not work.

Comment on lines 37 to 39
if (!c.entity) return false;
if (c.state && typeof c.state !== "string") return false;
if (c.state_not && typeof c.state_not !== "string") return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't not merge all if states into a huge if a and b or c and d or e and f. Since that would make it unreadable.

@github-actions
Copy link

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@github-actions github-actions bot added stale and removed stale labels Jul 19, 2022
@elupus
Copy link
Contributor Author

elupus commented Jul 19, 2022

Had forgotten about this one. Will resolve reviews.

@jlsjonas
Copy link

@elupus friendly ping :) (would've helped me out today 😬 )
Are you still up to getting this one through? If not I'll see what I can do! (thanks either way!)

@erkr
Copy link

erkr commented Jun 5, 2023

So pitty this is not delivered 🥲

@ildar170975
Copy link
Contributor

Is this PR reviewed already?

@elupus
Copy link
Contributor Author

elupus commented Jun 26, 2023

Yes though, i have not tested it much after i resolved comments.

@FaberO42
Copy link

This one seems to be stuck?

@bramkragten
Copy link
Member

We discussed this, and think this is not the way to go.

  • You are now using a filtering syntax for a condition, which is a different usecase.
  • We recently updated the syntax of condition card, when we added the screen condition
  • We think the syntax should be similar to the conditions syntax we use for automations
    For example:
  - condition: state
    entity_id: sensor.weather_precip
    state: "rain"
  - condition: numeric_state
    entity_id: "sensor.temperature"
    below: 20

We agree state_not should be removed and replaced by the a not condition like we have in the automation conditions too. This will need a migration.

Therefor I am going to close this PR, thanks for willing to contribute and if you want to continue based on the above, feel free to open a new PR!

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.

None yet

10 participants