Velbus binding for OpenHAB

Thanks @Daniel615be

It’s great that you’re jumping in and helping develop the openHAB binding.

Do you have a long term plan, or are you doing what you can, when you can?

I’m doing what I can, when I can :wink:

1 Like

The channel name bug describe here is fixed in this new releases.

1 Like

That’s really kind of you.

Just as with Cédric, if there is anything I can do to assist, please just ask.

It is also possible to get an “old” 2.5.x release?

I am on the 2.5.11 version (and reported the channel name bug). Planning to move to 3.x but not any time soon due to time constraints.

Grt Matthijs

As a construction foreman said to the new ground worker…

“Take your pick”

anyone tried to use the vmb4an with openhab. I’m getting erros and not getting any values in openhab.

at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[?:?]

at java.lang.Integer.parseInt(Integer.java:652) ~[?:?]

at java.lang.Byte.parseByte(Byte.java:152) ~[?:?]

at java.lang.Byte.parseByte(Byte.java:178) ~[?:?]

at org.openhab.binding.velbus.internal.handler.VelbusVMB4ANHandler.convertTextAnalogInputChannelUIDToChannelByte(VelbusVMB4ANHandler.java:253) ~[?:?]

at org.openhab.binding.velbus.internal.handler.VelbusVMB4ANHandler.convertChannelUIDToChannelByte(VelbusVMB4ANHandler.java:219) ~[?:?]

at org.openhab.binding.velbus.internal.handler.VelbusVMB4ANHandler.handleCommand(VelbusVMB4ANHandler.java:120) ~[?:?]

at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.channelLinked(BaseThingHandler.java:191) ~[bundleFile:?]

at org.eclipse.smarthome.core.thing.link.ThingLinkManager.lambda$0(ThingLinkManager.java:267) [bundleFile:?]

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]

at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]

at java.lang.Thread.run(Thread.java:834) [?:?]

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