[SOLVED] LED Control

Hello, I am currently using SmartMeter binding and all I want to do for now is setup a GPIO-connected LED to light up whenever the binding is online and shutdown whenever the binding isn’t online.

I have seen that there’s a GPIO Binding but I don’t understand how can I use scripts and rules with that.

So my idea would be something like that:

Loop1: {
LEDPin=Low;

Loop2:{
if Thing changed [from ] {
LEDPin=High
goto Loop2
Else: goto Loop1 } } }

I know the syntax isn’t exactly the same but this is just to simplify what I am trying to achieve.

Thanks

Is this any help?

1 Like

Hello! Thanks for your reply. Unfortunately I have already read this but as I wrote, only the items file was modified here to include an LED and a Switch. But instead of a switch I want to write a script to shutdown the Lamp when the status is changed from online.

What status? Are you referring to an openHAB thing?

Use of “loop” in your psuedocode is not the way to go. openHAB rules are event driven , so it will be more like your text description.
When XX changes to A, turn Q on.
When XX changes to B, turn Q off.

1 Like

Yes exactly, using the SmartMeter binding, I want an LED to turn off when the connection changes from ONLINE to anything else. Do I need to install the GPIO binding or it can be done straight forward with a script.

So for the script you’ve written, I believe, when I write:
When
“Thingxxxx” changes from ONLINE
Then
Turn LED OFF // how can I here indetify the LED in the script?

In openHAB you would normally represent something like a LED as an Item. Probably a Switch type. You would link that Item to a channel of some Thing that would actually control the LED via an appropriate binding. Maybe GPIO for you.

You will find examples of rules responding to Thing status changes in this forum.

1 Like

Thank you! I managed to write a script with the given info here :slight_smile: