pantherale0 / ha-nintendoparentalcontrols

Home Assistant integration for Nintendo Switch Parental Controls
MIT License
86 stars 7 forks source link

Add a Remaining Time Sensor #65

Closed seanmccabe closed 9 months ago

seanmccabe commented 10 months ago

Checklist

Is your feature request related to a problem? Please describe.

Would like to be able to check how much playtime there is left.

Describe the solution you'd like

A datetime sensor with the amount of screen time remaining.

In essence. PlayTimeLimit - UsedScreenTime.

Describe alternatives you've considered

Have attempted to create custom sensors, but the current two attributes are different types, and I would prefer to see this information in the one view, under the integration.

Additional context

N/A

pantherale0 commented 9 months ago

Hi,

You can create a template sensor as a "workaround" for this.

I would publish as an attribute to the time entity, however Home Assistant doesn't allow overriding the additional state attributes property in the time platform currently.

{% set split_time = states('time.play_time_limit').split(':') %}
{{ ((split_time[0] | int) * 60)+(split_time[1] | int) - (states('sensor.used_screen_time') | int) }}
pantherale0 commented 9 months ago

Not sure why I closed this now lol.

Just released a beta with a specific sensor for this.

seanmccabe commented 9 months ago

Awesome thank you :)

JokerGermany commented 9 months ago

The nintendo switch shows a remaining time which includes the bedtime alarm. Can you get the data via the api?