Sonos speaker - morning play

I don’t want to use my Sonos speaker as a morning alarm (I have other alarms that I prefer), but once I am up and I start my morning routine I like to listen to radio. So I created a TP flow that plays my Sonos when I come into the living room, weekdays, after 6:30 A.M. (it triggers only the first time someone comes into the livingroom that day). I post the code here as inspiration for anybody that may be interested.

{
  "Id": "qalqfZOvblNzC3Y",
  "ClassId": "D7spKRB6EBGPilz",
  "Author": "",
  "Version": 0,
  "CreatedAt": "2020-10-11T08:24:05.309515007+02:00",
  "UpdatedAt": "2020-11-06T00:04:43.170776297+01:00",
  "Name": "Morning Sonos play",
  "Group": "sonos",
  "Description": "Morning Sonos play",
  "Nodes": [
    {
      "Id": "2",
      "Type": "action",
      "Label": "Play Sonos",
      "SuccessTransition": "9",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:cmd/rt:dev/rn:sonos/ad:1/sv:media_player/ad:5CAAFDCBB65601400",
      "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": 364,
        "y": 527
      }
    },
    {
      "Id": "7",
      "Type": "trigger",
      "Label": "Presence in the living room",
      "SuccessTransition": "14",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:evt/rt:dev/rn:zw/ad:1/sv:sensor_presence/ad:23_0",
      "Service": "sensor_presence",
      "ServiceInterface": "evt.presence.report",
      "Config": {
        "IsValueFilterEnabled": true,
        "LookupServiceNameAndLocation": false,
        "RegisterAsVirtualService": false,
        "Timeout": 0,
        "ValueFilter": {
          "Value": true,
          "ValueType": "bool"
        },
        "VirtualServiceGroup": "ch_0",
        "VirtualServiceProps": {}
      },
      "Ui": {
        "nodeType": "",
        "x": 379,
        "y": 338
      }
    },
    {
      "Id": "8",
      "Type": "set_variable",
      "Label": "enb_flow = true",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "DefaultValue": {
          "Value": true,
          "ValueType": "bool"
        },
        "Name": "enb_flow",
        "UpdateGlobal": true,
        "UpdateInputMsg": false
      },
      "Ui": {
        "nodeType": "",
        "x": 69,
        "y": 496
      }
    },
    {
      "Id": "9",
      "Type": "set_variable",
      "Label": "enb_flow = false",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "DefaultValue": {
          "Value": false,
          "ValueType": "bool"
        },
        "Name": "enb_flow",
        "UpdateGlobal": true,
        "UpdateInputMsg": false
      },
      "Ui": {
        "nodeType": "",
        "x": 658,
        "y": 518
      }
    },
    {
      "Id": "14",
      "Type": "if",
      "Label": "end_flow == true",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": [
          {
            "BooleanOperator": "",
            "LeftVariableIsGlobal": true,
            "LeftVariableName": "enb_flow",
            "Operand": "eq",
            "RightVariable": {
              "Value": true,
              "ValueType": "bool"
            }
          }
        ],
        "FalseTransition": "",
        "TrueTransition": "2"
      },
      "Ui": {
        "nodeType": "",
        "x": 630,
        "y": 338
      }
    },
    {
      "Id": "16",
      "Type": "time_trigger",
      "Label": "On 06:30 every weekday",
      "SuccessTransition": "8",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "DefaultMsg": {
          "Value": "",
          "ValueType": ""
        },
        "Expressions": [
          {
            "Comments": "",
            "Expression": "30 6 * * 1,2,3,4,5",
            "Name": "On 06:30 every weekday"
          }
        ],
        "GenerateAstroTimeEvents": false,
        "Latitude": 0,
        "Longitude": 0,
        "SunriseTimeOffset": 0,
        "SunsetTimeOffset": 0
      },
      "Ui": {
        "nodeType": "",
        "x": 76,
        "y": 309
      }
    }
  ],
  "Settings": null,
  "IsDisabled": false,
  "IsDefault": false,
  "ParallelExecution": "keep_last"
}
4 Likes

Hi, and welcome to the forum :slight_smile:
Nice example :smiley:

On my flow for Sonos speaker in the bathroom, I use the mirror light as trigger (as it only turns on by motion in home mode, but can manually turn on in sleep mode if I want). When it’s turned off I also reset te volume for next time someone goes into the bathroom :wink:

2 Likes

Set volume … ? What is the source code for that action? I only managed to do play/pause.

You have a full overview of what the media_player service can do here:


For the flow mentioned above here is the source code:

{
  "Id": "7i3QP3PwMv6Y2eG",
  "ClassId": "7i3QP3PwMv6Y2eG",
  "Author": "espenh.no",
  "Version": 0,
  "CreatedAt": "2020-07-05T19:22:52.311888789+02:00",
  "UpdatedAt": "2020-08-29T13:47:41.69831476+02:00",
  "Name": "sonos_bad on when speil is on",
  "Group": "sonos",
  "Description": "sonos_bad on when speil is on",
  "Nodes": [
    {
      "Id": "1",
      "Type": "trigger",
      "Label": "speil evt.binary.report",
      "SuccessTransition": "2",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:evt/rt:dev/rn:zw/ad:1/sv:out_bin_switch/ad:22_1",
      "Service": "out_bin_switch",
      "ServiceInterface": "evt.binary.report",
      "Config": {
        "InputVariableType": "",
        "IsValueFilterEnabled": false,
        "LookupServiceNameAndLocation": false,
        "PropFilterName": "",
        "PropFilterValue": "",
        "RegisterAsVirtualService": false,
        "Timeout": 0,
        "ValueFilter": {
          "Value": null,
          "ValueType": ""
        },
        "ValueJPath": "",
        "ValueJPathResultType": "",
        "VirtualServiceGroup": "",
        "VirtualServiceProps": null
      },
      "Ui": {
        "nodeType": "",
        "x": 70,
        "y": 170
      }
    },
    {
      "Id": "2",
      "Type": "if",
      "Label": "if home or sleep",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": [
          {
            "BooleanOperator": "or",
            "LeftVariableIsGlobal": true,
            "LeftVariableName": "fh.home.mode",
            "Operand": "eq",
            "RightVariable": {
              "Value": "home",
              "ValueType": "string"
            }
          },
          {
            "BooleanOperator": "",
            "LeftVariableIsGlobal": true,
            "LeftVariableName": "fh.home.mode",
            "Operand": "eq",
            "RightVariable": {
              "Value": "sleep",
              "ValueType": "string"
            }
          }
        ],
        "FalseTransition": "",
        "TrueTransition": "9"
      },
      "Ui": {
        "nodeType": "",
        "x": 76,
        "y": 322
      }
    },
    {
      "Id": "9",
      "Type": "if",
      "Label": "if true",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": [
          {
            "BooleanOperator": "",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "",
            "Operand": "eq",
            "RightVariable": {
              "Value": true,
              "ValueType": "bool"
            }
          }
        ],
        "FalseTransition": "10",
        "TrueTransition": "11"
      },
      "Ui": {
        "nodeType": "",
        "x": 79,
        "y": 518
      }
    },
    {
      "Id": "10",
      "Type": "if",
      "Label": "if false",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": [
          {
            "BooleanOperator": "",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "",
            "Operand": "eq",
            "RightVariable": {
              "Value": false,
              "ValueType": "bool"
            }
          }
        ],
        "FalseTransition": "",
        "TrueTransition": "12"
      },
      "Ui": {
        "nodeType": "",
        "x": 272,
        "y": 520
      }
    },
    {
      "Id": "11",
      "Type": "action",
      "Label": "set playback play",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:cmd/rt:dev/rn:sonos/ad:1/sv:media_player/ad:347E5C3E36DC01400",
      "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": 66,
        "y": 717
      }
    },
    {
      "Id": "12",
      "Type": "action",
      "Label": "set playback pause",
      "SuccessTransition": "13",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:cmd/rt:dev/rn:sonos/ad:1/sv:media_player/ad:347E5C3E36DC01400",
      "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": 282,
        "y": 717
      }
    },
    {
      "Id": "13",
      "Type": "action",
      "Label": "set volume 10%",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:cmd/rt:dev/rn:sonos/ad:1/sv:media_player/ad:347E5C3E36DC01400",
      "Service": "media_player",
      "ServiceInterface": "cmd.volume.set",
      "Config": {
        "DefaultValue": {
          "Value": 10,
          "ValueType": "int"
        },
        "IsVariableGlobal": false,
        "Props": {},
        "RegisterAsVirtualService": false,
        "ResponseToTopic": "",
        "VariableName": "",
        "VirtualServiceGroup": "",
        "VirtualServiceProps": {}
      },
      "Ui": {
        "nodeType": "",
        "x": 279,
        "y": 875
      }
    }
  ],
  "Settings": null,
  "IsDisabled": false,
  "IsDefault": false,
  "ParallelExecution": "keep_last"
}
1 Like

Min Sonos-morning play flow funker igrunn fint -den setter volumn og starter den. Eg kunne dog tenkt meg å ta den til neste nivå, og det innebærer å sette kva som skal spilles av -eks. viss nokon andre hustandsmedlemmer har fikla med radiokanalen min på de 3 sonos-playerene eg starter kvelden i forveien, så får eg jo ikkje morgon spelinga mi. Er det nokon som veit korleis eg kan sette eksplisitt det eg vil starte (ikkje bare sette “play”)?

According to the link @espen posted above, there are cmd.favorites.set and cmd.playlists.set available, but I am not sure how to use them. Maybe he does.

Eg har tatt dette eitt steg lenger, ved at eg har definert 1 favoritt. Bruker Heatit Z-push button 8 som fjernkontroll - ved enkelttrykk på knappen øverst til venstre startar den å spela frå der den var sist, mens ved å halda inne spelar den favoritten (definert som global variabel). Prøv om du kan henta noko inspirasjon ut frå denne koden:

{
  "Id": "GhwZqP1fQA6Uas1",
  "ClassId": "8ovjy2o7llwhMcJ",
  "Author": "",
  "Version": 0,
  "CreatedAt": "2020-11-19T20:24:33.40963368+01:00",
  "UpdatedAt": "2020-11-29T09:31:53.458934863+01:00",
  "Name": "Panel stue Sonos",
  "Group": "remote",
  "Description": "",
  "Nodes": [
    {
      "Id": "1",
      "Type": "action",
      "Label": "Play Stue",
      "SuccessTransition": "15",
      "TimeoutTransition": "",
      "ErrorTransition": "15",
      "Address": "pt:j1/mt:cmd/rt:dev/rn:sonos/ad:1/sv:media_player/ad:000E58B2AA6901400",
      "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": 76,
        "y": 627
      },
      "TypeAlias": "Action"
    },
    {
      "Id": "2",
      "Type": "trigger",
      "Label": "bryter",
      "SuccessTransition": "3",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:evt/rt:dev/rn:zw/ad:1/sv:scene_ctrl/ad:108_0",
      "Service": "scene_ctrl",
      "ServiceInterface": "evt.scene.report",
      "Config": {
        "IsValueFilterEnabled": false,
        "LookupServiceNameAndLocation": false,
        "RegisterAsVirtualService": false,
        "Timeout": 0,
        "ValueFilter": {
          "Value": "",
          "ValueType": "bool"
        },
        "VirtualServiceGroup": "ch_0",
        "VirtualServiceProps": {}
      },
      "Ui": {
        "nodeType": "",
        "x": 69,
        "y": 205
      },
      "TypeAlias": "Trigger"
    },
    {
      "Id": "3",
      "Type": "if",
      "Label": "scene=1.x",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": [
          {
            "BooleanOperator": "or",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "",
            "Operand": "eq",
            "RightVariable": {
              "Value": "1.0",
              "ValueType": "string"
            }
          },
          {
            "BooleanOperator": "",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "",
            "Operand": "eq",
            "RightVariable": {
              "Value": "1.2",
              "ValueType": "string"
            }
          }
        ],
        "FalseTransition": "4",
        "TrueTransition": "1"
      },
      "Ui": {
        "nodeType": "",
        "x": 65,
        "y": 425
      },
      "TypeAlias": "If condition"
    },
    {
      "Id": "4",
      "Type": "if",
      "Label": "scene=2.x",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": [
          {
            "BooleanOperator": "or",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "",
            "Operand": "eq",
            "RightVariable": {
              "Value": "2.0",
              "ValueType": "string"
            }
          },
          {
            "BooleanOperator": "",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "",
            "Operand": "eq",
            "RightVariable": {
              "Value": "2.2",
              "ValueType": "string"
            }
          }
        ],
        "FalseTransition": "8",
        "TrueTransition": "5"
      },
      "Ui": {
        "nodeType": "",
        "x": 332,
        "y": 428
      },
      "TypeAlias": "If condition"
    },
    {
      "Id": "5",
      "Type": "action",
      "Label": "Pause Stue",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:cmd/rt:dev/rn:sonos/ad:1/sv:media_player/ad:000E58B2AA6901400",
      "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": 335,
        "y": 619
      },
      "TypeAlias": "Action"
    },
    {
      "Id": "7",
      "Type": "set_variable",
      "Label": "volume",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "DefaultValue": {
          "Value": 0,
          "ValueType": ""
        },
        "Name": "",
        "UpdateGlobal": false,
        "UpdateInputMsg": false
      },
      "Ui": {
        "nodeType": "",
        "x": 1059,
        "y": 558
      },
      "TypeAlias": "Set variable"
    },
    {
      "Id": "8",
      "Type": "if",
      "Label": "scene=3.x",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": [
          {
            "BooleanOperator": "or",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "",
            "Operand": "eq",
            "RightVariable": {
              "Value": "3.0",
              "ValueType": "string"
            }
          },
          {
            "BooleanOperator": "",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "",
            "Operand": "eq",
            "RightVariable": {
              "Value": "3.2",
              "ValueType": "string"
            }
          }
        ],
        "FalseTransition": "11",
        "TrueTransition": "23"
      },
      "Ui": {
        "nodeType": "",
        "x": 573,
        "y": 430
      },
      "TypeAlias": "If condition"
    },
    {
      "Id": "9",
      "Type": "action",
      "Label": "cmd.volume.set",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:cmd/rt:dev/rn:sonos/ad:1/sv:media_player/ad:000E58B2AA6901400",
      "Service": "media_player",
      "ServiceInterface": "cmd.volume.set",
      "Config": {
        "DefaultValue": {
          "Value": "play",
          "ValueType": "int"
        },
        "IsVariableGlobal": false,
        "Props": {},
        "RegisterAsVirtualService": false,
        "ResponseToTopic": "",
        "VariableName": "volume",
        "VariableType": "int",
        "VirtualServiceGroup": "",
        "VirtualServiceProps": {}
      },
      "Ui": {
        "nodeType": "",
        "x": 572,
        "y": 1177
      },
      "TypeAlias": "Action"
    },
    {
      "Id": "10",
      "Type": "transform",
      "Label": "volume: +2",
      "SuccessTransition": "22",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": "variable+2",
        "IsLVariableGlobal": false,
        "IsRVariableGlobal": false,
        "IsTargetVariableGlobal": false,
        "IsTargetVariableInMemory": false,
        "LVariableName": "volume",
        "RValue": {
          "Value": 0,
          "ValueType": "int"
        },
        "RVariableName": "",
        "Rtype": "var",
        "TargetVariableName": "volume",
        "TargetVariableType": "int",
        "Template": "",
        "TransformType": "calc",
        "ValueMapping": [],
        "XPathMapping": []
      },
      "Ui": {
        "nodeType": "",
        "x": 515,
        "y": 770
      },
      "TypeAlias": "Transform"
    },
    {
      "Id": "11",
      "Type": "if",
      "Label": "scene=4.x",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": [
          {
            "BooleanOperator": "or",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "",
            "Operand": "eq",
            "RightVariable": {
              "Value": "4.0",
              "ValueType": "string"
            }
          },
          {
            "BooleanOperator": "",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "",
            "Operand": "eq",
            "RightVariable": {
              "Value": "4.2",
              "ValueType": "string"
            }
          }
        ],
        "FalseTransition": "",
        "TrueTransition": "24"
      },
      "Ui": {
        "nodeType": "",
        "x": 789,
        "y": 431
      },
      "TypeAlias": "If condition"
    },
    {
      "Id": "12",
      "Type": "transform",
      "Label": "volume: -2",
      "SuccessTransition": "22",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": "variable-2",
        "IsLVariableGlobal": false,
        "IsRVariableGlobal": false,
        "IsTargetVariableGlobal": false,
        "IsTargetVariableInMemory": false,
        "LVariableName": "volume",
        "RValue": {
          "Value": 0,
          "ValueType": "int"
        },
        "RVariableName": "",
        "Rtype": "var",
        "TargetVariableName": "volume",
        "TargetVariableType": "int",
        "Template": "",
        "TransformType": "calc",
        "ValueMapping": [],
        "XPathMapping": []
      },
      "Ui": {
        "nodeType": "",
        "x": 764,
        "y": 775
      },
      "TypeAlias": "Transform"
    },
    {
      "Id": "15",
      "Type": "if",
      "Label": "scene=1.2",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": [
          {
            "BooleanOperator": "",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "",
            "Operand": "eq",
            "RightVariable": {
              "Value": "1.2",
              "ValueType": "string"
            }
          }
        ],
        "FalseTransition": "",
        "TrueTransition": "16"
      },
      "Ui": {
        "nodeType": "",
        "x": 124,
        "y": 798
      },
      "TypeAlias": "If condition"
    },
    {
      "Id": "16",
      "Type": "action",
      "Label": "Play favourite",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:cmd/rt:dev/rn:sonos/ad:1/sv:media_player/ad:000E58B2AA6901400",
      "Service": "media_player",
      "ServiceInterface": "cmd.favorites.set",
      "Config": {
        "DefaultValue": {
          "Value": "",
          "ValueType": "string"
        },
        "IsVariableGlobal": true,
        "Props": {},
        "RegisterAsVirtualService": false,
        "ResponseToTopic": "",
        "VariableName": "sonos_favourite",
        "VariableType": "string",
        "VirtualServiceGroup": "",
        "VirtualServiceProps": {}
      },
      "Ui": {
        "nodeType": "",
        "x": 40,
        "y": 971
      },
      "TypeAlias": "Action"
    },
    {
      "Id": "20",
      "Type": "trigger",
      "Label": "evt.volume.report",
      "SuccessTransition": "21",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "pt:j1/mt:evt/rt:dev/rn:sonos/ad:1/sv:media_player/ad:000E58B2AA6901400",
      "Service": "media_player",
      "ServiceInterface": "evt.volume.report",
      "Config": {
        "IsValueFilterEnabled": false,
        "LookupServiceNameAndLocation": false,
        "RegisterAsVirtualService": false,
        "Timeout": 0,
        "ValueFilter": {
          "Value": "",
          "ValueType": "int"
        },
        "VirtualServiceGroup": "ch_0",
        "VirtualServiceProps": {}
      },
      "Ui": {
        "nodeType": "",
        "x": 1019,
        "y": 143
      },
      "TypeAlias": "Trigger"
    },
    {
      "Id": "21",
      "Type": "wait",
      "Label": "10s",
      "SuccessTransition": "7",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": 10000,
      "Ui": {
        "nodeType": "",
        "x": 1009,
        "y": 369
      },
      "TypeAlias": "Delay"
    },
    {
      "Id": "22",
      "Type": "wait",
      "Label": "0.3s",
      "SuccessTransition": "9",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": 300,
      "Ui": {
        "nodeType": "",
        "x": 584,
        "y": 985
      },
      "TypeAlias": "Delay"
    },
    {
      "Id": "23",
      "Type": "if",
      "Label": "volume<98",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": [
          {
            "BooleanOperator": "",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "volume",
            "Operand": "lt",
            "RightVariable": {
              "Value": 98,
              "ValueType": "int"
            }
          }
        ],
        "FalseTransition": "",
        "TrueTransition": "10"
      },
      "Ui": {
        "nodeType": "",
        "x": 558,
        "y": 618
      },
      "TypeAlias": "If condition"
    },
    {
      "Id": "24",
      "Type": "if",
      "Label": "volume>2",
      "SuccessTransition": "",
      "TimeoutTransition": "",
      "ErrorTransition": "",
      "Address": "",
      "Service": "",
      "ServiceInterface": "",
      "Config": {
        "Expression": [
          {
            "BooleanOperator": "",
            "LeftVariableIsGlobal": false,
            "LeftVariableName": "volume",
            "Operand": "gt",
            "RightVariable": {
              "Value": 2,
              "ValueType": "int"
            }
          }
        ],
        "FalseTransition": "",
        "TrueTransition": "12"
      },
      "Ui": {
        "nodeType": "",
        "x": 785,
        "y": 613
      },
      "TypeAlias": "If condition"
    }
  ],
  "Settings": null,
  "IsDisabled": false,
  "IsDefault": false,
  "ParallelExecution": "keep_last"
}

For å finna ut kva id du skal setja favorittvariabelen til, må du finna ein måte trigga cmd.playlists.get_report, og ta ein titt på rapporten i message stream.

Ja, eg formoda igrunn at eg måtte lytte på cmd.favorites.get_report, men eg har lytta på omtrent alle api’er i message stream, har sjekka githubs repository for kva props eg har tilgang til, og sågar lytta på console-loggeren i nettleseren (code-behind) -men det kjem ingenting ut, tross i at eg har ei liste med favoritter i Sonos…

Så lurer på om det er noko eg spesielt må tenke på? Kan eg bare ha 1 favoritt for at det skal få tilslag i message streamen? Må eg ungroupe Sonos-enheter? Må eg velge 1 spesifikk Sonos-enhet?

eks.
cmd.favorites.get_report

eks.
cmd.playlists.get_report

Det går stadig framover med meg… no fant eg infoen eg trenger i “Message viewer” for eventen i Message Stream. Då kan det vera eg finner ut av det etterkvart. Avblås alle aksjoner inntil videre :wink:

1 Like

Takker for innspel -då får eg satt favoritten min :slight_smile: (og har fått rydda i favorittlista på Sonos…)

Veit nokon også om det er mogleg å gruppere Sonos-enheter som har blitt un-grouped?

Det er høgt oppe på mi ynskjeliste. Men per i dag ikkje mulig uten å kjøra flow via separat server, feks Node Red:

1 Like

Hmm, ok. Sjølv om eg er utvikler, blir det litt too much hassel. Då får det stå sin prøve enn så lenge.

1 Like

OK, enn så lenge kan du stemma på denne feature requesten

1 Like

Vil du dele denne?

Den ligger i post 4 :slight_smile:

Hei!

Takk for flott kildekode til inspirsajson.
Jeg er ganske fersk i dette “gamet” og leker meg litt med styring av Sonos.
Har fått hentet ut cmd.favorites.get_report og sett på denne i message streams.

Sliter med hvordan jeg skal definere den globale variablen.
Har du noen tips til hvordan jeg skal sette denne? Legger ved koden fra Message Streams.

Ønsker at den skal spille P4 når jeg utløser en scene, og ikke “det siste som ble spilt”.
Har forsøkt og lege en Flow med din kode som inspirasjon (cmd.favorites.set)
men får den ikke til og sette favoritten.
Mistenker at jeg gjør noe feil i min globale variabel.

{
  "serv": "media_player",
  "type": "evt.favorites.report",
  "val_t": "object",
  "val": [
    {
      "id": "4",
      "name": "Daily Mix 1",
      "description": "Spotify spilleliste",
      "imageUrl": "https://dailymix-images.scdn.co/v2/img/b743a5f809f671be6a60f79aa662f9332e3d749e/1/en/default",
      "service": {
        "name": "Spotify",
        "id": "9"
      }
    },
    {
      "id": "5",
      "name": "P4 Radio Hele Norge",
      "description": "TuneIn stasjon",
      "imageUrl": "http://cdn-profiles.tunein.com/s6728/images/logoq.jpg?t=155713",
      "service": {
        "name": "TuneIn",
        "id": "254"
      }
    }
  ],
  "props": null,
  "tags": null,
  "src": "-",
  "ver": "1",
  "uid": "250334df-276f-4aba-ac3f-c2ef6ac3828a",
  "topic": "pt:j1/mt:evt/rt:dev/rn:sonos/ad:1/sv:media_player/ad:5CAAFD45C83201400"
}

Om eg hugsar rett set du variabelen i action noden (cmd.favorites.set). Global variabel er beste praksis, men du kan godt definera favoritten direkte i flowen mens du prøver deg fram.
I ditt tilfelle skal du iallfall setja default value “5” (string) for kanal P4.

Takk for tilbakemelding… fant ut at det var ID’n og ikke navnet jeg måtte legge inn :slight_smile: :see_no_evil:

1 Like