Valheim game server status sensors

Hello everyone,

I have recently started playing the game Valheim and hosting a dedicated server to host for some friends i play with. I would like be able to create sensors in home assistant to let me know information about the server and who or how many people are connected etc. I am running this docker container.

In the readme it has a section for a status webserver and writes updates to /status.json. Could we create sensors that scrape that file for information or what would be the best way to injest that information? Anyone have any insight or ideas?

Much appreciated

Yes, we can! You can, too using a REST sensor.

1 Like

Ok so i’ve got some updates. On the container side I enabled STATUS_HTTP and PUBLIC_SERVER. Then i exposed port 80:80 to the host:container and at the point i could browse to http://server.ip/status.json and get values.

I initially tried the rest integration to get a bunch of attributes/sensors at once. but could never get it to go with an error of setup not defined? so i switched to the restful sensor option and created the 4 that i wanted.

##Valheim Server
- platform: rest
  resource: http://192.168.30.83/status.json
  name: active users
  value_template: "{{ value_json.player_count }}"
- platform: rest
  resource: http://192.168.30.83/status.json
  name: last status update
  value_template: "{{ value_json.last_status_update }}"
- platform: rest
  resource: http://192.168.30.83/status.json
  name: error
  value_template: "{{ value_json.error }}"
- platform: rest
  resource: http://192.168.30.83/status.json
  name: players
  value_template: "{{ value_json.players }}"

Im only hoping the players one will work as the json syntax changes. How else could i manage that info? it would be cool to have an auto-entites card show who is online. Below is the JSON output im using.

{
  "last_status_update": "2021-03-07T21:42:16.076662+00:00",
  "error": null,
  "server_name": "My Docker based server",
  "server_type": "d",
  "platform": "l",
  "player_count": 1,
  "password_protected": true,
  "vac_enabled": false,
  "keywords": "[email protected]",
  "players": [
    {
      "name": "",
      "score": 0,
      "duration": 7.000421047210693
    }
  ]
}
1 Like

I know this is old, but did you ever get it working? @Chandler_K_Sharp

1 Like

Hey, yes i do here is my current setup. Enjoy!

valheim card

##Valheim Server
- platform: rest
  resource: http://192.168.30.83/status.json
  name: active users
  value_template: "{{ value_json.player_count }}"
- platform: rest
  resource: http://192.168.30.83/status.json
  name: last status update
  value_template: "{{ value_json.last_status_update }}"
- platform: rest
  resource: http://192.168.30.83/status.json
  name: error
  value_template: "{{ value_json.error }}"
- platform: rest
  resource: http://192.168.30.83/status.json
  name: players
  value_template: "{{ value_json.players }}"
- platform: rest
  resource: http://192.168.30.83/status.json
  name: version
  value_template: "{{ value_json.keywords }}"

Thank you!

Hi again,
I tried duplicating your sensors but they are not working for me. I can not even see the sensors created in history tab. I can successfully browse to my json file and see it. It is on port 2480 though. So my url looks like http://IPADDRESS:2480/status.json. Would that cause problems?
Any help is appreciated.

hmmm. not that im aware of. a couple questions tho… You say you are able to hit the web browser json page and browse it?

did you set:

STATUS_HTTP_PORT=2480
SERVER_PUBLIC=true

And your sensor.yaml looks like:

- platform: rest
  resource: http://ipaddress:2480/status.json
  name: active users

I also look for new entities in the devices/entities pages. But im not sure it get created unless it finds data on the json correctly.

Hello,
I got it working by putting that url behind my reverse proxy. For some reason it would not connect to the address when it was http. Putting it through the proxy with a valid SSL cert resolved the issue. I also put my rest sensors in a different format that is a little cleaner. I’ll include it here for reference.
Thank you for your help!

# REST for valheim test
rest:
  - resource: !secret valheim_status_url
    sensor:
      - name: "Valheim Player Count"
        value_template: "{{ value_json.player_count }}"
      - name: "Valheim last status update"
        value_template: "{{ value_json.last_status_update }}"
      - name: "Valheim error"
        value_template: "{{ value_json.error }}"
      - name: "Valheim players list"
        value_template: "{{ value_json.players }}"
      - name: "Valheim version"
        value_template: "{{ value_json.keywords }}"
1 Like