let vacuumName = "IdenticalVeneratedCat"; entityVacuum = "vacuum.valetudo_identicalveneratedcat"; mapSegments = [ {id = 1; name = "Hendrik";} {id = 2; name = "Schlafzimmer";} {id = 3; name = "Badezimmer";} {id = 4; name = "Toilette";} {id = 5; name = "Flur";} {id = 6; name = "Vorratsraum";} {id = 7; name = "Küche";} {id = 8; name = "Caro";} {id = 9; name = "Wohnzimmer";} ]; mkBooleanHelper = id: name: [ { name = "vacuum_segment_${toString id}"; value = { name = name; }; } ]; mkBooleanHelpers = ms: builtins.concatMap (s: (mkBooleanHelper s.id s.name)) ms; in { input_boolean = builtins.listToAttrs (mkBooleanHelpers mapSegments); group = { vacuum_rooms = { name = "Vacuum Rooms"; entities = builtins.concatMap (s: ["input_boolean.vacuum_segment_${toString s.id}"]) mapSegments; }; }; script = { vacuum_clean_segments = { mode = "single"; alias = "vacuum_clean_segments"; icon = "mdi:arrow-right"; sequence = [{ service = "script.turn_on"; target = { entity_id = "script.vacuum_clean_segments_message"; }; data = { variables = { segments = "{{expand(\"group.vacuum_rooms\") | selectattr(\"state\",\"eq\",\"on\") | map(attribute=\"attributes.room_id\") | list | to_json}}"; }; }; }]; }; vacuum_clean_segments_message = { alias = "vacuum_clean_segments_message"; mode = "single"; sequence = [{ service = "mqtt.publish"; data = { topic = "valetudo/${vacuumName}/MapSegmentationCapability/clean/set"; payload_template = ''{"segment_ids": {{segments}}}''; }; }]; }; }; }