Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions custom_components/keymaster/lovelace.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,15 @@ def _generate_entity_card_ll_config(
name: str,
parent: bool = False,
type_: str | None = None,
tap_action: MutableMapping[str, Any] | None = None,
) -> MutableMapping[str, Any]:
"""Generate entity configuration for use in Lovelace cards."""
prefix = "parent." if parent else ""
entity = f"{prefix}{domain}.code_slots:{code_slot_num}.{key}"
data: MutableMapping[str, Any] = {
"entity": entity,
"name": name,
"tap_action": {"action": "none"},
"tap_action": tap_action if tap_action is not None else {"action": "none"},
"hold_action": {"action": "none"},
"double_tap_action": {"action": "none"},
}
Expand Down Expand Up @@ -417,13 +418,14 @@ def _generate_conditional_card_ll_config(
conditions: list[MutableMapping[str, Any]],
parent: bool = False,
type_: str | None = None,
tap_action: MutableMapping[str, Any] | None = None,
) -> MutableMapping[str, Any]:
"""Generate Lovelace config for a `conditional` card."""
return {
"type": "conditional",
"conditions": conditions,
"row": _generate_entity_card_ll_config(
code_slot_num, domain, key, name, parent=parent, type_=type_
code_slot_num, domain, key, name, parent=parent, type_=type_, tap_action=tap_action
),
}

Expand Down Expand Up @@ -634,6 +636,11 @@ def _generate_date_range_entities(
) -> list[MutableMapping[str, Any]]:
"""Build the date range entities for the code slot."""
type_ = "simple-entity" if parent else None
# Non-parent views use the custom datetime row with pencil icon and
# more-info tap action for editing. Parent views use simple-entity
# with no tap action since the values are read-only (controlled by parent).
datetime_type = "simple-entity" if parent else "custom:keymaster-datetime-row"
datetime_tap: MutableMapping[str, Any] | None = None if parent else {"action": "more-info"}
return [
*([] if parent else [DIVIDER_CARD]),
_generate_entity_card_ll_config(
Expand All @@ -655,7 +662,8 @@ def _generate_date_range_entities(
)
],
parent=parent,
type_=type_,
type_=datetime_type,
tap_action=datetime_tap,
),
_generate_conditional_card_ll_config(
code_slot_num,
Expand All @@ -668,7 +676,8 @@ def _generate_date_range_entities(
)
],
parent=parent,
type_=type_,
type_=datetime_type,
tap_action=datetime_tap,
),
]

Expand Down
2 changes: 1 addition & 1 deletion custom_components/keymaster/www/generated/keymaster.js

Large diffs are not rendered by default.

Loading
Loading