iharosi / homebridge-plex-webhooks

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

Plug-in fails with more than one Occupancy Sensor #6

Closed brent7320 closed 3 years ago

brent7320 commented 3 years ago

I am running a clean install of the new plugin in homebridge and noticed if i add more than 1 occupancy sensor, i get the below error message with any webhook that is sent to Homebridge.

[24/12/2020, 04:27:16] [Plex Webhooks Platform] Checking filter rulesets of [Plex - Living Room Movies] sensor:
[24/12/2020, 04:27:16] [Plex Webhooks Platform]  > filter group #1
[24/12/2020, 04:27:16] [Plex Webhooks Platform]  + looking for "Living Room" at "Player.title", found "Living Room"
[24/12/2020, 04:27:16] [Plex Webhooks Platform]  + looking for "movie" at "Metadata.librarySectionType", found "movie"
[24/12/2020, 04:27:16] [Plex Webhooks Platform] Checking filter rulesets of [Plex - Playroom Movies] sensor:
[24/12/2020, 04:27:16] [Plex Webhooks Platform]  > filter group #1
[24/12/2020, 04:27:16] [Plex Webhooks Platform]  - looking for "Upstairs Playroom" at "Player.title", found "Living Room"
[24/12/2020, 04:27:16] [Plex Webhooks Platform]  - looking for "movies" at "Metadata.librarySectionType", found "movie"
TypeError: context.setState is not a function
    at /usr/local/lib/node_modules/homebridge-plex-webhooks/lib/platform.js:110:15
    at Array.forEach (<anonymous>)
    at PlexWebhooksPlatform._processPayload (/usr/local/lib/node_modules/homebridge-plex-webhooks/lib/platform.js:106:8)
    at /usr/local/lib/node_modules/homebridge-plex-webhooks/lib/server.js:26:7
    at Layer.handle [as handle_request] (/usr/local/lib/node_modules/homebridge-plex-webhooks/node_modules/express/lib/router/layer.js:95:5)
    at next (/usr/local/lib/node_modules/homebridge-plex-webhooks/node_modules/express/lib/router/route.js:137:13)
    at Array.<anonymous> (/usr/local/lib/node_modules/homebridge-plex-webhooks/node_modules/multer/lib/make-middleware.js:53:37)
    at listener (/usr/local/lib/node_modules/homebridge-plex-webhooks/node_modules/on-finished/index.js:169:15)
    at onFinish (/usr/local/lib/node_modules/homebridge-plex-webhooks/node_modules/on-finished/index.js:100:5)
    at callback (/usr/local/lib/node_modules/homebridge-plex-webhooks/node_modules/ee-first/index.js:55:10)

Only having one sensor seems to work fine though, it only does this when a second is added.

iharosi commented 3 years ago

Could you please share your config as well? Also, could you please share which version of the plugin are you using? Plugin initialization log could help as well.

brent7320 commented 3 years ago

Here is the config.json

        {
            "name": "Plex Webhooks Platform",
            "sensors": [
                {
                    "name": "Plex - Living Room Movies",
                    "filters": [
                        null,
                        [
                            {
                                "path": "Player.title",
                                "value": "Living Room"
                            },
                            {
                                "path": "Metadata.librarySectionType",
                                "value": "movie"
                            }
                        ]
                    ]
                },
                {
                    "name": "Plex - Playroom Movies",
                    "filters": [
                        null,
                        [
                            {
                                "path": "Player.title",
                                "value": "Upstairs Playroom"
                            },
                            {
                                "path": "Metadata.librarySectionType",
                                "value": "movies"
                            }
                        ]
                    ]
                }
            ],
            "verbose": false,
            "platform": "PlexWebhooks"
        }
    ],

Here are the platform initialization logs

[24/12/2020, 08:40:36] [Plex Webhooks Platform] Found 2 accessories in config:
[24/12/2020, 08:40:36] [Plex Webhooks Platform] • Plex - Living Room Movies
[24/12/2020, 08:40:36] [Plex Webhooks Platform] • Plex - Playroom Movies
[24/12/2020, 08:40:36] [Plex Webhooks Platform] Registering accessory [Plex - Playroom Movies] (c9fea026-c88a-48ae-ac02-1827dc747885)
[24/12/2020, 08:40:36] [Plex Webhooks Platform] Server is listening at http://x.x.x.x:32401

Plug-in version is 2.0.4.

iharosi commented 3 years ago

As I can see the plugin re-registering one of your sensor. Have you tried to restart homebridge server? After a restart did you notice the same activity?:

Registering accessory [Plex - Playroom Movies] (c9fea026-c88a-48ae-ac02-1827dc747885)

To force sensor registering, you can change something in sensor config, then you can restart the homebridge server and look for the initialization log.

Please report back after you've tried the above.

iharosi commented 3 years ago

Also, please note that in your second sensor's (Plex - Playroom Movies) config the Metadata.librarySectionType should be movie (singular) instead of movies (plural).

iharosi commented 3 years ago

@brent7320 please update to v2.1.0 and check your config once again. Remove unnecessary empty filtering options if any through Homebridge UI settings panel or remove null entries from filters array manually from config. Then restart homebridge server and please report back to me. Thanks!

brent7320 commented 3 years ago

I installed v2.1.0 and was able to configure two sensors without any issues and they both work. Thanks for the help and this great plugin!

iharosi commented 3 years ago

Glad to here it solved the issue! Thank you for reporting! :)