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

Enhancement - Nodered error output #56

Open
ASomerN opened this issue Nov 5, 2022 · 1 comment
Open

Enhancement - Nodered error output #56

ASomerN opened this issue Nov 5, 2022 · 1 comment

Comments

@ASomerN
Copy link

ASomerN commented Nov 5, 2022

Hi,

Great API in NodeRed and I've been able to completely automate charging of the car using solar power, modulating in real time for cloud cover and so on, and auto-shut-off if it exceeds charge and starts using too much house battery.

I've encountered an issue where Nodered can't easily capture failures on the API (i set the car to use my own wifi and opened a can of worms of mesh network but that's a different issue and resulted in me finding a potential improvement). As it stands it appears any error is stuck within the API request. Would it be possible to update so there are two outputs from the API, in essence (excuse the pseudo-code):

apirequest().then((success) => {
   return [{payload: success},null]
}).catch((error) => {
  return [null,{payload:error}]
})

This ought not to be a breaking change, as currently success is returned in the first instance anyway, but not the error. This would allow us to handle some rejected responses, instead of creating a mechanism in Nodered to detect a failed request based on nothing happening.

If the error included details we can map specific flows based on the error type.

Thanks for all the really great work you have done.

@ASomerN
Copy link
Author

ASomerN commented Nov 9, 2022

Hi,

I've forked this to build and do some testing:
https://github.com/ASomerN/node-red-contrib-tesla/tree/try-catch-outputs

Example working flow (had to wait for the vehicle to sleep):
image

Everything is working as intended, it outputs either success or fails, some minor changes are required but need to test the upgrade to see if it causes anything to break. Changed colour of the node to match the logo but this was more to differentiate locally.

The only change required is in the tesla.js send call and function, and setting outputs to 2 in the html.

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

1 participant