Radioh / ha_twitch_helix

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

[Question] Current Viewers #18

Closed Krojack closed 2 years ago

Krojack commented 2 years ago

I noticed the viewers drops to 0 when the streamer goes offline. Is this due to the Twitch API returns 0 when the streamer is offline or the sensor just defaults to 0 when offline? Reason I ask is if I'm watching someone and they go offline, I noticed the viewer count on the site still shows people.

Radioh commented 2 years ago

Hi,

It's most likely due to the way the stream data is retrieved and handled. If the stream data cannot be retrieved because the stream is offline, then the python script will fall back and set the state to STATE_OFFLINE. The other values should default to None, which I think might be translated to 0.

This is the part that handles the stream data: https://github.com/Radioh/ha_twitch_helix/blob/5f239072807ad427984a2b9bb17338100122f79d/custom_components/twitch_helix/sensor.py#L164