onokje / node-red-contrib-tesla

Node red nodes to control Tesla vehicles and devices
MIT License
20 stars 11 forks source link

Default values detected by || operator instead of ?? operator #28

Closed GaPhi closed 2 years ago

GaPhi commented 2 years ago

The || operator is a boolean OR. The ?? operator is a null/underfined detector.

The code uses || instead of ?? at several locations. Result: Writing (msg.autoWakeup || config.autoWakeup || false) gives true when at least one the expression is true (last expression is useless BTW)

It should be (msg.autoWakeup ?? config.autoWakeup ?? false) meaning "msg.autoWakeup if set, otherwise config.autoWakeup if set, otherwise false"

onokje commented 2 years ago

You'r right, I don't know how i missed that :P Thanks for the PR's, I will review them asap.