I know that 21 means kitchen based on a sensor that is exposed already in HA, in my case called “sensor.valetudo_r2_d2_map_segments” that has the following attributes:
'16': Studio
'17': Camera da Letto
'18': Bagno Secondario
'19': Soggiorno
'20': Bagno Principale
'21': Cucina
'23': Cameretta
'24': Corridoio
icon: mdi:vector-selection
friendly_name: Map segments
I tried to use my (poor) knowledge on template and MQTT with the following tentative:
I checked and I still see unknown. I noticed that I posted the wrong topic so I repost below all the data (in case I miss something else in the topic or some other detail):
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.
Sorry, I misunderstood your previous reply. I thought it was working because you thanked me for it.
The value in segment_ids is a list and the first filter gets the first item in the list. So if segment_ids contains ["17", "23"] then the first item is "17".
You can try this version but I have my doubts it will fix the problem:
The doubts I had were about changing the received value, and dictionary keys, from string to int. As expected, it made no difference.
Based on the information you have provided, the template should work. The topic appears to contain a payload, the payload contains data in JSON format, the key named segment_ids contains a list, etc.
As an experiment, try this just to see what it finds in segment_ids.
value_template: >-
{{ value_json.segment_ids | first }}
If it reports nothing then check the Log for any related errors.
I can also send vacuum cleaning multiple rooms, in this case @123 can you help me modify the value template with the join magic so I can see as state for example “Studio, Camera da Letto”?
The TOPPPPPPP would be “Studio AND Camera da Letto” or “Studio, Camera da Letto AND Soggiorno”.