jeremywillans / ha-rest980-roomba

HA iRobot Roomba Configuration using rest980
MIT License
211 stars 42 forks source link

Error in Template #56

Closed f4ntec closed 1 year ago

f4ntec commented 1 year ago

Hi all!

First I would like to thank for your good work :-) I'm still implementing this project into my homeassistant OS I'm at the step of translating the labels, messages and so on. But it seems that I made a mistake and I already spent hours of searching.

Because I'm not an expert in yaml and homeassistant I would like to request your help.

I receive some errors with the templates

The error message from the logs

Logger: homeassistant.helpers.template_entity
Source: helpers/template_entity.py:329
First occurred: 10:14:42 (12 occurrences)
Last logged: 10:44:03

TemplateError('UndefinedError: 'None' has no attribute 'notReady'') while processing template 'Template("{% if state_attr('sensor.rest980', 'cleanMissionStatus')['cycle'] == 'none' and state_attr('sensor.rest980', 'cleanMissionStatus')['notReady'] == 39 %} Pending {% elif state_attr('sensor.rest980', 'cleanMissionStatus')['notReady'] > 0 %} Not Ready {% else %} {% set mapper = { 'clean' : 'Reinigen', 'quick' : 'Reinigen', 'spot' : 'Spot', 'evac' : 'Leer', 'dock' : 'Station', 'train' : 'Lernen', 'none' : 'Bereit' } %} {% set state = state_attr('sensor.rest980', 'cleanMissionStatus')['cycle'] %} {{ mapper[state] if state in mapper else state }} {% endif %}")' for attribute '_attr_native_value' in entity 'sensor.vacuum'
TemplateError('TypeError: argument of type 'NoneType' is not iterable') while processing template 'Template("{% if state_attr('sensor.rest980', 'softwareVer') is defined %} {% set version = state_attr('sensor.rest980', 'softwareVer') %} {% if '+' in version %} {{ version.split('+')[1] }} {% else %} {{ version }} {% endif %} {% else %} n-a {% endif %}")' for attribute 'software_ver' in entity 'sensor.vacuum'
TemplateError('UndefinedError: 'None' has no attribute 'notReady'') while processing template 'Template("{% if state_attr('sensor.rest980', 'cleanMissionStatus')['cycle'] == 'none' and state_attr('sensor.rest980', 'cleanMissionStatus')['notReady'] == 39 %} Wartet {% elif state_attr('sensor.rest980', 'cleanMissionStatus')['notReady'] > 0 %} Nicht bereit {% else %} {% set mapper = { 'clean' : 'Reinigen', 'quick' : 'Reinigen', 'spot' : 'Spot', 'evac' : 'Leer', 'dock' : 'Station', 'train' : 'Lernen', 'none' : 'Bereit' } %} {% set state = state_attr('sensor.rest980', 'cleanMissionStatus')['cycle'] %} {{ mapper[state] if state in mapper else state }} {% endif %}")' for attribute '_attr_native_value' in entity 'sensor.vacuum'

Attached you can find the part of my yaml. Hopefully you can help :-)

vacuum.yaml TEMPLATE.txt

jeremywillans commented 1 year ago

does this happen consistently? or just during startup? sometimes if the template sensors kick off before the rest980 has returned results, this is kind of expected.

f4ntec commented 1 year ago

Hi!

thanks for your reply. After my post, I didn't spend so much time in this case and wanted to wait for reply. Now I researched the logs again and you're right! These logs are only on startup. So maybe as you write, it's about the start of rest980.

Am Mo., 1. Mai 2023 um 03:30 Uhr schrieb Jeremy Willans < @.***>:

does this happen consistently? or just during startup? sometimes if the template sensors kick off before the rest980 has returned results, this is kind of expected.

— Reply to this email directly, view it on GitHub https://github.com/jeremywillans/ha-rest980-roomba/issues/56#issuecomment-1529232419, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3QMBMFIEN4XDCPFCJBEXM3XD4G2JANCNFSM6AAAAAAWGMPYLQ . You are receiving this because you authored the thread.Message ID: @.***>

jeremywillans commented 1 year ago

Thanks, ill try and take a look at some stage to improve these sensors to prevent these start up errors. if you are keen please feel free to submit a PR!