{"action":"created","issue":{"url":"https://api.github.com/repos/RPi-Distro/python-gpiozero/issues/478","repository_url":"https://api.github.com/repos/RPi-Distro/python-gpiozero","labels_url":"https://api.github.com/repos/RPi-Distro/python-gpiozero/issues/478/labels{/name}","comments_url":"https://api.github.com/repos/RPi-Distro/python-gpiozero/issues/478/comments","events_url":"https://api.github.com/repos/RPi-Distro/python-gpiozero/issues/478/events","html_url":"https://github.com/RPi-Distro/python-gpiozero/issues/478","id":180531035,"number":478,"title":"color attribute for LED class","user":{"login":"thijstriemstra","id":305679,"avatar_url":"https://avatars.githubusercontent.com/u/305679?v=3","gravatar_id":"","url":"https://api.github.com/users/thijstriemstra","html_url":"https://github.com/thijstriemstra","followers_url":"https://api.github.com/users/thijstriemstra/followers","following_url":"https://api.github.com/users/thijstriemstra/following{/other_user}","gists_url":"https://api.github.com/users/thijstriemstra/gists{/gist_id}","starred_url":"https://api.github.com/users/thijstriemstra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thijstriemstra/subscriptions","organizations_url":"https://api.github.com/users/thijstriemstra/orgs","repos_url":"https://api.github.com/users/thijstriemstra/repos","events_url":"https://api.github.com/users/thijstriemstra/events{/privacy}","received_events_url":"https://api.github.com/users/thijstriemstra/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/RPi-Distro/python-gpiozero/labels/suggestion","name":"suggestion","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2016-10-02T19:52:07Z","updated_at":"2016-10-03T12:09:11Z","closed_at":null,"body":"I'm porting my app to python-gpiozero. My old `Pin` class is similar but also accepts a title and color, e.g.:\r\n\r\n```python\r\nRED = QColor(237, 33, 54)\r\nGREEN = QColor(83, 237, 89)\r\n\r\nled1_pin = Pin(15, 'System Error', RED)\r\nled2_pin = Pin(19, 'System OK', GREEN)\r\n```\r\n\r\nNow I see that the `LED` or `PWMLed` doesn't have a label or color attribute. But every LED has a color right? Not being able to add a label is not as big of a deal, but having a color would be nice. Do you think this is useful to have or should I subclass LED and add these attributes myself?"},"comment":{"url":"https://api.github.com/repos/RPi-Distro/python-gpiozero/issues/comments/251090334","html_url":"https://github.com/RPi-Distro/python-gpiozero/issues/478#issuecomment-251090334","issue_url":"https://api.github.com/repos/RPi-Distro/python-gpiozero/issues/478","id":251090334,"user":{"login":"lurch","id":476186,"avatar_url":"https://avatars.githubusercontent.com/u/476186?v=3","gravatar_id":"","url":"https://api.github.com/users/lurch","html_url":"https://github.com/lurch","followers_url":"https://api.github.com/users/lurch/followers","following_url":"https://api.github.com/users/lurch/following{/other_user}","gists_url":"https://api.github.com/users/lurch/gists{/gist_id}","starred_url":"https://api.github.com/users/lurch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lurch/subscriptions","organizations_url":"https://api.github.com/users/lurch/orgs","repos_url":"https://api.github.com/users/lurch/repos","events_url":"https://api.github.com/users/lurch/events{/privacy}","received_events_url":"https://api.github.com/users/lurch/received_events","type":"User","site_admin":false},"created_at":"2016-10-03T12:09:11Z","updated_at":"2016-10-03T12:09:11Z","body":"> So the bigger question is do we want user-defined metadata associated with device objects?\r\n\r\nCompletely off-the-wall suggestion, but what if we added a `user_data` dict to the base `Device` class, which people were free to do whatever they wanted with? (And which the GpioZero code would never touch)\r\nSo @thijstriemstra could do:\r\n```python\r\nRED = QColor(237, 33, 54)\r\nGREEN = QColor(83, 237, 89)\r\n\r\nled1 = LED(15)\r\nled1.user_data['label'] = 'System Error'\r\nled1.user_data['color'] = RED\r\n\r\nled2 = LED(19)\r\nled2.user_data['label'] = 'System OK'\r\nled2.user_data['color'] = GREEN\r\n```\r\n\r\nNo idea if that's *actually* a good idea or not though. As @bennuttall points out, you could easily 'invert' this and have:\r\n```python\r\nRED = QColor(237, 33, 54)\r\nGREEN = QColor(83, 237, 89)\r\n\r\nled1 = {\r\n    'led': LED(15),\r\n    'label: 'System Error',\r\n    'color': RED\r\n}\r\n\r\nled2 = {\r\n    'led': LED(19),\r\n    'label': 'System OK',\r\n    'color': GREEN\r\n}\r\n```\r\n"}}
{"actor":{"display_login":"lurch"}}