NewBee question: How to create a status card for mailbox example

Hello everyone,

a question from a newbee:
I want to have a card on my dashboard or lovelace where a card should show if my sensor in the mailbox was fired or not and if fired, change the color / icon and stay till 0:00 am.
Everyday at 0:00 am or if mailbox opened a 2nd time on that day it should then reset (example gray instead of red)

How can I achieve this?

What kind of Card do i need to create and how can I tell this card : now you need to be red, or gray.

Thanks
OktO

There are many ways to do this, but you might experiment with a Tile card, which is very versatile and allows changes of colour etc.

thanks @Stiltjack
currently I do have only

type: tile
entity: binary_sensor.aqara_door_sensor_briefkasten_contact
show_entity_picture: true
state_content: last-changed

what do i need to enter there in the yaml to change the icon color / or the color for example and stay in that color?

Have a look hereā€¦

Coloring card based on sensor value - #4 by Stiltjack.

Stilljack post will point you at customization. Iā€™d ask you to stop and think about the construct.

What are you ACTUALLY trying to accomplish? (sounds like notification of mail?)

Ok so if you notify on the mailbox door how are you going to tell when you opened the door to check mail v. The mailman? How are you going to reset it wheen you have the mail (all of these need to be figured out before you start worrying about colors.)

Reason. It changes what youā€™re customizing.

If I were doing this Iā€™d also create an input boolean helper to hold the state of the alert in a way that can be reset. That way the door can be opened and closed with impunity and only fire the ā€˜youā€™ve got mailā€™ notification once.

So youā€™d have your sensor (Door opened!)
When that happens have an automation turn on the input boolean. Put THAT on the dashboard. When itā€™s on the natural state of the dashboard will color it. You can call it whatever you want. Then once you grab the mail just turn off the boolean (which will change state in the dash) and all is well until the next time the mail comes.

2 Likes

thanks.
I think I did not make really clear what i want to achieve : A card which keeps the state when fired once. (Not change back to closed when the sensor closes back. )
Like an alarm ā€œyes, alarm was triggered therefore I am redā€
If I would know on how to yaml this thing, I would do like:
if ā€œlast changedā€ < 20h then change color to red.
Your idea with the boolen sounds the right way to me. But not sure on how to implement this in yaml

how would you implement an indicator that an alarm was triggered (which reset it self afterwards if wanted, but this is the second step)?

You do it as described above but also add a second automation that either resets the boolean at a specific time (midnight?) or waits for a delay (you can do this one but itā€™s generally bad to avoid long delays in automations)

1 Like

exactly, thanks.
but how do I implement it? I even dont now on how to start?`
itā€™s probably very simple, but I dont know how to start and enter my logic if else checks

@NathanCu is right. Write an automation to toggle an input_boolean, and write it using the UI (use entity ids and states, not device ids). If youā€™re interested in yaml you can look at that afterwards.

First create a ā€œtoggle helperā€. Weā€™ll call it ā€œmailbox flagā€.

Then create an automation. Itā€™s hard to show examples because we donā€™t have your sensors, but it would be something likeā€¦

When...
    Entity: mailbox sensor
    State: Changes to "open"

Then do...
    Input_boolean turn on: input_boolean.mailbox_flag

Then create a second automationā€¦

When...
    The time is equal to 00:00:01

Then do...
    Input_boolean turn off: input_boolean.mailbox_flag

Your dashboard should be based on the state of input_boolean.mailbox_flag.

Thereā€™s an introduction to automations here:

Itā€™s quite comprehensive if you follow the links through.

Input booleans are documented here:

1 Like

thanks, got it working, I think key was to create a helper.

type: entities
entities:
  - input_boolean.mailbox_helper
state_color: true

how do I get now the background red for example, if state is true?

You need a custom card for that.