Get the previousState / triggeringItem with Blocky (use one script / rule for multiple equipments / points / devices)

Hi all,

I’ve just read some things here about design patterns.
What I want to achieve is a general Rule that applies for all Hue Dimmer switches in my house.
Like if the on button is pressed again the color is changing …

Now I wonder if this can be done with Blocky because I’ve never seen a tutorial like that.
I’ve just seen examples in DSL and Pyton here:(BTW great tutorial).


Blockly doesn’t appear to support splitting Strings yet so you can’t use the same approach as is used in these examples. And Blockly really isn’t intended to address advanced approaches like this.

That doesn’t necessarily mean you can’t write one rule that works for all the Items in Blockly. You’ll just need to find a way to figure out what Item triggered the rule and construct the name of the other Items you need to interact with based on the triggering Item’s name or some other attribute of the Item.

HI @rlkoshak,

Thanks for that information. splitting strings is not an issue. I did this by removing the unit " %". (see below)
The main issue is that I cannot get the “Trigger” items name.
Is there an example to receive this (in Blocky or in JS) I just found examples in DSL and Python.


FrankS I found with Blocky you can get it to write much of the code for you. Then when you switch to the code window you can hopefully be 85% of the way to your completed code, just tailor to your liking at the end.

It looks like access to event which holds all the implicit variables is not yet supported in Blockly.

A small update: Blockly now contains all kinds of contextual info like triggeringItem, new state, previous state, triggered channel…
A lot of stuff was added in the openhab category and even more is available at the marketplace

1 Like

In stable or snapshot? Would you mind sharing howto access triggeringItem?

Finally found it, unfortunately still to new to some concepts of openhab.

In blockly, openHAB → Run & Process → contextual info (choose triggering item name)