Steam Status
Domoticz

Steam Status

Show your or friends Steam status in Domoticz
A flow by Galadril

Download flow

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".
  • πŸ›‘ 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:

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.