#Help with template sensor for registering blade timer from Landroid robot mower

1 messages · Page 1 of 1 (latest)

jaunty basalt
#

Hi, i have the Landroid Cloud and the Landroid Card working perfectly. I realized the metrics reported were not being saved in my influx db so I made a custom sensor. I got it working for a root attribute battery_level but I can't seem to get the data from nested attributes such as blades.total_on.
Here is my configuration: ```template:

  • sensor:
    • name: my_landroid Battery
      unique_id: mower_battery
      state: "{{ state_attr('vacuum.my_landroid','battery_level') | int(0) }}"
      device_class: battery
      unit_of_measurement: "%"

    • name: my_landroid State with Blade time
      unique_id: mower_state_blades_total_on
      state: "{{ state_attr('vacuum.my_landroid', 'blades.total_on') }}"```

idle anvil
#

Probably you want
"{{ state_attr('vacuum.my_landroid', 'blades').total_on }}"

#

However, you might want to add an availability template to avoid errors when the attribute is not available

jaunty basalt
#

Thanks a lot, i tried that but the value still shows up as Unknown (when this sensor is added to a simple card)

#

Are the attribute names case sensitive?
I tried state: "{{ state_attr('vacuum.my_landroid', 'Blades').total_on'}}"
And now the card does not show any value, where it used to show Unknown before

jaunty basalt
#

It was case sensitive and needed the conversion. This works now: state: "{{ state_attr('vacuum.my_landroid', 'blades')['total_on'] | int(0) }}"
Thanks a lot for the help. @idle anvil

#

👍

idle anvil
#

and adding | int(0) doesn't avoid errors here, it will error out when it tries to take the value for total_on when the state_attr() function returns none because the attribute is not available

jaunty basalt
#

the extra ' was en error when typing.
.total_on | int(0) seems to work fine too.
I'm currently looking at how to use avalabity_template. It's quite new to me:(

idle anvil
#

it will als long as the data is available

#

but you will get errors in your log after a reboot for example

#
    - name: my_landroid State with Blade time
      unique_id: mower_state_blades_total_on
      state: "{{ state_attr('vacuum.my_landroid', 'blades').total_on }}"
      availability: "{{ state_attr('vacuum.my_landroid', 'blades') is not none }}"
#

this should help to prevent those