TECH7Fox / sip-hass-card

A SIP client inside home assistant!
MIT License
189 stars 39 forks source link

Can't connect as a second user #27

Closed felipecrs closed 2 years ago

felipecrs commented 2 years ago

When I connect using my own account, everything works fine, but when I try in my tablet with my "Tablet" account/person, the HA-SIP fails as below:

image ShareX_kMUwRiBPr8

felipecrs commented 2 years ago

I tried to remove all extensions except tablet but the issue remains. Very weird. If you want to debug on my side, I can show on Discord.

TECH7Fox commented 2 years ago

It can't match the logged in user with any user in extensions. Are you sure you're logged in as tablet, and the person entity is correct?

felipecrs commented 2 years ago

Yes, I'm sure!

TECH7Fox commented 2 years ago

This is the code where it defines the logged in user. Could be useful.

${this.config.extensions.map(extension => {
    var stateObj = this.hass.states[extension.entity];
    var isMe = (this.hass.user.id == this.hass.states[extension.person].attributes.user_id);
    if (isMe) { this.user = extension; }
TECH7Fox commented 2 years ago

Maybe a refresh? Because it's a new entity.

felipecrs commented 2 years ago

I tried everything already, lol. Also, I wish I knew how to debug this to check which value is inside of these fields...

felipecrs commented 2 years ago

Ok now I think I found how to debug. One sec.

TECH7Fox commented 2 years ago

Debugging cards is indeed hard. I log the values and rebuild.

felipecrs commented 2 years ago

image

user_id for the person Tablet is undefined. But when it iterates as my user, it's set.

felipecrs commented 2 years ago

Wow, just found the issue:

image

I think. Checking...

felipecrs commented 2 years ago

Yes, worked. I don't know how the hell this happened, but whatever... Thank you for the tip on debugging!

TECH7Fox commented 2 years ago

Nice, never found that problem. I will add it in the wiki.

felipecrs commented 2 years ago

Exactly! That's what I don't understand. But my gut feeling is that I had an user called tablet (that's how I logged in) and then a person called tablet, but they were not linked.

TECH7Fox commented 2 years ago

I was thinking that too. Same name, different ID.