From 911cbb95e877c1ee2ad07a907c83221650664b82 Mon Sep 17 00:00:00 2001 From: Andrew Blackburn Date: Mon, 9 Oct 2023 12:11:20 +0100 Subject: [PATCH 1/3] Room card: add some animation icons --- .../icons/fan_animation.yaml | 67 +++++++++++++++++++ .../icons/garage-door_animation.yaml | 58 ++++++++++++++++ .../icons/motion_animation.yaml | 48 +++++++++++++ .../icons/shower_animation.yaml | 67 +++++++++++++++++++ .../icons/sprinkler_animation.yaml | 54 +++++++++++++++ 5 files changed, 294 insertions(+) create mode 100644 custom_cards/custom_card_andyblac_room/icons/fan_animation.yaml create mode 100644 custom_cards/custom_card_andyblac_room/icons/garage-door_animation.yaml create mode 100644 custom_cards/custom_card_andyblac_room/icons/motion_animation.yaml create mode 100644 custom_cards/custom_card_andyblac_room/icons/shower_animation.yaml create mode 100644 custom_cards/custom_card_andyblac_room/icons/sprinkler_animation.yaml diff --git a/custom_cards/custom_card_andyblac_room/icons/fan_animation.yaml b/custom_cards/custom_card_andyblac_room/icons/fan_animation.yaml new file mode 100644 index 0000000..bc4a660 --- /dev/null +++ b/custom_cards/custom_card_andyblac_room/icons/fan_animation.yaml @@ -0,0 +1,67 @@ +fan_animation: + variables: + timeout: "[[[ return Date.now() - Date.parse(entity.last_changed); ]]]" + triggers_update: "all" + show_icon: false + custom_fields: + icon: > + [[[ + let path = ` + + `, + style = ` + + + `; + if (entity.state === 'on' && variables.timeout < 1000) { + return `${style}${path}${path}`; + } + if (entity.state === 'off' && variables.timeout < 1000) { + return `${style}${path}`; + } + if (entity.state === 'on' && variables.timeout > 1000) { + return `${style}${path}`; + } else { + return `${style}${path}`; + } + ]]] + img_cell: "[[[ return ``; ]]]" diff --git a/custom_cards/custom_card_andyblac_room/icons/garage-door_animation.yaml b/custom_cards/custom_card_andyblac_room/icons/garage-door_animation.yaml new file mode 100644 index 0000000..ac84b1b --- /dev/null +++ b/custom_cards/custom_card_andyblac_room/icons/garage-door_animation.yaml @@ -0,0 +1,58 @@ +garage-door_animation: + variables: + timeout: "[[[ return Date.now() - Date.parse(entity.last_changed); ]]]" + # triggers_update: "all" + show_icon: false + custom_fields: + icon: > + [[[ + let path = ` + + `, + style = ` + + + `; + if (entity.state === 'open' && variables.timeout < -1000) { + return `${style}${path}`; + } + if (entity.state === 'closed' && variables.timeout < 1000) { + return `${style}${path}`; + } + if (entity.state === 'open' ) { + return `${style}${path}`; + } else { + return `${style}${path}`; + } + ]]] + + img_cell: "[[[ return ``; ]]]" diff --git a/custom_cards/custom_card_andyblac_room/icons/motion_animation.yaml b/custom_cards/custom_card_andyblac_room/icons/motion_animation.yaml new file mode 100644 index 0000000..6f04ff3 --- /dev/null +++ b/custom_cards/custom_card_andyblac_room/icons/motion_animation.yaml @@ -0,0 +1,48 @@ +motion_animation: + variables: + timeout: "[[[ return Date.now() - Date.parse(entity.last_changed); ]]]" + triggers_update: "all" + show_icon: false + custom_fields: + icon: > + [[[ + let path = ` + + `, + style = ` + + + `; + if (entity.state === 'on' && variables.timeout < -1000) { + return `${style}${path}`; + } + if (entity.state === 'off' && variables.timeout < 1000) { + return `${style}${path}`; + } + if (entity.state === 'on') { + return `${style}${path}`; + } else { + return `${style}${path}`; + } + ]]] + + img_cell: "[[[ return ``; ]]]" diff --git a/custom_cards/custom_card_andyblac_room/icons/shower_animation.yaml b/custom_cards/custom_card_andyblac_room/icons/shower_animation.yaml new file mode 100644 index 0000000..47d9759 --- /dev/null +++ b/custom_cards/custom_card_andyblac_room/icons/shower_animation.yaml @@ -0,0 +1,67 @@ +shower_animation: + variables: + timeout: "[[[ return Date.now() - Date.parse(entity.last_changed); ]]]" + # triggers_update: "all" + show_icon: false + custom_fields: + icon: > + [[[ + let path = ` + + `, + style = ` + + + `; + if (entity.state === 'on' && variables.timeout < 1000) { + return `${style}${path}${path}`; + } + if (entity.state === 'off' && variables.timeout < 1000) { + return `${style}${path}`; + } + if (entity.state === 'on' && variables.timeout > 1000) { + return `${style}${path}`; + } else { + return `${style}${path}`; + } + ]]] + img_cell: "[[[ return ``; ]]]" diff --git a/custom_cards/custom_card_andyblac_room/icons/sprinkler_animation.yaml b/custom_cards/custom_card_andyblac_room/icons/sprinkler_animation.yaml new file mode 100644 index 0000000..0d7d1fe --- /dev/null +++ b/custom_cards/custom_card_andyblac_room/icons/sprinkler_animation.yaml @@ -0,0 +1,54 @@ +sprinkler_animation: + variables: + timeout: "[[[ return Date.now() - Date.parse(entity.last_changed); ]]]" + triggers_update: "all" + show_icon: false + custom_fields: + icon: > + [[[ + let path = ` + + `, + style = ` + + + `; + if (entity.state === 'on' && variables.timeout < -1000) { + return `${style}${path}`; + } + if (entity.state === 'off' && variables.timeout < 1000) { + return `${style}${path}`; + } + if (entity.state === 'on') { + return `${style}${path}`; + } else { + return `${style}${path}`; + } + ]]] + + img_cell: "[[[ return ``; ]]]" From d03d612304b7db29ee85601b4666590b5f9e4a4a Mon Sep 17 00:00:00 2001 From: Andrew Blackburn Date: Mon, 9 Oct 2023 12:12:33 +0100 Subject: [PATCH 2/3] docs: update Room card to show animation templates. --- docs/usage/custom_cards/custom_card_andyblac_room.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/usage/custom_cards/custom_card_andyblac_room.md b/docs/usage/custom_cards/custom_card_andyblac_room.md index 92143d8..de74bdc 100644 --- a/docs/usage/custom_cards/custom_card_andyblac_room.md +++ b/docs/usage/custom_cards/custom_card_andyblac_room.md @@ -134,6 +134,8 @@ If you want to tweak this card a little bit more, below are some examples. The f entity_4: entity_id: fan.bathroom_extractor ulm_custom_card_andyblac_room_icon_color_on: blue + templates: + - fan_animation ``` ??? note "Template Code" From 0d3ed18b0ca2b74c6faaa1857804007163ecf1f7 Mon Sep 17 00:00:00 2001 From: Andrew Blackburn Date: Thu, 12 Oct 2023 21:00:22 +0100 Subject: [PATCH 3/3] Room card: fix sensor off colour for animation --- .../custom_card_andyblac_room.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_cards/custom_card_andyblac_room/custom_card_andyblac_room.yaml b/custom_cards/custom_card_andyblac_room/custom_card_andyblac_room.yaml index 54159df..9cbfdc7 100644 --- a/custom_cards/custom_card_andyblac_room/custom_card_andyblac_room.yaml +++ b/custom_cards/custom_card_andyblac_room/custom_card_andyblac_room.yaml @@ -1,6 +1,6 @@ --- custom_card_andyblac_room: - # v2.0.2 + # v2.0.3 template: - "ulm_translation_engine" @@ -662,9 +662,9 @@ custom_card_andyblac_room_sensor_icon: - fill: > [[[ if (variables.ulm_custom_card_andyblac_room_sensor_color_on == 'theme') { - return 'rgba(var(--color-'+variables.ulm_custom_card_andyblac_room_sensor_color_on+'),0.2)'; + return 'rgba(var(--color-'+variables.ulm_custom_card_andyblac_room_sensor_color+'),0.2)'; } else { - return 'rgba(var(--color-'+variables.ulm_custom_card_andyblac_room_sensor_color_on+'),0.4)'; + return 'rgba(var(--color-'+variables.ulm_custom_card_andyblac_room_sensor_color+'),0.4)'; } ]]] state: