If you're a Home Assistant user and want to create a dashboard with server controls for yourself or even share with a friend... Well you can!
HASS.Agent is a brilliant tool that can be used by Home Assistant to execute commands or retrieve data from sensors on your computer.
Installation
The agent can be found here: https://github.com/LAB02-Research/HASS.Agent
Installation instructions can be seen here:
https://hassagent.readthedocs.io/en/latest/installation-and-configuration-summary
Sensors Configuration
Note, if you've confirmed that your script is running successfully I would recommend adding the parameter -NoLogging so your log file doesn't get added too each time one of these sensors refresh.
Command used that's obscured in the below screenshot is:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File 'C:\Palworld Server\.PalworldServerTools.ps1' -info -NoLogging
For sensors that read text files (eg TodaysTheme.txt) I used this basic command:
get-content 'C:\Palworld Server\TodaysTheme.txt'
Commands
Note: As we are issuing commands I would recommend NOT putting the -NoLogging parameter in.
For starting scheduled tasks:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command "Get-ScheduledTask -TaskName 'Start Palworld Server' | Start-ScheduledTask"
For Issuing RCON commands:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "C:\Palworld Server\.PalworldServerTools.ps1" -Save
The yaml below is what I use on my Lovelace card.
I've added comments to the YAML below but to summarise, the conditions perform the following:
- If the serverhost itself is not powered on, don't show the card at all.
- If the serverhost is powered on but server isn't running only show relevant cards
- If serverhost is powered on and Server is running, show relevant cards.
- If serverhost is powered on, Server is running but needs an udpate, show a an update and restart option.
YAML to configure the card
I will note that I'm not an expert with Home Assistant by any means, so there may be a more efficient way of creating these cards.
Feel free to provide improvement suggestions or show me what you've setup!
type: conditional
conditions: # Is computer checking in. If it's unavailable then it's turned off.
- condition: state
entity: sensor.ExampleHostname_palworld_versionc_usernotificationstate
state_not: unavailable
card:
square: false
type: grid
cards:
- type: entities
entities:
- type: conditional
conditions: # If PalServer-Win64-Test-CMD.exe is not running.
- entity: sensor.ExampleHostname_processactive_palserverwin64testcmd
state_not: '1'
row:
type: text
name: 'PalServer-Win64-Test-CMD:'
text: Not Running :(
icon: mdi:server
- type: conditional
conditions:
- entity: sensor.ExampleHostname_processactive_palserverwin64testcmd
state: '1'
row:
type: text
name: 'PalServer-Win64-Test-CMD:'
text: Running
icon: mdi:server
- type: conditional
conditions: # If PalServer.exe is not running.
- entity: sensor.ExampleHostname_processactive_palserver
state_not: '1'
row:
type: text
name: 'PalServer:'
text: Not Running :(
icon: mdi:server
- type: conditional
conditions: # If PalServer.exe is running.
- entity: sensor.ExampleHostname_processactive_palserver
state: '1'
row:
type: text
name: 'PalServer:'
text: Running
icon: mdi:server
- type: conditional
conditions: # If PalServer-Win64-Test-CMD.exe is running.
- entity: sensor.ExampleHostname_processactive_palserverwin64testcmd
state: '1'
row:
entity: sensor.ExampleHostname_palworld_server_name
icon: mdi:rename
name: Server Name
- type: conditional
conditions: # If PalServer-Win64-Test-CMD.exe is running, show todays theme sensor.
- entity: sensor.ExampleHostname_processactive_palserverwin64testcmd
state: '1'
row:
entity: sensor.ExampleHostname_palworld_todays_theme
icon: mdi:rename
name: Todays Theme
- type: conditional
conditions: # If PalServer-Win64-Test-CMD.exe is running, show version sensor
- entity: sensor.ExampleHostname_processactive_palserverwin64testcmd
state: '1'
row:
entity: sensor.ExampleHostname_palworld_version
icon: mdi:update
name: Version
- type: conditional
conditions: # If PalServer-Win64-Test-CMD.exe is running, show updatecheck status sensor
- entity: sensor.ExampleHostname_processactive_palserverwin64testcmd
state: '1'
row:
entity: sensor.ExampleHostname_palworld_update_available
icon: mdi:update
name: Update Status
- type: conditional
conditions: # If PalServer-Win64-Test-CMD.exe is running, showplayers who online
- entity: sensor.ExampleHostname_processactive_palserverwin64testcmd
state: '1'
row:
entity: sensor.ExampleHostname_palworld_players
name: Players
icon: mdi:bug-play-outline
- type: conditional
conditions: # If PalServer-Win64-Test-CMD.exe is running, show count of players who are online
- entity: sensor.ExampleHostname_processactive_palserverwin64testcmd
state: '1'
row:
entity: sensor.ExampleHostname_palworld_player_count
name: Player Count
icon: mdi:counter
title: PalWorld Server Status
- type: entities
entities:
- type: conditional
conditions: # If PalServer-Win64-Test-CMD.exe is not running and steam CMD is not running (ie, not in the middle of an update), show the start server button,
- entity: sensor.ExampleHostname_processactive_palserverwin64testcmd
state_not: '1'
- entity: sensor.ExampleHostname_processactive_steamcmd
state_not: '1'
row:
entity: button.ExampleHostname_palworldstartserver
name: Start Server
icon: mdi:controller
- type: conditional
conditions: # If there's an update available, server is online and not currently updating, show update button
- entity: sensor.ExampleHostname_palworld_update_available
state: Update Available!
- entity: sensor.ExampleHostname_processactive_palserverwin64testcmd
state: '1'
- entity: sensor.ExampleHostname_processactive_steamcmd
state_not: '1'
row:
entity: button.ExampleHostname_palworldupdateserver
name: Update and Restart Server
icon: mdi:update
- type: conditional
conditions: # If server is running, show this stop button
- entity: sensor.ExampleHostname_processactive_palserverwin64testcmd
state: '1'
row:
entity: button.ExampleHostname_palworldstopservergracefully30
name: Stop Server Gracefully (30 Seconds)
icon: mdi:hand-back-right
- type: conditional
conditions: # If server is running, show this stop button
- entity: sensor.ExampleHostname_processactive_palserverwin64testcmd
state: '1'
row:
entity: button.ExampleHostname_palworldstopservergracefully10
name: Stop Server Gracefully (10 Seconds)
icon: mdi:hand-back-right
- type: conditional
conditions: # If server is running, show this stop now button
- entity: sensor.ExampleHostname_processactive_palserverwin64testcmd
state: '1'
row:
entity: button.ExampleHostname_palworldstopservernow
name: Stop Server NOW
icon: mdi:octagon
- type: conditional
conditions: # If server is running, show this Save button
- entity: sensor.ExampleHostname_processactive_palserverwin64testcmd
state: '1'
row:
entity: button.ExampleHostname_palworldsaveserver
name: Save Server
icon: mdi:content-save
- type: conditional
conditions: # if steamcmd process is active, server must be updating.
- entity: sensor.ExampleHostname_processactive_steamcmd
state: '1'
row:
type: text
name: 'PalServer:'
text: Server Updating
icon: mdi:update
- type: conditional
conditions: # I haven't figured out a way to send broadcasts yet, I'll probably investigate once Palworld devs resolve the bug with server messages not allowing space characters.
- entity: sensor.ExampleHostname_processactive_palserverwin64testcmd
state: '1'
row:
type: text
name: Broadcast message
text: Feature coming soon!
icon: mdi:bullhorn
title: Palworld Server Controls
columns: 1