runnane / node-red-contrib-easee

Node-Red module for streaming Easee charger data.
Apache License 2.0
7 stars 4 forks source link

Request Development, Enhancement: Another option for User Credentials #14

Open KIDNORswe opened 10 months ago

KIDNORswe commented 10 months ago

Can I ask for a development of the node please? Is there a possibility to add the option to insert user credentials (username, password and unit id) into the streamer-node please? (instead of entering them into the node when added to a flow the first time) Currently the only option to change any of the credentials is for someone with access and the knowledge on how to use Node-Red. I would love have the option to forward any of the credentials via another UI (Home Assistant for example) via input helpers and forwarded to node-red. In this case I can create an admin sight for the end-user to change the password when needed. The credentials would be inserted when node-red start or from another trigger via the websocket.

I would love to contribute myself but can’t do any programming, completely useless.

Thanks for creating this node. Its brilliant and very useful, good job

I-am-a-node commented 4 months ago

This looks like a good idea. To be able to insert/inject the user credentials into the node from an external point. Example a helper in home assistant.

KIDNORswe commented 4 months ago

Yea. The admin on credentials is the worse when it comes to Home Assistant. Plenty of the integrations don't even have an easy way to change username or passwords. Weird. Typical developers that can't understand how basic, non programming enthusiast... just regular users behave and need. So integration with this limitation makes it not ideal for a setup with HA at your grandparents house. (nightmare) I thought an additional function in Node-Red would solve this with the help of this node. However not an option, was hoping for too much. Have to build a more advanced flow (from my point of view and basic knowledge) to see if I can solve the Easee integration and user credential issue.

runnane commented 1 month ago

@KIDNORswe Is it OK if I add username and password parameters to the doLogin() function?

       node.doLogin = async (_username, _password) => {
        const url = "/accounts/login";
        const response = await fetch(node.RestApipath + url, {
          method: "post",
          body: JSON.stringify({
            userName: _username ?? node.credentials.username,
            password: _password ?? node.credentials.password,
          }),
          headers: {
            Accept: "application/json",
            "Content-Type": "application/json",
          },
        })
KIDNORswe commented 1 month ago

Hi @runnane. Thanks for getting back on this. Hope it won't take too much time with a modification of the current node. If you use the doLogin() function, will it only be for that moment of login that won't change the previous stored data in node.credentials?

I think for the best use and advantage and looking at the purpose of the function + making it better than other integrations or nodes is giving the config a function with the option to change the previous stored credentials in node.credentials.

To make it a little more "safe" and minimise the chances of making any changes by misstake, I reckon it would be best to have an update function that can receive input data and change the current in the config/node.credentials.

Example. You can have a helper in Home Assistant (HA) that will hold your credential data. There is one that keeps the password hidden. Depending on how the function and trigger in HA to forward this data the to Node-red flow with the Easee node is up to the user creating the function. In the Node-Red Easee flow you have the option to create an input node with the following:

msg.topic: "change_credentals"; msg.payload = {"change_username": "newusername", "change_password:"newpassword" };

This way the data will be forwarded and overwrite the old credentials. However here is where my knowledge is bad... will the password be seen in the log? or can it be hidden? If not there should be a warning that if the user, on their own risk, use this function. They have to be aware that it might be seen in the log. I guess that its only if you are debugging and record longer logs that you will se such a change being pushed through.

What do you think? Thanks.

I-am-a-node commented 1 month ago

@KIDNORswe @runnane I can't tell if that is possible (the suggestion you made @KIDNORswe) I don't have the knowledge to judge if this is against or OK with the common process in handling user credentials.

The option to be able to change or update the username and/or password from another hub or platform like the Home Assistant would be great. At least for a few of us that has decided to go with the Easee node and Node-Red instead of the current integration. It will make this node more attractive.

Using Node-Red with other UIs will also benefit from this however in my case, together with the Node-Red add-on in Home Assistent will be very useful. I would setup a function and flow what KIDNORswe is suggesting.

I wish I had the knowledge to create this and contribute. However I cant so the only way I can help is to test it when its available.

Thanks both for taking time for this.