Hey,
i’m absolutely new to Home Assistant and I’m actually working on a small Idea.
Unfortunately I’m unable to get it to work.
The following is what I want:
I Have a switch in lovelace called “testswitch” and I simply want that this switch toggles if there is a confirmation when clicking a button in lovelace or not…
Relatively simple I thought… but it isn’t for me… I just googled for hours asked friends with more experience but no one was able to help til now…
Maybe you can explain me what I’m doing wrong.
I just Broke down the Button to the bare minimum. The code looks like this:
Okay,
at first: Thanks for your answers!
I will have to try custom:button-card tomorrow. For today I’ve tried long enough.
Maybe I (try to) shortly explain what I’m trying to achieve:
In my home we have a Roborock Vacuum. I’m already controling it via HA with his basic features like Play Pause and Stop.
For each service I use a “Button”.
Sometimes it happened that I started it and forgot to clean the Mop or the Dust bin.
To prevent this in future I count the Cycles the “Start” Button has been pressed and count upwards.
If the Number is higher than 1 (so it cleaned the appartment already one time) I want a Notification in Lovelace, asking me if I really want to run the vacuum because it hasn’t cleaned yet(input sensor mop attached was never false during the last mop).
If I continue anyway it’s supposed to start and add another count in the cycles (in this case 2)
If you try now, after the 2nd time without cleaning, to start the vacuum it’s thought to give an “error” or something and it doesn’t call the service to start.
I Hope it’s understandable… even if it’s not absolutely necessary to explain it may interests someone…
So, as far as I know I am unable to bring up an Popup message on the device I pressed the “Start” Button. I only thought the function “Confirmation” could help here, but unfortunately it doesn’t.
Maybe anyone else has an good idea how to solve it? I Also thought about an entity filter card which shows only the corresponding button (with or without textmessage) regarding on the state, but I don’t have any idea yet how.
type: custom:button-card
tap_action:
confirmation:
text: |
[[[
if (states["counter.roborock_laufe_seit_reinigung"].state == '1')
return "Sicher? Roborock wurde seit dem letzten Lauf noch nicht gereinigt.";
if (states["counter.roborock_laufe_seit_reinigung"].state == '0')
return "Starten? Roborock ist sauber und bereit.";
if (states["counter.roborock_laufe_seit_reinigung"].state > '1')
return "Abbruch! Roborock wurde ewig nichtmehr gereinigt, Bitte Reinigen!";
]]]
action: call-service
service: script.1642074332166
icon: mdi:play
color: null
name: Start
aspect_ratio: 4/4
Thanks for the support so far!
two further questions:
Any Idea how to bring the Icon in the right color? I don’t know how the standard homeassistant color is named so i don’t know what to enter in the icon_color field.
Any Idea how to Align the text “Start” with the other “Pause” or “Stop” text?