Best Nintendo Switch/Xbox One sensor

What would be the best/most accurate/fastest sensor to monitor the power state of a Nintendo Switch and an Xbox One? I just need to monitor power state not actually turn them on or off.

The easiest way is probably to plug them both into a smart power plug that tells you power usage (I use TP-110’s for this). I’m using an XBox One add-on, but it (or maybe more accurately the REST server it uses) doesn’t seem that reliable, and if I use it to turn the XBox on/off I have to restart the add-on to get it to continue working.

I use the device tracker function of my router to check if my PS4 is on. If there is already a set-up for the device tracker in your system, you should only add another IP and your done.

I use this for automating my TV and receiver when the PS4 comes on. The time frame here is mostly within 5 seconds, maximum 12 seconds.

1 Like

If you have a spare ethernet adapter and want to detect if the Switch is connected to the dock, then connect the adapter to the dock and use the ping component to see if the IP address of the LAN adapter is responding.

1 Like

Thanks for all the responses. My aim is to replicate what infineghost did. Only with a sleeping Switch and a sleeping Xbox. I also have a harmony hub. But that side of things is taken care of.

What you mean with “sleeping” ?

Both in sleep mode.

Yeah maybe i’m an idiot, but i still don’t get what you mean with sleep mode with a Xbox switch?.

But if you understand yourself than its oke :slight_smile:

A Nintendo Switch in sleep mode and an Xbox One in sleep mode.

Did you ever work this out for Switch? My ethernet adapter seems to respond to ping even when the Switch is asleep, and I don’t have a spare smartplug to monitor its power so I’m looking for other options.

2 Likes

There might be a way to make this work out for the Switch though but it might be very dirty and not that elegant as far as I can believe…it would be very reliable though.

Recently I recognized the green LED of the Nintendo Switch and I was reading about LDRs:
German Site, you do not need to read it - just look at the Picture to get an Idea:

You could make a very solid bayesian sensor with that LAN-Adapter and that green LED, because the LED only keeps glowing when the nintendo switch is unlocked/working.

He means Standby or power saving mode. Just like a smart phone the Nintendo Switch is in a sleep mode / locked / standby state.

Hmm, interesting. I’d looked for a way to sense LEDs using a camera stream, but couldn’t find anything easy enough for me. This solution looks pretty interesting! Will have to have a closer look.

For a minute I thought SysDVR would let me to set up motion detection on the Switch feed to detect activity, but Motion can’t connect to the RTSP feed (I think it’s an issue with the buffer settings but haven’t figured it out), and processing a 720p feed over network just for an on/off state seems like a lot of overkill.

I’m finally a little closer to a solution thanks to NXBT. It lets you emulate a Switch controller via webui/command line, so installing NXBT on Debian and running nxbt macro -c "0.1s" -r > /dev/null 2>&1 && echo success || echo fail will give echo/fail depending on whether it can connect to the Switch. Unfortunately I can’t just install NXBT inside the Home Assistant container, and while there are a few options to get Home Assistant talking to NXBT over LAN, they all seem like some pretty involved setup.

I’m thinking of trying to get some kind of script running on the NXBT host to run this script at a set interval and publish the output to an MQTT topic, but have a bunch of other stuff to fix before getting further stuck into that.

2 Likes

I tried running my Switch through a Sonoff S31 smartplug and here were my findings. As expected, changes in Switch state are reflected in power consumption but specific state cannot be determined from power consumption. For example, an 8W measurement could mean the Switch is charging, active play, or idle (sitting at the game home menu screen). Also, this was a short test so there may be uncaught cases where the Switch does something different based on other factors.

My only use case is to turn off the TV when I’ve finished my gaming session, since the Switch doesn’t do that even with CEC enabled. If my graph values hold true, it should be trivial to create an automation which triggers the TV off when the power drops from anything >4W to 4W. I would also want to add a condition to check that the TV is on the Switch HDMI input to prevent accidental shutdown while watching something else.

Nintendo published system update v13.0 today which adds a new setting “Maintain Internet Connection in Sleep Mode”. Prior versions hard-coded this to “on”, meaning the Switch would always respond to ping regardless of state. Setting this to “off” means we can now use the HA ping binary sensor to track Nintendo Switch state. I’ve just enabled this and will check how it goes over the next few days.

Update: The solution to use the new setting along with Ping to determine Switch state works, with a few caveats.

1. The Switch seems to wake the network periodically while asleep. I was using a 10s scan interval and each “connect” was 10s, meaning the network wake is less than 10s as the next ping did not respond. Any automation should use the “for” condition greater than the scan interval to avoid false positives (ie. the binary sensor should be “on” for 2 ping cycles to ignore these false-positives)

2. Upon putting the Switch to sleep after playing there is a network bounce on → off → on → off again for 1 interval cycle. The same automation “for” condition greater than the scan interval would prevent re-triggering.
Screen Shot 2021-09-16 at 1.29.30 PM

1 Like

Far out, that’s an awesome update/discovery. I’m subbed to this thread but somehow missed the notifications… @The-May’s post inspired me to start learning soldering and ESPHome, and I just came came today to share v2 of my Wemo LDR build. I know the LDR connection is badly finished but I didn’t have the right sized heatshrink or a 3D printer for some tidy housing… And now it’s all useless since ping works as expected -_-

Imgur
Imgur
Imgur

2 Likes

Is this still working good for you? I like the idea

I needed to know the switch on/off status for check my sleeping time.
My solution is as follows

  1. TV’s HDMI check
    When I turn on your Samsung TV, it automatically switches to the registered HDMI1 and turns on Game Mode.
    So if the TV is on with HDMI1, I can assume the switch is on. Even if your TV doesn’t automatically change the HDMI, it’s probably fixed anyway, so if you have a corresponding HDMI sensor, you can implement it.
  - platform: template
    sensors:
      nintendo_sensor:
        friendly_name: "Nintendo Switch Sensor"
        icon_template: mdi:nintendo-switch
        value_template: >- 
          {% if is_state('media_player.samsungtv', 'on') and is_state('sensor.tv_title', 'NintendoSwitch')%}
            on
          {% else %}
            off
          {% endif %}
  1. Ping Check
    I use both handheld and docked mode. I’ve heard that ping doesn’t give an accurate check because it also responds in sleep mode, but I tried it and it worked fine. Nintendo has a setting to disable network behavior in sleep mode. Check this setting.
binary_sensor:
  - platform: ping
    host: 192.168.0.13
    name: "Nintendo Switch Ping"
    count: 2
    scan_interval: 30 

As a side note, I struggled with this sensor not being added when I registered this setting in my config. When I checked, it was added but set to invisible. (I don’t know why it was behaving this way.) That said, if you do set this config, look for the sensor in Developer Tools>Status.

Note: I don’t know if this setting affects network games (games that require a stable network, like Splatoon).

And I mixed two config.

  - platform: template
    sensors:
      nintendo_sensor:
        friendly_name: "Nintendo Switch Sensor"
        icon_template: mdi:nintendo-switch
        value_template: >- 
          {% if is_state('media_player.samsungtv', 'on') and is_state('sensor.tv_title', 'NintendoSwitch')%}
            on
          {% elif is_state('binary_sensor.nintendo_switch_ping', 'on')%}
            on 
          {% else %}
            off
          {% endif %}

I hope this information is helpful to someone else.

Though I’s share how I turn off my TV when the Switch is set to sleep or off using my “SamsungTV Smart” integration.

Using the integration, I get information about the TV’s current picture_mode. Which is Game when the Nintendo Switch is on. This attribute changes to Adaptive Picture when the Nintendo Switch goes to sleep or is turned off.

The automation triggers within 1-10 seconds and turns off the TV based on a couple of conditions ensuring I have not changed HDMI input to watch something else.

  - id: 'Turn off TV when Switch is offline'
    alias: 'Turn off TV when Switch is offline'
    trigger:
      - platform: state
        entity_id: media_player.samsung_the_frame_65_tizen
        attribute: picture_mode
        from: 'Game'
        to: 'Adaptive Picture'
    condition:
      - "{{ is_state('media_player.samsung_the_frame_65_tizen', 'on') }}"
      - "{{ is_state_attr('media_player.samsung_the_frame_65_tizen', 'source', 'HDMI2') }}"
    action:
      - service: media_player.turn_off
        data: {}
        target:
          entity_id: media_player.samsung_the_frame_65_tizen

This will probably work for most gaming consoles. And can also be used to detect if you have turned on said console as well.

The key takeaway here is using the status of the TV instead of using ping.