Thanks for the reply. I'll try to better explain myself. Sorry for lack of using proper term, I'm new to node-red. I code in Java (well, used to) and the method get and set are there because that's how I learned to used these. The property will end private and get used through these command.
Now, for better explanation. In the HTML file for the "controller", I have 4 fields:
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-config-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-config-input-clientID"><i class="fa fa-tag"></i> Client ID</label>
<input type="text" id="node-config-input-clientID">
</div>
<div class="form-row">
<label for="node-config-input-accessToken"><i class="fa fa-tag"></i> Access Token</label>
<input type="text" id="node-config-input-accessToken">
</div>
<div class="form-row">
<label for="node-config-input-refreshToken"><i class="fa fa-tag"></i> Refresh Token</label>
<input type="text" id="node-config-input-refreshToken">
</div>
These fields can be seen in the GUI when someone click on the ecobeeController under configuration nodes. One of these field is clientID, which is input by the user and contain the API key from ecobee, generated for his app.
Now, I can access this value from the controller node by doing this.clientID, and this is without doing any "this.clientID = config.clientID". Since config from the ecobeePinRequest module contain a reference to the controller, config.clientID from a pinRequest node. I only did that so I can use set/get method later on for a good object usage (unless rules of access changed since early 2000 when I learned them).
For simplicity sakes, what I want is this.
When the use press the button on the pinrequest node, it start query to get the pincode and accesstoken (I already have this working in the .js file, triggered by the button). Now, once I have these information, I want them to be "pasted" in the ecobeecontroller node GUI, i.e. the html side, so when the user click on the controller in the configuration nodes, he can see the values. This is what I'm missing.
One of the problem (on my understanding) right now is the fact that I used part of the code from openhab2 nodes (which use a controller and ajax query) and inject node (for better understanding of the button).
Right now, the code to send back the ajax (and only that work) is res.sendStatus(200);.
The way I've done my trigger is that way:
> ecobee.html - button code for pinrequest
> button: {
> onclick: function() {
> //ecoControl = RED.nodes.node(this.controller);
>
> $.ajax({
> url: "ecobee/"+this.id,
> type:"POST",
> success: function(resp) {
> //ecoControl = RED.nodes.node(this.controller);
> //RED.notify(node._("inject.success",{label:label}),{type:"success",id:"inject"});
> RED.notify("resp: " + resp ,"information");
> //ecoControl.ecobeePin = resp; //WORK BUT RESP = OK...
> },
> error: function(jqXHR,textStatus,errorThrown) {
> if (jqXHR.status == 404) {
> RED.notify(node._("common.notification.error",{message:node._("common.notification.errors.not-deployed")}),"error");
> } else if (jqXHR.status == 500) {
> RED.notify(node._("common.notification.error",{message:node._("inject.errors.failed")}),"error");
> } else if (jqXHR.status == 0) {
> RED.notify(node._("common.notification.error",{message:node._("common.notification.errors.no-response")}),"error");
> } else {
> RED.notify(node._("common.notification.error",{message:node._("common.notification.errors.unexpected",{status:jqXHR.status,message:textStatus})}),"error");
> }
> }
> });
> }
> }
To be honest, I don't quite understand this syntax. I've check the syntax in w3school for jquery and they say success/error are depreciated and to use done. I tried and that made an error so I guess we aren't using 3.0+. Aside of that, they use textResponse to get the message but this throw me an error. I've tried resp (which output OK), looked at all of his children and can't see where it is. I tried to add object and that didn't work.
The calling is done to here (that might be another problem) outside any node:
> ecobee.js
> module.exports = function(RED) {
>
> RED.httpAdmin.post("/ecobee/:id", function(req,res) {
> var node = RED.nodes.getNode(req.params.id);
> var ecobeeController = node.getController();
> if (node != null) {
> try {
> ecobeeController.pinRequest(res,node);
>
> } catch(err) {
> node.warn("test2");
> res.sendStatus(500);
> node.error(RED._("inject.failed",{error:err.toString()}));
> }
> } else {
> node.warn("test3");
> res.sendStatus(404);
> }
> });
Since everything is async, i had to put the answer at the end of the pinRequest method, else it would try to output without having any info in it.
So my goal, unless there's a way in the js file to do it, is to have the values field in the HTML so I can see them.
I know I can do
ecoControl = RED.nodes.node(this.controller);
ecoControl.clientID="asdf"
and that will change it in the GUI from the html file.
I hope I'm clearer, thanks again, I know it's not easy to understand my confused mind.