{"action":"created","issue":{"url":"https://api.github.com/repos/pdf/golifx/issues/1","labels_url":"https://api.github.com/repos/pdf/golifx/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/pdf/golifx/issues/1/comments","events_url":"https://api.github.com/repos/pdf/golifx/issues/1/events","html_url":"https://github.com/pdf/golifx/pull/1","id":111400669,"number":1,"title":"Use power state from event instead of making network request when republishing power update event","user":{"login":"brutella","id":125641,"avatar_url":"https://avatars.githubusercontent.com/u/125641?v=3","gravatar_id":"","url":"https://api.github.com/users/brutella","html_url":"https://github.com/brutella","followers_url":"https://api.github.com/users/brutella/followers","following_url":"https://api.github.com/users/brutella/following{/other_user}","gists_url":"https://api.github.com/users/brutella/gists{/gist_id}","starred_url":"https://api.github.com/users/brutella/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brutella/subscriptions","organizations_url":"https://api.github.com/users/brutella/orgs","repos_url":"https://api.github.com/users/brutella/repos","events_url":"https://api.github.com/users/brutella/events{/privacy}","received_events_url":"https://api.github.com/users/brutella/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-14T13:41:40Z","updated_at":"2015-10-15T07:10:46Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/pdf/golifx/pulls/1","html_url":"https://github.com/pdf/golifx/pull/1","diff_url":"https://github.com/pdf/golifx/pull/1.diff","patch_url":"https://github.com/pdf/golifx/pull/1.patch"},"body":"This fixes an issue where setting the power state of a light to `false` results in reseting power to `true` again.\r\n\r\nSo this happened.\r\n\r\n1. The physical device has the power state set to `true`.\r\n2. Set the power to `false` using `Device::SetPower(false)` which sends an network request to the device accordingly.\r\n3. Inside `Group::addDeviceSubscription()` the event `common.EventUpdatePower` is handled where `Device::GetPower()` is called. \r\n4. Inside `Device::GetPower()` the power state is fetched using a network request. But at this point the physical device didn't finish processing the previously made power state change request and therefore power is `true`. The power state is set using `Device::SetStatePower(true)` and an event is emitted.\r\n\r\nThe fix is to not request the power state but to use the value stored in the `EventUpdatePower.Power` field."},"comment":{"url":"https://api.github.com/repos/pdf/golifx/issues/comments/148300652","html_url":"https://github.com/pdf/golifx/pull/1#issuecomment-148300652","issue_url":"https://api.github.com/repos/pdf/golifx/issues/1","id":148300652,"user":{"login":"brutella","id":125641,"avatar_url":"https://avatars.githubusercontent.com/u/125641?v=3","gravatar_id":"","url":"https://api.github.com/users/brutella","html_url":"https://github.com/brutella","followers_url":"https://api.github.com/users/brutella/followers","following_url":"https://api.github.com/users/brutella/following{/other_user}","gists_url":"https://api.github.com/users/brutella/gists{/gist_id}","starred_url":"https://api.github.com/users/brutella/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brutella/subscriptions","organizations_url":"https://api.github.com/users/brutella/orgs","repos_url":"https://api.github.com/users/brutella/repos","events_url":"https://api.github.com/users/brutella/events{/privacy}","received_events_url":"https://api.github.com/users/brutella/received_events","type":"User","site_admin":false},"created_at":"2015-10-15T07:10:46Z","updated_at":"2015-10-15T07:10:46Z","body":"I'm a little irritated by the implementation of `Device::GetPower()`.\r\nIs it true that the method only makes a network request if the power state is `false`? If yes, why?"}}