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

Add support for environment variables in characteristic properties #217

Closed
sjorge opened this issue Mar 1, 2020 · 18 comments · Fixed by #418
Closed

Add support for environment variables in characteristic properties #217

sjorge opened this issue Mar 1, 2020 · 18 comments · Fixed by #418
Assignees
Labels
enhancement 👍 New feature or request

Comments

@sjorge
Copy link

sjorge commented Mar 1, 2020

It would be nice to have support for environment variables inside the characteristic properties section too. That way you can embed a service inside a subflow and configure it via some subflow variables.

https://nodered.org/docs/user-guide/environment-variables

@Shaquu
Copy link
Member

Shaquu commented Mar 1, 2020

@sjorge thanks for a feature request.
Do you see it as a good feature actually that could be used wider?

I wouldn't be a problem to implement I guess but it might overcomplicate our plugin too much.
Also it could be added in #53

@crxporter
Copy link
Member

This has been discussed twice that I remember - having homekit inside of a subflow. Up to now it’s been recommended as “probably don’t do this”

But I do see benefit of it for example if one has 15 identical switches around their house they can set up one flow and just put it in 15 times with different names for each switch.

@Shaquu
Copy link
Member

Shaquu commented Mar 1, 2020

Okay, I see an option to make it work for us. We would have to abandon current node id system in favor of our internal id generator in NRCHKB.

Th�en every service node would generate random id on first flow save but it would persist even in sub flows I guess? I have to look at this closer.

@sjorge
Copy link
Author

sjorge commented Mar 1, 2020 via email

@Shaquu
Copy link
Member

Shaquu commented Mar 2, 2020

Standard fields are node-red fields. And characteristic field is JSON field so I guess it is the thing. I will look at this and see if it's ease to add it.

@sjorge
Copy link
Author

sjorge commented Mar 2, 2020

They are supported in JSONata Expressions Parhaps there is a node-red json from string fucntion that takes care of that.

@crxporter
Copy link
Member

@Shaquu is this request covered by the new “Wait for setup” feature?

@Shaquu
Copy link
Member

Shaquu commented Oct 26, 2020

To be honest. I did not checked

// Update: not yet

image

@Shaquu
Copy link
Member

Shaquu commented Oct 28, 2020

Also I tested with
image
Failed too.

Also it is causing some more problems during Bridge pair :)

@Shaquu Shaquu added this to To do in NRCHKB 1.4.0 via automation Mar 27, 2021
@Shaquu Shaquu self-assigned this Aug 2, 2021
@Shaquu
Copy link
Member

Shaquu commented Aug 2, 2021

I have tested in the subflow (with 1.4.0-dev.7).

{
    "Brigthness": {
        "description": "${test}"
    }
}

${test} got evaluated as 100 as I requested

@Shaquu Shaquu changed the title [feature] support for environment variables in characteristic properties Add support for environment variables in characteristic properties Aug 2, 2021
@Shaquu Shaquu linked a pull request Aug 2, 2021 that will close this issue
@Shaquu Shaquu moved this from To do to Review in progress in NRCHKB 1.4.0 Aug 2, 2021
@Shaquu
Copy link
Member

Shaquu commented Aug 2, 2021

@sjorge please test solution on dev branch

@sjorge
Copy link
Author

sjorge commented Aug 5, 2021

Doesn't look available yet in the current release? But that is not showing 1.4.0 for me though.

@crxporter
Copy link
Member

To install newest dev release from today:

  1. Stop node-red
  2. Backup ~/.node-red folder
  3. cd ~/.node-red
  4. npm i node-red-contrib-homekit-bridged@1.4.0-dev.11
  5. Start node-red

@sjorge
Copy link
Author

sjorge commented Aug 5, 2021

Not sure it's working for number values

{
    "On": true,
    "Brightness": true,
    "ColorTemperature": {
        "minValue": "${ctMin}",
        "maxValue": "${ctMax}"
    }
}

I had this on a bulb and I set ctMin=250,ctMax=454

And got:
Screen Shot 2021-08-05 at 21 37 34

What I expected and got with:

{
    "On": true,
    "Brightness": true,
    "ColorTemperature": {
        "minValue": 250,
        "maxValue": 454
    }
}

Screen Shot 2021-08-05 at 21 39 55

Edit: I tested with 'Service' I also noticed there was a 'Service 2' should I test with that one instead?

@TheNON75
Copy link
Collaborator

TheNON75 commented Oct 1, 2021

@sjorge would you mind coming to our discord (NRCHKB)? I would have a question in a different topic, but I can reach out to you only this way.

thank you

@sjorge
Copy link
Author

sjorge commented Oct 1, 2021

@sjorge would you mind coming to our discord (NRCHKB)? I would have a question in a different topic, but I can reach out to you only this way.

thank you

I don't really use discord, but we could use the github discussion page?

@Shaquu
Copy link
Member

Shaquu commented Oct 2, 2021

I have tested using latest dev.

02 Oct 02:43:26 NRCHKB-Trace:CharacteristicUtils [Test:f9350f72.bee7] Evaluating value: +0ms
02 Oct 02:43:26 NRCHKB-Trace:CharacteristicUtils [Test:f9350f72.bee7] {    "On": true,    "Brightness": true,    "ColorTemperature": {        "minValue": ${ctMin},        "maxValue": ${ctMax}    }} +0ms
02 Oct 02:43:26 NRCHKB-Trace:CharacteristicUtils [Test:f9350f72.bee7] Evaluated as: +1ms
02 Oct 02:43:26 NRCHKB-Trace:CharacteristicUtils [Test:f9350f72.bee7] {"On":true,"Brightness":true,"ColorTemperature":{"minValue":250,"maxValue":400}} +0ms

Known issue. For some Characteristics value must be a number type.
So it cannot be "minValue": "${ctMin}" but has to be "minValue": ${ctMin}
With the second option, nodered will complain but nrchkb will work correctly.

@Shaquu
Copy link
Member

Shaquu commented Oct 2, 2021

I would say to go prod with that issue. Reasons:

  1. It will be time-consuming to resolve it, probably custom editor required.
  2. We have scheduled the current editor to be replaced with new table (non json, more user-friendly).

@Shaquu Shaquu moved this from Review in progress to Reviewer approved in NRCHKB 1.4.0 Oct 4, 2021
Shaquu added a commit that referenced this issue Oct 4, 2021
### Fixed

- Fixed customCharacteristics incorrect refresh in UI
- Implemented static accessoryUUIDs for subflows Enables the use of nrchkb nodes in subflows with backwards
  compatibility #393 - thanks @kevinkub
- Fixed Custom MDNS Configuration not showing in UI for Standalone Accessory
- Stop components from clearing other component's node.status call
- Add missing advertiser selector in UI for Standalone Accessory
- Not naming the host node causes a crash #424
- Do not output oldValue for onSet as it does not have access to old value

### Added

- Notice during app launch: Node.js 10 will be deprecated in Node-RED 2.0.0
- Event output in Service 2 which is available in NRCHKB_EXPERIMENTAL #392 #437
- Status node to fetch Serialized Service #210
- Support for environment variables in characteristic properties #217

### Changed

- Updated hap-nodejs to 0.9.5 (added new iOS 15 Services and Characteristics)
- Updated dependencies to latest versions
- Changed `BatteryService` to `Battery` in demo examples as `BatteryService` is deprecated #381 - thanks @crxporter
- Readme rework - thanks @crxporter
- More descriptive error when incorrect Characteristic has been used in msg.payload
- Add msg.hap.allChars to service nodes #438
@Shaquu Shaquu moved this from Reviewer approved to Done in NRCHKB 1.4.0 Oct 4, 2021
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
No open projects
NRCHKB 1.4.0
  
Done
Development

Successfully merging a pull request may close this issue.

4 participants