Minecraft Server Help

fixed it, found the pink command in the sensor.py and just commented out - it no longer pings (i dont want this anyways) and the state only changes once on new users or less users !!! nailed it !!

thank you so much !!

Crap. I was editing my post rather than replying. See above.

Glad you got it sorted.

ha ha, thank you so much for the help.

one final thing ā€¦ is it possible to show the users connected in my message ? might be pushing my luck here :slight_smile:

Sure, this sensor should do it:

sensor:
- platform: template
  sensors:
    minecraft_server_users:
      friendly_name: Minecraft Server Users
      entity_id: sensor.finley_dads_minecraft_server
      value_template: "{{ states('sensor.finley_dads_minecraft_server')|replace('/2', '') }}"

And change your automation to:

- id: '1567778733250'
  alias: Minecraft Server Activity
  trigger:
  - entity_id: sensor.finley_dads_minecraft_server
    platform: state
  condition: []
  action:
  - data_template: #### <---- NOTEICE THIS
      message: "There are {{ states('sensor.minecraft_server_users') }} users
        connected to our Minecraft Server"
    service: notify.ios_steves_iphone

Or you could skip the sensor and do it directly in the automation template:

- id: '1567778733250'
  alias: Minecraft Server Activity
  trigger:
  - entity_id: sensor.finley_dads_minecraft_server
    platform: state
  condition: []
  action:
  - data_template: #### <---- NOTEICE THIS
      message: "There are {{ states('sensor.minecraft_server_users')|replace('/2', '') }} users
        connected to our Minecraft Server"
    service: notify.ios_steves_iphone

Iā€™m not familiar with that minecraft integration, but you can access state attributes like so:

state_attr('sensor.finley_dads_minecraft_server', 'users_online')

where 'users_online' is the name of the attribute.

Except users online is empty looking at the screenshot posted earlier.

Ah, thatā€™s no good thenā€¦

Iā€™d assume the ā€œUsers Onlineā€ would populate names of users connected or their Xbox IDā€™s, likely in a list or CSV format.

1 Like

yes it populates

so what do i change this to, to get the user names ?

{{ states(ā€˜sensor.finley_dads_minecraft_serverā€™) }}

can i test in developer - template ?

Users Online: Stove_Assemble
MOTD: Finley & Dads Minecraft Server
Version: 1.14.4
friendly_name: Finley & Dads Minecraft Server
icon: mdi:minecraft

if i look in states

I donā€™t see connected usernames listed as attributes of your sensor (just total number). So It can not be done unless there is a setting you can change in your server to report this data.

message: "There are {{ states('sensor.minecraft_server_users')|replace('/2', '') }} users
        connected to our Minecraft Server. They are: {{ state_attr('sensor.minecraft_server_users', 'Users Online') }}"

Perfect - you are a legend !!! thanks !!!

YESSSS. I love it. LOL.

1 Like

does this work with 99.2 Home Assistant ? getting entity not available

I donā€™t have a minecraft server so I donā€™t know. Check the release notes for breaking changes related to the sensor.

Can you tell me which part you commented out? Iā€™m having the same issue at the moment

Thanks for this guide.

In case somebody wants to display the currently connected players in a card, you can use this one (credits to Bishma ):

See an example of the card configuration:

type: 'custom:list-item-card'
title: Minecraft Players
entity: sensor.minecraft_server_players_online
attribute: players_list
icon: 'mdi:minecraft'
emptyValue: []

This cards will autorefresh once the players are logged in/out (itā€™s not immediate tough).