Skip to content

Commit

Permalink
Make sure that shelly rgb devices are turned off when going to black.
Browse files Browse the repository at this point in the history
  • Loading branch information
sknull committed Apr 3, 2024
1 parent f0bf37b commit cdd123b
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ class ShellyColor(
return ShellyColor(deviceId, ipAddress, color.clone(), deviceGain, deviceTurnOn)
}

override fun getTurnOn(): Boolean = deviceTurnOn?:false
override fun getTurnOn(): Boolean {
var turnOn = deviceTurnOn?:false
if ((color.red == 0 && color.green == 0 && color.blue == 0) || deviceGain == 0.0f) {
turnOn = false
}
return turnOn
}

override fun setTurnOn(turnOn: Boolean?) {
this.deviceTurnOn = turnOn
Expand Down Expand Up @@ -50,7 +56,7 @@ class ShellyColor(
rgbColor = color,
gain = deviceGain,
transitionDuration = transitionDuration,
turnOn = deviceTurnOn
turnOn = getTurnOn()
)
}
}
Expand Down

0 comments on commit cdd123b

Please sign in to comment.