Announcement

Collapse
No announcement yet.

Anyone using Plex / Tautulli to trigger Events?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Anyone using Plex / Tautulli to trigger Events?

    I have Plex/Tautulli located on the same PC as HS3. Tautulli send MQTT to HS3

    Hoping someone can help me with a quick example of what I need to setup in mcsMQTT for Tautulli data to trigger events?

    I'd like to setup lighting on/off/dim and other based on... User, Room, Media type, Action: play/pause/resume/stop)

    Data looks like this...

    {"subject": "MediaRoom", "body": "episode paused, FireFly", "topic": "tautulli"}
    {"subject": "LivingRoom", "body": "movie stopped, Serenity", "topic": "tautulli"}


    thx!

    #2
    mcsMQTT will make available on the Association tab three rows based upon the data you are showing. Assume topic is Plex/ABC for illustration.
    Plex/ABC:subject, Plex/ABC:body, Plex/ABC:topic will be the three. You can click the A column checkbox to create a HS device for each. The HS device will be populated with MediaRoom, episode paused,Firefly and tautulli for the three devices based upon the first line of data shown.

    Some decisions are needed as to how HS will use the data. For example if you want a set of devices for MediaRoom and a different set for LivingRoom then the payload becomes part of the topic from mcsMQTT perspective. This is covered in the manual and is initiated by using the elevate checkbox.

    Another choice is if there is a limited number of subject values. In that case you will want the Control/Status UI on the Edit tab to be List or Button. This will create VSP for each and use numbers in the DeviceValue. This is easier to trigger events using numbers. It looks like body and topic will be free-form so the Control/Status UI will be Text and the DeviceString rather than DeviceValue will be populated. HS does not have a native trigger for DeviceString.

    Comment


      #3
      Michael McSharry thx for the help.
      I figured out how to trigger events without creating devices... would be helpful if we could add IF conditions from mcsMQTT, not just triggers? (did I miss this? -- see screenshot)

      My goals...

      1. Trigger events
      -- for this, I don't think devices are necessary? Especially if I can use mcsMQTT conditions to look for keywords to take action on

      2. Show info on phone/tablet dashboard...
      a. "Now Playing" section - Currently Playing show/music/movie w/ last change time
      b. "at-a-glance" view of what my kids are watching - quickly see what kids are doing, amount of screen time, etc

      -- 2 Devices per room?
      -- "Current"
      -- "Previous" : have an event that moves the text from "Current" when it detects change in 'media title'

      Seems like I need some way to parse the BODY to pull out info / data points (media type, action, media title)? Being new to MQTT, I'm not sure what's possible.

      Maybe...make TOPIC = <Room Name> (trigger events with this since they will be room based) and make SUBJECT = <media title> and keep PAYLOAD = <media type>,<action>
      .. still doesn't solve parsing PAYLOAD to trigger events...could really use mcsMQTT event conditions ?

      thoughts?
      Attached Files

      Comment


        #4
        Maybe the ‘’condition’’ could added in the mcsmqtt trigger .

        ex: if mqtt topic ‘’ ‘’ received payload xxx
        and if the payload contain xxx

        This is what ultralogs and big5 plugin are doing .

        Comment


          #5
          HS Event Conditions are not supported in mcsMQTT. You get the trigger (Topic) and one condition (Payload), but cannot setup multiple conditions using AND and OR logic.

          You can trigger events based upon a MQTT Topic and the payload of that topic containing some sequence of characters. This is what you have shown in your screenshot. No device is needed for this.

          For your item 2 you will need to get to look at the payload content. mcsMQTT will parse the JSON keys and put the key value in the HS DeviceString or DeviceValue. You could then do what you want with the device content to show on your dashboard.

          If you need further dissection of payload, such as extracting "FireFly" from "episode paused, FireFly" as the now playing content then you are likely into scripting or perhaps you could use regular expression within mcsMQTT if the data is delivered in a regular format. To support scripting you can do a callback and get the topic and payload to do whatever you want. Look at the manual for setting up a scripting callback. You can invoke your script with a DeviceChange event or MQTT Receive event. In these cases you will need an event defined for each topic pattern or device.

          If you have control of the MQTT messages being sent then you can design a structure that works easily with mcsMQTT. If you are trying to use something that already exists you are limited. General practice with MQTT communications using JSON is to have keys for each object. In your case it looks like the body key contains a state and a title. This would be easier to handle if these each had their own JSON keys.

          Comment


            #6
            Michael McSharry I think i did write my post while you were writtinh yours. Do you think it would be possible to add a condition directly in the mcsmqtt trigger that would check if something else is also present in the payload?

            Attached Files

            Comment


              #7
              The API does support conditions, but I have never implemented it for any of my plugins. This may be an area of departure between the HS3 and HS4 pluign in the future.

              Comment


                #8
                Originally posted by Michael McSharry
                If you have control of the MQTT messages being sent then you can design a structure that works easily with mcsMQTT. If you are trying to use something that already exists you are limited. General practice with MQTT communications using JSON is to have keys for each object. In your case it looks like the body key contains a state and a title. This would be easier to handle if these each had their own JSON keys.
                Yes, Tautulli lets us put in any text and any Plex variable (see screenshot). What do you suggest to make it easiest to parse the data I need?

                Originally posted by Michael McSharry
                The API does support conditions, but I have never implemented it for any of my plugins. This may be an area of departure between the HS3 and HS4 pluign in the future.
                Would love if you could add for HS3...I suspect many (including myself) will not move to HS4 for a while. For me too much risk and I do not any benefit with HS4.

                Attached Files

                Comment


                  #9
                  Yes, Tautulli lets us put in any text and any Plex variable (see screenshot). What do you suggest to make it easiest to parse the data I need?
                  In the screenshot the message body contains media type, "started" and title. If you are looking to get the title to show on a dashboard or use as a trigger then this should be the only thing in the body. Create a different body for media type if you want that information, etc.

                  Would love if you could add for HS3...I suspect many (including myself) will not move to HS4 for a while. For me too much risk and I do not any benefit with HS4.
                  For the near term neither will get conditions support. It has not something that has even been mentioned before in the near three years that the plugin has been available. Since you have the ability to manage what is being sent then the payloads can be very specific and the need for conditions should be reduced or eliminated.

                  Using devices the plugin will parse the JSON components into individual elements. Event triggers do not have an equivalent feature, but treat the payload as a single string with no context of it being JSON, XML, etc. Of course scripting provides the greatest flexibility to do whatever you want with the payloads.

                  What may help is to go through one specific example so I may be able to provide specific suggestions.

                  Comment


                    #10
                    Originally posted by Michael McSharry View Post
                    Since you have the ability to manage what is being sent then the payloads can be very specific and the need for conditions should be reduced or eliminated.

                    Using devices the plugin will parse the JSON components into individual elements. Event triggers do not have an equivalent feature, but treat the payload as a single string with no context of it being JSON, XML, etc. Of course scripting provides the greatest flexibility to do whatever you want with the payloads.

                    What may help is to go through one specific example so I may be able to provide specific suggestions.
                    I think you are saying we can create JSON inside the Message Body that the plugin will parse into different devices?

                    If yes, how would we format the JSON in the Message Body?

                    I can create a single, or several 'MQTT notifiers' inside Tautulli. Looks like I can control what is sent in 3 fields: Topic,Subject Line, Message

                    Topic
                    -- Not sure if I can use system variables here. I can type text, have not tried variables, prob cannot
                    -- maybe make this the Room Name? and have one Notifier instance per room?

                    Subject Line
                    -- any text combined with any system variable, in {}

                    Message Body
                    -- any text combined with any system variable, in {}

                    Info I want to get to Homeseer:

                    MediaType -- {media_type}
                    Action -- {action}
                    MediaTitle -- {title}
                    User -- {user} *in my case I'm have a different user for each Room, this way I can control things based on room
                    IP Address of Client -- {ip_address} *to do a check to ensure the proper device is using the correct user login -- kids are not trying to cheat the system


                    thx!

                    Comment


                      #11
                      In the MQTT context the Topic identifies the nature of the message. I suspect you will pick one topic such as "Plex/Tautulli"

                      Subject Line is delivered as part of the MQTT Payload so it has the same context as Message Body. In essence you have two top-level fields that can be populated. Which combination you use is a design decision. For simplicity I suggest making the the subject line static such as "Status"

                      Message Body is where the real information will be encoded. The following seems appropriate to me
                      Code:
                      {"MediaType":"{media_type}","Action":"{action}","MediaTitle":"{title}","User": "{user}","IPAddressofClient":"{ip_address}"}
                      Associate Plex/Tautulli:body:MediaType, Plex/Tautulli:body:Action, Plex/Tautulli:body:MediaTitle, Plex/Tautulli:body:User, and Plex/Tautulli:body:IPAddressofClient to HS devices from the Association Tab of mcsMQTT. You will now have five devices that are updated based upon the current status delivered from Plex/Tautulli.

                      HS does very poorly with managing text. It is designed to manage numbers. What mcsMQTT does for you is to rewrite the DeviceValue each time the DeviceString is updated. This means you can setup event triggers when any of these five devices have their text updated. The action of the event will be to do whatever you want on your dashboard. The DeviceString will have the information that you will want to put on your dashboard.

                      Comment


                        #12
                        Originally posted by Michael McSharry View Post
                        Message Body is where the real information will be encoded. The following seems appropriate to me
                        Code:
                        {"MediaType":"{media_type}","Action":"{action}","MediaTitle":"{title}","User": "{user}","IPAddressofClient":"{ip_address}"}
                        Associate Plex/Tautulli:body:MediaType, Plex/Tautulli:body:Action, Plex/Tautulli:body:MediaTitle, Plex/Tautulli:body:User, and Plex/Tautulli:body:IPAddressofClient to HS devices from the Association Tab of mcsMQTT. You will now have five devices that are updated based upon the current status delivered from Plex/Tautulli.
                        I used your suggestions (removed start/end {}). Please see attached screenshots. Showing what you'd expect?

                        How do I create the devices?

                        Thanks for all the help! Your plugin looks powerful and complex- far more capable than what I need. I have no idea how to even create devices
                        Attached Files

                        Comment


                          #13
                          Looks like your Plex/Tautulli source is escaping the quotes (i.e. C convention so uses backslash quote for quote). It means that the body is no longer compliant JSON format. Disable plugin. Replace \bin\MCSMQTT_2020.dll with the attached. Start plugin. The intent of the update is the overcome the C convention for quotes that is being used by your source.
                          Attached Files

                          Comment


                            #14
                            Originally posted by Michael McSharry View Post
                            Looks like your Plex/Tautulli source is escaping the quotes (i.e. C convention so uses backslash quote for quote). It means that the body is no longer compliant JSON format. Disable plugin. Replace \bin\MCSMQTT_2020.dll with the attached. Start plugin. The intent of the update is the overcome the C convention for quotes that is being used by your source.
                            the ZIP you provided has an XML file?

                            I copied it into \bin ... now the PI hangs at 'pending' when restarting

                            Comment


                              #15
                              I don't think I ever made that mistake before. The .dll rather than .xml file is attached here. Remove the .xml that was previously copied.
                              Attached Files

                              Comment

                              Working...
                              X