Open v1605 opened 1 year ago
I like this idea a lot! It's definitely doable
This is the current payload for the /games/playing API endpoint. Would it be suitable for what you're imagining?
{
"core": "PSX",
"system": "PSX",
"systemName": "Playstation",
"game": "PSX/Crash Bandicoot.mgl",
"gameName": "Crash Bandicoot"
}
I guess I can put an option in the remote.ini file to specify a url to post to
Exactly the sort of request I was thinking of. I would maybe add two more fields "platform: mister" and possibly hostname. That way if this type of standard more prevalent, you can differentiate between different platforms and help if users have multi Mister setups.
I also realized this could potentially be used in the Retrotink 4k via pico (depending on the cli). Per core and per game profiles for the Mister could be huge (and a fun project for me lol).
Give this a try! Just replace your current remote.sh in the Script folder and it will auto-update later with the real release.
Create a file in the Scripts folder called remote.ini
like this:
[remote]
announce_game_url=http://10.0.0.193:8080/
And then restart mister or do restart remote service from the settings page.
From then on it will send the POST payload to that address every time the game/core state changes. Below is the example data consumed by a dummy python server
Oh and you must have the recents
option enabled in the mister ini or else the game won't be detected only the core
Thanks for getting a this up and running so fast! I was able to get a webhook up and running in home assistant to start looking at different automatons. I did notice some strange behavior when switching cores. For example
Load up core: works perfectly
{"platform":"MiSTer","hostname":"MiSTer","core":"SNES","system":"SNESMusic","systemName":"SNES Music","gamePath":"","gameFilename":".","gameName":""}
Launch game: works perfectly
{"platform":"MiSTer","hostname":"MiSTer","core":"SNES","system":"SNESMusic","systemName":"SNES Music","gamePath":"/media/fat/games/SNES/1 US - S/Super Mario World (USA).sfc","gameFilename":"Super Mario World (USA).sfc","gameName":"Super Mario World (USA)"}
Switch to a different core: it sends two request, a duplicate of the one above and then one with the new core but old game
{"platform":"MiSTer","hostname":"MiSTer","core":"SNES","system":"SNESMusic","systemName":"SNES Music","gamePath":"/media/fat/games/SNES/1 US - S/Super Mario World (USA).sfc","gameFilename":"Super Mario World (USA).sfc","gameName":"Super Mario World (USA)"} {"platform":"MiSTer","hostname":"MiSTer","core":"PSX","system":"PSX","systemName":"Playstation","gamePath":"/media/fat/games/SNES/1 US - S/Super Mario World (USA).sfc","gameFilename":"Super Mario World (USA).sfc","gameName":"Super Mario World (USA)"}
Launch game on new core: again two requests with the first blanking out the name and the second with the new game
{"platform":"MiSTer","hostname":"MiSTer","core":"PSX","system":"PSX","systemName":"Playstation","gamePath":"","gameFilename":".","gameName":""} {"platform":"MiSTer","hostname":"MiSTer","core":"PSX","system":"PSX","systemName":"Playstation","gamePath":"/media/fat/games/PSX/bin/Ape Escape (USA)/Ape Escape (USA)/Ape Escape (USA).cue","gameFilename":"Ape Escape (USA).cue","gameName":"Ape Escape (USA)"}
Unfortunately, that is just how it works. MiSTer's own reporting of launched games and cores are wildly out of sync with each other
I could come up with some sort of buffering for it to make them look in sync, but it's not a 10 minute job like this was. I would say give it a shot how it is, and then let me know what features you want to see added that are stopping automations from working
One thing missing from this payload is the intention of the event that triggered it. For other apps they normally also know this event is because a core was stopped/started or a game was stopped/started
Understood. Nothing should block any automation, just adding a debounce to the home assistant side should be enough to filter out the double requests and as long as I keep track of the current game, everything should work fine. The intent would be a neat addition.
The idea for this feature is that when launching a game, the Mister could send a post request to a specific url(s) containing the core and game name being launched. This would allow users to integrate external services and sync them to Mister activity. For example, you could change smart lighting based on the games,or track games played in an external database.