Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdziekon/4fb2d0d8db89dab07951e04246f76b1a to your computer and use it in GitHub Desktop.
Save mdziekon/4fb2d0d8db89dab07951e04246f76b1a to your computer and use it in GitHub Desktop.
ha_lovelace_vacuum_selective_cleaning
type: custom:button-card
tap_action:
action: call-service
service: script.vacuum_clean_segments
confirmation: true
service_data: {}
target: {}
lock:
enabled: >-
[[[ return states['group.VACUUM_ROOMS_GROUP'].state !== 'on' ||
states['vacuum.ROBOT_ENTITY'].state !== 'docked' ]]]
exemptions: []
entity: script.vacuum_clean_segments
# Expand required to recalculate "name" on each entity change
group_expand: true
name: |-
[[[
const selectedRoomsCount = states["group.VACUUM_ROOMS_GROUP"].attributes.entity_id.reduce((accumulator, entity) => { return accumulator + (states[entity].state === "on" ? 1 : 0); }, 0);
return `Vacuum selected rooms (${selectedRoomsCount})`;
]]]
show_state: false
show_icon: true
layout: icon_name
icon: mdi:vacuum-outline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment