Minecraft Server Sensor

I recently made a sensor to show the amount of online players and the ping to a Minecraft server.

You can download it here: https://github.com/GreenTurtwig/MinecraftServer-HA

If you have any questions just ask. :smiley_cat:

1 Like

Interesting, I’ve been fiddling around with the same type of sensor.
How would you consider extending it or do you see it as feature complete?

I could possibly add the players online (their usernames), the motd and the server icon since they can be queryed from the server. But those weren’t really useful for me at the time. So I didn’t add them. :cat:

I run a white-listed server for my kids and their friends. The usernames would be great so I could see who is online with them. Or even better yet, to get a notification when a certain player logs in that I am keeping an eye on because they may be a bit of a trouble maker, or notifications if one of my kids logs in when they aren’t supposed to be online. LOL

I’ll see if I can add that (if possible) when I have time. :cat:
Seems a pretty cool thing to have. :smile_cat:

Thanks!! I agree. A list of online players will be great!!!

1 Like

Nice - going to give this a try :smiley:

hmm I just get this

Aug 7 14:06:34 hass hass[4953]: ERROR:homeassistant.loader:Unable to find component sensor.minecraft
Aug 7 14:06:34 hass hass[4953]: ERROR:homeassistant.bootstrap:Unable to find platform sensor.minecraft

And it broke all my zwave stuff. Have removed it all for now.

@GreenTurtwig would you mind if I forked, improved the sensor, and eventually submitted it to HASS?

Sure, go ahead. :cat:
But it’s not really a needed component for HA in my opinion, which is why I never improved or submitted it, just left it here. But you can do what you want. :smiley_cat:

Maybe not for you! I’ve been trying to create automations around when my Minecraft server unexpectedly goes offline, or if someone joins the server. There are some public JSON API’s out there, but I have found they are not very reliable. Best to run a small script like this locally to query the server.

Forked and added online users last night.
(only tested with one user so far, so I’m not sure if it parses correctly when more than one user is online.)
Edit: It does parse correctly
You will need to enable querying in your server config file.

May improve later.

1 Like

That’s great! :smile_cat:

Now submit it as a component =)

1 Like

I might once I clean it up a bit more.
Currently it prevents Home Assistant from starting if the server doesn’t have querying enabled.

Added a couple more attributes to display the Message of the Day and build version.

I plan on adding a version checker for automation when the server version is out of date, and will look into adding remote management for starting, stopping and restarting of servers.

This sensor is great! I have a private server for my kids running on a raspi and they are constantly logging in to see if one of their cousins is on. Does anyone have an example of a notification they have created using this sensor when a specific user is logged in? I am thinking either simple push notification or having a light turn on. I am relatively new to HASS and haven’t done anything yet with automations.

Thanks!

hmm … This is great work. Is it possible to change the state to just a number though? This way we could use it as a numeric trigger pretty easily.

Having max players as a attribute would be a good addition also since it rarely changes.