[Announce] Event Trigger - execute commands triggered by LMS server events

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Roland0
    Senior Member
    • Aug 2012
    • 1343

    [Announce] Event Trigger - execute commands triggered by LMS server events

    LMS Event Trigger is a plugin for executing external commands triggered by LMS server events.

    Example scenarios
    • Send a notification that a library rescan has finished to an Android device (using Gotify)
    • Power off the server after a playlist has finished
    • Show song informaion on an attached display

    More information on the homepage
    Various SW: Web Interface | Text Interface | Playlist Editor / Generator | Music Classification | Similar Music | Announce | EventTrigger | Ambient Noise Mixer | DB Optimizer | Image Enhancer | Chiptunes | LMSlib2go | ...
    Various HowTos: build a self-contained LMS | Bluetooth/ALSA | Control LMS with any device | ...
  • davemal
    Member
    • Dec 2008
    • 61

    #2
    Hi Roland,

    A couple of questions with this please.

    1. Will this trigger on volume events ? I have tried "event":[["mixer"],["volume","+1"]]} and a few variations but not able to fire.
    2. Is it possible to isolate to events from a specific player ?

    thanks

    Comment

    • Roland0
      Senior Member
      • Aug 2012
      • 1343

      #3
      Originally posted by davemal
      1. Will this trigger on volume events ? I have tried "event":[["mixer"],["volume","+1"]]} and a few variations but not able to fire.
      "event":[["mixer"], ["volume"]]

      2. Is it possible to isolate to events from a specific player ?
      The player status is passed as a parameter to the executed command. This includes the player id/name, so e.g. for a shell script one can do:

      Code:
      PL=$(echo $2|sed -e 's/.*player_id":"\(..:..:..:..:..:..\)".*/\1/')
      VOL=$(echo $2|sed -e 's/.*mixer volume":\([[:digit:]]*\).*/\1/')
      if [[ "$PL" == "00:11:22:33:44:55" ]]; then
      	echo "volume: $VOL"
      fi
      I'd recommend using jq for more complex json processing.
      Various SW: Web Interface | Text Interface | Playlist Editor / Generator | Music Classification | Similar Music | Announce | EventTrigger | Ambient Noise Mixer | DB Optimizer | Image Enhancer | Chiptunes | LMSlib2go | ...
      Various HowTos: build a self-contained LMS | Bluetooth/ALSA | Control LMS with any device | ...

      Comment

      • davemal
        Member
        • Dec 2008
        • 61

        #4
        Thanks

        I will brush up on some shell scripting and have a play.

        Comment

        • bidule
          Member
          • Feb 2008
          • 84

          #5
          Hello Roland,

          Here are the steps I took:

          I installed your plugin from the repository
          I created a conf file
          Code:
          nano /etc/lmseventtrigger.json
          #Test automatic PAUSE behaviour
          {
          "enabled": true,
          "numStatusResults":1,
          "events": [
          {"cmd":"/usr/local/bin/lmsclient.sh","event":[["client"]]},
          {"cmd":"/usr/local/bin/lmsplaylist.sh","event":[["playlist"],["newsong","pause"]]}
          ]
          }
          Nothing happen

          Then I tried as per your wiki to use the url http://10.144.1.1:9000/plugins/LMSeventTrigger/js.html without success
          404 Not Found: plugins/LMSeventTrigger/js.html
          Your help is welcomed.

          Jean
          Last edited by bidule; 2020-12-23, 16:24.

          Comment

          • Roland0
            Senior Member
            • Aug 2012
            • 1343

            #6
            Originally posted by bidule
            I installed your plugin from the repository
            Nothing happen
            - Does the plugin appear in the LMS Web interface > Settings > Plugins > Active plugins list ?
            - If so, switch logging to debug for the plugin (LMS Web interface > Settings > Advanced > Logging > plugin.lmseventtrigger) and check the server log.
            You should have something like:
            Code:
            [20-12-24 08:45:56.3320] Plugins::LMSeventTrigger::Plugin::initPlugin (74) LMSeventTrigger init start
            [20-12-24 08:45:56.3327] Plugins::LMSeventTrigger::Plugin::initSubscriptions (113) LMSeventTrigger: using /usr/local/etc/lmseventtrigger.json
            [20-12-24 08:45:56.3360] Plugins::LMSeventTrigger::Plugin::initSubscriptions (120) LMSeventTrigger: parsed lmseventtrigger.json
            Various SW: Web Interface | Text Interface | Playlist Editor / Generator | Music Classification | Similar Music | Announce | EventTrigger | Ambient Noise Mixer | DB Optimizer | Image Enhancer | Chiptunes | LMSlib2go | ...
            Various HowTos: build a self-contained LMS | Bluetooth/ALSA | Control LMS with any device | ...

            Comment

            • bidule
              Member
              • Feb 2008
              • 84

              #7
              Thank you Rolland,

              Yes the plugin in active.
              Here is a part of the log file
              [20-12-24 09:22:41.5877] Plugins::LMSeventTrigger::Plugin::initPlugin (74) LMSeventTrigger init start
              [20-12-24 09:22:41.5895] Plugins::LMSeventTrigger::Plugin::initSubscription s (110) LMSeventTrigger: using /etc/lmseventtrigger.json
              [20-12-24 09:22:41.5909] Plugins::LMSeventTrigger::Plugin::initSubscription s (122) LMSeventTrigger: error parsing lmseventtrigger.json
              [20-12-24 09:22:41.5919] Plugins::LMSeventTrigger::Plugin::initSubscription s (128) LMSeventTrigger: no valid configuration found, disabling plugin
              [20-12-24 09:22:41.5929] Plugins::LMSeventTrigger::Plugin::initPlugin (85) LMSeventTrigger initialized (v0.0.2)
              Jean

              Comment

              • bidule
                Member
                • Feb 2008
                • 84

                #8
                Hello Rolland,

                I had a look at where any squeezelite.log could be, I'm using DietPi.
                Here is the result:
                /var/lib/dietpi/dietpi-ramlog/storage/squeezelite.log
                /var/log/squeezelite.log
                /var/tmp/dietpi/logs/dietpi-ramlog_store/squeezelite.log
                Three empty files.

                EDIT:
                Sorry this message has no relation to this subject, it is related the other post.


                Jean
                Last edited by bidule; 2020-12-24, 13:01.

                Comment

                • Roland0
                  Senior Member
                  • Aug 2012
                  • 1343

                  #9
                  Originally posted by bidule
                  Here is a part of the log file
                  Log says:
                  Originally posted by LMS log
                  [20-12-24 09:22:41.5909] Plugins::LMSeventTrigger::Plugin::initSubscription s (122) LMSeventTrigger: error parsing lmseventtrigger.json
                  check that lmseventtrigger.json is valid json, has the correct structure and file encoding (Unix line ends, probably UTF-8)
                  Various SW: Web Interface | Text Interface | Playlist Editor / Generator | Music Classification | Similar Music | Announce | EventTrigger | Ambient Noise Mixer | DB Optimizer | Image Enhancer | Chiptunes | LMSlib2go | ...
                  Various HowTos: build a self-contained LMS | Bluetooth/ALSA | Control LMS with any device | ...

                  Comment

                  • Hotti
                    Junior Member
                    • Feb 2015
                    • 11

                    #10
                    Hello,

                    can I use event trigger to execute a script when a certain player is powered on or off?
                    Please, if so, how?

                    Regards, Cules

                    Comment

                    • Roland0
                      Senior Member
                      • Aug 2012
                      • 1343

                      #11
                      Originally posted by Hotti
                      can I use event trigger to execute a script when a certain player is powered on or off?
                      Use the "client disconnect" and "client reconnect" events
                      Various SW: Web Interface | Text Interface | Playlist Editor / Generator | Music Classification | Similar Music | Announce | EventTrigger | Ambient Noise Mixer | DB Optimizer | Image Enhancer | Chiptunes | LMSlib2go | ...
                      Various HowTos: build a self-contained LMS | Bluetooth/ALSA | Control LMS with any device | ...

                      Comment

                      • justjason
                        Member
                        • Jan 2020
                        • 89

                        #12
                        Sending HTTP requests

                        Could I ask , what would be the correct syntax for sending a HTTP request on an event ? For example this
                        Code:
                        http://192.168.1.1/cm?cmnd=Power%20TOGGLE
                        to toggle a Tasmota device, or would I need to wrap this in a shell command ?

                        Comment

                        • Paul Webster
                          Senior Member
                          • Apr 2005
                          • 10339

                          #13
                          I had a look at the homepage linked to from the first post

                          and I did not see anything suggesting that it would automatically handle a command starting with http ... so I guess that you need to launch something and pass in the request as a parameter.
                          For example ... try launching curl or wget

                          Might be better to write a script that does what you want and has some tracing in it (to help diagnose issues) and then have the plugin run your script once the script is working.
                          Paul Webster
                          Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
                          and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

                          Comment

                          • justjason
                            Member
                            • Jan 2020
                            • 89

                            #14
                            I agree , a curl http .... would not be difficult. I will use that.

                            Comment

                            • mh_
                              Member
                              • Oct 2011
                              • 52

                              #15
                              Hi, I'd like to receive a message when a specific player gets powered on or off. I would like to further automate it with e.g. node-red to automatically power on/off an audio system connected to my sb3. Could this be implemented with the existing notification types?

                              Comment

                              Working...