Fix light sensor control (#1065)

This commit is contained in:
Daniel Shokouhi 2020-10-16 11:55:11 -07:00 committed by GitHub
parent 366b02ed15
commit 16625e9614
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -44,7 +44,7 @@ class LightControl {
RangeTemplate(
entity.entityId,
0f,
255f,
100f,
(entity.attributes["brightness"] as? Number)
?.toFloat()
?.div(255f)
@ -74,12 +74,13 @@ class LightControl {
true
}
is FloatAction -> {
val convertBrightness = action.newValue.div(100).times(255)
integrationRepository.callService(
action.templateId.split(".")[0],
"turn_on",
hashMapOf(
"entity_id" to action.templateId,
"brightness" to action.newValue.toInt()
"brightness" to convertBrightness.toInt()
)
)
true