I’m trying to figure out how to create a bunch of toggle switches (or similar), based on a lot of key/value pairs. The key/value pairs are created from my vacuum’s room segments, so the data looks like this:
<1, Kitchen>
<2, Living room>
<3, Bedroom>
and so on. Instead of creating a toggle for each room, then using the toggle’s name to use the correct room ID in an automation, what other options do I have? Can I create these toggles dynamically?
I also want the possibility to “untoggle”/disable all of the toggles, so that when I select 3 rooms and hit clean, it should set the 3 toggles to false/off.
I might need to make my own integration for this, as I think it’s too much for Home Assistant, as it requires a lot of logic.
What is the vacuum intergration that you are using? I dont know if this helps but I have seen custom vacuum cards which could do this for you without creating any toggles switches. For example the following is a vacuum card for xiaomi vaccums.
I use Xiaomi Miio and that card you linked there. However, I do not want to specify where each of my zones are, when I have a list of segments already, that just calls the vacuum with which rooms should be vacuumed. Exactly the same behavior as going into the app, selecting a few rooms, and pressing clean.
The vacuum-map card only allows you to make a zone cleanup, which is usually a square, which would take way too much time to create by hand, unfortunately.
My current “flow” consists of a bunch of input_booleans/toggles (one for each room), and then I have a script that selects which rooms should be vacuumed and sends that array to the vacuum clean segments service. For a noobie, this is a lot of work, and requires a lot of modification. It would be nice, if I could just create an array with a bunch of IDs and names, and then have Home Assistant create the input_booleans based on that array.