Homematic HmIP-BROLL & HmIP-FROLL - Get them to work in openHAB

  • Platform information:
    • Hardware: Raspi 3
    • OS: Raspian OS 10
    • openHAB version: 3.1.0 Release Build running on Docker 2.6.2
    • Homematic Binding for CCU 2 (controlling lights via Alexa, logging the heating), Gardena Binding (logging soil humidity), Alexa Binding (controlling the Homematic lights)

I’m fairly new to openHAB and managed to get most of the things running that I wanted to (controlling lights, for now only logging heating, soil humidity, etc). However, what I have not yet gotten to work, despite multiple efforts and reading through various posts (e.g. Homematic shutters HmIP-BROLL always close when sending command "UP", [SOLVED] HmIP-BROLL - wrong item label? and https://openhabforum.de/viewtopic.php?t=2938) is to be able to controll my shading / shutters (nine Homematic HmIP-FROLL actors) via openHAB (and then via Alexa).

What I did achieve:

  1. Creating the item that lets me steer the level by pressing “up” and “down”
  2. Creating an item that lets me view the current level

What I failed miserably so far:
From what I understood, those two items need to be combined to a “proxy-item”. Here Homematic shutters HmIP-BROLL always close when sending command "UP" - #59 by Cplant you can find the documentation of what I tried. However, not surprisingly, having already errors in step #1, this did not work.

My problem is that the hints in the threads always start a bit too far for me, as in, I do not always know where to allocate the code (item definition in the UI, rules created in the UI, scripts created in the UI (ECMA Script / Rule DSL?), items definition in the “items-folder”?).

I got the impression from the three threads above that the solution is already out there. Would someone be able to provide an easy step-by-step description?

As far as I know the proxy items are no longer necessary it is OK for you OH defines open and close opposite to Homematic.

I don’t own any of these devices, so probably somebody else can help you better.

Ok let´s start.

I´m using the original CCU3 and openHABian on a raspberry Pi4.
If you´re using a CCU3 aswell, please have a look at Cloudmatic.
It´s a service to make your CCU3 available for certain Apps (@Home App) and you can connect it to Amazon.
It´s very responsive compared to the openHAB integration and you can use the homematic states.
The values in openHAB are inverted, so homematic sees 100% as open and 0% as closed. openHAB sees 100% as closed and 0% as open.
You could use the invert feature of the Alexa integration but i think it´s another point of failure.
CCU3 → Cloudmatic → Alexa = Responsive and the same states
CCU3 → openHAB → myopenhab → Alexa = Sometimes slower and the states are inverted
The prices are pretty fair and you can access your CCU3 without dealing with a VPN connection or other tricks.

Back to openHAB.
My HmIP-BROLL devices are connected to openHAB and i created the Things in the UI.
As i´m using openHAB for quiet some time now, i prefer the text based configuration with *.items files.

homematic.items

// Groups to control the roller shutters
Group gRolladenProxy
Group gRolladenControl
Group gRolladenStatus

// Rollade Arbeitszimmer
Rollershutter hmRolladeArbeit "Arbeitszimmer" <rollershutter> (Arbeitszimmer, gRolladenProxy) 
Rollershutter hmRolladeArbeitControl (gRolladenControl) {channel="homematic:HmIP-BROLL:ccu3:<SERIAL>:4#LEVEL"}
Rollershutter hmRolladeArbeitStatus (gRolladenStatus) {channel="homematic:HmIP-BROLL:ccu3:<SERIAL>:3#LEVEL"}
Switch hmRolladeArbeitStop (gRolladenControl) {channel="homematic:HmIP-BROLL:ccu3:<SERIAL>:4#STOP"}

// Optional channels for the weekly schedules
Number hmRolladeArbeitTCLs {channel="homematic:HmIP-BROLL:ccu3:<SERIAL>:7#WEEK_PROGRAM_TARGET_CHANNEL_LOCKS"}
String hmRolladeArbeitCombined {channel="homematic:HmIP-BROLL:ccu3:<SERIAL>:7#COMBINED_PARAMETER"}
String hmRolladeArbeitTCL {channel="homematic:HmIP-BROLL:ccu3:<SERIAL>:7#WEEK_PROGRAM_TARGET_CHANNEL_LOCK"}
Number hmRolladeArbeitCL {channel="homematic:HmIP-BROLL:ccu3:<SERIAL>:7#WEEK_PROGRAM_CHANNEL_LOCKS"}

As you can see i´m using one proxy item hmRolladeArbeit in the group gRolladenProxy.
Followed by hmRolladeArbeitControl that controls the BROLL and is in the group gRolladenControl.
Next is the hmRolladeArbeitStatus that represents the BROLL state and is in the group gRolladenStatus.
The last item is hmRolladeArbeitStop to stop the BROLL when moving and it´s in the gRolladenControl group.

Now for the tricky part, the proxy rule.
Again, i´m using the text based rules with the Rules DSL.

RolladenProxy.rules

import org.openhab.core.model.script.ScriptServiceUtil

val String ruleId = "hmRolladenProxy"

rule "Rolladen Status Update"
when
    Member of gRolladenStatus received update
then
    var name = triggeringItem.name
    name = name.replace('Status','') 

    var correspondingProxy = ScriptServiceUtil.getItemRegistry.getItem(name)

    if(triggeringItem.state != correspondingProxy.state.toString){
        correspondingProxy.postUpdate(triggeringItem.state.toString)
    }
end

rule "Rolladen steuern"
when
    Member of gRolladenProxy received command
then
    var correspondingControl = ScriptServiceUtil.getItemRegistry.getItem(triggeringItem.name + "Control")
    var correspondingStop = ScriptServiceUtil.getItemRegistry.getItem(triggeringItem.name + "Stop")

    switch(receivedCommand){
        case DOWN: {
            if(correspondingControl.state != "100"){
                correspondingControl.sendCommand("100")
            }
        }
        case UP:{
            if(correspondingControl.state != "0"){
                correspondingControl.sendCommand("0")
            }
        }
        case STOP:{
            if(correspondingControl.state != "STOP"){
                correspondingStop.sendCommand(ON)
            }
        }

        default: {
            if(correspondingControl.state != receivedCommand){
                correspondingControl.sendCommand(receivedCommand)
            }
        }
    }
    
end

The first part that will be triggered by Member of gRolladenStatus received update will update our Proxy item with the current state of the roller shutters.
The seconds part that will be triggered by Member of gRolladenProxy received command will control the roller shutters when using the Proxy item.

You need to create the items for all roller shutters and the groups + rule is for all of them.

Bonus, a rule to lift the roller shutters when the window is open while the roller shutter should be closed.
You need a BROLL and a window contact to achieve this.

RolladenLueften.rules

val String ruleId = "hmRolladenLueften"

rule "Rolladen Lueften"

when

    Member of gWindows changed to OPEN

then

    var name = triggeringItem.name

    logDebug(ruleId, triggeringItem.name + " wurde geöffnet.")
    logDebug(ruleId, name + " soll geprüft werden.")

    switch name {
        case 'hmRolladeArbeit': {
            if(hmRolladeArbeitStatus.state >= 86)
            {
                logDebug(ruleId, "Rollade Arbeitszimmer wird zum Lüften angehoben.")
                hmRolladeArbeit.sendCommand(87)
            }
        }
    }

end

rule "Rolladen Lueften nach Schliessung"

when

    Member of gRolladenStatus changed to 100

then

    var name = triggeringItem.name
    name = name.replace("Status","")

    logDebug(ruleId, name + " wurde geschlossen und soll geprüft werden.")

    switch name {
        case 'hmRolladeArbeit': {
            if(hmRolladeArbeitStatus.state >= 86 && hmFensterArbeit.state == OPEN)
            {
                logDebug(ruleId, "Rollade Arbeitszimmer wird zum Lüften angehoben.")
                hmRolladeArbeit.sendCommand(87)
            }
        }
    }

end

rule "Rolladen schliessen"

when

    Member of gWindows changed to CLOSED

then

    var name = triggeringItem.name

    logDebug(ruleId, triggeringItem.name + " wurde geschlossen.")
    logDebug(ruleId, name + " soll geschlossen werden.")

    switch name {
        case 'hmRolladeArbeit': {
            if(hmRolladeArbeitStatus.state == 87)
            {
                logDebug(ruleId, "Rollade Arbeitszimmer wird wieder geschlossen.")
                hmRolladeArbeit.sendCommand(100)
            }
        }
    }

end

Thes rule is a little bit longer and i only used the example of my workspace.
You need to copy the case 'hmRolladeArbeit' part for every BROLL you want to control.
The values are different because only two of my windows are identical and so the roller shutters all need a different value for the ventilation position.
I closed the roller shutters and then lifted them until the shades are still closed but the slots are open.
Then look at the status item and use this value for the lifting.
So for this example the CCU3 sees the roller shutters as 13% while openHAB sees it as 87%.

I hope that gets you in the right direction.

kind regards
Michael

2 Likes

Hi.

UP and DOWN is working without proxy or rules in my configuration like Martin said too. Text based configuration.

Greetings,
Markus

Michael, first of all, thanks a lot!

Btw: I updated my initial description above: I’m running a CCU2, …, kinda old, I know. But switching from the Homematic Access Point to the CCU-enviroment I first wanted to see whether I’m getting used to it before buying a CCU3. So far I also do not plan to use Cloudmatic, not so much because of cost, but to keep things local. Let’s see whether I can stick to that.

Your hints indeed got me into the right direction, and I got to reproduce your steps on my end (for now without the weekly schedules and without the rule for the “lüften”, to get started with a smaller base case).

So, I managed to create the items and the rule as per your description (and adapted them to my namings). However, I’m somewhat puzzled about the next steps / how to get to the point I had in mind: Having an openHAB-item similar to this (see below), which a) shows the status, b) allows me to control the status in openHAB and c) allows me to control the status via Alexa.

I thought that the proxy-item will serve that purpose, but on my end it looks like this, so nothing much I can do with it in openHAB or via Alexa? Or am I missing a point here?

You can control the Proxy item not the Proxy group.
And you need to control it within homematic once so that openHAB can update the state of the Proxy Item.

I´m a little bit confused, you want to keep things local but want to control your roller shutters with Alexa?
You can expose the Proxy item to Alexa with the Amazon Alexa Skill.
I missed that in my first answer but you need to expose the openHAB items to myopenhab.org first.
So it would be: CCU → openHAB → myopenhab → Amazon Alexa

Thanks for the answer, and apologies for not making myself 100% clear.

What I meant by “keep things local” was: Going from CCU to Openhab to Alexa not via Cloudmatic…

  • CCU2 → Cloudmatic → Amazon Alexa

… but go from the CCU2 locally to openHAB and then via myopenhab to Alexa:

  • CCU2 → openHAB → myopenhab/Alexa Binding → Amazon Alexa

I do not yet fully understand this part:

Am I maybe misunderstanding your solution proposal? As in:

  • How do I get from “the end result of what you described above” to an openHAB item which I can control in openHAB via a slider / embed it into my openHAB Dashboard (similar to my lights-example-screenshot above which works perfectly well already)
  • How do I get from “the end result of what you described above” to an openHAB item that I can access in openHAB via Alexa (similar to the way I already control my openHAB light-items via Alexa) via adding the “Amazon Alexa” metadata of an item to make it discoverable).

In both examples, I’d like to go the “CCU2 → openHAB → myopenhab/Alexa Binding → Amazon Alexa”-route.

I don’t want to sound stupid (as in: I am pretty new, but got several item working in openHAB already, and my lights also work perfectly via Alexa via myopenhab). But to me, at the end of your instructions at the very top, I am not sure what to do with the three items & groups, because to me they look like nothing I can “slide” in openHAB to set the shutter level or nothing I could sensefully add the “Amazon Alexa” metadata, to have Alexa do exactly that.

Maybe you get my intention from the description.

To add some more context why a Proxy item is useful.
You can send anything to the Proxy item and use it for the current state.
You don´t need to think about what item can be used to control the roller shutters and what item returns the current state.
And you can build rules like the one i posted for ventilation without working through multiple groups of states and controls.

To stay with the example i provided.
The Proxy item hmRolladeArbeit is the one you control and the two rules in RolladenProxy.rules are used to do the magic behind this Proxy item.
The Proxy groups gRolladenProxy, gRolladenControl and gRolladenStatus are only used by the Proxy rule.
You wont get a slider to control the roller shutters because they normally only work with UP, DOWN and STOP.
It´s the same method like physically controlling the BROLL and described in the posts you linked.
You could use Dimmer instead of Rollershutter but then you´re not able to stop the blinds when they´re moving.
There´s always a gap of functionality between Rollershutter and Dimmer.
Rollershutter: Using UP, DOWN and STOP directly and % from rules
Dimmer: Only using % but can´t STOP when already moving

To achieve a slider, you need to define the 4#LEVEL as a Dimmer instead of Rollershutter, but i´m not sure how to do this in the UI.

Anyway, after exposing your Proxy item to myopenhab and from there to Alexa, you can use a slider within the Alexa app.
You only need to add the metadata for Alexa to the Proxy item.

Edit: Ah i see, there´s nothing that reflects a roller shutter in the oH 3 UI…
You would always need to use a combination of multiple widgets/items to show the state, control the % and control them via UP/DOWN/STOP.

To be honest, that´s why i´m using the @Home app.
It can do exactly that:

Compared to Alexa:

oH 3 UI as Rollershutter

oH 3 as Dimmer

Thanks a lot!

With your description I managed to achieve what I tried for some months now: a) have the %-age status values of my 9 HmIP-BROLLs being shown / logged in OH and b) control the %-ages of the shutters via OH with Amazon Alexa. :slight_smile:

@Bredmich, quick follow-up question on your solution (which still works like a charm, so thanks a lot again):

Although the Status-Item perfectly shows the opening in %…

… the graph (via “analyze”, which I use to check how my shading program behaved) is completely empty:

My first reaction was “maybe there’s a senseful state description missing”, but looking at the log, the values are already simple integer values, so they should be logged?

Am I missing something?

1.5 years later, I found the solution: The type must not be “Rollershutter”, but “Number”.

1 Like

@Bredmich, quick question on how you set it up on your end:

  • If I define the status-item as “Number”, the status is logged in the graphs (via “Analyze”), but is shown in the dashboards as a number between 0% and 1%…
  • … and if I define the status-item as “Rollershutter”, it is shown on in the dashboards as a number between 0% and 100% (so far so good), but is not logged in the graphs via “Analyze”).

Any idea on how to achieve both?

Update: With the Type "Number:Dimensionless"

… the item itself shows the correct %-age…

and the graph shows data, but the y-axis only goes from 0% to 1%…

… and the tiles whow up as “100%”.
image

Apart from the weird y-axis, I’d say things work as intended.

If anyone has an idea on how to fix the y-axis (“100%” instead of “1%”), without impacting the other visualizations, please let me know.