Status forwarding to linked channel

Hello all,
I’m using openHAB3 for a while with mysensor addon. I have created simple item “Blind 1 Cmd” for my window cover and there are two linked channels. One from the controller and second remote button. I need to send command and update status on both these channels but it doesn’t work - both channels are set to DEFAULT profile. Is it correct settings? What is wrong?

I would expect this is base functionality of OpenHAB - to synchronize status of all nodes linked together.

When I try to control window cover by button, status in OpenHAB is updated but not forwarded to the controller. Same when status is changed by controller, new status is not forwarded to the button (to change LED status).

I have lates OpenHAB 3.2 running on Windows and org.openhab.binding.mysensors-3.2.0-SNAPSHOT.jar.

Before I tried MQTT communication with mysensors. There is possibility use parameter postCommand=“true” but it does an echo, it is sending cmd back to origin node.

I’m a bit confused about what you are trying to achieve here. Maybe it needs re-phrasing in the terms openHAB uses -
commands are instructions to do something e.g. go UP
states are information about conditions e.g. position 75% open

So if you take a “status” from a control button and apply it to your Item … nothing happens. There is no instruction to do something.
And it doesn’t make sense anyway - the button cannot tell you much about the status of the window covering.

There are a number of different ways to take an incoming message and treat it like a command - as you found for example with MQTT postCommand option. For that to do anything useful, it needs to get to an Item linked to some channel that will use the command.

Tell us a bit more about your binding channels here.

Thank for the reply. I’m confused about configuring the channels.

Mysensor controller for window cover has 2 channels:

  • V_PERCENTAGE [0-100]
  • V_VAR1 [0=STOP, 1=UP, 2=DOWN]

The controller can be commanded by both channels. E.g. when cover is open (V_PERCENTAGE=0) and stopped and I set V_PERCENTAGE channel to 50% in OpenHAB Item, it will drive the cover to 50%. While the cover is moving V_VAR1 is updated by the controller to DOWN. When the cover reach the target 50%, V_VAR1 is set to STOP by the controller.
Vice versa when I click the button in OpenHab to set V_VAR1 to UP, the cover will go fully up to 0%. When it reach the target, both channels are updated by controller, V_PERCENTAGE=0, V_VAR1=STOP.
I can do some tricks using this status tracking. Like control the cover by one button. One button press starts the move up or down based on V_PERCENTAGE. Second press change the direction (when cover is moving). Long press stops the move. Also I use button LED to shows the status both channels: LED is ON/OFF based on V_PERCENTAGE==0 and LED is blinking when the cover is moving (V_VAR1!=STOP).

Alright, what doesn’t happen for you?

When using MySensor binding, the command is not forwarded from one linked channel to second one. For example, when I press the button, the status is updated on the item, but not send to the controller. And when cover reach the target, controller update position on the OpenHAB item and set V_VAR1=STOP, but these information again are not send to the button.

Yes, that is normal and by design. Messages coming into openHAB are usually treated as status reports, not do-something instructions. By design, a state update is not normally forwarded to any other linked channels for action.

Some bindings allow to specify incoming messages to be treated as openHAB commands; some don’t.

A generic way to achieve converting an incoming status into a command for another channel is the follow profile.
But if you try using that in “both directions” on a single channel you are likely to make a feedback loop. Take care about what you set up to follow what.

Thanks, it is unpleasant surprise that this type of synchronization is not implemented in OpenHAB by default :frowning:
MySensors doesnt offer trigger a commands on status change. So I need to use follow profile and 2 items instead 1 (read and write channels). Pretty extra work for me to modify everything.

Why should it be? the last thing most people would want is ghostly actions linking two devices that they did not ask for. All you have to do is configure what you want.

Yes, probably. Not much detail of your channels yet to say for sure.

They do come free of cost.
You’re dealing with two different devices - one is a blinds motor controller, the other is a remote hand controller. It’s quite logical to represent these as different Items. You might want to set up your remote to operate several devices.

Or let’s say you want to flash the indicator LED on your remote. If you just have both channels on a simple link to one Item, you can’t flash the LED without stop-starting the blinds as well.

Sorry, probably I don’t understand to the configuration.
What is the purpose of Default profile? For me it would be logical to share and update a variable across OpenHAB. When I change the value in one device, the value is updated in all linked devices.

To simplify my usecase: Lets say I have a light switch (ON/OFF) and two smart buttons with LED indicating a status ON/OFF. The light and buttons channels are linked under one item Switch. How to configure MySensor binding to have synchronized status in all 3 devices?

So I need to create 3 items and setup a rules?

With MQTT binding I can use postCommand=“true” parameter, but it is also painful, because echo message is sending back to origin channel.

No, that is not what it does.

No, that is not what it does.

Okay, so you will have something like -

channel XX associated with the light.
This will accept commands ON/OFF and pass them to the light.
The light will send status reports to this channel, which wil turn them into ON/OFF state updates.
You can link that to an Item, Switch type “myLight” say, and control it from rules or GUI, and inspect state from rules or GUI.

Ordinary so far.

This is a more complicated device than you think. We can send it instructions to turn the LED on and off - at least, I’m guessing there is just one LED?
So you’d have a channel ZZ representing the LED, and you can treat that just like the real light earlier. You could link it to an Item “myLED”, and send it commands from GUI etc… but you don’t want to do that, you just want it to “follow” the real light status.

Linking both channels to one Item in a simple way would be an error. The Item can only have one state, while channels from two different devices may have conflicting states. Which one wins the fight? There’s no way to say, no way to configure.
One Item just cannot satisfactorily represent two devices.

But for the LED, you are not really interested in the LED status at the openHAB end - you don’t need to find out if the LED is actually on or off, you just want to pass it instructions, yes?
This is where the “follow profile” comes in.

With the “myLight” Item, link it twice.
Link to channelXX, using ordinary default profile.
Link to channelZZ, using follow profile.

Now when you send an openHAB command to “myLight” Item from GUI or rule, it goes on to the real light via channel XX in the usual way. (This does NOT go to channel ZZ.)
When a new status comes back from the light and updates the Item, the change gets transformed into a command by the follow profile and sent to the LED via channel ZZ.
The new status can be the result of an openHAB command, or some manual action at the light, it doesn’t matter which. That is important - otherwise the LED could get out of step.

So that part does what you want, using one Item.

(If you wanted to do something fancy later, like flash the LED when the doorbell rings, you can’t. You would have to create that extra Item so that you can command the LED separately from the big light.)

Not enough info yet to say how to set that up - “two buttons” can make stuff happen in three or four very different ways. Are there two channels issuing “pressed” and “unpressed” events? Or just one channel with “pressA” and “pressB”? Or is there logic hiding the buttons altogether, so that openHAB just sees ON and OFF changes? etc.

The “follow” profile is clear, thanks.

The buttons are separate devices running at Arduino. Each button has own channel. As the state is always updated within all devices, when a button is pressed the actual state is negated and send to OpenHAB - new value ON/OFF is send on the button channels. But I can change the implementation since I use Arduino…
How to configure these channels? Can I mix state & command channels to use only one channel?

That’s how an ordinary channel works. It carries state updates in one direction, from binding to Item, and carries openHAB commands in the other direction, from Item to binding.

By use of special binding features, incoming messages can sometimes be configured to produce commands to be sent to Item through the channel, i.e. the reverse of usual function.

If you are asking if you can somehow turn some external messages into state updates and some external messages into commands and pass to Item along the same channel … no.

Can’t advice you what to do, don’t even know what binding you are using for button controls. MQTT I guess?

There is a completely different approach to button inputs, where you often don’t really care about “button state”, but instead about “button event” i.e when a button is pressed. Some bindings support incoming messages causing channel “trigger events”, with no Item linking at all (since there is no state to remember). To make best use of that, you would use rules.

Yes, now I have switched back from MySensors binding to MQTT. So I need to create new Item and channel for each button and create rule “state was updated”? This is proper way?

There are at least three different ways to set all this up. First decide how your buttons are going to work over MQTT.

Can you describe these options briefly please? I can see only one option - write the rule reacting on event and depending on the event type send a command. I want to use the easiest way.

I’ve no idea how your button related MQTT messages come. Is there one topic with different payloads? Different topics?

The easiest way is to set up channels and Items to accept whatever is incoming, and convert that to something suitable for the real target device using a rule.

If you are somehow frightened of rules, you might be able to exploit the postCommand option of MQTT binding.
Assuming you have different messages on one topic, set up a channel listening to that topic using stateTopic. If necessary, use a transformation to convert “message-this” into ON, and “message-that” into OFF. The Switch type channel has some built-in on/off parameters for very simple jobs like that.
The set the postCommand option true. That makes the incoming messages issue openHAB commands instead of the usual updates.
Now link the channel to the openHAB Item already representing the target device.
When that Item recieves the commands, they get passed along to the usual channel/binding and onwards to the device.

Rules and postCommand option I’m using now. Triggering postCommand is not also the best solution. It sends echo to the channel of origin. I was hoping for a hidden option to synchronize all linked channels in one item.

I think we can close this topic. Thanks for the support rossko57. I appreciate it!

Not necessarily. But if you have a commandTopic set up somewhere to listen for commands on the Item you are sending commands to using postCommand, then it is doing exactly what you asked it to do, after all.

It remains difficult to give advise with no concrete example of what you have, and what you want instead.

I suspect your troubles come down to trying to use the same Item to model both a device that you want to control, and a separate device tat you want to do the controlling.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.