{"action":"created","issue":{"url":"https://api.github.com/repos/SoCo/SoCo/issues/275","labels_url":"https://api.github.com/repos/SoCo/SoCo/issues/275/labels{/name}","comments_url":"https://api.github.com/repos/SoCo/SoCo/issues/275/comments","events_url":"https://api.github.com/repos/SoCo/SoCo/issues/275/events","html_url":"https://github.com/SoCo/SoCo/pull/275","id":54341448,"number":275,"title":"Event timestamp","user":{"login":"rrowe629","id":2278218,"avatar_url":"https://avatars.githubusercontent.com/u/2278218?v=3","gravatar_id":"","url":"https://api.github.com/users/rrowe629","html_url":"https://github.com/rrowe629","followers_url":"https://api.github.com/users/rrowe629/followers","following_url":"https://api.github.com/users/rrowe629/following{/other_user}","gists_url":"https://api.github.com/users/rrowe629/gists{/gist_id}","starred_url":"https://api.github.com/users/rrowe629/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rrowe629/subscriptions","organizations_url":"https://api.github.com/users/rrowe629/orgs","repos_url":"https://api.github.com/users/rrowe629/repos","events_url":"https://api.github.com/users/rrowe629/events{/privacy}","received_events_url":"https://api.github.com/users/rrowe629/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-01-14T16:19:39Z","updated_at":"2015-01-14T19:36:55Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/SoCo/SoCo/pulls/275","html_url":"https://github.com/SoCo/SoCo/pull/275","diff_url":"https://github.com/SoCo/SoCo/pull/275.diff","patch_url":"https://github.com/SoCo/SoCo/pull/275.patch"},"body":"I have a Play:1 that I would like to be able to control without the controller app - I don't always have my phone on me. I've built a python app that does just that, but had to make a slight change to <b>events.py</b> to accomplish it. Basically, the Play:1 behaves normally in all respects except when a \"trigger\" event occurs. I've defined the trigger to be a volume change in one direction, followed by a change in the opposite direction - within two seconds. Outside of that window, the volume buttons behave normally. Once the trigger event occurs, I use SoCo and Google TTS to report the local temperature and then speak the names of the favorite radio stations. The user uses the \"+\" button to select and the \"-\" button to cancel.\r\n\r\nThe change I had to make was to add a timestamp to events. This allows me to determine if the volume change events are within the two second window or not. Here's the change I made to <b>events.py</b> - it appears to be as simple as adding a timestamp to the dictionary for the event as follows:\r\n\r\n```python\r\n         # overridden, and will not allow direct setting of attributes\r\n         self.__dict__['sid'] = sid\r\n         self.__dict__['seq'] = seq\r\n+        self.__dict__['timestamp'] = time.time()    #Local Time the Event object was created\r\n         self.__dict__['service'] = service\r\n         self.__dict__['variables'] = variables if variables is not None else {}\r\n```\r\nI've been using this for a while now and it works just fine. I'm effectively able to control the Play:1 like a desktop radio and, when I want to, join it to the other Sonos system in my house. There may be a better way to do this - but I believe it would be useful to include a timestamp on events in any case.\r\n\r\nP.S. New to GitHub - all three commits essentially do the same thing."},"comment":{"url":"https://api.github.com/repos/SoCo/SoCo/issues/comments/69977039","html_url":"https://github.com/SoCo/SoCo/pull/275#issuecomment-69977039","issue_url":"https://api.github.com/repos/SoCo/SoCo/issues/275","id":69977039,"user":{"login":"rrowe629","id":2278218,"avatar_url":"https://avatars.githubusercontent.com/u/2278218?v=3","gravatar_id":"","url":"https://api.github.com/users/rrowe629","html_url":"https://github.com/rrowe629","followers_url":"https://api.github.com/users/rrowe629/followers","following_url":"https://api.github.com/users/rrowe629/following{/other_user}","gists_url":"https://api.github.com/users/rrowe629/gists{/gist_id}","starred_url":"https://api.github.com/users/rrowe629/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rrowe629/subscriptions","organizations_url":"https://api.github.com/users/rrowe629/orgs","repos_url":"https://api.github.com/users/rrowe629/repos","events_url":"https://api.github.com/users/rrowe629/events{/privacy}","received_events_url":"https://api.github.com/users/rrowe629/received_events","type":"User","site_admin":false},"created_at":"2015-01-14T19:36:55Z","updated_at":"2015-01-14T19:36:55Z","body":"Thanks for the tips. Lawrence was kind enough to fold this into #273 for me.\r\n\r\nFrom:  Dave Beckett <notifications@github.com>\r\nReply-To:  SoCo/SoCo\r\n<reply+0022c34a8eab8a60c1a2a82dd611c4255bcd7c4b74f280ac92cf0000000110ce68259\r\n2a169ce033d2f48@reply.github.com>\r\nDate:  Wednesday, January 14, 2015 at 11:23 AM\r\nTo:  SoCo/SoCo <SoCo@noreply.github.com>\r\nCc:  Roger Rowe <rw.rowe@cox.net>\r\nSubject:  Re: [SoCo] Event timestamp (#275)\r\n\r\n\r\nFYI the test failure reports code style problems on the line you changed:\r\nsoco/events.py:181:1: E101 indentation contains mixed spaces and tabs\r\nsoco/events.py:181:1: W191 indentation contains tabs\r\nsoco/events.py:181:46: E262 inline comment should start with '# '\r\nsoco/events.py:181:80: E501 line too long (85 > 79 characters)\r\nsoco/events.py:182:1: E101 indentation contains mixed spaces and tabs\r\nSo if you replace the tab with spaces and fix the comment (remove it?) you\r\nshould be get a pass.\r\n\r\n‹\r\nReply to this email directly or view it on GitHub\r\n<https://github.com/SoCo/SoCo/pull/275#issuecomment-69954086> .\r\n\r\n \r\n   \r\n "}}