Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lights are not turning on/off when observing device #22

Closed
scheelings opened this issue Mar 18, 2019 · 3 comments
Closed

Lights are not turning on/off when observing device #22

scheelings opened this issue Mar 18, 2019 · 3 comments

Comments

@scheelings
Copy link

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:

  1. button which will turn all lights on:
    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 with tradfriController.GatewayController.GetDeviceObjects
  2. button which will turn the lights on using the group (I only have 1 group with 4 lights):
    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.

@scheelings
Copy link
Author

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.

@dominicusmento
Copy link
Owner

Yes, you are right, library should handle it... I'll check it as soon as I find some time for it.

@dominicusmento dominicusmento changed the title Lights are not turning on/off Lights are not turning on/off when observing device Mar 24, 2019
@dominicusmento
Copy link
Owner

This is now fixed by rewriting the observable part

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants