Flow Details
βοΈ Script Activation:
The script is active by default, as indicated by active = true
.
β° Trigger:
The script is triggered when the device "Steam - %Username% Status" changes state.
π Logging:
Uses the logging level domoticz.LOG_INFO
, with entries marked by "AWTRIX3_STEAM" for easy identification.
π Execution:
When triggered, the script performs the following actions:
π Condition Check:
Checks the new state of the "Steam - %Username% Status" device:
- β
Recognized states include:
-
In-Game: Fetches the game name from "Steam - %Username% Game Name", or defaults to
"In-game"
. -
Online: Notification displays
"Online"
. -
Offline: Notification displays
"Offline"
.
-
In-Game: Fetches the game name from "Steam - %Username% Game Name", or defaults to
- π If the state is unrecognized, the script logs a warning and stops further actions.
π Action:
- Sends a JSON payload (state and icon) to the "AWTRIX3 - Send Notification" device:
- β If the AWTRIX3 device is found: The notification is sent.
- π If the AWTRIX3 device is not found: Logs an error.
More Information:
- Domoticz: www.domoticz.com
- Domoticz AWTRIX3 Plugin: GitHub Repository
- Domoticz Steam Plugin: GitHub Repository
return {
active = true,
on = {
devices = {
'Steam - Username Status'
}
},
logging = {
level = domoticz.LOG_INFO,
marker = "AWTRIX3_STEAM"
},
execute = function(domoticz, steamStatus)
-- Check the new state of the "Steam Status" switch
local newState = steamStatus.state
domoticz.log("Steam Status changed to: " .. newState, domoticz.LOG_INFO)
-- Define default text and icon
local notificationText = ""
local notificationIcon = 28166 -- Fixed icon ID for all states
if newState == "In-Game" then
local gameNameDevice = domoticz.devices('Steam - Username Game Name')
if gameNameDevice and gameNameDevice.text and gameNameDevice.text ~= "" then
notificationText = "Playing: " .. gameNameDevice.text
domoticz.log("Fetched game name: " .. gameNameDevice.text, domoticz.LOG_INFO)
else
notificationText = "In-game"
domoticz.log("No game name found in Steam Game Name device", domoticz.LOG_WARNING)
end
elseif newState == "Online" then
notificationText = "Online"
elseif newState == "Offline" then
notificationText = "Offline"
else
domoticz.log("Unhandled state: " .. newState, domoticz.LOG_WARNING)
return
end
-- Format the JSON payload for AWTRIX3
local payload = {
text = notificationText,
icon = notificationIcon
}
local payloadJSON = domoticz.utils.toJSON(payload)
domoticz.log("Sending to AWTRIX3: " .. payloadJSON, domoticz.LOG_INFO)
-- Send the JSON to the AWTRIX3 "Send Notification App" device
local awtrixDevice = domoticz.devices('AWTRIX3 - Send Notification')
if awtrixDevice then
awtrixDevice.setDescription(payloadJSON)
awtrixDevice.switchOn().afterSec(2)
else
domoticz.log("AWTRIX3 - Send Notification device not found", domoticz.LOG_ERROR)
end
end
}
-- Flow first published on January 6, 2025.