iharosi / homebridge-plex-webhooks

Plex Webhooks Server plugin for Homebridge
GNU Affero General Public License v3.0
48 stars 6 forks source link

Plex webhooks not working in Hoobs #7

Closed dkoblar closed 3 years ago

dkoblar commented 3 years ago

Hello, I am having problems with integration of plex webhooks inside hoobs.

I have set up a configuration in Hoobs under sensors:

[
    {
        "name": "Plex Movie",
        "filters": [
            [
                {
                    "path": "Metadata.librarySectionType",
                    "value": "movie"
                }
            ]
        ]
    },
    {
        "name": "Plex Show",
        "filters": [
            [
                {
                    "path": "Metadata.librarySectionType",
                    "value": "show"
                }
            ]
        ]
    }
]

And when I start a movie the sensor on Apple Home app does not show as occupied. (I see the sensor but it occupancy is not detected).

When I check the log file in Hoobs I get:

29. 12. 2020 12:56:37 [Plex Webhooks Platform] {"event":"media.resume","user":true,"owner":true,"Account":{"id":1,"thumb":"https://plex.tv/users/1544cab079f51f58/avatar?c=1554406764","title":"koblar"},"Server":{"title":"MacMini","uuid":"db9ae304f3aac5e7cc17de5b51caa7f3acdc30fb"},"Player":{"local":true,"publicAddress":"85.10.26.180","title":"Safari","uuid":"xxfq3utczyr0odwp06ku2jou"},"Metadata":{"librarySectionType":"movie","ratingKey":"2530","key":"/library/metadata/2530","guid":"plex://movie/5d7770de6afb3d0020623c0b","studio":"A24","type":"movie","title":"On the Rocks","librarySectionTitle":"Movies","librarySectionID":1,"librarySectionKey":"/library/sections/1","contentRating":"R","summary":"Faced with sudden doubts about her marriage, a young New York mother teams up with her larger-than-life playboy father to tail her husband.","rating":8.6,"audienceRating":4.9,"viewOffset":563000,"viewCount":1,"lastViewedAt":1609242997,"year":2020,"thumb":"/library/metadata/2530/thumb/1605640168","art":"/library/metadata/2530/art/1605640168","duration":5760000,"originallyAvailableAt":"2020-09-22","addedAt":1603563988,"updatedAt":1605640168,"audienceRatingImage":"rottentomatoes://image.rating.spilled","primaryExtraKey":"/library/metadata/2871","ratingImage":"rottentomatoes://image.rating.ripe","Genre":[{"id":102,"filter":"genre=102","tag":"Comedy","count":154},{"id":206,"filter":"genre=206","tag":"Drama","count":184},{"id":4,"filter":"genre=4","tag":"Action/Adventure","count":205}],"Director":[{"id":14369,"filter":"director=14369","tag":"Sofia Coppola"}],"Writer":[{"id":14370,"filter":"writer=14370","tag":"Sofia Coppola"}],"Producer":[{"id":14371,"filter":"producer=14371","tag":"Sofia Coppola"},{"id":14372,"filter":"producer=14372","tag":"Youree Henley"}],"Country":[{"id":7,"filter":"country=7","tag":"United States of America","count":317}],"Guid":[{"id":"imdb://tt9606374"},{"id":"tmdb://575417"},{"id":"tvdb://133530"}],"Role":[{"id":14335,"filter":"actor=14335","tag":"Bill Murray","count":2,"role":"Felix","thumb":"https://metadata-static.plex.tv/people/5d776825151a60001f24a402.jpg"},{"id":4625,"filter":"actor=4625","tag":"Rashida Jones","count":3,"role":"Laura","thumb":"https://metadata-static.plex.tv/people/5d77683a8a7581001f12dfe6.jpg"},{"id":14336,"filter":"actor=14336","tag":"Marlon Wayans","role":"Dean","thumb":"https://metadata-static.plex.tv/people/5d776827103a2d001f564636.jpg"},{"id":14337,"filter":"actor=14337","tag":"Jessica Henwick","count":2,"role":"Fiona","thumb":"https://metadata-static.plex.tv/people/5d7769a9594b2b001e6a6c26.jpg"},{"id":14338,"filter":"actor=14338","tag":"Jenny Slate","role":"Vanessa","thumb":"https://metadata-static.plex.tv/people/5d776896431c830024c100cd.jpg"},{"id":14339,"filter":"actor=14339","tag":"Liyanna Muscat","role":"Maya","thumb":"https://metadata-static.plex.tv/people/5f6e1762b33e5600416169da.jpg"},{"id":14340,"filter":"actor=14340","tag":"Alexandra  Mary Reimer","role":"Theo","thumb":"https://metadata-static.plex.tv/people/5d9c08d1e9d5a1001f4dcdce.jpg"},{"id":14341,"filter":"actor=14341","tag":"Anna Reimer","role":"Theo","thumb":"https://metadata-static.plex.tv/people/5d9c08d1e9d5a1001f4dcdd0.jpg"},{"id":14342,"filter":"actor=14342","tag":"Barbara Bain","role":"Gran","thumb":"https://metadata-static.plex.tv/1/people/1beee6225cf0323d62db9a9245292a92.jpg"},{"id":14343,"filter":"actor=14343","tag":"Juliana Canfield","role":"Amanda","thumb":"https://metadata-static.plex.tv/people/5d9c091b08fddd001f2a7f70.jpg"},{"id":14344,"filter":"actor=14344","tag":"Alva Chinn","role":"Diane"},{"id":12504,"filter":"actor=12504","tag":"Mike Keller","count":2,"role":"Officer O'Callaghan","thumb":"https://metadata-static.plex.tv/people/5d7768b5308bca0020330948.jpg"},{"id":14345,"filter":"actor=14345","tag":"Musto Pelinkovicci","role":"Musto","thumb":"https://metadata-static.plex.tv/people/5d77682e7e9a3c0020c6b9f1.jpg"},{"id":14346,"filter":"actor=14346","tag":"Zora Casebere","role":"Babysitter 1"},{"id":14347,"filter":"actor=14347","tag":"Melissa Errico","role":"Music Teacher","thumb":"https://metadata-static.plex.tv/people/5d776835a091de001f2e7f1e.jpg"},{"id":14348,"filter":"actor=14348","tag":"Zoe Bullock","role":"Jenna"},{"id":14349,"filter":"actor=14349","tag":"Chase Sui Wonders","role":"Chase"},{"id":14350,"filter":"actor=14350","tag":"Elizabeth Guindi","role":"Carla"},{"id":14351,"filter":"actor=14351","tag":"Jules Willcox","role":"Mom","thumb":"https://metadata-static.plex.tv/people/5d776a64fb0d55001f544ea5.jpg"},{"id":14352,"filter":"actor=14352","tag":"Ximena Lamadrid","role":"Mandy"},{"id":14353,"filter":"actor=14353","tag":"Kelly Lynch","role":"Blonde","thumb":"https://metadata-static.plex.tv/6/people/60406c5d80eec0a5285078fb568caaaa.jpg"},{"id":14354,"filter":"actor=14354","tag":"Earl Rose","role":"Piano Player"},{"id":14355,"filter":"actor=14355","tag":"Catherine G. Blair","role":"Cocktail Party Guest 1"},{"id":14356,"filter":"actor=14356","tag":"Anne Goldrach","role":"Cocktail Party Guest 2"},{"id":14357,"filter":"actor=14357","tag":"Waltrudis Buck","role":"Lady 1","thumb":"https://metadata-static.plex.tv/people/5d776834a091de001f2e7bf9.jpg"},{"id":14358,"filter":"actor=14358","tag":"Nancy Ozelli","role":"Lady 2"},{"id":14359,"filter":"actor=14359","tag":"Chris Cenatiempo","role":"Police Officer 2","thumb":"https://metadata-static.plex.tv/people/5dce6cdff4b82c00206571ed.jpg"},{"id":14360,"filter":"actor=14360","tag":"Cliff Samara","role":"Security Attendant"},{"id":14361,"filter":"actor=14361","tag":"Natia Dune","role":"Waitress"},{"id":14362,"filter":"actor=14362","tag":"Nadia Dajani","role":"Kelly","thumb":"https://metadata-static.plex.tv/people/5d77682a54f42c001f8c31a8.jpg"},{"id":14363,"filter":"actor=14363","tag":"Spice Greene","role":"Host"},{"id":14364,"filter":"actor=14364","tag":"Grayson Eddey","role":"Milo"},{"id":14365,"filter":"actor=14365","tag":"Charlotte D'Alessio","role":"Model Mom"},{"id":14366,"filter":"actor=14366","tag":"Kim Hill","role":"Mom at School"},{"id":14367,"filter":"actor=14367","tag":"Evangeline Young","role":"Miss Mindy"},{"id":14368,"filter":"actor=14368","tag":"John Tropea","role":"Guitar Player"}]}}
29. 12. 2020 12:56:38 [Plex Webhooks Platform] Checking filter rulesets of [Plex Movie] sensor:
29. 12. 2020 12:56:38 [Plex Webhooks Platform]  > filter group #1
29. 12. 2020 12:56:38 [Plex Webhooks Platform]  + looking for "movie" at "Metadata.librarySectionType", found "movie"
29. 12. 2020 12:56:38 [Plex Webhooks Platform] Checking filter rulesets of [Plex Show] sensor:
29. 12. 2020 12:56:38 [Plex Webhooks Platform]  > filter group #1
29. 12. 2020 12:56:38 [Plex Webhooks Platform]  - looking for "show" at "Metadata.librarySectionType", found "movie"
29. 12. 2020 12:56:38 [Plex Webhooks Platform] Error: context.setState is missing
    at /home/hoobs/.hoobs/node_modules/homebridge-plex-webhooks/lib/platform.js:113:24
    at Array.forEach (<anonymous>)
    at PlexWebhooksPlatform._processPayload (/home/hoobs/.hoobs/node_modules/homebridge-plex-webhooks/lib/platform.js:106:8)
    at /home/hoobs/.hoobs/node_modules/homebridge-plex-webhooks/lib/server.js:38:7
    at Layer.handle [as handle_request] (/home/hoobs/.hoobs/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/hoobs/.hoobs/node_modules/express/lib/router/route.js:137:13)
    at Array.<anonymous> (/home/hoobs/.hoobs/node_modules/multer/lib/make-middleware.js:53:37)
    at listener (/home/hoobs/.hoobs/node_modules/on-finished/index.js:169:15)
    at onFinish (/home/hoobs/.hoobs/node_modules/on-finished/index.js:100:5)
    at callback (/home/hoobs/.hoobs/node_modules/ee-first/index.js:55:10)
    at IncomingMessage.onevent (/home/hoobs/.hoobs/node_modules/ee-first/index.js:93:5)
    at IncomingMessage.emit (events.js:215:7)
    at endReadableNT (_stream_readable.js:1184:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
29. 12. 2020 12:56:38 [Plex Webhooks Platform] One of your sensor did not register properly, please restart your homebridge server!
29. 12. 2020 12:56:38 [Plex Webhooks Platform] In case you're still having this error, please raise a ticket: https://github.com/iharosi/homebridge-plex-webhooks/issues

Since I am playing a Movie in plex I am focused on this lines from the log file:

29. 12. 2020 12:56:38 [Plex Webhooks Platform] Checking filter rulesets of [Plex Movie] sensor:
29. 12. 2020 12:56:38 [Plex Webhooks Platform]  > filter group #1
29. 12. 2020 12:56:38 [Plex Webhooks Platform]  + looking for "movie" at "Metadata.librarySectionType", found "movie"
29. 12. 2020 12:56:38 [Plex Webhooks Platform] Checking filter rulesets of [Plex Show] sensor:
29. 12. 2020 12:56:38 [Plex Webhooks Platform]  > filter group #1
29. 12. 2020 12:56:38 [Plex Webhooks Platform]  - looking for "show" at "Metadata.librarySectionType", found "movie"
29. 12. 2020 12:56:38 [Plex Webhooks Platform] Error: context.setState is missing

Can you please help me what am I doing wrong. As it looks to me apparently I am not providing a setState?

iharosi commented 3 years ago

Hi @dkoblar, Could you please update the plugin to the latest version, restart Hoembridge and try again?

dkoblar commented 3 years ago

Hi @iharosi Thanks for quick reply. You mean Plex webhooks plugin in Hoobs? It is up to date: Plex Webhooks 2.1.0 published 12/25/2020 • 4 days ago

iharosi commented 3 years ago

In that case just restart Homebridge/Hoobs and try again.

dkoblar commented 3 years ago

I have also tried restarting service multiple times, but there is no difference. I also tried rebooting the complete device just now, but I get the same error:

29. 12. 2020 13:33:49 [Plex Webhooks Platform] Checking filter rulesets of [Plex Movie] sensor:
29. 12. 2020 13:33:49 [Plex Webhooks Platform]  > filter group #1
29. 12. 2020 13:33:49 [Plex Webhooks Platform]  + looking for "movie" at "Metadata.librarySectionType", found "movie"
29. 12. 2020 13:33:49 [Plex Webhooks Platform] Checking filter rulesets of [Plex Show] sensor:
29. 12. 2020 13:33:49 [Plex Webhooks Platform]  > filter group #1
29. 12. 2020 13:33:49 [Plex Webhooks Platform]  - looking for "show" at "Metadata.librarySectionType", found "movie"
29. 12. 2020 13:33:49 [Plex Webhooks Platform] Error: context.setState is missing
    at /home/hoobs/.hoobs/node_modules/homebridge-plex-webhooks/lib/platform.js:113:24
    at Array.forEach (<anonymous>)
    at PlexWebhooksPlatform._processPayload (/home/hoobs/.hoobs/node_modules/homebridge-plex-webhooks/lib/platform.js:106:8)
    at /home/hoobs/.hoobs/node_modules/homebridge-plex-webhooks/lib/server.js:38:7
    at Layer.handle [as handle_request] (/home/hoobs/.hoobs/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/hoobs/.hoobs/node_modules/express/lib/router/route.js:137:13)
    at Array.<anonymous> (/home/hoobs/.hoobs/node_modules/multer/lib/make-middleware.js:53:37)
    at listener (/home/hoobs/.hoobs/node_modules/on-finished/index.js:169:15)
    at onFinish (/home/hoobs/.hoobs/node_modules/on-finished/index.js:100:5)
    at callback (/home/hoobs/.hoobs/node_modules/ee-first/index.js:55:10)
    at IncomingMessage.onevent (/home/hoobs/.hoobs/node_modules/ee-first/index.js:93:5)
    at IncomingMessage.emit (events.js:215:7)
    at endReadableNT (_stream_readable.js:1184:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
29. 12. 2020 13:33:49 [Plex Webhooks Platform] One of your sensor did not register properly, please restart your homebridge server!
29. 12. 2020 13:33:49 [Plex Webhooks Platform] In case you're still having this error, please raise a ticket: https://github.com/iharosi/homebridge-plex-webhooks/issues
iharosi commented 3 years ago

Unfortunately this is happening because you've had a previus version of this plugin most probably. You can fix this with the following steps:

Hopefully, with this the occupancy sensors will be re-registered in homebridge. Please let me know if it solves your issue!

dkoblar commented 3 years ago

I have figured it out.

The advice below did not help.

I had to delete the plug in and reinstall it. After reinstalling I pasted the same config and it started working.

iharosi commented 3 years ago

Glad to hear it! Thanks for reporting!

iharosi commented 3 years ago

Reopening as turned out this is a bug in the plugin.