Skip to content

Add 'for' duration to lovelace state visibility condition, and add 'not' lovelace visibility condition #26094

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

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

LukeMondy
Copy link

@LukeMondy LukeMondy commented Jul 7, 2025

Proposed change

This is an alternative implementation of this PR: #25864.

In that PR, I added a new condition called 'Last Entity Change', which would allow the user to specify a 'within' and 'after' duration, which would show a card based on the last changed time of an entity (either 'within' a certain duration since a change; or 'after' some duration since a change).

Thanks to the comments of @karwosts , they suggested this could be implemented to more closely follow how the automation interface works.

To do this, this PR adds a 'For' duration to the State visibility condition, and adds a 'Not' condition. The 'Not' condition is required to replicate the behavior of the 'within' duration in the previous PR.

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: entity
entity: light.kitchen_floor_lamp_light
visibility:
  - condition: not
    conditions:
      - condition: state
        entity: light.kitchen_floor_lamp_light
        for:
          hours: 0
          minutes: 0
          seconds: 10
        state:
          - "on"
          - "off"

Additional information

Demo:
last_state_change_demo_with_not

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.

Some help with letting me know where to add tests would be much appreciated :)

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

@LukeMondy LukeMondy force-pushed the add_last_changed_to_state_condition branch 4 times, most recently from 780e512 to caed19a Compare July 7, 2025 06:09
@LukeMondy LukeMondy marked this pull request as ready for review July 7, 2025 07:07
@LukeMondy LukeMondy force-pushed the add_last_changed_to_state_condition branch from caed19a to 3bed2bc Compare July 13, 2025 03:15
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.

1 participant