Sonos kontroll med z-push4

Hei, noen som kan hjelpe meg med å lage flow for å styre sonos ? Har en heatit z-push 4 som jeg ønsker play/pause, volum opp/ned på :slight_smile:

Har prøvd å rote i tp i dag uten hell

Hei!
Har laget et lite forsøk her så du kan teste ut.
Knapp oppe til venstre: play
Knapp oppe til høyre: pause
Knapp nede til venstre: volume - 5
Knapp nede til høyre: volume + 5
Importer denne;

{
  "Id": "gjOwzhepnLJZVGS",
  "ClassId": "gjOwzhepnLJZVGS",
  "Author": "espenh.no",
  "Version": 0,
  "CreatedAt": "2024-05-06T10:17:36.361087026+02:00",
  "UpdatedAt": "2024-05-06T10:36:49.549024896+02:00",
  "Name": "Sonos - Heatit z-push4",
  "Group": "sonos",
  "Description": "Controls sonos from Heatit Z-Push 4",
  "Nodes": [
    {
      "Id": "1",
      "Type": "trigger",
      "Label": "Volume report",
      "SuccessTransition": "14",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:evt/rt:dev/rn:sonos/ad:1/sv:media_player/ad:{{setting \"sonos.address\"}}",
      "Service": "media_player",
      "ServiceInterface": "evt.volume.report",
      "Config": {
        "ConnectorID": "",
        "InputVariableType": "",
        "IsValueFilterEnabled": false,
        "LookupServiceNameAndLocation": false,
        "PropFilterName": "",
        "PropFilterValue": "",
        "RegisterAsVirtualService": false,
        "Timeout": 0,
        "ValueFilter": {
          "Value": null,
          "ValueType": "int"
        },
        "ValueJPath": "",
        "ValueJPathResultType": "",
        "VirtualServiceGroup": "",
        "VirtualServiceProps": null
      },
      "Ui": {
        "nodeType": "",
        "x": 148,
        "y": 239
      },
      "TypeAlias": "Trigger",
      "LastValue": 20
    },
    {
      "Id": "2",
      "Type": "set_variable",
      "Label": "Update variable",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "DefaultValue": {
          "Value": 0,
          "ValueType": ""
        },
        "IsVariableInMemory": false,
        "Name": "volume",
        "UpdateGlobal": false,
        "UpdateInputMsg": false
      },
      "Ui": {
        "nodeType": "",
        "x": 146,
        "y": 564
      },
      "TypeAlias": "Set variable"
    },
    {
      "Id": "3",
      "Type": "trigger",
      "Label": "Scene report",
      "SuccessTransition": "4",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:evt/rt:dev/rn:zw/ad:1/sv:scene_ctrl/ad:{{setting \"remote.address\"}}_0",
      "Service": "scene_ctrl",
      "ServiceInterface": "evt.scene.report",
      "Config": {
        "IsValueFilterEnabled": false,
        "LookupServiceNameAndLocation": false,
        "RegisterAsVirtualService": false,
        "Timeout": 0,
        "ValueFilter": {
          "Value": "",
          "ValueType": "string"
        },
        "VirtualServiceGroup": "ch_0",
        "VirtualServiceProps": {}
      },
      "Ui": {
        "nodeType": "",
        "x": 844,
        "y": 228
      },
      "TypeAlias": "Trigger",
      "LastValue": "4.0"
    },
    {
      "Id": "4",
      "Type": "if",
      "Label": "1.0",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": [
          {
            "BooleanOperator": "",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "",
            "Operand": "eq",
            "RightVariable": {
              "Value": "1.0",
              "ValueType": "string"
            }
          }
        ],
        "FalseTransition": "5",
        "TrueTransition": "8"
      },
      "Ui": {
        "nodeType": "",
        "x": 481,
        "y": 425
      },
      "TypeAlias": "If condition"
    },
    {
      "Id": "5",
      "Type": "if",
      "Label": "2.0",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": [
          {
            "BooleanOperator": "",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "",
            "Operand": "eq",
            "RightVariable": {
              "Value": "2.0",
              "ValueType": "string"
            }
          }
        ],
        "FalseTransition": "6",
        "TrueTransition": "9"
      },
      "Ui": {
        "nodeType": "",
        "x": 705,
        "y": 422
      },
      "TypeAlias": "If condition"
    },
    {
      "Id": "6",
      "Type": "if",
      "Label": "3.0",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": [
          {
            "BooleanOperator": "",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "",
            "Operand": "eq",
            "RightVariable": {
              "Value": "3.0",
              "ValueType": "string"
            }
          }
        ],
        "FalseTransition": "7",
        "TrueTransition": "11"
      },
      "Ui": {
        "nodeType": "",
        "x": 934,
        "y": 424
      },
      "TypeAlias": "If condition"
    },
    {
      "Id": "7",
      "Type": "if",
      "Label": "4.0",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": [
          {
            "BooleanOperator": "",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "",
            "Operand": "eq",
            "RightVariable": {
              "Value": "4.0",
              "ValueType": "string"
            }
          }
        ],
        "FalseTransition": "",
        "TrueTransition": "12"
      },
      "Ui": {
        "nodeType": "",
        "x": 1167,
        "y": 427
      },
      "TypeAlias": "If condition"
    },
    {
      "Id": "8",
      "Type": "action",
      "Label": "Play",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:cmd/rt:dev/rn:sonos/ad:1/sv:media_player/ad:{{setting \"sonos.address\"}}",
      "Service": "media_player",
      "ServiceInterface": "cmd.playback.set",
      "Config": {
        "DefaultValue": {
          "Value": "play",
          "ValueType": "string"
        },
        "IsVariableGlobal": false,
        "Props": {},
        "RegisterAsVirtualService": false,
        "ResponseToTopic": "",
        "VariableName": "",
        "VirtualServiceGroup": "",
        "VirtualServiceProps": {}
      },
      "Ui": {
        "nodeType": "",
        "x": 466,
        "y": 627
      },
      "TypeAlias": "Action",
      "LastValue": "play"
    },
    {
      "Id": "9",
      "Type": "action",
      "Label": "Pause",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:cmd/rt:dev/rn:sonos/ad:1/sv:media_player/ad:{{setting \"sonos.address\"}}",
      "Service": "media_player",
      "ServiceInterface": "cmd.playback.set",
      "Config": {
        "DefaultValue": {
          "Value": "pause",
          "ValueType": "string"
        },
        "IsVariableGlobal": false,
        "Props": {},
        "RegisterAsVirtualService": false,
        "ResponseToTopic": "",
        "VariableName": "",
        "VirtualServiceGroup": "",
        "VirtualServiceProps": {}
      },
      "Ui": {
        "nodeType": "",
        "x": 698,
        "y": 630
      },
      "TypeAlias": "Action",
      "LastValue": "play"
    },
    {
      "Id": "10",
      "Type": "action",
      "Label": "Vol adjust",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:cmd/rt:dev/rn:sonos/ad:1/sv:media_player/ad:{{setting \"sonos.address\"}}",
      "Service": "media_player",
      "ServiceInterface": "cmd.volume.set",
      "Config": {
        "DefaultValue": {
          "Value": "",
          "ValueType": "int"
        },
        "IsVariableGlobal": false,
        "Props": {},
        "RegisterAsVirtualService": false,
        "ResponseToTopic": "",
        "VariableName": "volume_new",
        "VirtualServiceGroup": "",
        "VirtualServiceProps": {},
        "VariableType": "int"
      },
      "Ui": {
        "nodeType": "",
        "x": 1076,
        "y": 818
      },
      "TypeAlias": "Action",
      "LastValue": 25
    },
    {
      "Id": "11",
      "Type": "transform",
      "Label": "vol - 5",
      "SuccessTransition": "10",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": "volume-5",
        "IsRVariableGlobal": false,
        "LVariableName": "volume",
        "RValue": {
          "Value": 0,
          "ValueType": "int"
        },
        "RVariableName": "",
        "Rtype": "var",
        "TargetVariableName": "volume_new",
        "Template": "",
        "TransformType": "calc",
        "ValueMapping": [],
        "XPathMapping": [],
        "IsLVariableGlobal": false,
        "TargetVariableType": "int",
        "IsTargetVariableGlobal": false,
        "IsTargetVariableInMemory": false
      },
      "Ui": {
        "nodeType": "",
        "x": 931,
        "y": 631
      },
      "TypeAlias": "Transform"
    },
    {
      "Id": "12",
      "Type": "transform",
      "Label": "vol + 5",
      "SuccessTransition": "10",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": "volume+5",
        "IsRVariableGlobal": false,
        "LVariableName": "volume",
        "RValue": {
          "Value": 0,
          "ValueType": "int"
        },
        "RVariableName": "",
        "Rtype": "var",
        "TargetVariableName": "volume_new",
        "Template": "",
        "TransformType": "calc",
        "ValueMapping": [],
        "XPathMapping": [],
        "IsLVariableGlobal": false,
        "TargetVariableType": "int"
      },
      "Ui": {
        "nodeType": "",
        "x": 1166,
        "y": 637
      },
      "TypeAlias": "Transform"
    },
    {
      "Id": "14",
      "Type": "wait",
      "Label": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "SuccessTransition": "2",
      "ErrorTransition": "",
      "Config": 1000,
      "Ui": {
        "x": 145,
        "y": 417,
        "nodeType": ""
      },
      "TypeAlias": "Delay"
    }
  ],
  "Settings": {
    "sonos.address": {
      "Value": "347E5C3E36DC01400",
      "ValueType": "string",
      "Key": "sonos.address",
      "Description": "The address for the sonos device"
    },
    "remote.address": {
      "Value": "660",
      "ValueType": "string",
      "Key": "remote.address",
      "Description": "The address for the remote device"
    }
  },
  "IsDisabled": false,
  "IsDefault": false,
  "ParallelExecution": "parallel"
}

Etter import, åpne flowen og klikk på pensel ikonet.
Fyll ut addressen til Sonos høyttaleren og den trådløse bryteren - disse kan du finne i appen :slight_smile: (Dette er for å slippe å måtte endre på hver node :wink: )
Husk å lagre både i “popup vinduet” og i flowen etterpå.

!! NB !!
Ved hyppig endring av volum så sendes det mange forespørsler til Sonos’ API, som kan resultere i rate-limit (forespørslene blir blokkert da det blir sendt for mange)

1 Like

Tusen takk :blush::+1: testa det nå, fikk play/pause til å fungere, men ikke volum opp/ned. Noen forslag? :blush:

1 Like

Flott :slight_smile:
Kan du sjekke om flow har generert variablere når du importerte? Det er en “show variables” knapp når du har flowen åpen.