Hi Peter,
Give this a shot…
NOTE! I havent tested this - just put it together this morning so it might have a couple of mistakes
Let me know how you go
If its all good, ill add it to the FAQ as a guide for adding a second level.
Cheers
Changes
secrets.yaml
#replace existing map with map0
vacuum_map_0: http://<ip or fqdn of docker host>:<nginxphpport>/image0.php
vacuum_map_1: http://<ip or fqdn of docker host>:<nginxphpport>/image1.php
vacuum.yaml
###################################
# Sensor
###################################
sensor:
#... EXISTING...
- platform: template
sensors:
vacuum:
#... EXISTING...
attribute_templates:
#... EXISTING...
# pmap1_id I7/S9 Models - Level 1 (represented by the second pmap list entry)
pmap1_id: >-
{% if state_attr('sensor.rest980', 'pmaps')[1] is defined %}
{{ state_attr('sensor.rest980', 'pmaps')[1] | regex_findall_index("{'([\w\-]+)': '\w+'}") }}
{% else %}
n-a
{% endif %}
# pmap1_timestamp I7/S9 Models
pmap1_timestamp: >-
{% if state_attr('sensor.rest980', 'pmaps')[1] is defined %}
{{ state_attr('sensor.rest980', 'pmaps')[1] | regex_findall_index("{'[\w\-]+': '(\w+)'}") }}
{% else %}
n-a
{% endif %}
###################################
# Input Boolean
###################################
input_boolean:
# existing room entries, add "_0_" between clean and name
vacuum_clean_0_kitchen:
name: Kitchen
icon: mdi:silverware-fork-knife
# new map entries, add "_1_" before between clean and name
vacuum_clean_1_bedroom:
name: Second Floor Bedroom
icon: mdi:bed-empty
###################################
# Input Text
###################################
input_text:
# existing room entries, add "_0_" between clean and name
vacuum_clean_0_kitchen:
name: Kitchen
initial: !secret vacuum_kitchen
# new map entries, add "_1_" before between clean and name
vacuum_clean_1_bedroom:
name: Second Floor Bedroom
initial: !secret vacuum_second_floor_bedroom
###################################
# Group
###################################
group:
vacuum_rooms_0: #renamed from existing group
# existing room entries, add "_0_" between clean and name
vacuum_rooms_1:
# new map entries, add "_1_" before between clean and name
###################################
# Input Select
###################################
input_select:
vacuum_map_selection:
name: Vacuum Map Selection
options:
- 'Ground'
- 'Level 1'
###################################
# Automation
###################################
automation:
# Initiate Selective Room Clean Map 0
- alias: Vacuum Clean Rooms 0 #renamed from existing, adds extra action for level selection (camera)
trigger:
- platform: event
event_type: initiate_vacuum_clean_0
action:
- service: input_select.select_option
data:
entity_id: input_select.vacuum_map_selection
option: "Ground"
- service: rest_command.vacuum_clean
data_template:
payload: >
{
"ordered": 0,
"pmap_id": "{{ state_attr('sensor.vacuum', 'pmap0_id') | string }}",
"regions": [{% for boolean in states.input_boolean if 'vacuum_clean_0_' in boolean.entity_id and is_state(boolean.entity_id, 'on') %}
{% set room = 'input_text.' + boolean.entity_id.split('.')[1] %} {{ states(room) | string }} {%- if not loop.last %},{%- endif %}
{%- endfor %}
],
"user_pmapv_id": "{{ state_attr('sensor.vacuum', 'pmap0_timestamp') | string }}"
}
- service: input_boolean.turn_off
data:
entity_id: group.vacuum_rooms_0
# Initiate Selective Room Clean Map 1
- alias: Vacuum Clean Rooms 1
trigger:
- platform: event
event_type: initiate_vacuum_clean_1
action:
- service: input_select.select_option
data:
entity_id: input_select.vacuum_map_selection
option: "Level 1"
- service: rest_command.vacuum_clean
data_template:
payload: >
{
"ordered": 0,
"pmap_id": "{{ state_attr('sensor.vacuum', 'pmap1_id') | string }}",
"regions": [{% for boolean in states.input_boolean if 'vacuum_clean_1_' in boolean.entity_id and is_state(boolean.entity_id, 'on') %}
{% set room = 'input_text.' + boolean.entity_id.split('.')[1] %} {{ states(room) | string }} {%- if not loop.last %},{%- endif %}
{%- endfor %}
],
"user_pmapv_id": "{{ state_attr('sensor.vacuum', 'pmap1_timestamp') | string }}"
}
- service: input_boolean.turn_off
data:
entity_id: group.vacuum_rooms_1
###################################
# Camera
###################################
camera:
- platform: generic
still_image_url: !secret vacuum_map_0
content_type: image/png
name: Roomba_Ground
camera:
- platform: generic
still_image_url: !secret vacuum_map_1
content_type: image/png
name: Roomba_Level_1
lovelace.yaml
### VERTICAL STACK CARD ###
cards:
- entity: sensor.vacuum
type: 'custom:roomba-vacuum-card'
- entities:
# existing room entries, add "_0_" between clean and name
- input_boolean.vacuum_clean_0_kitchen
- entity: automation.vacuum_clean_rooms_0
lock:
enabled: |
[[[
if ((states['group.vacuum_rooms_0'].state == "on") && (states['sensor.vacuum'].state == "Ready"))
return false;
return true;
]]]
exemptions: []
name: Clean Rooms
styles:
card:
- height: 50px
tap_action:
action: call-service
service: automation.trigger
service_data:
entity_id: automation.vacuum_clean_rooms_0
type: 'custom:button-card'
head:
label: Ground Floor Cleaning
type: section
type: 'custom:fold-entity-row'
- entities:
# new map entries, add "_1_" before between clean and name
- input_boolean.vacuum_clean_1_bedroom
- entity: automation.vacuum_clean_rooms_1
lock:
enabled: |
[[[
if ((states['group.vacuum_rooms_1'].state == "on") && (states['sensor.vacuum'].state == "Ready"))
return false;
return true;
]]]
exemptions: []
name: Clean Rooms
styles:
card:
- height: 50px
tap_action:
action: call-service
service: automation.trigger
service_data:
entity_id: automation.vacuum_clean_rooms_1
type: 'custom:button-card'
head:
label: Level 1 Floor Cleaning
type: section
type: 'custom:fold-entity-row'
### PICTURE GLANCE CARD >> INSIDE STATE-SWITCH ###
type: custom:state-switch
entity: input_select.coffee_time
states:
Ground:
aspect_ratio: 0%
camera_image: camera.roomba_0
entities: []
type: picture-glance
Level 1:
aspect_ratio: 0%
camera_image: camera.roomba_1
entities: []
type: picture-glance
image.php -> rename to image0.php
create second copy as image1.php and update to reflect your second level