Nintendo Switch Home Assistant Integration

Here is another way to extract state_attr.

{% set x = ['sensor.used_screen_time'] | map('state_attr', 'daily') | list %}

{% for i in range(x[0] | length) %}
  {{  x[0][i]['date'] }}
  
  {% for j in range(x[0][i]['playedApps'] | length) %}
    {{  x[0][i]['playedApps'][j]['title'] }}
    {{  x[0][i]['playedApps'][j]['imageUri']['small'] }}
  {% endfor %}
  
  {% for k in range(x[0][i]['devicePlayers'] | length) %}
    {{  x[0][i]['devicePlayers'][k]['imageUri'] }}
    {{  x[0][i]['devicePlayers'][k]['nickname'] }}
    {{  x[0][i]['devicePlayers'][k]['playingTime'] }}
  {% endfor %}
  
{% endfor %}
2 Likes

I got a 500 Internal Server Error
Server got itself in trouble

When I try to add this integration. Any ideas?

Could you describe the steps you are taking before to get to the 500 ?

In the HA UI go to “Configuration” → “Integrations” click “+” and search for “Nintendo Switch Parental Controls”
After selecting it I got the 500 error. It’s this step in the docs:

A will automatically navigate to a middleware site (see middleware.html in this repository) which will redirect you to Nintendo to login.

Can you create an issue on GitHub please and attach your logs? Perhaps the latest HA has changed http views.

Currently I’m not on the latest HA version (2023.11.1) but I will do that when I did the upgrade.

Did you manage to resolve this issue, @BernieV ?
I’ve got the same issue…

  • Core2024.1.3
  • Supervisor2023.12.0
  • Operating System11.4

Downloaded the integration today, so version: 2023.12.5

‘Middleware’-page just says:

thats awesome - playing with this to try and iterate through the array nodes and also match it up to player and applicationId

No I still have this issue. On my system (HA Core 2024.1.2) the middleware page won’t open with an 500 error.

FileNotFoundError: [Errno 2] No such file or directory: ‘/home/homeassistant/custom_components/nintendo_parental/middleware.html’

I checked and this file exist. Still need to make an issue on GitHub.

Make sure popups are enabled as this page will redirect you to Nintendo’s website for authentication.

Where does your configuration.yaml file sit? I’ve not tested this with core, only HAOS.

This is my path of configuration yaml:
/mnt/dietpi_userdata/homeassistant

My system is HA Core on a DietPi OS.

This will be the issue I think.

Even if the file exists, the data is sitting outside of somewhere the integration expects. There might be a future change to move away from the middleware. But for now this setup isn’t supported.

this is now resolved in the latest beta, removed it entirely :slight_smile:

I cannot generate a token on the Nintendo accounts site. It isn’t possible to select the user. When I click on it it does nothing. Any idea?

You need to copy the link thats in the red button for the account you would like to sign in with

1 Like

I get an error from the Nintendo page when trying to retrieve an access token which says, " Linking error This account cannot be linked to Nintendo Switch Parental Controls." I do already have Nintendo parental controls set up on this account. Would that cause this error or does the integration work with a child’s Nintendo account which already has parental controls set up?

1 Like

Yes, I have the same problem & message for the time being.

It shouldn’t be a problem, however if Nintendo is blocking you from signing in, it sounds like the problem is with either the account you are using (it needs to be the same account you would sign into the mobile app with), or something else is going on.

Try signing into the Nintendo Switch Parental Controls app with the same account. If it throws an error I would recommend contacting Nintendo support.

1 Like

I got it working. Was using my kids credentials where I needed to use my own of course. HA is tracking usage now! Thanks for your work.

1 Like