homebridge-plex-webhooks
homebridge-plex-webhooks copied to clipboard
Clarification Needed on Filter Ruleset Logic for Local Playback
Hello y'all!
I've successfully set up the homebridge-plex-webhooks
plugin, and everything is working as expected, except for some confusion I'm experiencing with the filter ruleset logic.
Issue Description
I am trying to set up sensors to trigger automations only when media is played locally on my Plex TVs. For this, I have configured key-value pairs in the filter rules for events like media.play
and media.resume
, specifically targeting Player.local
as true
and Player.uuid
with the respective UUIDs of my devices.
Configuration Example
Here's an example of how I've set up one of the sensors:
-
Sensor Name: Plex Playing in Living Room
-
Key Value Pair 1
-
event === media.play
-
Player.local === true
-
Player.uuid === [player uuid]
-
-
Key Value Pair 2
-
event === media.resume
-
Player.local === true
-
Player.uuid === [player uuid]
-
-
Observed Behavior
Despite the configuration, the logs indicate that the sensor is triggered even when the conditions don't seem to be met. For instance:
[1/3/2024, 8:59:32 PM] [PLEX] Checking filter rulesets of [Playing Locally (WHZ)] sensor:
[1/3/2024, 8:59:32 PM] [PLEX] > filter group #1
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "media.play" at "event", found "media.resume"
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "true" at "Player.local", found "false"
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "UUID1" at "Player.uuid", found "ANOTHER-UUID (NOT MINE)"
[1/3/2024, 8:59:32 PM] [PLEX] > filter group #2
[1/3/2024, 8:59:32 PM] [PLEX] + looking for "media.resume" at "event", found "media.resume"
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "true" at "Player.local", found "false"
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "UUID1" at "Player.uuid", found "ANOTHER-UUID (NOT MINE)"
[1/3/2024, 8:59:32 PM] [PLEX] > filter group #3
[1/3/2024, 8:59:32 PM] [PLEX] Checking filter rulesets of [Playing Locally (SCHZ)] sensor:
[1/3/2024, 8:59:32 PM] [PLEX] > filter group #1
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "media.play" at "event", found "media.resume"
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "true" at "Player.local", found "false"
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "UUID2" at "Player.uuid", found "ANOTHER-UUID (NOT MINE)"
[1/3/2024, 8:59:32 PM] [PLEX] > filter group #2
[1/3/2024, 8:59:32 PM] [PLEX] + looking for "media.resume" at "event", found "media.resume"
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "true" at "Player.local", found "false"
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "UUID2" at "Player.uuid", found "ANOTHER-UUID (NOT MINE)"
[1/3/2024, 8:59:32 PM] [PLEX] Checking filter rulesets of [PLEX WHZ Stopped] sensor:
[1/3/2024, 8:59:32 PM] [PLEX] > filter group #1
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "media.pause" at "event", found "media.resume"
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "true" at "Player.local", found "false"
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "UUID1" at "Player.uuid", found "ANOTHER-UUID (NOT MINE)"
[1/3/2024, 8:59:32 PM] [PLEX] > filter group #2
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "media.stop" at "event", found "media.resume"
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "true" at "Player.local", found "false"
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "UUID1" at "Player.uuid", found "ANOTHER-UUID (NOT MINE)"
[1/3/2024, 8:59:32 PM] [PLEX] Checking filter rulesets of [PLEX SCHZ Stopped] sensor:
[1/3/2024, 8:59:32 PM] [PLEX] > filter group #1
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "media.pause" at "event", found "media.resume"
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "true" at "Player.local", found "false"
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "UUID2" at "Player.uuid", found "ANOTHER-UUID (NOT MINE)"
[1/3/2024, 8:59:32 PM] [PLEX] > filter group #2
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "media.stop" at "event", found "media.resume"
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "true" at "Player.local", found "false"
[1/3/2024, 8:59:32 PM] [PLEX] - looking for "UUID2" at "Player.uuid", found "ANOTHER-UUID (NOT MINE)"
[1/3/2024, 8:59:32 PM] [PLEX] [Playing Locally (WHZ)] is active
Question
My understanding is that all key-value pairs in at least one group of the sensor should be true
for the sensor to be triggered. However, as per the logs, it seems the sensor is activated even when not all conditions are met.
Could you please help clarify how the filter ruleset logic is supposed to work in this scenario? Specifically, I'm looking to understand:
- Why the sensor is triggered despite not all conditions being met?
- How should I configure the rules to ensure the sensor only activates for local playback on specific devices?
Any insights or guidance on this matter would be greatly appreciated.
Thank you!
It also doesn't work for the other sensor, even though it should, see the log:
[1/3/2024, 9:12:36 PM] [PLEX] Checking filter rulesets of [Playing Locally (WHZ)] sensor:
[1/3/2024, 9:12:36 PM] [PLEX] > filter group #1
[1/3/2024, 9:12:36 PM] [PLEX] - looking for "media.play" at "event", found "media.stop"
[1/3/2024, 9:12:36 PM] [PLEX] + looking for "true" at "Player.local", found "true"
[1/3/2024, 9:12:36 PM] [PLEX] + looking for "UUID1" at "Player.uuid", found "UUID1"
[1/3/2024, 9:12:36 PM] [PLEX] > filter group #2
[1/3/2024, 9:12:36 PM] [PLEX] - looking for "media.resume" at "event", found "media.stop"
[1/3/2024, 9:12:36 PM] [PLEX] + looking for "true" at "Player.local", found "true"
[1/3/2024, 9:12:36 PM] [PLEX] + looking for "UUID1" at "Player.uuid", found "UUID1"
[1/3/2024, 9:12:36 PM] [PLEX] > filter group #3
[1/3/2024, 9:12:36 PM] [PLEX] Checking filter rulesets of [Playing Locally (SCHZ)] sensor:
[1/3/2024, 9:12:36 PM] [PLEX] > filter group #1
[1/3/2024, 9:12:36 PM] [PLEX] - looking for "media.play" at "event", found "media.stop"
[1/3/2024, 9:12:36 PM] [PLEX] + looking for "true" at "Player.local", found "true"
[1/3/2024, 9:12:36 PM] [PLEX] - looking for "UUID2" at "Player.uuid", found "UUID1"
[1/3/2024, 9:12:36 PM] [PLEX] > filter group #2
[1/3/2024, 9:12:36 PM] [PLEX] - looking for "media.resume" at "event", found "media.stop"
[1/3/2024, 9:12:36 PM] [PLEX] + looking for "true" at "Player.local", found "true"
[1/3/2024, 9:12:36 PM] [PLEX] - looking for "UUID2" at "Player.uuid", found "UUID1"
[1/3/2024, 9:12:36 PM] [PLEX] Checking filter rulesets of [PLEX WHZ Stopped] sensor:
[1/3/2024, 9:12:36 PM] [PLEX] > filter group #1
[1/3/2024, 9:12:36 PM] [PLEX] - looking for "media.pause" at "event", found "media.stop"
[1/3/2024, 9:12:36 PM] [PLEX] + looking for "true" at "Player.local", found "true"
[1/3/2024, 9:12:36 PM] [PLEX] + looking for "UUID1" at "Player.uuid", found "UUID1"
[1/3/2024, 9:12:36 PM] [PLEX] > filter group #2
[1/3/2024, 9:12:36 PM] [PLEX] + looking for "media.stop" at "event", found "media.stop"
[1/3/2024, 9:12:36 PM] [PLEX] + looking for "true" at "Player.local", found "true"
[1/3/2024, 9:12:36 PM] [PLEX] + looking for "UUID1" at "Player.uuid", found "UUID1"
[1/3/2024, 9:12:36 PM] [PLEX] Checking filter rulesets of [PLEX SCHZ Stopped] sensor:
[1/3/2024, 9:12:36 PM] [PLEX] > filter group #1
[1/3/2024, 9:12:36 PM] [PLEX] - looking for "media.pause" at "event", found "media.stop"
[1/3/2024, 9:12:36 PM] [PLEX] + looking for "true" at "Player.local", found "true"
[1/3/2024, 9:12:36 PM] [PLEX] - looking for "UUID2" at "Player.uuid", found "UUID1"
[1/3/2024, 9:12:36 PM] [PLEX] > filter group #2
[1/3/2024, 9:12:36 PM] [PLEX] + looking for "media.stop" at "event", found "media.stop"
[1/3/2024, 9:12:36 PM] [PLEX] + looking for "true" at "Player.local", found "true"
[1/3/2024, 9:12:36 PM] [PLEX] - looking for "UUID2" at "Player.uuid", found "UUID1"
[1/3/2024, 9:12:36 PM] [PLEX] [Playing Locally (WHZ)] is inactive
[1/3/2024, 9:12:36 PM] [PLEX] [PLEX WHZ Stopped] is inactive
filter group #2 full matches and as far as I understand the groups are in an "OR" relation this sensor should be triggered, wouldn't it?
Hi @hevalito! Could you please provide your config and other environment details like node version etc. It would highly help the investigation. You can find a bug ticket here which does have a template for this. Thanks.
Hey! I didn't create a bug ticket just yet because I was unsure of wether this behavior is normal or if it indeed is a bug. Looking at the logs - do you agree this looks wrong?
Yeah something's strange, that's why I'd like to see your config. I wouldn't want you to create a bug ticket, just use the template from there if you need it. We can start with your config in JSON format and don't forget to remove any personal data like UUID or other things.
{
"name": "PLEX",
"sensors": [
{
"name": "Playing Locally (WHZ)",
"filters": [
[
{
"path": "event",
"operator": "===",
"value": "media.play"
},
{
"path": "Player.local",
"operator": "===",
"value": "true"
},
{
"path": "Player.uuid",
"operator": "===",
"value": "UUID2"
},
{
"operator": "==="
}
],
[
{
"path": "event",
"operator": "===",
"value": "media.resume"
},
{
"path": "Player.local",
"operator": "===",
"value": "true"
},
{
"path": "Player.uuid",
"operator": "===",
"value": "UUID2"
}
],
[
{
"operator": "==="
},
{
"operator": "==="
},
{
"operator": "==="
}
]
]
},
{
"name": "Playing Locally (SCHZ)",
"filters": [
[
{
"path": "event",
"operator": "===",
"value": "media.play"
},
{
"path": "Player.local",
"operator": "===",
"value": "true"
},
{
"path": "Player.uuid",
"operator": "===",
"value": "UUID1"
}
],
[
{
"path": "event",
"operator": "===",
"value": "media.resume"
},
{
"path": "Player.local",
"operator": "===",
"value": "true"
},
{
"path": "Player.uuid",
"operator": "===",
"value": "UUID1"
}
]
]
},
{
"name": "PLEX WHZ Stopped",
"filters": [
[
{
"path": "event",
"operator": "===",
"value": "media.pause"
},
{
"path": "Player.local",
"operator": "===",
"value": "true"
},
{
"path": "Player.uuid",
"operator": "===",
"value": "UUID2"
}
],
[
{
"path": "event",
"operator": "===",
"value": "media.stop"
},
{
"path": "Player.local",
"operator": "===",
"value": "true"
},
{
"path": "Player.uuid",
"operator": "===",
"value": "UUID2"
}
]
]
},
{
"name": "PLEX SCHZ Stopped",
"filters": [
[
{
"path": "event",
"operator": "===",
"value": "media.pause"
},
{
"path": "Player.local",
"operator": "===",
"value": "true"
},
{
"path": "Player.uuid",
"operator": "===",
"value": "UUID1"
}
],
[
{
"path": "event",
"operator": "===",
"value": "media.stop"
},
{
"path": "Player.local",
"operator": "===",
"value": "true"
},
{
"path": "Player.uuid",
"operator": "===",
"value": "UUID1"
}
]
]
}
],
"verbose": true,
"_bridge": {
"username": "REDACTED",
"port": REDACTED
},
"platform": "PlexWebhooks"
}