Problem with Rule created with Blockly

  • Platform information: RaspBerry PI 4
  • openHAB version: 4.1.1
  • Script type ECMA Script Edition 11

I have created 2 rules

  1. Sonos_Volume_Down
  2. Sonos_Volum_Up

![Scherm­afbeelding 2024-02-22 om 13.08.05|690x255]strong text(upload://hWeAidp6VG4W2uzOFgdjvCR8Tav.png)

Volume down
Sonos_Volume_Down works fine, every time I press the “volume down” button, the volume level is decreased by 1.

Volume up
When the volume is at level 1, pressing the “volume up” button changes the volume to 11 instead of 2.
When the volume is at level 5, pressing the “volume up” button changes the volume to 51 instead of 6.

It looks like the updated volume is a string rather then a numerical value.
1+ 1 = “11” , 5+1 = “51”

I updated the Sonos_Volume_Up script as shown below

Instead of adding 1, I subtracted -1.
Now, on every press of the “volume up” button, the volume level is increased by 1.

Use get numericState of item instead of get state of item (default is get name of item, where name is a dropdown option)

I made the changes as recommended by you.
Problem has been solved !!

Many thanks for your fast reply.

1 Like