Step by step guide to run a script from habPanel

I use openHAB 3.3.0

I have a simple script to turn a lamp back to a bright white after it was set to another color, the script runs correctly if I start it from settings > scripts.

events.sendCommand('WZ_Farbe', '0,0,100');
events.sendCommand('WZ_Temp', '75');

I want to run the script by pressing a button in HABPanel. I read that I need to define an item and a rule that triggers when the item is changed and then connect the new item to a button in HABPanel.

However I seem to be missing a step or have made a mistake or missed a step. Could someone give me a step by step description of what I need to do, including which type the Item should have, etc. (or if there’s a simpler way to trigger the script)

thanks in advance

First of all, please review/re-review Rules | openHAB and possibly the rules section of the Getting Started Tutorial so you have a good foundational understanding of Rules and Scripts and the parts of a Rule. A Script is a Rule lacking any triggers and conditions. You want a Rule with a Trigger.

  1. Create the Item. Could be anything but a Switch make se sense. See Semantic Model | openHAB for several ways to do that through MainUI.

  2. Create an “advanced” rule: Rules - Advanced | openHAB. You will create a trigger that runs the rule when your Item created in 1 receives an ON command (assuming you chose a Switch). You’ll create a Script Action and put the code above into that script action. That’s the code that will be run when the Rule is triggered.

  3. Create your whatever in HABPanel that sends an ON command to the Item created in 1 when it’s clicked.