Skip to content

onevent script abort condition when status changes (to prevent execution) to trigger smart wall socket #908

@microfx

Description

@microfx

Hey!

Using the onevent feature for quite a time now but never managed to make it work properly to shut down my smart wall socket after pressing pause (and then leaving home) – which results in my speaker to stay powered on (which is obviously not very smart). So I reworked it a bit and now seems to work ... but now when I press pause and then press play again the script will trigger anyways. Which is also a problem (pressing play / pause sequentially a few times will trigger the scripts as many times as pressed...).

My script currently looks like this:

#!/bin/bash
if [[ "$PLAYER_EVENT" = @("playing"|"preloading"|"started") ]]; then
  curl -d "" http://microlabs-p1:8123/api/webhook/p3_airplay_on 
elif [ "$PLAYER_EVENT" = "stopped" ]; then
  curl -d "" http://microlabs-p1:8123/api/webhook/p3_airplay_off
elif [ "$PLAYER_EVENT" = "paused" ]; then
  sleep 10
  curl -d "" http://microlabs-p1:8123/api/webhook/p3_airplay_off
fi

I figure I need another condition after sleep 10 to exit further execution of the script. Any idea how I can achieve this? Some kind of sub if-condition? Is that possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions