LordBoos / discord_game

Home Assistant custom component to get online and game status of Discord users
MIT License
57 stars 9 forks source link

Attributes as sensor values #18

Closed bradsour closed 4 years ago

bradsour commented 4 years ago

I'd like to do some filtering based on the attributes values. Like knowing when the game field is not empty so that I can flash my lights or turn them a certain color when a certain friend is playing a game. Is it possible to make it so that the attributes show up as sensors? Unfortunately at this time I don't know enough about what that would take for setup to get done.

LordBoos commented 4 years ago

You can use template sensors in HA configuration.

    sensors:
      sensor_name_1:
        value_template: '{{ states.sensor.discord_username_###.attributes.game}}'
bradsour commented 4 years ago

I tried for hours to reference the game attribute in a filter entity only to have to give up. I could not figure our how to filter it out when there was not a game populated. It worked fine if there was a game being played, but that is not what I'm trying to accomplish. What is the value when it's empty? I was able to get the developer tools to show it as None, but setting that as the value didn't work.

On Sun, Aug 2, 2020, 7:31 AM Jakub Kolář notifications@github.com wrote:

Closed #18 https://github.com/LordBoos/discord_game/issues/18.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/LordBoos/discord_game/issues/18#event-3613265839, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYJM2ITC75SBSHMF5QY67TR6VFBLANCNFSM4PSKQUMQ .

bradsour commented 4 years ago

Setting up a template sensor for whatever reason has allowed me to correctly compare against None and do what I want. Thanks!

On Sun, Aug 2, 2020 at 10:05 AM Brad Sweet sweet.brad@gmail.com wrote:

I tried for hours to reference the game attribute in a filter entity only to have to give up. I could not figure our how to filter it out when there was not a game populated. It worked fine if there was a game being played, but that is not what I'm trying to accomplish. What is the value when it's empty? I was able to get the developer tools to show it as None, but setting that as the value didn't work.

On Sun, Aug 2, 2020, 7:31 AM Jakub Kolář notifications@github.com wrote:

Closed #18 https://github.com/LordBoos/discord_game/issues/18.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/LordBoos/discord_game/issues/18#event-3613265839, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYJM2ITC75SBSHMF5QY67TR6VFBLANCNFSM4PSKQUMQ .