Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion custom_components/webrtc/www/webrtc-camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ class WebRTCCamera extends VideoRTC {

this.streamID = -1;
this.nextStream(false);
if(this.config.entity)
setTimeout(() => this.checkStateChange(), 2000);
}

checkStateChange() {
if (!this.config.state){
this.config.state = this.hass.states[this.config.entity].state
console.log("config state set", this.config.state)
}
const state = this.hass.states[this.config.entity].state
if (this.config.state != state) {
this.config.state = state
if (this.config.state === "idle" || this.config.state === "streaming")
this.nextStream(true);
}
setTimeout(() => this.checkStateChange(), 2000);
}

set hass(hass) {
Expand Down Expand Up @@ -639,4 +655,3 @@ const card = {
// Apple iOS 12 doesn't support `||=`
if (window.customCards) window.customCards.push(card);
else window.customCards = [card];