brutella / hc

hc is a lightweight framework to develop HomeKit accessories in Go.
Apache License 2.0
1.74k stars 189 forks source link

OnValueRemoteUpdate error #166

Closed pyxiscloud closed 4 years ago

pyxiscloud commented 4 years ago

Hello! I'm think commits on 3 feb 2020 cause some errors With last version of sources, when I'm open Homekit App , hc calls "OnValueRemoteUpdate" method on opening Homekit app. But this method should be called only of user press something on device icon With "git checkout" to 27 jan 2020 it works fine.

pyxiscloud commented 4 years ago

I've checked and found it normally works if remove commit "Allow characteristic to send the value change event multiple times #128" When I edit characteristic.go - add this: `// Ignore when new value is same

if c.Value == value {   
    return  
}

`

all works nice

brutella commented 4 years ago

What value does the OnValueRemoteUpdate callback provide and for which characteristic?

pyxiscloud commented 4 years ago

acc.Lightbulb.On.OnValueRemoteUpdate(func(on bool) { //Send to MQTT bool value }) acc.Lightbulb.Brightness.OnValueRemoteUpdate(func(brightness int) { //Send to MQTT int value })

brutella commented 4 years ago

What values does the arguments on and brightness have, when you open the HomeKit app?

pyxiscloud commented 4 years ago

On = true Brightness = 100

brutella commented 4 years ago

Do you know which values those characteristics have before the Home app is opened?

pyxiscloud commented 4 years ago

yes, before it has:

On = false Brightness = 0

brutella commented 4 years ago

So this means that on startup the Home app automatically turns on the light bulb? This doesn't seem right.

pyxiscloud commented 4 years ago

I'm think this means that when homekit update status, it send request, but package make request to set value. (OnValueRemoteUpdate)

brutella commented 4 years ago

I've fixed that in the ignore-values branch. Please check out this branch and report if it works now.

pyxiscloud commented 4 years ago

Checked ignore-values branch - works fine

brutella commented 4 years ago

Great, I've merged that into master now.