Thisrepo'sintendedpurposehasbeenmetbyhomebridge-plex-sensors.Irecommenditinplaceofthispackage.Thecodehereisstilladecentstartingpointifyouwanttomapaplexwebhooktosomeotherformofwebrequest,butitisnotsuperusefulinitscurrentstate.
GettingStartedInordertorunthisapp:
Installnode.js.Clonetherepository.Installdependenciesusingnpminstall.Addthewebhookhttps://localhost:12000/toyourplexserver(theportisconfigurable)Youshouldbeusinghomebridgeandhomebridge-http-webhooksnpminstall-ghomebridgehomebridge-http-webhooksConfigsIn~/.homebridge/config.json:
"platforms":[{"platform":"HttpWebHooks","webhook_port":"51828","sensors":[{"id":"plexContact","name":"PlexWebhookContactSensor","type":"contact"}]}]FirstrunThisscriptfiltersforaspecificplayerbeforehittingthehomebridgewebhook.Todeterminetheplayer:
RuntheappDEBUG=plex*\ACCESSORY=plexContact\PLEX_WEBHOOK_PORT=12000\HB_WEBHOOK_URL=https://localhost:51828/\nodeindex.jsPlayavideoonthedeviceyouwanttotriggerthewebhookYouwillseetheeventloggedtotheconsolewhenthewebhookishit.CopytheuuidfortheplayerReplace<PLAYER_UUID>withthecopiedplayeruuidinthecommandintheRunsection.pRunNowrunthescriptwiththePLAYERargument:
DEBUG=plex*\ACCESSORY=plexContact\PLEX_WEBHOOK_PORT=12000\HB_WEBHOOK_URL=https://localhost:51828/\PLAYER=<PLAYER_UUID>\nodeindex.jsFromnowon,whenyoutoggletheplexplaystatefromthePLAYER,youshouldseethecontactsensorstateupdateintheiOS10Homeapp.UsingtheHomeapp,youcancreateAutomationrulesbasedonthesechanges.
Thankstoplexinc/webhooks-home-automation.
评论