Skip to content

Map card editor: add UI for conditions#30247

Open
ildar170975 wants to merge 56 commits intohome-assistant:devfrom
ildar170975:map-conditions
Open

Map card editor: add UI for conditions#30247
ildar170975 wants to merge 56 commits intohome-assistant:devfrom
ildar170975:map-conditions

Conversation

@ildar170975
Copy link
Contributor

@ildar170975 ildar170975 commented Mar 20, 2026

Breaking change

Proposed change

Added "conditions" UI (#29614).

Currently “conditions” UI for “state” & “numeric state” include an input field to select an entity.
This is meaningless for “filtering conditions” used for entities in:
-- Entity filter card
-- Map card
-- Badge filter
i.e. “conditions” UI for these cards (which does not exist yet) should not include that “entity” input field.

This PR adds a possibility to “not show” that “entity” input field in the “state” & “numeric state” conditions.
Also, for these “no entity” conditions, a “test” button was removed from a menu.

Screenshots

image

Note that for a "State" condition, a list is prefilled with possible values for device_tracker entities (standard ones like home /not_home and zones):

изображение

Since the state selector is not attached to some particular entity, the list is supposed to be empty, and a user has to input values manually (instead of selecting them from a list). Prefilling the list with possible values simplifies the job.
Of course, not only device_tracker (or person) entities can be placed on a map; for other domains a user will have to input values manually.
For example, this condition only shows a zone.home entity (which has a state = 2):

image

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

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue or discussion:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to backend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

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

To help with the load of incoming pull requests:

@ildar170975
Copy link
Contributor Author

Found an issue, a "state" field is disabled.
Keeping as a draft...

image

@ildar170975 ildar170975 marked this pull request as ready for review March 26, 2026 16:31
(stateObj?: HassEntity) =>
[
{ name: "entity", selector: { entity: {} } },
...(this.no_entity
Copy link
Member

Choose a reason for hiding this comment

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

no_entity should be passed to the memoized funditon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

(localize: LocalizeFunc) =>
[
{ name: "entity", selector: { entity: {} } },
...(this.no_entity
Copy link
Member

Choose a reason for hiding this comment

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

no_entity should be passed to the memoized funditon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines +240 to +252
const mockStateObj: HassEntity = {
entity_id: "device_tracker.xxx",
attributes: {},
state: "home",
last_changed: "",
last_updated: "",
context: {
id: "",
user_id: null,
parent_id: null,
},
};
const states = getStates(this.hass, mockStateObj);
Copy link
Member

Choose a reason for hiding this comment

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

This looks very hacky and fragile

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code is taken from a test. OK, will try to compose a list of 4 states (home, not_home, unavailable, unknown) with translations manually.

Copy link
Contributor Author

@ildar170975 ildar170975 Mar 27, 2026

Choose a reason for hiding this comment

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

@MindFreeze Can you tell me, is there any way to get translated names for "home" & "not_home"? Frontend translations ("en.json") contains translations for a state-badge element - and I guess in many languages the strings are SHORTENED.
Update - found a way, I hope...

ildar170975 and others added 2 commits March 27, 2026 11:47
Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>
@ildar170975 ildar170975 marked this pull request as draft March 27, 2026 09:03
@ildar170975
Copy link
Contributor Author

ildar170975 commented Mar 27, 2026

Leaving with this 4 standard states:

изображение

Will enrich it with zone names - in a future PR or in the current one (if it will be not merged yet).


Update: added zones.

изображение

@ildar170975 ildar170975 marked this pull request as ready for review March 27, 2026 10:34
@ildar170975 ildar170975 marked this pull request as draft March 27, 2026 11:06
@ildar170975 ildar170975 marked this pull request as ready for review March 27, 2026 11:14
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.

2 participants