New to node-red-contrib-ramp-thermostat

Totally new to this with little programming but want to try to use this node to control a terrarium. Found several threads that say this node can be programmed via the dashboard but I am unable to find the right wording. I have found several examples of how to program it but none show how to do it via code. The closest I have gotten is

var time1 = {hr:0, min:0, temp:0};
time1.hr = 08;
time1.min = 00;
time1.temp = 23;

msg = {
topic: 'setProfile',
payload:
{"name":"YoProfile",
"points":
[time1.hr+":"+time1.min+": "+time1.temp]

}

}
but the node throws an error that says invalid character at json 5. If I look at the output it differs from the examples in that the input to the node is a string from my code and looks like it must be numeric from the examples I've found. I've tried multiple variations of the code but this one seems to be the closest but still doesn't work. Any help in pointing me to the right direction would be appreciated.
thanks

If you use the a string template literal it is easier to build it, so something like

`${time1.hr}:${time1.min}`: time1.temp, `${time2.hr}:${time2.min}`: time2.temp,...]

If that doesn't work feed it into a debug node and show us what you see.
Notice that the node says it needs at least two points and specifies what the first and last should be.

I'm sorry but either my eyes aren't good enough or something but when I enter this code

msg = {
topic: 'setProfile',
payload:
{"name":"YoProfile",
"points":
['{time1.hr}:{time1.min}': time1.temp,
'{time2.hr}:{time2.min}': time2.temp]

}

}

for some reason the dollar sign gets left off when I upload, there is a dollar sign in front of the { where your suggestion puts them.

I get a message

2020_03_08_10_24_31_Node_RED_192.168.1.177

[{"id":"e3c744d0.f9058","type":"function","z":"ba5c6ff4.5809e8","name":"describe profile","func":"\nvar time1 = {hr:0, min:0, temp:0};\nvar time2 = {hr:0, min:0, temp:0};\nvar time3 = {hr:0, min:0, temp:0};\nvar time4 = {hr:0, min:0, temp:0};\ntime1.hr = 0;\ntime1.min = 0;\ntime1.temp = 23;\ntime2.hr = 23;\ntime2.min = 59;\ntime2.temp = 23;\n\nmsg = {\n    topic: 'setProfile',\n    payload:\n    {\"name\":\"YoProfile\",\n    \"points\":\n    ['${time1.hr}:${time1.min}:' time1.temp,\n    '${time2.hr}:${time2.min}:' time2.temp]\n    }\n}\n/*\n\nObjects use names to access its \"members\". In this example, person.firstName returns John:\nObject:\nvar person = {firstName:\"John\", lastName:\"Doe\", age:46};\n\n\n\nmsg = {payload:\n    {\"name\":\"myGreatProfile\",\n    \"points\":\n    {\"00:00\":16.0,\n    \"08:00\":20.0, \n    \"20:00\":20.0,\n    \"23:59\":16.0}\n    }\n}\n}\n*/\n//node.status({fill:\"blue\",shape:\"dot\",text:\"Set Profile \" + msg.payload});\n\n\nreturn msg;","outputs":1,"noerr":8,"x":380,"y":960,"wires":[["bb812209.b251a8","4e667ecc.3260c8"]]}]

Are those backticks you have used? Not single quotes.

As described in the link I posted.

They are the single quotes (I think), on the key below the ", and I did read your link, though some doesn't make sense, but I did read it.

Well, I did blow right over the grave ticks versus back ticks versus single or double quotes, I did change it to the grave tick but no change in the code.

They need to be backticks. Copy/paste from my post or the link if you can't find the right key. On a UK keyboard it is on top left key but it varies with keyboard.

Did use the grave tick,(finally), it is the upper left key on my keyboard but still get a message that the code is wrong.

[{"id":"e3c744d0.f9058","type":"function","z":"ba5c6ff4.5809e8","name":"describe profile","func":"\nvar time1 = {hr:0, min:0, temp:0};\nvar time2 = {hr:0, min:0, temp:0};\nvar time3 = {hr:0, min:0, temp:0};\nvar time4 = {hr:0, min:0, temp:0};\ntime1.hr = 0;\ntime1.min = 0;\ntime1.temp = 23;\ntime2.hr = 23;\ntime2.min = 59;\ntime2.temp = 23;\n\nmsg = {\n    topic: 'setProfile',\n    payload:\n    {\"name\":\"YoProfile\",\n    \"points\":\n    [`${time1.hr}:${time1.min}:` time1.temp,\n    `${time2.hr}:${time2.min}:` time2.temp]\n    }\n}\n/*\n\nmsg = {payload:\n    {\"name\":\"myGreatProfile\",\n    \"points\":\n    {\"00:00\":16.0,\n    \"08:00\":20.0, \n    \"20:00\":20.0,\n    \"23:59\":16.0}\n    }\n}\n}\n*/\n\nreturn msg;","outputs":1,"noerr":19,"x":380,"y":960,"wires":[["bb812209.b251a8","4e667ecc.3260c8"]]}]

As I suggested earlier, feed the output of the function node into a debug node and see what it is generating. Always the first thing to do when something doesn't like some data is to look at the data.

[Edit] You have the ticks the wrong side of the :
With computers the details are important.

Oh, it seems you can't use template strings when setting up property names, I wonder why. Actually I am struggling to work out how exactly to code it.....
Edit, sorry haven't got time to look further at the moment, perhaps someone else will jump in.

Thank you for your efforts.

Sorry, not much time again, Try something like this

var time1 = {};
var time2 = {};
time1.hr = 0;
time1.min = 0;
time1.temp = 23;
time2.hr = 23;
time2.min = 59;
time2.temp = 23;
point1 = {}
point2 = {}
point1[`${time1.hr}:${time1.min}`] = time1.temp
point2[`${time2.hr}:${time2.min}`] = time2.temp

msg.topic = "setProfile"
msg.payload = { "name":"YoProfile", points: [ ]  }
msg.payload.points.push(point1)
msg.payload.points.push(point2)
return msg

It would be more efficient to build the points as an array in the first place, dependent on how you are defining the profile in the first place.

WOW! I have absolutely no idea what your code does, it will take some long study to figure it out, but the output into the debug node looks great. I will need to do some testing to see if it's totally fixed but so far it works. Thanks for your obvious effort to help.
again, thanks

Hi,

Maybe the example in the Wiki is what you are looking for:

https://github.com/cflurin/node-red-contrib-ramp-thermostat/wiki/Profile-with-more-than-10-points

I spent a lot of time looking at that example but it doesn't show how to set the time and temp via a variable. In looking through the forum someone used the term wife factor. I needed the wife to be able to set the time and temp and she definitely isn't going to open up the editor to set the program so I needed to be able to do it via a dashboard. I think most of my code was working except I couldn't get the thermostat node programmed via a variable input. If I could find the author of the node I would ask him to put in an example of using variables to set the program. Colin apparently spent a lot of time and went to a huge amount of trouble to figure it out and I'd like to see his efforts preserved for the next person who wants to do what I did.

I am the author :slight_smile: - I'll have a look at your use case later.

Thanks, just trying to help out the next person.

Are you wanting to set the whole profile from the dashboard or just override the current setpoint?