Skip to content

Commit

Permalink
Tweak nightlight update
Browse files Browse the repository at this point in the history
  • Loading branch information
tsightler committed Jan 21, 2023
1 parent 7f8b36e commit 7baafdc
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions devices/chime.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ export default class Chime extends RingPolledDevice {
this.data.volume = volumeState
}

if (nightlightState !== this.data.nightlight_enabled || isPublish) {
this.mqttPublish(this.entity.nightlight_enabled.state_topic, nightlightState ? 'ON' : 'OFF')
this.data.nightlight_enabled = nightlightState
}

if (snoozeState !== this.data.snooze || isPublish) {
this.mqttPublish(this.entity.snooze.state_topic, snoozeState)
this.data.snooze = snoozeState
Expand All @@ -105,6 +100,11 @@ export default class Chime extends RingPolledDevice {
this.data.snooze_minutes_remaining = snoozeMinutesRemaining
}

if (nightlightState !== this.data.nightlight_enabled || isPublish) {
this.mqttPublish(this.entity.nightlight_enabled.state_topic, nightlightState ? 'ON' : 'OFF')
this.data.nightlight_enabled = nightlightState
}

// Local states are published only for publish/republish
if (isPublish) {
this.mqttPublish(this.entity.snooze_minutes.state_topic, this.data.snooze_minutes.toString())
Expand Down Expand Up @@ -238,10 +238,11 @@ export default class Chime extends RingPolledDevice {
"light_sensor_enabled": command === 'on' ? true : false
}
})
this.mqttPublish(this.entity.nightlight_enabled.state_topic, command.toUpperCase())
this.device.requestUpdate()
break;
default:
this.debug('Received invalid command for nightlight enabled mode!')
}
this.device.requestUpdate()
}
}

0 comments on commit 7baafdc

Please sign in to comment.