Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Pass through meta from msg #511

Open
lougreenwood opened this issue Dec 27, 2022 · 8 comments
Open

[Feature]: Pass through meta from msg #511

lougreenwood opened this issue Dec 27, 2022 · 8 comments
Assignees
Labels
enhancement 👍 New feature or request

Comments

@lougreenwood
Copy link

lougreenwood commented Dec 27, 2022

Your Current NRCHKB Plugin Version

1.5.0

Operating System

No response

What is your idea?

When a NK service node is triggered, it should be possible to pass additional metadata through the service node and receive that metadata on the output.

For example, if I pass the following data to a switch, I would expect the following output:

Service node input

msg: {
  payload: {
    On: true
  },
  meta: {
    someMetaValue: 123,
  }
}

Service node output

msg: {
  payload: {
    On: true
  },
  hap: { ... },
  name: 'device name',
  meta: {
    someMetaValue: 123,
  }
}

I already have message passthrough enabled, but it seems that a service node builds a completely new message and disregards almost all values passed to it's input.

Any more details?

If this is specific to some hardware or specific software version, please explain here.

Additional comments?

Additional comments here, if any.

Any code or functions to add?

No response

@lougreenwood lougreenwood added the enhancement 👍 New feature or request label Dec 27, 2022
@lougreenwood lougreenwood changed the title [Feature]: Pass through properties from msg [Feature]: Pass through meta from msg Dec 27, 2022
@deancs
Copy link

deancs commented Jun 24, 2023

+1 for this request. Thanks for a great addition to NR. Its pretty much a NR convention that msg objects are passed-through with the node only making the specified changes based on its function.

@Shaquu
Copy link
Member

Shaquu commented Jul 2, 2023

+1 for this request. Thanks for a great addition to NR. Its pretty much a NR convention that msg objects are passed-through with the node only making the specified changes based on its function.

Noted :)

@petrica
Copy link

petrica commented Jun 17, 2024

Hi! This should be marked as must have, not enhancement, as it is nearly impossible to stop any loop without the pass-through. The plugin is highly customizable and works very well, apart from this trivial to fix issue. Thank you!

@Shaquu
Copy link
Member

Shaquu commented Jun 17, 2024

Hello, will look into this. @crxporter any thoughts?

@petrica
Copy link

petrica commented Jun 17, 2024

@Shaquu
Copy link
Member

Shaquu commented Jun 18, 2024

This one is tough to implement. @lougreenwood

  1. we have original message on input
  2. then we trigger HomeKit characteristic set value which is async
  3. it triggers callback which sends msg to output, but it has no context of 1.

@petrica
Copy link

petrica commented Jun 19, 2024

I see that this is deprecated, however at the moment you can use the Context attribute to pass an object from the input to the output:

Input:

msg: {
  payload: {
    Context: 'Some value here'
  }
}

let context: any = null
if (msg.payload.hasOwnProperty('Context')) {
context = msg.payload.Context
delete msg.payload.Context
}

Output:

msg: {
  hap: {
    context: 'Some value here'   
  }
}

if (context) {
hap.context = context
}

@GogoVega
Copy link
Contributor

In fact, onInput should be asynchronous - it should wait for the response from the callback then send the message (original msg + hap response).
Currently this function only takes msg as argument which makes it synchronous, it should take 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 👍 New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants