Closed scheelings closed 5 years ago
I was able to create a workaround by creating a 2nd instance of the TradfriController which I use for observing the devices. It works but in my opinion the library should handle this.
Yes, you are right, library should handle it... I'll check it as soon as I find some time for it.
This is now fixed by rewriting the observable part
Hi,
I have created a UI app similar to the old GUI application which works with the .Net Standard library. I have added 2 buttons:
private async void button1_Click(object sender, EventArgs e) { foreach (var device in _devices) { if (device.DeviceType == DeviceType.Light) await _tradfriController.DeviceController.SetLight(device, true); } }
_devices is my List instance with all devices, retrieved withtradfriController.GatewayController.GetDeviceObjects
await _tradfriController.GroupController.SetLight(_group, true);
Button 1 only turns the last light (of 4 lights) on (or off). Button 2 does not turn a light on/off at all.
So, I tried to turn the lights on/off individually. I have tried to call await
_tradfriController.DeviceController.SetLight(xx, true);
for all 4 light device ID's, but it does not matter which ID I pass to the SetLight method, it always turns on/off the last light.I think this is really strange behavior, so I analyzed my code a bit more and I also added the ObserveDevice method calls on the DeviceController property of the tradfriController instance. When I removed these method call, all lights and groups are correctly turned on/off. So there is some strange behavior with the ObserveDevice method.
Does anyone have an idea what the problem is?
Thanks, Danny
P.s. I am using a copy of the Tradfri project, where I set the CoapClient property of the TradfriController to public, so I am able to use this property for the ObserveDevice method call.