pdmangel / node-red-contrib-openhab2

Other
21 stars 15 forks source link

Preserve original message when using openhab2-get? #15

Closed dakipro closed 6 years ago

dakipro commented 6 years ago

Hi, one question / feature request, would it be possible to preserve original message when using openhab2-get node? One typical scenario would be flow control, based on the control/override switches. F.eks. presence is detected, complex rule is formatting appropriate action and message that needs to be sent to the openhab2-out node, but ONLY if a "ManualOverride" virtual switch in openhab is set to OFF. Flow would look like this: input_event -> complex_logic_that_constructs_final_message -> openhab2-get(controlItem) -> openhab2-out(desiredItem)

This works fine to a point, but the original message payload is overwritten by openhab2-get. One workaround is to: input -> logic -> store_message_globaly -> openhab2-get(controlItem) -> restore_global_message -> openhab2-out(desiredItem)

Another is to use openahb2-get earlier in the flow, before the complex logic, but that is impossible/unpractical when making subflows or links or some "general logic". Another example is notifications logic, where it is difficult to implement controlItem check beforehand, as input to a subflow can come from meny other flows.

Any thoughts about how this could be solved? Perhaps some sort of msg.origianal_payload output, or another out channel?

dakipro commented 6 years ago

I see now a pull request that sounds similar to what I mentioned above? https://github.com/pdmangel/node-red-contrib-openhab2/pull/5

pdmangel commented 6 years ago

Version 1.0.8 now copy incoming payload to output message's msg.payload_in