Skip to content

Commit 42add3b

Browse files
authored
Merge pull request #173 from miguelangel-nubla/feature/sip-status-indicator
feat: update call button color based on SIP registration status
2 parents 2f12e0a + 22506ff commit 42add3b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/sip-call-dialog.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ class SIPCallDialog extends LitElement {
195195
videoElement.pause();
196196
}
197197
}
198+
this.updateButtonState();
198199
};
199200

200201
connectedCallback() {
@@ -620,5 +621,24 @@ class SIPCallDialog extends LitElement {
620621
this.setupButton();
621622
});
622623
}
624+
this.updateButtonState();
625+
}
626+
627+
private updateButtonState() {
628+
const homeAssistant = document.getElementsByTagName("home-assistant")[0];
629+
const panel = homeAssistant?.shadowRoot
630+
?.querySelector("home-assistant-main")
631+
?.shadowRoot?.querySelector("ha-panel-lovelace");
632+
633+
const actionItems = panel?.shadowRoot?.querySelector("hui-root")?.shadowRoot?.querySelector(".action-items");
634+
const callButton = actionItems?.querySelector("#sipcore-call-button") as HTMLElement;
635+
636+
if (callButton) {
637+
if (sipCore.registered) {
638+
callButton.style.color = "";
639+
} else {
640+
callButton.style.color = "var(--label-badge-red)";
641+
}
642+
}
623643
}
624644
}

0 commit comments

Comments
 (0)