Cannot post to group item - Error 400?

Hi there,

I’m just trying to get started with openhab (2), added Thermostates and Blinds (Somfy through RFXTRX433e) which works fine.

I want to create a switch for the blinds now in habpanel and therefore created a group and rules like this:

If I hit the button I get a 400 Bad Request. It posts to
If I substitute the group eg_blinds with the actual thing, and use UP as body, it works.

The group is listed in /items (via GET) - do I have to do anything else?

Ok the above results in “undefined status” - I can only post UP or DOWN to the group.

Can anyone maybe tell me how to realize a toggle switch?

Alright I managed to get the POST working, however, can anyone tell me why my blinds go down, then up again with the following rule?

Could you reveal the secret for anyone else that may run into the same problem?

when Item eg_rolladen received command

makes a closed loop. Should be evident in your logs.
You might implement a timer that prevents repeated actions, or a proxy item to disconnect cause and effect.

@rossko57 thanks a lot, I just realized that it creates a loop.
The correct solution would be to send to the individual shutters I guess.

However: Isn’t there any way to
a) send to the groups elements via group without triggering the action (command) in the rule?
b) use a different command for the group (I noticed only shutter commands are possible) that I can send and catch, e.g. ‘received command toggle’ ?

It would make sense.
Another option is to create a subgroup but that’s a mess as well…
Or create a dummy item for the toggle if that’s possible?

You can use postUpdate to avoid triggering the bindings linked to the Items. However, if these are coming from the sitmap/habpanel you will probably need to use a Proxy Item to receive the command and then figure out how/when to pass the command on to the members of the group. (your dummy Item idea).

Thanks @rlkoshak - I’ve created a dummy item now (string) it seems I can only use postUpdate on strings.
The problem is I don’t know how to update this String item via habpanel so I can use it in the rule.
It only seends Commands.

Correct. The UIs will only send commands. Hence the need for the proxy Item.

And you can post update to any Item type. However, if you use the postUpdate Action (postUpdate("MyItem", "NewState")) instead of the method (MyItem.postUpdate(NewState)) it indeed only accepts Strings for the state. However, it will parse the String into what ever format the Item needs.

What you do is put the Proxy Item on your UI and have a Rule triggered by this Proxy Item.

The Rule body stays the same as you have it now.

With this proxy Item you will break the infinite loop because the command to eg_rolladen will not retrigger the rule.

With this approach you don’t have to worry about postUpdates. Everything will be commands.

@rlkoshak I’m not sure if I follow:

I created a String Item as a proxy object like this:
String rolladen_toggle

I then use a rule to see if it changes:

when Item rolladen_toggle received command // (or received update)

The problem is, I have no idea how I can trigger the receive update/command via habpanel.
It does not seem to work if I send a command to the String Item, and I read that Strings need to use
postUpdate in rules. I have no idea how to send postUpdate from habpanel though.

Do I need a different dummy object than string?

Forget about postUpdate.

You don’t need it. You are not using it. It is irrelevant.

Everything is a command.

To send a command from Habpanel you must use a controlling widget. Dummy is text only. You cannot cause anything to happen using a Dummy widget. You probably want to use a Button or a Switch and use a Switch Item.

Now to address your misconception.

ANY state can be sent using postUpdate to ANY Item type. The difference is one uses postUpdate to change the state of an Item internally to OH where sendCommand activates the binding/channels linked to that Item. So, for example:

MyLight.sendCommand(ON) // goes to the binding and causes the light to turn on
MyLight.postUpdate(ON) // changes the state of the Item inside OH but the command does not get sent out to the device

That is the only difference. The String issue you read about is that the postUpdate Action only can take a String as the state. This String gets parsed into whatever is appropriate for that Item type. So, to postUpdate a numerical value to a Number Item using the postUpdate Action you need to do:

postUpdate("MyNumberItem", "123")

but if you use the postUpdate method you can pass the actual number and avoid the parsing:


Thank you @rlkoshak

I also figured out the issue with proxies, as you describe them in a tutorial.

The code is executed, however, the only thing that doesn’t work is conditions like:
myrollershuter.state == DOWN

Also, if I try to log the state, it’s always null - although I explicitly set it in the frontend before.
It’s a RFXCOM RFY shutter, not sure what’s wrong with that

@rlkoshak any idea what I did wrong here?

Somehow it always enters
if (EGKuecheRolladen_Shutter.state != UP) { // item UP or uninitialized

If I want to log EGKuecheRolladen_Shutter.state it seems to be null.
I thought that if I set it from the frontend, it should at least be not null?

Had to use numbers instead of UP/DOWN in the if statements.
The behavior is weird, sometimes I get 100/0 when printing the value in the frontend
and sometimes it says UP/DOWN.

@rlkoshak last question: do I really not have to use postUpdate to set the state as well? It seemed to me that
the sendCommand did not alter the state I am checking

sendCommand will change the state of the Item so there is no need to postUpdate too.

It could be that Habpanel takes time to refresh or the device is turning around to report some other state. You can watch events.log to see your actual state changes. I sheets recommend checking here first to eliminate the possibility that the UI is lagging behind or experiencing some other issue.

I’ve no experience with Rollers gutters but I’m not surprised it stores is state as a number. Dimmers work the same way. You can send an ON/OFF but it’s internal state is always a PwrcentType.

Thanks @rlkoshak the remaining problem was that I chained the group things with OR, but wanted to use AND in the shutter group.

It’s working now.