{"action":"created","issue":{"url":"https://api.github.com/repos/nfarina/homebridge/issues/493","labels_url":"https://api.github.com/repos/nfarina/homebridge/issues/493/labels{/name}","comments_url":"https://api.github.com/repos/nfarina/homebridge/issues/493/comments","events_url":"https://api.github.com/repos/nfarina/homebridge/issues/493/events","html_url":"https://github.com/nfarina/homebridge/issues/493","id":129539902,"number":493,"title":"Characteristic setValue not reporting back to iOS device","user":{"login":"DerEisvogel","id":5556143,"avatar_url":"https://avatars.githubusercontent.com/u/5556143?v=3","gravatar_id":"","url":"https://api.github.com/users/DerEisvogel","html_url":"https://github.com/DerEisvogel","followers_url":"https://api.github.com/users/DerEisvogel/followers","following_url":"https://api.github.com/users/DerEisvogel/following{/other_user}","gists_url":"https://api.github.com/users/DerEisvogel/gists{/gist_id}","starred_url":"https://api.github.com/users/DerEisvogel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DerEisvogel/subscriptions","organizations_url":"https://api.github.com/users/DerEisvogel/orgs","repos_url":"https://api.github.com/users/DerEisvogel/repos","events_url":"https://api.github.com/users/DerEisvogel/events{/privacy}","received_events_url":"https://api.github.com/users/DerEisvogel/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-01-28T18:42:15Z","updated_at":"2016-01-28T19:49:17Z","closed_at":"2016-01-28T19:49:17Z","body":"Hey everyone,\r\n\r\nI have been working with homebridge for more than a month now. Great work! So far everything is working fine for me, apart from problems arising due to my custom plugins for my home.\r\n\r\nExperimenting with different services, characteristics and various different approaches on how to map some mechanisms of my home to HomeKit I have come across one minor issue.\r\n\r\nSometimes I wish to just implement a simple Push Button, for example a mute button. Pressing the button once enables mute, pressing it again disables mute. First I tried to use a Stateless Programmable Switches, but those cannot be set from iOS but are rather meant to be set by the devices themselves. I need this to work the other way round. I am now using a switch. Thing is, that there is no On or Off with the mute function, therefore I'd like it to be just a push button. When I turn on the switch the mute function is triggered and a few milliseconds later I reset the switch from within homebridge.\r\n\r\nNow, when listening to the 'set' event for 'Characteristic.On' it is required to call the callback function for the value to be actually set. The documentation states, that the value can be changed directly which is working. The 'change' event is triggered, when I change the value to something other the old or the newly set value, and the value is being reported back to HomeKit. But in my case the initial value of the switch is 'false'. When I turn on the switch from iOS it is set to 'true'. In the 'set' listener I would like to be able to call the callback function with 'false'. But when doing that the new value is not being reported back to HomeKit, because the callback only compares the value to the old value.\r\n\r\nWouldn't it be wiser to compare the value from the listener to the newly set value rather than the old cached value?\r\n\r\nBasically change the following lines from (Characteristic.js, ll. 168-169):\r\n`        // emit a change event if necessary\r\n        if (oldValue !== actualNewValue)\r\n          this.emit('change', { oldValue:oldValue, newValue:actualNewValue, context:context });`\r\nto:\r\n`        // emit a change event if necessary\r\n        if (newValue !== actualNewValue)\r\n          this.emit('change', { oldValue:oldValue, newValue:actualNewValue, context:context });`\r\n\r\nOr maybe another event is needed here, as the value is not really being changed, but needs to be reported back to HomeKit.\r\n\r\nBest Regards,\r\nDer Eisvogel"},"comment":{"url":"https://api.github.com/repos/nfarina/homebridge/issues/comments/176372849","html_url":"https://github.com/nfarina/homebridge/issues/493#issuecomment-176372849","issue_url":"https://api.github.com/repos/nfarina/homebridge/issues/493","id":176372849,"user":{"login":"KhaosT","id":1725664,"avatar_url":"https://avatars.githubusercontent.com/u/1725664?v=3","gravatar_id":"","url":"https://api.github.com/users/KhaosT","html_url":"https://github.com/KhaosT","followers_url":"https://api.github.com/users/KhaosT/followers","following_url":"https://api.github.com/users/KhaosT/following{/other_user}","gists_url":"https://api.github.com/users/KhaosT/gists{/gist_id}","starred_url":"https://api.github.com/users/KhaosT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KhaosT/subscriptions","organizations_url":"https://api.github.com/users/KhaosT/orgs","repos_url":"https://api.github.com/users/KhaosT/repos","events_url":"https://api.github.com/users/KhaosT/events{/privacy}","received_events_url":"https://api.github.com/users/KhaosT/received_events","type":"User","site_admin":false},"created_at":"2016-01-28T19:49:17Z","updated_at":"2016-01-28T19:49:17Z","body":"It depends on what you want :)\r\nSince you already have a solution, I'll close this issue."}}