I’ve created a custom sensor that hooks into the Destiny 2 API and reports the subclass of your active / most recently played character. I use it to update the lighting in my man cave based on the state of the sensor.
It’s available over on my GitHub:
And here’s a demo of it in action:
Note: My first bash at a custom component for HA so any feedback is welcomed!
Cool, digging into the api a bit… Would be neat to have a character sensor with attributes like, Power/Light, Emblem, current subclass, maybe even level progression stats.
I’m using the PS4 component. I use it to only update the light colour from Destiny2 sensor when Destiny2 is running.
I can probably add more to this sensor. I’m throwing away loads of data that I get from the Destiny2 API. I’ve not bothered yet because it does everything I need it to for my automations. If there’s anything specific you’re after I can look at adding it.
Can you help me with the configuration of the app at bungie’s website? I installed the sensor, configured everything like the read.me and used the api key from the app, but I always get the status as unknown.
You’ll have to give me a few more details before I can be of any help. Are you getting any errors in the logs? Can you make a request to the API via curl qith your key?
Can you explain the application setup for those of us that may not be as savvy with redirects? Not really sure how to set that part up on the Bungie site.
@danrspencer or others, wanted to check back in to see if you could help me out? I’m not quite sure what I need to input for the redirect on the application page. I’m assuming that I need some sort of webpage? I’d like to set this up the easiest way possible so any guidance would be awesome.
Awesome, Thanks! I was able to get the api key to work. However, the sensor is showing up as unknown (I did click the authorization link and approved access. It then took me to my home assistant page).
2017-10-13 16:58:31 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.destiny2 fails
Traceback (most recent call last):
File "/home/homeassistant/.homeassistant/custom_components/sensor/destiny2.py", line 113, in update
characters = response.json()['Response']['characters']['data']
KeyError: 'Response'
you mentioned you were using the wrong membership ID, could you elaborate? What i have in the sensor above is what i see on the bungie site when i click view profile.
You’re making the same mistake as me. On you profile page click on your specific platform(psn, xbox), when that page opens the values of membership type/id will change, because they are platform specific.
Not sure why I was seeing something different than what you posted. I also worked tonight on the automations for changing the light colors based on the sensors and all is now working like the video above.