csuermann / node-red-contrib-presence-faker

Node-RED node that fakes presence in a smart home by switching devices (e.g. lights) on and off at random times.
MIT License
23 stars 2 forks source link

Not restarting after one cycle? #37

Open A380Coding opened 2 years ago

A380Coding commented 2 years ago

I noticed that lately the presence faker node does not restart the next day. Everything is set up and running. After a cycle is complete I get the "next cycle:

Anything changed on the behavior of the node?

Edit: Running version 1.8.5 now

A380Coding commented 2 years ago

I monitored the behavior today. I'm setting the sunset and other values via input message. This is triggered by the sunset each day. Currently days are getting longer and sunset is therefore later than the sunset presently set to the presence faker node. I saw that actually the presence faker node starts with the next cycle (in my case a off cycle). A few seconds later the new sunset triggers a new input message to the presence faker node with the new sunset time. Then the presence faker node switches to "next cycle". If I trigger the input message again, it actually starts the cycle. For some reason the node does not like a new sunset time being set if it just started.

A380Coding commented 2 years ago

Looks like if I already set "WindowBegin" to some value and I send a new message with a new "WindowBegin" message, it does not like that. Seems to be a timing issue if both values are close together. I now modified my workflow to avoid such cases.

csuermann commented 2 years ago

Hi @A380Coding!

Thanks for investigating this issue! I was wondering if you happen to have any debug output that could be useful?! If you activate the "Logging" option in the presence-faker settings, there should be a ton of helpful information appearing on the Node-RED debug tab.

A380Coding commented 2 years ago

Hey @csuermann I'm still looking into that and actually thought I solved it or at least had a work around. The strange thing is that on some days it works as expected and on others it does not. the cycle restarts once per day so it takes a while to check in more detail. Additionally if I change anything on the workflow it will restart everything and therefore not show the issue initially.

What I'm currenty thinking:

  1. Maybe there is an issue because I'm using multiple nodes.
  2. I'm sending a input message every night now as I thought there was an issue with that. But looks like that does not change anything.
  3. Somehow it appears that the node gets stuck after some time

I have to set up some debugging with export to a file, otherwise I'll not be able to move forward.

A380Coding commented 2 years ago

Something strange is happening, not sure if this is connected here: I'm sending input values to the presence faker node and in the settings normally the text gets red and I can see the values that have been configured using the input message.

Message is: {"payload":{"windowBegin":"16:49:00","windowEnd":"23:59:59","minDuration":900,"maxDuration":3600,"minCount":4,"maxCount":7,"topic":true},"_msgid":"3858f9833eef205a"}

I do not get any red text in the configuration. I activated the debug messages and actually all the information seems to be considered according to the debug output:

!!!! CONFIG OBJECT RECEIVED !!! new windowBegin: 16:49:00 and so on.

Any idea on this?

csuermann commented 2 years ago

Hi @A380Coding,

I could not reproduce that problem. Could you please observe the Network activity of the Developer tools while opening up the Node details? It should show a call to Node-RED's context API similar to what's shown below. Is this call going through?

image

A380Coding commented 2 years ago

Where should I observe that? I actually do not have any dev tools installed. Can I check that call anywhere in node red?

csuermann commented 2 years ago

If you use Chrome, you should find the developer tools under 'View > Developer > Developer Tools'. Since you need to inspect the communication between the Node-RED frontend and its backend, there is no way to do this directly in Node-RED.

A380Coding commented 2 years ago

There is a get request to the node and I get an error: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

Status 401 Unauthorized

csuermann commented 2 years ago

Hmm, is there anything being displayed when you select the presence-faker node and then click the "Context Data" button in the sidebar?

A380Coding commented 2 years ago

I found this one: nodered

In the Context Data I can see the values e.g. maxCount, minCount, and so on, properly set to my values. The node as such is working with my values and if I activate the debug it shows that is receiving the right values. So it is only an optical thing.

I activated node red authentication lately, not sure when that would fit to the error message.

csuermann commented 2 years ago

That might be spot on, since you mentioned a 401 / Unauthorized error.

ssillen commented 1 year ago

I have the same issue, presence-faker is not restarting after the first cycle. In the network monitor I get 404 error:

image