Minecraft Server Sensor

It should not. It’s possible - but it should not.

Also, because you’re on a LAN between the Home Assistant and the Minecraft server, it’s not your firewall/router, so were not gonna look further into that bit.

You can try using putty or a similar telnet client to connect to the server 192.168.X.X port 25566 and see if there’s response.

getting entity not available error, any ideas or can you point me in the right direction ?

Update for sensor.finleys_modded_creative_server fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 261, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 441, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/minecraft/sensor.py", line 55, in update
    status = self._mcserver.lookup(self._server).status()
  File "/usr/local/lib/python3.7/site-packages/mcstatus/server.py", line 49, in status
    connection = TCPSocketConnection((self.host, self.port))
  File "/usr/local/lib/python3.7/site-packages/mcstatus/protocol/connection.py", line 129, in __init__
    self.socket = socket.create_connection(addr, timeout=timeout)
  File "/usr/local/lib/python3.7/socket.py", line 727, in create_connection
    raise err
  File "/usr/local/lib/python3.7/socket.py", line 716, in create_connection
    sock.connect(sa)
socket.timeout: timed out

Any ideas ?

From the socket timeout error, there is some sort of issue communicating with your server.

Some basic troubleshooting stuff but might help

Is the Minecraft Server on the same network? Make sure that the port is open.
If you aren’t sure try using telnet to connect to the Minecraft port from your HA box, it should give you a “Connected” message, if it can’t reach it then there’s a networking issue that needs to be resolved.

Also there’s been a few forks that haven’t been pulled back into the main repository.
https://github.com/olenoerby/MinecraftServer-HA worked for me with the most recent version.

Maybe double heck your minecraft server config that query=true

When I enable this in configuration.yaml and restart my Hass.io on Pi (0.103.4), it hangs and never finishes booting. I can’t tell what’s wrong, but I’m also fairly new to HA. Is there a startup log that I can look at to see what it doesn’t like and see if I can fix it?

  • edit - I can still ssh and samba to it, it just won’t load the HA interface. But I don’t know what log to look at.

  • edit - SSH’d in, saw the command “hassio homeassistant logs” and saw that the fork I was using was really messed up. Changed back to the one right above this post, and am now getting the socket timeout errors from a previous post. Status checkers like https://mcsrvstat.us/ show that it’s up and shows me all of its stats… Troubleshooting that, will update…

I see everywhere that “query=true” should be set. But according to https://minecraft.gamepedia.com/Server.properties#Java_Edition_3, should it be “enable-query=true”?

Hi - did you get anywhere with this? The HA interface doesn’t load in 0.105, and if I try the suggested https://github.com/olenoerby/MinecraftServer-HA it doesn’t even load, complains about the config/port not responding. Did you figure out the query config - I think that would have just been a typo?
This - https://github.com/sondregronas/MinecraftServer-HA - worked great previously, though seemed to crash the UI after a few hours too, not sure if it was when the server was unavailable as I have it shutting down at night.

No, I eventually took it out. I never got it resolved.

I wonder if its possible to add minecraft time of day to the entities for this? I’ve looked over the python code and sadly its beyond my understanding… but if we knew the time of day in minecraft we could do cool things with lights in the real world

Here we go:

There’s an official Minecraft server sensor https://www.home-assistant.io/integrations/minecraft_server/

1 Like

What have a missed?
I can ping, telnet to minecraft server. Nothing in firewall logs.
minecraft1

2 Likes

Hi Everyone!

I’m trying to use the integration with an external IP address. So it looks something like:

Host: 213.99.22.105:25565 (This is a random IP address ofcourse)

In this case the integration gives an error: IP address is invalid (MAC address could not be determined).

I’ve tried it with my internal IP address and i can connect to the server. But externally with an IP address doesn’t seem to work for the integration. My Minecraft client can connect to the host.

Does someone know what to try out next?

2 Likes

Ran into same issue, and came here searching for solution too

Keep in mind this is only for the java version, not bedrock.

There is an (unnecessary?) check on the mac address. If your server isn’t running in the same LAN segment it will fail.
When using a hostname, it won’t do the mac check and works.

I don’t know enough of github/programming to do a pr, but maybe someone else could try?
Github comment

1 Like

I’m running java version

1 Like

Hi!
The MAC address check is still there but you can fix this with a workaround in Linux.
Associate the address of your server to an IP in the /etc/hosts file of your server (or if you also have a pihole in your net, add a DNS entry for your server IP) and it should work correctly!

Hi all. FYI: The MAC check for the Minecraft Server integration was removed in HA core 2023.10. And in 2023.11 support for Bedrock Edition servers was added.

I’m curious if anyone has any bedrock and/or java sensors that display what the latest version is? Not the version my server is running, but the latest one available. Seems to me this should be doable with a Rest or command_line sensor, but I’m having a hard time determining what resource I could query for the current latest version.

I wrote a shell_command service that runs upgrades on my Turnkey servers, would love it if I could get a notification that an update is available.

Answered my own question today, using LinuxGameServer’s source, specifically update_mc.sh (Line 42) and update_mcb.sh (Line 56)

I’ve created two one liners based on their code, resulting in these command_line sensors:

command_line:
  - sensor:
      name: Minecraft Bedrock Latest Version
      command: 'curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -Ls -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.${randomint}.212 Safari/537.36" "https://www.minecraft.net/en-us/download/server/bedrock/" | grep -o "https://minecraft.azureedge.net/bin-linux/[^\"]*" | sed "s/.*\///" | grep -Eo "[.0-9]+[0-9]"'
      icon: mdi:update

  - sensor:
      name: Minecraft Java Latest Version
      command: curl -s "https://launchermeta.mojang.com/mc/game/version_manifest.json" | jq -r '.latest.release'
      icon: mdi:update

image

From there it’s just a simple matter of writing an automation that triggers when this sensor is different from the current values provided by the installation to flag when an update is available.