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

dont works on boolean or integers #3

Open
stephjj opened this issue Jun 23, 2019 · 3 comments
Open

dont works on boolean or integers #3

stephjj opened this issue Jun 23, 2019 · 3 comments

Comments

@stephjj
Copy link

stephjj commented Jun 23, 2019

on map-map, if the input is a boolean, it doesnt works for the false input.
It's works for the true value

payload: true => payload: "ON"
payload: false => payload: "Unknown: false"

The mapping is
true = ON
false = OFF

@woozar
Copy link

woozar commented Mar 2, 2020

It is the same for integers, in the case of "0".
Just a wild guess, but it might be, that the input is being validated like "if (msg.payload[path])" with is false if the value is "false" or "0".

@woozar
Copy link

woozar commented Mar 2, 2020

I believe map.js line 74 "if ( !keyValue ) { return null; }" causes this behavior.

@rsenden rsenden changed the title dont works on boolean dont works on boolean or integers Mar 3, 2020
@rsenden
Copy link
Owner

rsenden commented Mar 3, 2020

I agree that the code could be improved to properly handle values that evaluate to false. Apart from map.js line 74, I think there may be other places where undefined/null/false/0 handling could be improved.

Unfortunately at the moment I don't have time to investigate which code requires improvements to properly handle such edge cases, implement the necessary changes, and set up test scenarios for testing these edge cases.

As such, for now you will need to use some work-around. For example, a standard 'change' node could be used for the boolean mapping. Alternatively, you could try converting the payload into a string before passing the message to one of the node-red-contrib-map nodes.

Of course if you are willing to implement and test the necessary fixes to handle these edge cases, I'm more than willing to accept a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants