Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New script: ps5-mqtt #1198

Merged
merged 21 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
62b9e84
Add ps5-mqtt script
liecno Jan 3, 2025
447357f
Update location of currently installed version for ps5-mqtt script
liecno Jan 3, 2025
fc0647e
Add version number to update information for ps5-mqtt script
liecno Jan 3, 2025
69473f4
Reformat dependencies when installing ps5-mqtt
liecno Jan 3, 2025
720d170
Remove superfluous information messages when installing ps5-mqtt
liecno Jan 3, 2025
e82d88f
Remove superfluous comment from ps5-mqtt install script
liecno Jan 3, 2025
44c9b4e
Improve wording for the config location for the ps5-mqtt script
liecno Jan 3, 2025
664f28a
Remove superfluous empty lines in ps5-mqtt install script
liecno Jan 3, 2025
399484f
Merge branch 'community-scripts:main' into main
liecno Jan 3, 2025
15e8858
Reorder code structure for ps5-mqtt script
liecno Jan 4, 2025
e2b8e9a
Remove superfluous .service string vom systemctl calls in ps5-mqtt sc…
liecno Jan 4, 2025
23008bf
Refactor handling with folders in the ps5-mqtt script
liecno Jan 4, 2025
d990541
Reorder code in ps5-mqtt script
liecno Jan 4, 2025
9a961b9
Reorder the code for getting release version in ps5-mqtt script
liecno Jan 4, 2025
8365af6
Update ps5-mqtt-install.sh
michelroegl-brunner Jan 9, 2025
480e9d3
Update ps5-mqtt-install.sh
michelroegl-brunner Jan 9, 2025
ee71f16
Update ps5-mqtt.json
michelroegl-brunner Jan 9, 2025
040f276
Update
michelroegl-brunner Jan 9, 2025
6e3eea5
Update ps5-mqtt-install.sh
michelroegl-brunner Jan 9, 2025
916a045
Fix npm
michelroegl-brunner Jan 9, 2025
b4df014
Fix Date in json
michelroegl-brunner Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions ct/ps5-mqtt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env bash
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2025 community-scripts ORG
# Author: liecno
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/FunkeyFlo/ps5-mqtt/

# App Default Values
APP="PS5-MQTT"
var_tags="smarthome;automation"
var_cpu="1"
var_ram="256"
michelroegl-brunner marked this conversation as resolved.
Show resolved Hide resolved
var_disk="3"
var_os="debian"
var_version="12"
var_unprivileged="1"

# App Output & Base Settings
header_info "$APP"
base_settings

# Core
variables
color
catch_errors

function update_script() {
if [[ ! -d /opt/ps5-mqtt ]]; then
msg_error "No ${APP} installation found!"
exit
fi

RELEASE=$(curl -s https://api.github.com/repos/FunkeyFlo/ps5-mqtt/releases/latest | jq -r '.tag_name')

header_info
check_container_storage
check_container_resources

liecno marked this conversation as resolved.
Show resolved Hide resolved
if [[ "${RELEASE}" != "$(cat /opt/ps5-mqtt/cs_release)" ]]; then
msg_info "Stopping service"
systemctl stop ps5-mqtt.service
liecno marked this conversation as resolved.
Show resolved Hide resolved
msg_ok "Stopped service"

msg_info "Updating PS5-MQTT"
michelroegl-brunner marked this conversation as resolved.
Show resolved Hide resolved
cd ~
michelroegl-brunner marked this conversation as resolved.
Show resolved Hide resolved
wget -q https://github.com/FunkeyFlo/ps5-mqtt/archive/refs/tags/${RELEASE}.tar.gz
tar zxf ${RELEASE}.tar.gz
rm -rf /opt/ps5-mqtt
michelroegl-brunner marked this conversation as resolved.
Show resolved Hide resolved
mv ps5-mqtt-* /opt/ps5-mqtt
rm ${RELEASE}.tar.gz
echo ${RELEASE} > /opt/ps5-mqtt/cs_release
liecno marked this conversation as resolved.
Show resolved Hide resolved
msg_ok "Updated PS5-MQTT"

msg_info "Building new PS5-MQTT version"
cd /opt/ps5-mqtt/ps5-mqtt/
michelroegl-brunner marked this conversation as resolved.
Show resolved Hide resolved
npm install &>/dev/null
npm run build &>/dev/null
msg_ok "Built new PS5-MQTT version"

msg_info "Starting service"
systemctl start ps5-mqtt.service
liecno marked this conversation as resolved.
Show resolved Hide resolved
msg_ok "Started service"

else
msg_ok "No update required. ${APP} is already at ${RELEASE}"
michelroegl-brunner marked this conversation as resolved.
Show resolved Hide resolved
MickLesk marked this conversation as resolved.
Show resolved Hide resolved
fi

exit
}

start
build_container
description

msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8645${CL}"
111 changes: 111 additions & 0 deletions install/ps5-mqtt-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/usr/bin/env bash

# Copyright (c) 2021-2025 community-scripts ORG
# Author: liecno
# License: MIT
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE

# source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
liecno marked this conversation as resolved.
Show resolved Hide resolved
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os

msg_info "Installing Dependencies"
$STD apt-get install -y curl jq
liecno marked this conversation as resolved.
Show resolved Hide resolved

msg_info "Installing NodeJS and NPM"
$STD apt-get install -y nodejs npm
msg_ok "Installed NodeJS and NPM"

msg_info "Installing playactor"
liecno marked this conversation as resolved.
Show resolved Hide resolved
$STD npm i -g playactor
msg_ok "Installed playactor"

liecno marked this conversation as resolved.
Show resolved Hide resolved
msg_ok "Installed Dependencies"

RELEASE=$(curl -s https://api.github.com/repos/FunkeyFlo/ps5-mqtt/releases/latest | jq -r '.tag_name')
michelroegl-brunner marked this conversation as resolved.
Show resolved Hide resolved
liecno marked this conversation as resolved.
Show resolved Hide resolved

msg_info "Installing PS5-MQTT"
wget -q https://github.com/FunkeyFlo/ps5-mqtt/archive/refs/tags/${RELEASE}.tar.gz

tar zxf ${RELEASE}.tar.gz

mv ps5-mqtt-* /opt/ps5-mqtt
echo ${RELEASE} > /opt/ps5-mqtt/cs_release
liecno marked this conversation as resolved.
Show resolved Hide resolved

cd /opt/ps5-mqtt/ps5-mqtt/
michelroegl-brunner marked this conversation as resolved.
Show resolved Hide resolved
$STD npm install
$STD npm run build
msg_ok "Installed PS5-MQTT"

msg_info "Creating Configuration"
liecno marked this conversation as resolved.
Show resolved Hide resolved

mkdir -p /root/.config/ps5-mqtt
mkdir -p /root/.config/playactor
cat <<EOF > /root/.config/ps5-mqtt/config.json
michelroegl-brunner marked this conversation as resolved.
Show resolved Hide resolved
{
"mqtt": {
"host": "",
"port": "",
"user": "",
"pass": "",
"discovery_topic": "homeassistant"
},

"device_check_interval": 5000,
"device_discovery_interval": 60000,
"device_discovery_broadcast_address": "",

"include_ps4_devices": false,

"psn_accounts": [
{
"username": "",
"npsso":""
}
],

"account_check_interval": 5000,

"credentialsStoragePath": "/root/.config/ps5-mqtt/credentials.json",
"frontendPort": "8645"
}
EOF
msg_ok "Created Configuration"

msg_info "Creating Service"
liecno marked this conversation as resolved.
Show resolved Hide resolved
cat <<EOF >/etc/systemd/system/ps5-mqtt.service
[Unit]
Description=PS5-MQTT Daemon
After=syslog.target network.target

[Service]
WorkingDirectory=/opt/ps5-mqtt/ps5-mqtt
Environment="CONFIG_PATH=/root/.config/ps5-mqtt/config.json"
michelroegl-brunner marked this conversation as resolved.
Show resolved Hide resolved
Environment="DEBUG='@ha:ps5:*'"
Restart=always
RestartSec=5
Type=simple
ExecStart=node server/dist/index.js
KillMode=process
SyslogIdentifier=ps5-mqtt

[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now ps5-mqtt
msg_ok "Created Service"

motd_ssh
customize

msg_info "Cleaning up"
cd /
liecno marked this conversation as resolved.
Show resolved Hide resolved
$STD apt-get -y autoremove
$STD apt-get -y autoclean
rm ${RELEASE}.tar.gz
msg_ok "Cleaned"
39 changes: 39 additions & 0 deletions json/ps5-mqtt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "PS5-MQTT",
"slug": "ps5-mqtt",
"categories": [
3
],
"date_created": "2025-01-03",
"type": "ct",
"updateable": true,
"privileged": false,
"interface_port": 8645,
"documentation": null,
"website": "https://github.com/FunkeyFlo/",
"logo": "https://github.com/FunkeyFlo/ps5-mqtt/blob/main/add-ons/ps5-mqtt/logo.png?raw=true",
"description": "Integrate your Sony Playstation 5 devices with Home Assistant using MQTT.",
"install_methods": [
{
"type": "default",
"script": "ct/ps5-mqtt.sh",
"resources": {
"cpu": 1,
"ram": 265,
"hdd": 3,
"os": "debian",
"version": "12"
}
}
],
"default_credentials": {
"username": null,
"password": null
},
"notes": [
{
"text": "config file: `/root/.config/ps5-mqtt/config.json`",
"type": "info"
}
michelroegl-brunner marked this conversation as resolved.
Show resolved Hide resolved
]
}
Loading