Radioh / ha_twitch_helix

Home Assistant custom component to integrate with Twitch helix api.
MIT License
21 stars 2 forks source link

How do I obtain more values #4

Closed NicciZar closed 2 years ago

NicciZar commented 2 years ago

Hi,

I want to get the same values (or more) like the default twitch integration with Hassio.

There are some things missing..

This is how I obtain the values

{{states.sensor.twitchstreamername.attributes}}

and I'm getting

{
  "subscribed": false,
  "subscription_is_gifted": false,
  "following": true,
  "following_since": "2016-08-15T14:48:02Z",
  "friendly_name": "twitchstreamername",
  "icon": "mdi:twitch",
  "entity_picture": "https://static-cdn.jtvnw.net/jtv_user_pictures/1-profile_image-300x300.jpg"
}

before that (using the old sensor)

{
  "followers": XXX,
  "views": XXX,
  "friendly_name": "twitchstrreamername",
  "icon": "mdi:twitch",
  "entity_picture": "https://static-cdn.jtvnw.net/jtv_user_pictures/1-profile_image-300x300.jpg"
}

You see that there are some things missing (followers and views)

Is it still possible to obtain these with the new helix api and this integration?

Radioh commented 2 years ago

Hi! I didn't port those values over to begin with since I didn't need them. :) I've added them now, it took an extra API call to get the total follows count value, but I wouldn't be too worried about hitting the Twitch API rate limit unless you have a ton of streamer sensors, so I think it's fine.

I've added the following attributes: followers - the total follower count viewers - the current viewer count of the stream

I've created a new release where you can check it out - V.0.3.0

NicciZar commented 2 years ago

Hey thank you so much for the adding those.

I've updated now to V.0.3.0 and its working.

The old views attribute is the total view count of the streamer. (You can see the number when visiting the stream dashboard) image

Is that something that is also possible to get?


Oh and maybe you can make it possible to let the user decide what Attributes they need (checkbox inside a config menu) so we can configure ourselfs how the API calls are going to be used.

Radioh commented 2 years ago

Alright, I've added "channel_views" as an attribute showing that, it's data already available when fetching the streamer info, so it's not a problem. You can update to the v.0.3.1 to see it.

It sounds like a good optimization to be able to 'opt out' of API calls if you are hitting the Twitch API rate limit. If it turns out this is really an issue for the normal user it might be worth looking in to.

NicciZar commented 2 years ago

Great. I've updated and It'ss working :)

Thanks for the fast responses / updates

Radioh commented 2 years ago

Awesome, I'm closing this issue.

Radioh commented 2 years ago

@NicciZar - I had some time and added an api_opt_outs list to the config, so we can opt out of Twitch API calls if we don't need all info.

NicciZar commented 2 years ago

Oh thats great! Thank you