TRANSCRIÇÃOEnglish

Home Assistant Cards That Respond & Animate Automatically

12m 26s2,088 palavras134 segmentsEnglish

TRANSCRIÇÃO COMPLETA

0:00

Hi! I made this video explaining how to use animated icons on your

0:04

Home Assistant dashboard some time ago. Two years later, things have changed,

0:08

and I will show you how to do this in the new section dashboards in Home Assistant! From now on,

0:13

your dashboard will look amazing with these animated icons and cards. Let’s dive in!

0:29

The new section dashboards in Home Assistant are great, but they can sometimes feel a

0:34

bit static. Fortunately, you can change that yourself, and with the help of this tutorial,

0:39

you don’t need to be very technical to do so. I’ve created several ready-to-use animations in this

0:44

video that you can quickly implement. By the way, I got this idea from Rhys,

0:49

who has shared many more ideas on the Home Assistant forums. The link to

0:52

that page is in the description of this video. I will show you how to create these animations,

0:58

but first, we need to install a HACS integration. You can change the looks of cards on your

1:02

dashboard by using CSS. To use CSS in cards, you need a HACS integration called card-mod.

1:08

If you do not have HACS installed yet, I created this easy-to-follow video on how

1:13

to do that. Check it out. Let’s first install the card-mod integration.

1:18

To install card-mod, we are going to HACS. Search for card-mod.

1:26

Click on card-mod. Click Download.

1:30

Click download again. Click Reload

1:36

Clear your browser cache to be sure. Now that Card-Mod is installed, we can change our

1:41

dashboard to include animated cards. I prepared some animated cards and will explain how I created

1:47

them. Although it’s not necessary, I also use Mushroom cards. So, if you want to use them,

1:53

please install the Mushroom cards using HACS. Let’s start with explaining the animated badges:

1:58

As you can see, I created five badges on this page:

2:02

A Home badge that bounces. A Power badge that pulsates.

2:06

A fan badge that spins. A mailbox badge that jumps around.

2:10

And a Motion Detector badge that flashed the motion sign.

2:14

If I put the dashboard in Edit mode by clicking the pencil icon,

2:17

I can show you how I created each badge. For the animated home badge, I chose to add

2:22

a mushroom-template badge. Because I added some YAML code, I can no longer view this badge in

2:28

the Visual Editor. However, as I will show you later, this does work for tile cards.

2:33

At the bottom of the badge’s code, I added the following lines:

2:36

I start with card_mod: to activate the card_mod integration we installed via HACS. Then comes

2:42

the line “style: |”. After that, we add the CSS code to make the house icon bounce.

2:49

We do this by modifying the behavior of ha-state-icon,

2:52

which is why we start with ha-state-icon. In this case, I named my animation “Boing”;

2:58

it lasts 3 seconds and will repeat infinitely. The transform-origin transforms on the x-axis

3:04

at 50% and the y-axis at 90% of the image. Now, we have to define the animation itself. For this,

3:12

I created the line “@keyframes” for the boing animation that we named before. Within the

3:17

boing keyframes, we define what should happen at specific percentages of the animation time. In

3:23

this case, we use the scale3d function that scales our image on the x, y, and z-axis. In this case,

3:30

it scales at 0, 7, 10, 12, 16, 19, and 25% of the timeline of our animation. You can play with the

3:38

numbers yourself to change the actual animation. The second animation animates the power button.

3:48

Again, we define a ha-state icon. I called it pulse this time, and the timeframe is 3

3:54

seconds. The animation occurs on the x-axis at 50% and the Y-axis at 60%. As we did with

4:00

the House icon, I defined keyframes for the animation called “Pulse.” Now, we use the

4:05

scale function to scale at certain keyframes, this time at 0, 10, 17, 33, and 60 percent.

4:12

I hope you already have an idea about how this mechanism works. The House and the Power button

4:17

animations do not differ much. But there is one difference that I haven’t explained yet. I have

4:22

added code after the animation line that checks whether the power button is turned on. This code

4:27

ensures that the animation is only applied if the power button is on. For this tutorial,

4:32

I created Toggle Helpers, and in this case, I am checking whether the input_boolean.power_office

4:37

helper’s state is set to “on.” Of course, you can also use the sensor’s state for this.

4:42

Let’s do this for the fan badge, too. This time, we will make it spin only when the fan is on!

4:50

We start with ha-state-icon again. This time, I named the animation rotation. It runs infinitely,

4:56

and a full rotation takes 1 second. To ensure that the animation only shows when the fan is on,

5:02

I’ve added an if statement that checks if the state of my animate_airconditioning is

5:07

“on.” Using this, the animation will only trigger if the state is “on.”

5:12

I defined the animation in the keyframes section, which I named “rotation.” At 0%,

5:17

the icon is rotated 0 degrees. At 100%, it is rotated 360 degrees.

5:27

The mailbox animation is similar to the other animations we’ve already created.

5:31

I called the animation bounce and added an if statement again. This time, it checks if

5:36

an input boolean “mail_arrived” is set to On. If you want to automate your letterbox, please

5:41

watch this easy-to-follow video explaining how to set it up. It uses the older menu structure,

5:47

and the Home Assistant interface looks slightly different but is still valid.

5:52

The keyframes for the bounce animation are set so that the icon jumps up and down on the y-axis

5:57

and rotates a little bit simultaneously. Now, we will introduce a new thing in our

6:03

animation: the polygon clip-path. Using a polygon clip-path, you can mask some

6:08

parts of the icon so that that part is only visible. There are various tools for that on

6:13

the internet. The one that I use is the CSS Clip Path Generator at cssportal.com. First,

6:19

I downloaded the “mdi:icon” I’d like to use from materialdesignicons.com. Search

6:24

for motion-sensor. Click the download icon and download the image as an SVG image. Then,

6:37

go to the CSS clip-path generator and upload that image via the Upload image link.

6:47

Then, please select one of the example symbols and adapt it so that it only

6:51

shows the part of the icon you want to show in the animation. Then, copy the clip-path

7:01

line shown below the image to your clipboard. Now that we’ve determined the clip path for our

7:06

icon, we can apply it to our animation. Let’s set it up.

7:14

We start with ha-state-icon again. I named the animation “clip”. It runs for 2 seconds and will

7:20

loop infinitely. I also added an if-statement so that the animation would only play when motion

7:26

was detected. If we look at the keyframes for the clip animation, I added just one

7:33

line that activates the clip-path at 50% of the animation. So, I’ve pasted the code we copied from

7:39

the CSS Clip-path generator in this line. The result is that the whole icon is shown at 0%,

7:45

and the clip-path gets applied at 50%, which means that the motion symbol is not visible then,

7:50

and it looks like the animation is flashing. Our badges are ready. I hope you now know how

7:55

to create animated badges. Let’s quickly look at the other cards I’ve created. They use the

8:00

exact mechanisms I’ve shown in the badges, but they have some extra functionalities.

8:05

Let’s look at the air conditioning card. This is a Tile Card. I click on Show Code Editor

8:11

to see how I animated it. This animation code is the same as the fan badge code,

8:16

so there’s no difference between codes for badges and cards. Instead of linear, you can

8:20

also use ease-in or ease-out, but I prefer linear in this case. Again, I’ve added an if statement

8:27

to check if the air conditioning is on or off. The next card is the light card that blinks when

8:32

it’s on. Again, we are using the clip-path polygon animation for this card, just like

8:37

we did for the badge’s motion sensor icon. Let’s open the visual editor for the light card. I used

8:43

a Mushroom template Card this time. I click Show Code Editor to view the YAML code. We start with

8:49

ha-state-icon again. Within ha-state-icon, we name our animation “illumination,” which lasts

8:55

2 seconds and loops infinitely. And I’ve added an if statement again that checks if the light is on.

9:01

Then, I created the keyframes for the illumination animation. I created a clip-path polygon using

9:07

the CSS Clip-Path generator site just like I did for the motion sensor badge and pasted

9:11

the code here. The clipping path kicks in at 80% of the timeframe, resulting in a light-flashing

9:17

effect. It doesn’t matter if you fill in 80% or another percentage because the clip-path gets

9:22

activated only once within 2 seconds. The sprinkler card makes use of the

9:26

polygon clip-path, but this time I use two polygon clip paths that alternate. I first

9:31

created two clip-path polygons using the CSS Clip-Path generator site. You see, I started

9:36

with ha-state-icon again. I called the animation “Spray,” it lasts 2 seconds, eases in, and loops

9:43

infinitely. And I’ve added an if-statement again to check whether the sprinkler is on. I’ve also

9:49

created this lovely video explaining how to set up your fully automated garden watering system. Check

9:54

it out if you need something like that, too. I added two keyframes for the spray automation.

10:00

The first clip path shows at 0, 50, and 100%, while the second one shows at 25

10:05

and 75 percent, so it looks like it is spraying. Next, I’ve created three scene buttons to switch

10:11

between scenes on my dashboard. If you want to know how to switch scenes with a button in Home

10:15

Assistant like Philips Hue, check out this awesome video that explains exactly how to set that up!

10:21

The first button spins the icon when I click it, the second button pushes the icon in a bit,

10:26

and the third button pushes the icon down when you press it. Let’s see how you can set this up.

10:31

For the first button, we click on Show Code Editor. When you click on a card, it becomes

10:36

active, so this time, we trigger the animation when the card is active. For the first button,

10:40

we rotate the icon 360 degrees and set the rotation transition to 500ms. As you can see,

10:47

rotating an icon when you click on a card differs from rotating an icon infinitely.

10:52

For the second card, we are again triggering the active state of the card. To give this

10:56

card the effect that it seems to be pushed in, we transform the scale to a value lower than

11:01

1 and set the transition to 0 seconds. I moved the card 1.5 pixels down for the

11:15

third card and added a box shadow. The shadow is not visible in dark mode but

11:19

creates a nice extra effect in light mode. This is how you can create animated icons

11:24

and cards in the new sections view of Home Assistant! The possibilities are endless!

11:29

You can see more examples on this site. The link is in the description below. I am curious about

11:34

what animations you can create. Let me know in the comments, and send me your dashboards

11:38

on the Dump Your Dashboard channel on my Discord server. You’ll also find the link

11:43

to my discord server in the description. If you don’t want to type the code from the

11:47

screen, you can sponsor me with a coffee and download the code I created for this

11:51

video in return via the Ko-fi link in the description below. This will allow

11:55

me to continue making these videos for you. I want to thank everyone who has supported

12:00

me in making these videos and tutorials. I could never have done this without you. Thank you! You

12:07

can support me through Patreon, Ko-Fi, or becoming a paid channel member. If you want to support me,

12:12

look in the description of this video for the links. With that, you make it possible for me

12:16

to continue to make these videos for you. Don’t forget to give this video a thumbs up,

12:21

subscribe to my channel, and hit the notification bell.

12:24

I will see you soon! Bye bye!

DESBLOQUEAR MAIS

Registe-se gratuitamente para aceder a funcionalidades premium

VISUALIZADOR INTERATIVO

Assista ao vídeo com legendas sincronizadas, sobreposição ajustável e controlo total da reprodução.

REGISTE-SE GRATUITAMENTE PARA DESBLOQUEAR

RESUMO DE IA

Obtenha um resumo instantâneo gerado por IA do conteúdo do vídeo, pontos-chave e conclusões.

REGISTE-SE GRATUITAMENTE PARA DESBLOQUEAR

TRADUZIR

Traduza a transcrição para mais de 100 idiomas com um clique. Baixe em qualquer formato.

REGISTE-SE GRATUITAMENTE PARA DESBLOQUEAR

MAPA MENTAL

Visualize a transcrição como um mapa mental interativo. Entenda a estrutura rapidamente.

REGISTE-SE GRATUITAMENTE PARA DESBLOQUEAR

CONVERSAR COM A TRANSCRIÇÃO

Faça perguntas sobre o conteúdo do vídeo. Obtenha respostas com tecnologia de IA diretamente da transcrição.

REGISTE-SE GRATUITAMENTE PARA DESBLOQUEAR

APROVEITE MAIS DE SUAS TRANSCRIÇÕES

Inscreva-se gratuitamente e desbloqueie o visualizador interativo, resumos de IA, traduções, mapas mentais e muito mais. Não é necessário cartão de crédito.

    Home Assistant Ca… - Transcrição Completa | YouTubeTranscript.dev