Robot vacuum service notification

Hello all,

I have been trying to create automation which notify me if robot vacuum needs service.
The attributes which I want to follow are:

main_brush_left: 
side_brush_left: 
filter_left:
sensor_dirty_left:

Now, I have been testing with one attribute the functionality but this seems quite strange for me.

In the first automation vacuum attribute is used as condition and it is not working.
In the second automation I created template sensor from this same attribute and then it is working.

Does somebody know do I need to create separate template sensor from each attribute or is there some specific reason why the following code doesn’t work?

I couldn’t get this work:

alias: 'Notification: Robot vacuum needs service'
description: ''
trigger:
  - platform: state
    attribute: status
    entity_id: vacuum.roborock_s5
    from: Returning home
    to: Charging
condition:
  - condition: state
    entity_id: vacuum.roborock_s5
    state: '0'
    attribute: sensor_dirty_left
action:
  - service: notify.mobile_app_iphone_test
    data:
      message: 'Robot vacuum needs attention'
      title: Robot vacuum
mode: single

Created separate template sensor from same attribute:

sensor_dirty_left:
friendly_name: Sensor dirty left
value_template: >
{{ states.vacuum.roborock_s5.attributes.sensor_dirty_left }}

Put this template sensor as condition and then it is working:

alias: 'Notification: Robot vacuum needs service'
description: ''
trigger:
  - platform: state
    attribute: status
    entity_id: vacuum.roborock_s5
    from: Returning home
    to: Charging
condition:
  - condition: state
    entity_id: sensor.sensor_dirty_left
    state: '0'
action:
  - service: notify.mobile_app_iphone_test
    data:
      message: 'Robot vacuum needs attention'
      title: Robot vacuum
mode: single

States are always strings. Attributes can be other types, like numbers. Try this:

condition:
  - condition: state
    entity_id: vacuum.roborock_s5
    attribute: sensor_dirty_left
    state: 0

Thanks for the fast reply!

I tested your code with no success.
Somehow I feel that the automation can’t read the numeric value of vacuum attribute:

I’m not sure why this is not working, same in UI:

image

Edit. It seems that the numeric state is working!

This is working.

condition: numeric_state
entity_id: vacuum.roborock_s5
attribute: sensor_dirty_left
below: '0'