[Resolved] Using "For Each" to cycle devices and change attributes


#1

1) Give a description of the problem

I am trying to use a “for each” along with a couple of variables to set the volume individually on each Sonos Player. Is this correct approach?

Note: Currently to test it I am using its External URL to trigger the piston and hardcoding the PlayListSwitchChosen, manually changing it for each test.

This is only part of a larger piston I am working on, but I wanted to get this part working first because I am not quite clear on the use of “for each”. As an FYI, I have individual tested each of the variable expression and they are working.

2) What is the expected behaviour?

The piston cycles through each Player and sets it appropriate volume using lookup expressions based on:

Players’ > PlayerVolumeToSet and PlayerList

Play list’s > PlayListIDList and PlayListSwitchList

Each Player’s Default Volume > DefaultVolumeList and VolumeModifierList

3) What is happening/not happening?

Nothing, the piston is not changing the volume at all. However, if I remove the “Set variable” line and hardcode a value into the setVolume line it works but it of course sets all the Players at the same volume, which is not the desired outcome.

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full

3/25/2021, 2:10:05 PM +606ms
+0ms ╔Received event [My home].execute = 104.206.12.223 with a delay of 257ms
+147ms ║RunTime Analysis CS > 24ms > PS > 17ms > PE > 107ms > CE
+150ms ║Runtime (49180 bytes) successfully initialized in 17ms (v0.3.113.20210203) (149ms)
+151ms ║╔Execution stage started
+162ms ║║Cancelling statement #26’s schedules…
+167ms ║║Executed virtual command [Bedroom Player].setVariable (1ms)
+186ms ║║Executed physical command [Bedroom Player].setVolume([(round(PlayerDefaultVolume)(VolumeModifierChosen))]) (15ms)
+187ms ║║Executed [Bedroom Player].setVolume (17ms)
+195ms ║║Cancelling statement #26’s schedules…
+200ms ║║Executed virtual command [Kitchen Player].setVariable (1ms)
+212ms ║║Executed physical command [Kitchen Player].setVolume([(round(PlayerDefaultVolume)
(VolumeModifierChosen))]) (8ms)
+213ms ║║Executed [Kitchen Player].setVolume (11ms)
+221ms ║║Cancelling statement #26’s schedules…
+225ms ║║Executed virtual command [Laundry Player].setVariable (1ms)
+237ms ║║Executed physical command [Laundry Player].setVolume([(round(PlayerDefaultVolume)(VolumeModifierChosen))]) (9ms)
+238ms ║║Executed [Laundry Player].setVolume (10ms)
+246ms ║║Cancelling statement #26’s schedules…
+251ms ║║Executed virtual command [Living Player].setVariable (1ms)
+274ms ║║Executed physical command [Living Player].setVolume([(round(PlayerDefaultVolume)
(VolumeModifierChosen))]) (19ms)
+275ms ║║Executed [Living Player].setVolume (21ms)
+284ms ║║Cancelling statement #26’s schedules…
+289ms ║║Executed virtual command [Office Player].setVariable (1ms)
+302ms ║║Executed physical command [Office Player].setVolume([(round(PlayerDefaultVolume)(VolumeModifierChosen))]) (9ms)
+303ms ║║Executed [Office Player].setVolume (11ms)
+311ms ║║Cancelling statement #26’s schedules…
+316ms ║║Executed virtual command [Quin Room Player].setVariable (0ms)
+328ms ║║Executed physical command [Quin Room Player].setVolume([(round(PlayerDefaultVolume)
(VolumeModifierChosen))]) (8ms)
+329ms ║║Executed [Quin Room Player].setVolume (10ms)
+337ms ║║Cancelling statement #26’s schedules…
+341ms ║║Executed virtual command [TV Room Player].setVariable (1ms)
+353ms ║║Executed physical command [TV Room Player].setVolume([(round(PlayerDefaultVolume)*(VolumeModifierChosen))]) (9ms)
+354ms ║║Executed [TV Room Player].setVolume (11ms)
+357ms ║╚Execution stage complete. (205ms)
+358ms ╚Event processed successfully (358ms)


#2

First glance, the setVolume parameter looks like it’s being sent as a string.

Edit: Change the field to Expression instead of Value


#3

Thank you @eibyer, I completed missed that configuration requirement.