context.set('latestMode',msg.payload);context.set('nIntervId',context.get('nIntervId')||null);context.set('lastMessages',context.get('lastMessages')||null); var CHECK_PERIOD = 2000; // millisecondsclearInterval(context.get('nIntervId'));
var sI = setInterval(function() { var msg1 = ""; var msg2 = ""; var msg3 = ""; var msg4 = ""; var msg5 = ""; var msg6 = ""; var msg7 = ""; var msg8 = ""; var msg9 = ""; var condition = context.get('latestMode'); var hday = ''; var d = new Date(); var wday = d.getDay(); var month = d.getMonth()+1; if (month < 10) { month = '0'+ month; } var day = d.getDate(); if (day < 10) { day = '0'+ day; } d.setDate(d.getDate() + 1); var month_tomorrow = d.getMonth()+1; if (month_tomorrow < 10) { month_tomorrow = '0'+ month_tomorrow; } var day_tomorrow = d.getDate(); if (day_tomorrow < 10) { day_tomorrow = '0'+ day_tomorrow; } var td = month+day; var tm = month_tomorrow+day_tomorrow; if (global.get('myHolidays').indexOf(tm)>-1 && global.get('myHolidays').indexOf(td)==-1){ condition = 'holiday_tomorrow'; } if (global.get('myHolidays').indexOf(tm)>-1 && global.get('myHolidays').indexOf(td)>-1){ condition = 'holiday_today'; } if (global.get('myHolidays').indexOf(tm)==-1 && global.get('myHolidays').indexOf(td)>-1){ if(wday < 5){ condition = 'holiday_ends'; } hday = 'h_ends'; } switch (condition) { case 'holiday_today': msg1 = { payload:"disabled" }; msg2 = { payload:"disabled" }; msg3 = { payload:"disabled" }; msg4 = { payload:"disabled" }; msg5 = { payload:"disabled" }; msg6 = { payload:"disabled" }; msg7 = { payload:"auto" }; msg8 = { payload:"disabled" }; msg9 = { payload:"disabled" }; hday = 'Holiday today'; myMsg = 0; if(myMsg !== context.get('lastMessages')){ node.send([msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9]); context.set('lastMessages',myMsg); } break; case 'holiday_tomorrow': msg1 = { payload:"disabled" }; msg2 = { payload:"disabled" }; msg3 = { payload:"disabled" }; msg4 = { payload:"disabled" }; msg5 = { payload:"disabled" }; msg6 = { payload:"disabled" }; msg7 = { payload:"disabled" }; msg8 = { payload:"auto" }; msg9 = { payload:"disabled" }; hday = 'Holiday tomorrow'; myMsg = 1; if(myMsg !== context.get('lastMessages')){ node.send([msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9]); context.set('lastMessages',myMsg); } break; case 'holiday_ends': msg1 = { payload:"disabled" }; msg2 = { payload:"disabled" }; msg3 = { payload:"disabled" }; msg4 = { payload:"disabled" }; msg5 = { payload:"disabled" }; msg6 = { payload:"disabled" }; msg7 = { payload:"disabled" }; msg8 = { payload:"disabled" }; msg9 = { payload:"auto" }; hday = 'Holiday ends today'; myMsg = 2; if(myMsg !== context.get('lastMessages')){ node.send([msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9]); context.set('lastMessages',myMsg); } break; case 'auto': msg1 = { payload:"auto" }; msg2 = { payload:"auto" }; msg3 = { payload:"auto" }; msg4 = { payload:"auto" }; msg5 = { payload:"disabled" }; msg6 = { payload:"disabled" }; msg7 = { payload:"disabled" }; msg8 = { payload:"disabled" }; msg9 = { payload:"disabled" }; if(hday == 'h_ends'){ hday = 'Auto(Holiday Ends)'; } else{ hday = 'Automatic'; } myMsg = 3; if(myMsg !== context.get('lastMessages')){ node.send([msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9]); context.set('lastMessages',myMsg); } break; case 'on': msg1 = { payload:"on" }; msg2 = { payload:"disabled" }; msg3 = { payload:"disabled" }; msg4 = { payload:"disabled" }; msg5 = { payload:"disabled" }; msg6 = { payload:"disabled" }; msg7 = { payload:"disabled" }; msg8 = { payload:"disabled" }; msg9 = { payload:"disabled" }; hday = 'On'; myMsg = 4; if(myMsg !== context.get('lastMessages')){ node.send([msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9]); context.set('lastMessages',myMsg); } break; case 'off': msg1 = { payload:"off" }; msg2 = { payload:"disabled" }; msg3 = { payload:"disabled" }; msg4 = { payload:"disabled" }; msg5 = { payload:"disabled" }; msg6 = { payload:"disabled" }; msg7 = { payload:"disabled" }; msg8 = { payload:"disabled" }; msg9 = { payload:"disabled" }; hday = 'Off'; myMsg = 5; if(myMsg !== context.get('lastMessages')){ node.send([msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9]); context.set('lastMessages',myMsg); } break; case 'disabled': msg1 = { payload:"disabled" }; msg2 = { payload:"disabled" }; msg3 = { payload:"disabled" }; msg4 = { payload:"disabled" }; msg5 = { payload:"disabled" }; msg6 = { payload:"disabled" }; msg7 = { payload:"disabled" }; msg8 = { payload:"disabled" }; msg9 = { payload:"disabled" }; hday = 'Disabled'; myMsg = 6; if(myMsg !== context.get('lastMessages')){ node.send([msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9]); context.set('lastMessages',myMsg); } break; case 'vacation': msg1 = { payload:"disabled" }; msg2 = { payload:"disabled" }; msg3 = { payload:"disabled" }; msg4 = { payload:"disabled" }; msg5 = { payload:"auto" }; msg6 = { payload:"disabled" }; msg7 = { payload:"disabled" }; msg8 = { payload:"disabled" }; msg9 = { payload:"disabled" }; hday = 'Vacation'; myMsg = 7; if(myMsg !== context.get('lastMessages')){ node.send([msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9]); context.set('lastMessages',myMsg); } break; case 'away': msg1 = { payload:"disabled" }; msg2 = { payload:"disabled" }; msg3 = { payload:"disabled" }; msg4 = { payload:"disabled" }; msg5 = { payload:"disabled" }; msg6 = { payload:"auto" }; msg7 = { payload:"disabled" }; msg8 = { payload:"disabled" }; msg9 = { payload:"disabled" }; hday = 'Away'; myMsg = 8; if(myMsg !== context.get('lastMessages')){ node.send([msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9]); context.set('lastMessages',myMsg); } break; } node.status({ text : hday });}, CHECK_PERIOD);
context.set('nIntervId',sI);
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
For more options, visit https://groups.google.com/d/optout.
Im pretty dumb but don't you need to setup var myMsg = {}
if (global.get('myHolidays').indexOf(tm)>-1 && global.get('myHolidays').indexOf(td)<0){
condition = 'holiday_tomorrow'; } if (global.get('myHolidays').indexOf(tm)>-1 && global.get('myHolidays').indexOf(td)>-1){ condition = 'holiday_today'; }
if (global.get('myHolidays').indexOf(tm)<0 && global.get('myHolidays').indexOf(td)>-1){
if(hday === 'h_ends'){
default: hday = 'Unknown';
or indeed reuse the same msg on several outputs...
msg1 = { payload:"auto" };msg2 = { payload:"auto" };msg3 = { payload:"auto" };msg4 = { payload:"auto" };msg5 = { payload:"disabled" };msg6 = { payload:"disabled" };msg7 = { payload:"disabled" };msg8 = { payload:"disabled" };msg9 = { payload:"disabled" };
...node.send([msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9]);could bemsg1 = { payload:"auto" };
msg2 = { payload:"disabled" };...node.send([msg1,msg1,msg1,msg1,msg2,msg2,msg2,msg2,msg2]);
I don't have a definitive answer for you. I can acknowledge the error is odd and I can't explain it. We will need to investigate it properly by understanding what ace is doing.
My suggestion of using that comment was not the final fix. It was just a workaround to suppress that particular error message to help you carry on.
Nick
--
How you have node-red installed and what version of nodejs you are using has no bearing here. It is some configuration issue with the ACE editor widget we use, and that is entirely self-contained within the browser.
We have enough information to go on, and we're at the point where someone needs to dig into the code and debug it properly. The basic questions are:
- why is it hitting so many errors but not flagging anything until you hit a limit (50), and
- what are those errors, given none of us can see anything wrong with the code provided.
Walter - if you wanted to raise an issue on GitHub with the details you've provided here, we can tackle it in due course.
Nicj
--
/*globals context,msg,node */
'use strict';var myMsg;
...
Yup, that was going to be the first thing I looked at when I came to debug it properly... we don't tell ace about the globals available to you in a Function. But it is still odd that it doesn't highlight them at all.
Nick
--