Hi,
I want to run different scripts when clicking a button based on whether my robot vacuum is docked or cleaning. According to the documentation, this should be possible by using a javascript action. Given the following code, the confirmation is asked for correctly. But after confirming, nothing happens. Can someone help me out here?
- type: custom:button-card
name: Kehrbert
entity: vacuum.valetudo_1stfloor
...
tap_action:
confirmation:
text: |
[[[
let state = states['vacuum.valetudo_1stfloor'].state;
if (state == "docked") {
return "Start cleaning?"
} else if (state == "cleaning") {
return "Cancel cleaning?"
}
]]]
action: javascript
javascript: |
[[[
let state = states['vacuum.valetudo_1stfloor'].state;
if (state == "docked") {
return {
"action": "call-service",
"service": "script.valetudo_clean_segments",
"service_data": {
"vacuum": "1stFloor"
}
};
} else if (state == "cleaning") {
return {
"action": "call-service",
"service": "script.valetudo_cancel",
"service_data": {
"vacuum": "1stFloor"
}
};
}
]]]