Velbus binding for OpenHAB

Does Cédric’s latest version help you?

Great work @Daniel615be!
Don’t hesitate to ask if you have questions about the code.

Once you’re confident enough about your changes, you can initiate a PR to get your code back to the official openHab repository.

Regards,
Cédric

2 Likes

Stuart,
the latest version, posted yesterday, works. I only tested the analog input, so only that part can be confirmed. I’ll test the analog out one of these days

1 Like

HI,

I’m trying to get my Ikea lamps to work with an input from VMBGPOD. The bridge is up and I see the POD… my ikea lamp is also connected and working through openhab.

Then I created 2 rules:
when channel velbus:vmbgpod:input:CH1 was triggered
send command 72,100,100 to Ikea_color
but only if Ikea_color = OFF

and
when channel velbus:vmbgpod:input:CH1 was triggered
send command OFF to Ikea_color
but only if Ikea_color = ON

When running these rules manually (pressing > in the GUI) the light goes on and off… but it doesnt respond to the press of a button on CH1 in the logs I do see:

2021-06-03 19:51:34.164 [INFO ] [openhab.event.ChannelTriggeredEvent ] - velbus:vmbgpod-2:7f964e441a:02:input#CH1 triggered PRESSED
2021-06-03 19:51:34.324 [INFO ] [openhab.event.ChannelTriggeredEvent ] - velbus:vmbgpod-2:7f964e441a:02:input#CH1 triggered RELEASED

but no further actions…

Does anyone have a 123 easy guide to follow? (I’m new at this…)

Hi

Can you paste in the exact rules you’re using please?

(Don’t forget to use the code formatting, so that we see the rules correctly


)

It might also be useful for us to read the exact content of the Events.log that shows the button activity.

One hint is that you haven’t conditioned the trigger.

Meaning your rule might be getting run twice.

Once when the button is pressed and again when it is released


Are you using a graphical rules method, or a text file?

For what you looking for, it might be easier to learn how the text file rules work.

There is a section in this video that very briefly goes into it.

https://forumtest.velbus.eu/t/how-to-setup-dietpi-debian-linux-with-openhab-node-red-and-velbus/16114

You might like to read the PDF mentioned in that post :sunglasses:

Simple DSL rule https://youtu.be/TqZquvxN_aQ?t=1323


Now that openHAB3 is out, I guess I need to make another video…

Hi,

Thxn for the answer!.. I’m using Openhab3 and indeed it was the condition, it seems the IKEA lights dont expose ON/OFF but 0,0,0 or anything else (depending on color etc). So setting the condition to == 0,0,0 => ON and != 0,0,0 => OFF worked

but then, I got in trouble when I tried to make the long press option work… as it would always initialize a PRESSED before sending a LONG_PRESSED - in short, if the device was on and I wanted to make a dim on long-press, it would go off first… making the dim unusable…

so I’m now playing with Blockly that kinda works now…

I’m rather new at this… so learning a lot …

the goal is to have:
CH1 (PRESSED) == on/off
CH1 (LONG_PRESSED) == DIM UP or DIM DOWN
CH2 (PRESSED) == preset color
CH2 (LONG_PRESSED) == rotate colors

But how to find out which commands I can send to an item? is there a query I can make on what it supports? (like on/off - x,y,x - dimup/dimdown - etc?)

In that case, a massive congratulations is in order. :confetti_ball:

You’ve achieved greatness in your first outing.

But… By doing that and moving on to the whole Long_Press to dim issue, you’ve opened a can of worms.

However, I read somewhere recently of a method that might interest you.

Instead of triggering your rules with Pressed or Long_Pressed, try triggering them with Released & Long_Pressed.

But!!!
Make use of a variable that is changed by the Pressed & Long_Pressed trigger.

The work flow might be to refer to the previous state of the trigger.

As in, when a rule is triggered by Released it checks the previous state.

If previous state was Pressed, then switch on or off.

If current state is Long_Pressed, do your magic with the dimming.

That’s a very different question.

It very much depends on the binding for that device in openHAB3.

If you go to the Item for the colour device, which options does it give you?

For example, if you look at a Velbus Thermostat mode Item, it’ll show you the 4 valid states.

Are there any hints in here?

You could try something like…

If long pressed.

And you want it to dim up.

Query current %

Add 10%

Send new command ikea_brightness.sendCommand(ikea_brightness.state + 10)

I’d be very interested in seeing what you come up with.


FYI

You might find this interesting

Got it sort of to work, but the system is still doing some crazy stuff… the log:

21:45:23.906 [INFO ] [org.openhab.core.model.script.TEST   ] - Test fired! LONG_PRESSED
21:45:23.917 [INFO ] [org.openhab.core.model.script.IKEA   ] - IKEA_Color=124,69,59
21:45:23.928 [INFO ] [org.openhab.core.model.script.IKEA   ] - IKEA_Color_HUE=134
21:45:23.935 [INFO ] [org.openhab.core.model.script.IKEA   ] - IKEA_Color_SATURATION=69
21:45:23.942 [INFO ] [org.openhab.core.model.script.IKEA   ] - IKEA_Color_BRIGHNTESS=59
21:45:23.951 [INFO ] [org.openhab.core.model.script.IKEA   ] - IKEA_Color_BRIGHNTESS DIM DOWN
21:45:23.962 [INFO ] [org.openhab.core.model.script.IKEA   ] - IKEA_Color_BRIGHNTESS=49
21:45:23.972 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'IKEA_Color' received command 134,69,49
21:45:23.980 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'IKEA_Color' predicted to become 134,69,49
21:45:23.989 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'IKEA_Color' changed from 124,69,59 to 134,69,49
21:45:24.027 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'IKEA_Color' changed from 134,69,49 to 133,69,59
21:45:24.630 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'IKEA_Color' changed from 133,69,59 to 133,69,49
21:45:24.973 [INFO ] [org.openhab.core.model.script.IKEA   ] - IKEA_Color_BRIGHNTESS DIM DOWN NEXT
21:45:24.985 [ERROR] [.internal.handler.ScriptActionHandler] - Script execution of rule with UID 'myrules-2' failed: An error occurred during the script execution: Could not invoke method: org.openhab.core.model.script.lib.NumberExtensions.operator_greaterThan(org.openhab.core.types.Type,java.lang.Number) on instance: null in myrules
21:45:27.838 [INFO ] [openhab.event.ChannelTriggeredEvent  ] - velbus:vmbgpod-2:7f964e441a:02:input#CH1 triggered RELEASED

As you can see, the DIM down actually is invoked and the light dims, but as soon as it reaches below 30 it goes back to the other loop (and essentially goes to the other statement) as it now tries to brighten it up again - and fluctuates between the 30 mark

ideas?

var ButtonLong=false
var ButtonDown=false

rule “Test short press”
when
Channel ‘velbus:vmbgpod-2:7f964e441a:02:input#CH1’ triggered PRESSED
then
ButtonLong=false
var IKEA_state = IKEA_Color.state()
logInfo(“IKEA”,"IKEA detected on with luminosity " + IKEA_state.toString)
end

rule “Test long press”
when
Channel ‘velbus:vmbgpod-2:7f964e441a:02:input#CH1’ triggered LONG_PRESSED
then
logInfo(“TEST”, “Test fired! LONG_PRESSED”)
ButtonLong=true
ButtonDown=true
if (IKEA_Color.state.toString != “0,0,0”) {
var HSBType hsbValue = IKEA_Color.state as HSBType
logInfo(“IKEA”, “IKEA_Color=” + hsbValue)
var DecimalType hue = new DecimalType(hsbValue.hue.intValue % 360 + 10) // 0-360; 0=red, 120=green, 240=blue, 360=red(again)
var PercentType sat = new PercentType(hsbValue.saturation.intValue) // 0-100
var PercentType bright = new PercentType(hsbValue.brightness.intValue) // 0-100
logInfo(“IKEA”, “IKEA_Color_HUE=” + hue)
logInfo(“IKEA”, “IKEA_Color_SATURATION=” + sat)
logInfo(“IKEA”, “IKEA_Color_BRIGHNTESS=” + bright)
if (bright <30) {
logInfo(“IKEA”, “IKEA_Color_BRIGHNTESS DIM UP”)
while(bright < 100 && ButtonDown == true) {
bright = bright + 10
logInfo(“IKEA”, “IKEA_Color_BRIGHNTESS=” + bright)
var newStatus = hue+“,”+sat+“,”+bright
IKEA_Color.sendCommand(newStatus)
Thread::sleep(1000)
}
}
if (bright >30 ) {
logInfo(“IKEA”, “IKEA_Color_BRIGHNTESS DIM DOWN”)
while(bright < 100 && bright > 10 && ButtonDown == true) {
bright = bright - 10
logInfo(“IKEA”, “IKEA_Color_BRIGHNTESS=” + bright)
var newStatus = hue+“,”+sat+“,”+bright
IKEA_Color.sendCommand(newStatus)
Thread::sleep(1000) // one minute
logInfo(“IKEA”, “IKEA_Color_BRIGHNTESS DIM DOWN NEXT”)
}
}
}
end

rule “Test release”
when
Channel ‘velbus:vmbgpod-2:7f964e441a:02:input#CH1’ triggered RELEASED
then
ButtonDown = false
if (ButtonLong==false){
logInfo(“IKEA”, “Test fired! PRESSED”)
if (IKEA_Color.state.toString == “0,0,0”) {
IKEA_Color.sendCommand(“ON”)
}
else{
IKEA_Color.sendCommand(“OFF”)
}
}
ButtonLong=false
end

I’ll have a think, but you might be better off pitching this on the openHAB forum, as the rules experts live there. :wink:


FYI

Thread::sleep(1000) // 1000 x 1ms = 1 second

Got it working (in OH3)… the full code:

var ButtonLong=false
var ButtonDown=false    

rule "Test short press"
when
    Channel 'velbus:vmbgpod-2:7f964e441a:02:input#CH1' triggered PRESSED
then
    ButtonLong=false
    var IKEA_state = IKEA_Color.state()
    logInfo("IKEA","IKEA detected on with luminosity " + IKEA_state.toString)
end

rule "Test long press"
when
    Channel 'velbus:vmbgpod-2:7f964e441a:02:input#CH1' triggered LONG_PRESSED
then
    logInfo("TEST", "Test fired! LONG_PRESSED")
        ButtonLong=true
        ButtonDown=true 
    if (IKEA_Color.state.toString != "0,0,0") { 
        var HSBType hsbValue = IKEA_Color.state as HSBType
        logInfo("IKEA", "IKEA_Color=" + hsbValue)
        var DecimalType hue = new DecimalType(hsbValue.hue.intValue % 360 + 10) // 0-360; 0=red, 120=green, 240=blue, 360=red(again)
        var PercentType sat = new PercentType(hsbValue.saturation.intValue) // 0-100
        var bright = (IKEA_Color.state as HSBType).brightness.intValue // 0-100
        logInfo("IKEA", "IKEA_Color_HUE=" + hue)
        logInfo("IKEA", "IKEA_Color_SATURATION=" + sat)
        logInfo("IKEA", "IKEA_Color_BRIGHNTESS=" + bright
        if (bright <30) {
            logInfo("IKEA", "IKEA_Color_BRIGHNTESS DIM UP")
            while(bright < 100 && ButtonDown == true) {
                bright = bright + 10
                if (bright >100) {bright=100}
                logInfo("IKEA", "IKEA_Color_BRIGHNTESS=" + bright)                
                var newStatus = hue+","+sat+","+bright 
                IKEA_Color.sendCommand(newStatus)
                Thread::sleep(500) //.5 seconds
            }
    }
    if (bright >30 ) {
         logInfo("IKEA", "IKEA_Color_BRIGHNTESS DIM DOWN")
        while(bright <= 100 && bright > 1 && ButtonDown == true) {
            bright = bright - 10
            if (bright <1) {bright=10}
                logInfo("IKEA", "IKEA_Color_BRIGHNTESS=" + bright)
                var newStatus = hue+","+sat+","+bright 
                IKEA_Color.sendCommand(newStatus)
                Thread::sleep(500) //  .5 seconds
                logInfo("IKEA", "IKEA_Color_BRIGHNTESS DIM DOWN NEXT")
            }
        }
    }
end

rule "Test release"
when
    Channel 'velbus:vmbgpod-2:7f964e441a:02:input#CH1' triggered RELEASED
then
    ButtonDown = false
    if (ButtonLong==false){
        logInfo("IKEA", "Test fired! PRESSED")
        if (IKEA_Color.state.toString == "0,0,0") { 
            IKEA_Color.sendCommand("ON")
    }
    else{
        IKEA_Color.sendCommand("OFF")
    }
}
    ButtonLong=false
end
1 Like

Nicely done :smile:

Congratulations.

I particularly like your while loop, I didn’t know it could reference global variables, but now I see what you’ve created it makes perfect sense.

We almost have it… The>30 statement needs to be een else if … To avoid dimming after increasing…

1 Like

My small improvement of the Velbus Add-on (simulation of the PRESSED and LONG PRESSED messages of an input) is now integrated in OpenHAB v3.1.0. :partying_face:

2 Likes

what would be the code to set the feedback LED’s on the VMBELO directly from a script - can we send a color code / name ?

Setting the ambient colours can be done easily with NodeRed.

(I’ll dig out the code later)

Colour changing the feedback LEDs isn’t possible with openHAB… Yet


Try importing this into a NodeRed flow, to try colour changing the ambient options.

BUT… do consider how many times you will be writing to the memory map, as @Ggaljoen points out in this post https://forumtest.velbus.eu/t/memo-on-vmbelo-multi-line-support/16995/4

Change the suffix of the attached file back to .json

2022 Ambient colour changing Edgelit flows.json.change_suffix.csv (32.9 KB)

Hi guys

I’m still on the “bleeding edge” version from a few years ago, which works absolutely perfect for me!
Now I added a VMB1RYS, but that doesn’t seem to be supported in the version I have running.

I also have a VP01, and someone (I think it was @MDAR) suggested I could use a 8PBU fot that, which actually worked. So I’m kind of asking the same thing, is there an item I can use in stead of the 1RYS, which will work, without having to update my velbus binding version?

Hello :slight_smile:

The VMB1RYS is supported in the latest public version… is there a good reason why you don’t want to update?

Unfortunately, there isn’t anything else in that form factor that does the same task.

However…

Do you have any Spare “virtual relay” channel in your system on other relays?

You can always add a 0104 action and move your logic to the virtual relay, so that openHAB can see it?

Hello,

I have a velbus installation and OpenHab with the velbus binding.
Is there a possibility to add support for the VMBDALI in the velbus binding for OpenHab?

Cheers,

Roel

Hi

That would be up to the volunteer developers for the Velbus binding for OpenHAB

At this stage, the best you can do is put a request on their GutHub page for it.

Put Velbus in the title in square brackets to help them find it.

IE
[Velbus] feature request - VMBDALI

Or start a thread in the openHAB community forum

However, the DALI module isn’t very common and I very much doubt the developer/s have one to hand to work with.

But, as always, I have a demo rig that they can remotely connect to that does have a VMBDALI module onboard.

As a tip, please be very precise with what you are asking to be supported.

I would imagine that if it were treated like a multi channel dimmer, that could be incorporated quicker than if you asked for all the bells and whistles.

Thank you for the advice, I have put a request on the GitHub page, fingers crossed…

1 Like