I also found a few mismatches. So, I’ve updated the Node-RED flow to query MobyGames if there’s no match in the Xbox.com data.
This worked well for me with “DOOM Eternal,” which wasn’t found in the Xbox.com extract (it has two entries: “DOOM Eternal Standard Edition” and “DOOM Eternal Deluxe Edition,” but no plain “DOOM Eternal” as it is reported from the Xbox integration). However, MobyGames did have a match.
Unfortunately, “Mafia I: Definitive Edition” isn’t found in either source.
I’ve added a connection point in the flow for cases where there’s no match. You can use this to update the state in Home Assistant to set a generic image if you like.
I’ve also included some manually injected values for testing different scenarios, along with an MBG_API_KEY
environment variable for setting up your API key. I’ll keep working on improving it to handle more edge cases.
Here is the updated flow in case you want to try it.
[
{
"id": "31deacb256799b20",
"type": "tab",
"label": "Update Xbox Current Game",
"disabled": false,
"info": "",
"env": []
},
{
"id": "c560093b6b2d638e",
"type": "function",
"z": "31deacb256799b20",
"name": "Extract game name",
"func": "return {query: msg.payload.split(' - ')[0]};",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 610,
"y": 200,
"wires": [
[
"1032799666cdaf6a"
]
]
},
{
"id": "30b7f9319586fc7b",
"type": "server-state-changed",
"z": "31deacb256799b20",
"name": "Current Game Changed",
"server": "b55816b8.c497b8",
"version": 5,
"outputs": 1,
"exposeAsEntityConfig": "",
"entityId": "sensor.paulorichards_status",
"entityIdType": "exact",
"outputInitially": false,
"stateType": "str",
"ifState": "",
"ifStateType": "str",
"ifStateOperator": "is",
"outputOnlyOnStateChange": true,
"for": "0",
"forType": "num",
"forUnits": "minutes",
"ignorePrevStateNull": false,
"ignorePrevStateUnknown": false,
"ignorePrevStateUnavailable": false,
"ignoreCurrentStateUnknown": false,
"ignoreCurrentStateUnavailable": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "eventData"
},
{
"property": "topic",
"propertyType": "msg",
"value": "",
"valueType": "triggerId"
}
],
"x": 140,
"y": 140,
"wires": [
[
"86ab7b20afacf703"
]
]
},
{
"id": "86ab7b20afacf703",
"type": "switch",
"z": "31deacb256799b20",
"name": "Filter Actual games",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "Home",
"vt": "str"
},
{
"t": "cont",
"v": "Last seen",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 370,
"y": 140,
"wires": [
[
"4186958e7c16e93f"
],
[
"4186958e7c16e93f"
],
[
"c560093b6b2d638e"
]
]
},
{
"id": "4186958e7c16e93f",
"type": "ha-sensor",
"z": "31deacb256799b20",
"name": "Update Sensor",
"entityConfig": "8643d05c555130c3",
"version": 0,
"state": "Inactive",
"stateType": "str",
"attributes": [
{
"property": "entity_picture",
"value": "",
"valueType": "str"
}
],
"inputOverride": "allow",
"outputProperties": [],
"x": 600,
"y": 80,
"wires": [
[]
]
},
{
"id": "37aaba4f72b8d684",
"type": "csv",
"z": "31deacb256799b20",
"name": "Parse CSV",
"spec": "rfc",
"sep": ",",
"hdrin": true,
"hdrout": "none",
"multi": "one",
"ret": "\\n",
"temp": "",
"skip": "0",
"strings": false,
"include_empty_strings": "",
"include_null_values": "",
"x": 1190,
"y": 200,
"wires": [
[
"fd250c8d70ace24e"
]
]
},
{
"id": "21486a04579c8159",
"type": "http request",
"z": "31deacb256799b20",
"name": "Get CSV",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 1020,
"y": 200,
"wires": [
[
"37aaba4f72b8d684"
]
]
},
{
"id": "fd250c8d70ace24e",
"type": "switch",
"z": "31deacb256799b20",
"name": "Match Game Title",
"property": "payload[\"Game Title\"]",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "query",
"vt": "msg"
},
{
"t": "else"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 490,
"y": 320,
"wires": [
[
"762729495184c0b4"
],
[
"10729ce07ce73b95"
]
]
},
{
"id": "762729495184c0b4",
"type": "ha-sensor",
"z": "31deacb256799b20",
"name": "Update Sensor",
"entityConfig": "8643d05c555130c3",
"version": 0,
"state": "Active",
"stateType": "str",
"attributes": [
{
"property": "entity_picture",
"value": "payload[\"Cover URL\"]",
"valueType": "msg"
}
],
"inputOverride": "allow",
"outputProperties": [],
"x": 800,
"y": 320,
"wires": [
[]
]
},
{
"id": "1032799666cdaf6a",
"type": "template",
"z": "31deacb256799b20",
"name": "Setup URL",
"field": "url",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "https://{{env.HOMEASSISTANT_HOST}}/local/xbox_game_titles.csv",
"output": "str",
"x": 830,
"y": 200,
"wires": [
[
"21486a04579c8159"
]
]
},
{
"id": "d368b0cbb905dd44",
"type": "inject",
"z": "31deacb256799b20",
"name": "Mafia I: Definitive edition",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "Mafia I: Definitive edition",
"payloadType": "str",
"x": 170,
"y": 300,
"wires": [
[
"86ab7b20afacf703"
]
]
},
{
"id": "10729ce07ce73b95",
"type": "switch",
"z": "31deacb256799b20",
"name": "Nothing matched",
"property": "parts.count",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "$.parts.index + 1",
"vt": "jsonata"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 490,
"y": 420,
"wires": [
[
"430c943f33720c9c"
]
]
},
{
"id": "dbf02c1302b5eb14",
"type": "inject",
"z": "31deacb256799b20",
"name": "DOOM Eternal",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "DOOM Eternal",
"payloadType": "str",
"x": 140,
"y": 260,
"wires": [
[
"86ab7b20afacf703"
]
]
},
{
"id": "d85edff32493dbd0",
"type": "inject",
"z": "31deacb256799b20",
"name": "Home",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "Home",
"payloadType": "str",
"x": 110,
"y": 220,
"wires": [
[
"86ab7b20afacf703"
]
]
},
{
"id": "430c943f33720c9c",
"type": "template",
"z": "31deacb256799b20",
"name": "Setup Game URL",
"field": "url",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "https://api.mobygames.com/v1/games?api_key={{env.MBG_API_KEY}}&title={{query}}&format=id",
"output": "str",
"x": 790,
"y": 420,
"wires": [
[
"8cac63c18b5449f4"
]
]
},
{
"id": "8cac63c18b5449f4",
"type": "http request",
"z": "31deacb256799b20",
"name": "Find Game ID",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 1040,
"y": 420,
"wires": [
[
"7d4f50950f1af073"
]
]
},
{
"id": "7d4f50950f1af073",
"type": "json",
"z": "31deacb256799b20",
"name": "Parse JSON",
"property": "payload",
"action": "",
"pretty": false,
"x": 1250,
"y": 420,
"wires": [
[
"c7dd1d621ac4864a"
]
]
},
{
"id": "32275ada01c4f1b8",
"type": "template",
"z": "31deacb256799b20",
"name": "Setup Cover URL",
"field": "url",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "https://api.mobygames.com/v1/games/{{payload.games.0}}/platforms/289/covers?api_key={{env.MBG_API_KEY}}",
"output": "str",
"x": 730,
"y": 580,
"wires": [
[
"d6cbd4e4e96995d7"
]
]
},
{
"id": "7e89b8018a5cbd6d",
"type": "template",
"z": "31deacb256799b20",
"name": "Setup Cover URL",
"field": "url",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "https://api.mobygames.com/v1/games/{{payload.games.0}}/platforms/142/covers?api_key={{env.MBG_API_KEY}}",
"output": "str",
"x": 730,
"y": 660,
"wires": [
[
"9d50f9ca3ee53f63"
]
]
},
{
"id": "6eb9f6c6536428e1",
"type": "http request",
"z": "31deacb256799b20",
"name": "",
"method": "GET",
"ret": "txt",
"paytoqs": false,
"url": "",
"persist": false,
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 1330,
"y": 620,
"wires": [
[
"02ddac9a770e46ad"
]
]
},
{
"id": "10cd20aa7dfeae24",
"type": "delay",
"z": "31deacb256799b20",
"name": "",
"pauseType": "delay",
"timeout": "1",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 1140,
"y": 580,
"wires": [
[
"6eb9f6c6536428e1"
]
]
},
{
"id": "784540448c4fbb71",
"type": "delay",
"z": "31deacb256799b20",
"name": "",
"pauseType": "delay",
"timeout": "3",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 1140,
"y": 660,
"wires": [
[
"6eb9f6c6536428e1"
]
]
},
{
"id": "02ddac9a770e46ad",
"type": "json",
"z": "31deacb256799b20",
"name": "Parse Json",
"property": "payload",
"action": "",
"pretty": false,
"x": 1530,
"y": 620,
"wires": [
[
"1252f98054ed1c8f"
]
]
},
{
"id": "d6cbd4e4e96995d7",
"type": "template",
"z": "31deacb256799b20",
"name": "Set platform",
"field": "platform",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "xbox-series",
"output": "str",
"x": 950,
"y": 580,
"wires": [
[
"10cd20aa7dfeae24"
]
]
},
{
"id": "9d50f9ca3ee53f63",
"type": "template",
"z": "31deacb256799b20",
"name": "Set platform",
"field": "platform",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "xbox-one",
"output": "str",
"x": 950,
"y": 660,
"wires": [
[
"784540448c4fbb71"
]
]
},
{
"id": "1252f98054ed1c8f",
"type": "join",
"z": "31deacb256799b20",
"name": "Merge Covers",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "platform",
"joiner": "\\n",
"joinerType": "str",
"useparts": false,
"accumulate": true,
"timeout": "",
"count": "2",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 510,
"y": 760,
"wires": [
[
"b578020877c4b3f0"
]
]
},
{
"id": "b578020877c4b3f0",
"type": "function",
"z": "31deacb256799b20",
"name": "Select Cover from plarform",
"func": "if (msg.payload[\"xbox-series\"].cover_groups.length > 0)\n return { payload: msg.payload[\"xbox-series\"].cover_groups[0].covers[0].image }\nelse if (msg.payload[\"xbox-one\"].cover_groups.length > 0)\n return {payload: msg.payload[\"xbox-one\"].cover_groups[0].covers[0].image }\nelse\n return { payload: null }",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 760,
"y": 760,
"wires": [
[
"c76999761bfe3859"
]
]
},
{
"id": "c7dd1d621ac4864a",
"type": "switch",
"z": "31deacb256799b20",
"name": "Game Found?",
"property": "payload.games",
"propertyType": "msg",
"rules": [
{
"t": "else"
},
{
"t": "nempty"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 500,
"y": 560,
"wires": [
[],
[
"32275ada01c4f1b8",
"7e89b8018a5cbd6d"
]
]
},
{
"id": "c76999761bfe3859",
"type": "ha-sensor",
"z": "31deacb256799b20",
"name": "Update Sensor",
"entityConfig": "8643d05c555130c3",
"version": 0,
"state": "Active",
"stateType": "str",
"attributes": [
{
"property": "entity_picture",
"value": "payload",
"valueType": "msg"
}
],
"inputOverride": "allow",
"outputProperties": [],
"x": 1020,
"y": 760,
"wires": [
[]
]
},
{
"id": "b55816b8.c497b8",
"type": "server",
"name": "Home Assistant",
"addon": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "",
"connectionDelay": false,
"cacheJson": false,
"heartbeat": false,
"heartbeatInterval": "",
"statusSeparator": "",
"enableGlobalContextStore": false
},
{
"id": "8643d05c555130c3",
"type": "ha-entity-config",
"server": "b55816b8.c497b8",
"deviceConfig": "e0d4f3aa6af52387",
"name": "xbox-cover",
"version": "6",
"entityType": "sensor",
"haConfig": [
{
"property": "name",
"value": "Xbox Current Game Cover"
},
{
"property": "icon",
"value": ""
},
{
"property": "entity_picture",
"value": ""
},
{
"property": "entity_category",
"value": ""
},
{
"property": "device_class",
"value": ""
},
{
"property": "unit_of_measurement",
"value": ""
},
{
"property": "state_class",
"value": ""
}
],
"resend": false,
"debugEnabled": false
},
{
"id": "e0d4f3aa6af52387",
"type": "ha-device-config",
"name": "Xbox",
"hwVersion": "",
"manufacturer": "Node-RED",
"model": "Xbox Series X",
"swVersion": ""
}
]