Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while loading roomba-vacuum-card in lovelace #2

Closed
andreabenini opened this issue Aug 7, 2020 · 1 comment
Closed

Error while loading roomba-vacuum-card in lovelace #2

andreabenini opened this issue Aug 7, 2020 · 1 comment

Comments

@andreabenini
Copy link

Hi Jeremy,
I'm facing a strange problem with your lovelace card and I don't know how to solve it, I guess there's some sort of bug with latest software releases. I'll try to describe my situation:

Device: iRobot 965
HomeAssistant v0.112.4
Host; Raspberry Pi, Python Virtual Env. No docker stuff, "production"/home environment, not a test.
HACS installed and up to date, I usually install software with it
iRobot Roomba Integration from HomeAssistant, latest version

iRobot Roomba integration found three sensors:

(bool) binary_sensor.tiefighter_bin_full
(int) sensor.tiefighter_battery_level
(obj) vacuum.tiefighter  [Docked Status]

tiefighter is the name detected from the device itself, I didn't changed the name, just autodetected from HA.

Then I've installed your Card (with HACS) and I've altered my yaml files

# Roomba Vacuum
- url: /hacsfiles/lovelace-roomba-vacuum-card/roomba-vacuum-card.js
  type: module

in the lovelace: / resources: section
and added the card: custom:roomba-vacuum-card in the interface, as suggested in your MD file here's the basic config:

- type: custom:roomba-vacuum-card
  entity: sensor.vacuum

With this config I get this JS error (from Chrome console)

TypeError: Cannot read property 'attributes' of null (roomba-vacuum-card.js:176)

And this would be reasonable because my entity is named vacuum.tiefighter from the sensors list, this is not a name I've chosen, this is something automatically configured after the pairing (and I cannot change it from the interface without raising "Domain needs to stay the same" error).

So I've made these tests but without success:

# basically wrong because it doesn't exists
entity: sensor.tiefighter
# and from browser console here's the error:
# TypeError: Cannot read property 'attributes' of null (roomba-vacuum-card.js:176)
# basically wrong because it doesn't exists
entity: sensor.vacuum.tiefighter
# and from browser console here's the error:
# TypeError: Cannot read property 'attributes' of null (roomba-vacuum-card.js:176)
# basically wrong because it doesn't exists
entity: tiefighter
# message on screen [card]:
#      Please define a sensor entity.
#      type: 'custom:roomba-vacuum-card'
#      entity: tiefighter
# and from browser console here's the error:
#      card custom:roomba-vacuum-card Error: Please define a sensor entity.
#      at HTMLElement.setConfig (roomba-vacuum-card.js:365)

This "should" be right but I still get errors

entity: vacuum.tiefighter
# message on screen [card]:
#      Please define a sensor entity.
#      type: 'custom:roomba-vacuum-card'
#      entity: tiefighter
# and from browser console here's the error:
#      card custom:roomba-vacuum-card Error: Please define a sensor entity.
#      at HTMLElement.setConfig (roomba-vacuum-card.js:365)

So I guess I've covered a lot of different configs.
After some debugging I've found an hack and where the real bug is (or could be).
First of all I've changed the entity check, in my case: vacuum.tiefighter
so I've changed:

          if (config.entity.split('.')[0] !== 'sensor') throw new Error('Please define a sensor entity.');

to

          if (config.entity.split('.')[0] !== 'vacuum') throw new Error('Please define a sensor entity.');

to avoid that dummy check. after this it works.

This could be the patch:

365c365
<           if (config.entity.split('.')[0] !== 'sensor') throw new Error('Please define a sensor entity.');
---
>           if (config.entity.split('.')[0] !== 'vacuum') throw new Error('Please define a sensor entity.');

What do you think about it ?
(sorry for the long post)

Cheers and thank you for the awesome card

@jeremywillans
Copy link
Owner

jeremywillans commented Sep 7, 2020

I have updated this card to support using a vacuum entity now, however this card isn't intended to be used with the HA native integration as i doubt if the attributes will line up correctly?

If you want full support of this card, i would suggest you checking my other repo - ha-rest980-roomba which takes advantage of the rest980 docker image / HA Addon to provide this functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants