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

can the time window span midnight? #9

Closed crackers8199 closed 4 years ago

crackers8199 commented 4 years ago

i have a few presence faker nodes set up and it seems to be working relatively well, but it's running stuff outside of the window. i have the window set from 7pm-8am, but according to my debug messages i have stuff running during the day as well...

csuermann commented 4 years ago

Hi @crackers8199,

That's weird! Could you please share an export of your nodes with me so that I can debug?

Thanks!

Best regards, C.

crackers8199 commented 4 years ago

[{"id":"7a6ab70e.efbb98","type":"tab","label":"vacation","disabled":false,"info":""},{"id":"54cd7348.610d0c","type":"presence-faker","z":"7a6ab70e.efbb98","name":"fake tv 79","onPayload":"turn_on","onPayloadType":"str","onTopic":"switch.christmas_tree_79","offPayload":"turn_off","offPayloadType":"str","offTopic":"switch.christmas_tree_79","windowBegin":"19:00","windowEnd":"08:00","minDurationHours":0,"minDurationMinutes":"30","minDurationSeconds":"0","minDuration":"1800","maxDurationHours":"3","maxDurationMinutes":"0","maxDurationSeconds":0,"maxDuration":"10800","minCount":"5","maxCount":"15","startupBehavior":"onMsg","actionOnDisable":"none","x":440,"y":200,"wires":[["a70609fb.55ffb8","d9e9cb21.6ce218"]]},{"id":"a70609fb.55ffb8","type":"debug","z":"7a6ab70e.efbb98","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","x":730,"y":280,"wires":[]},{"id":"d9e9cb21.6ce218","type":"api-call-service","z":"7a6ab70e.efbb98","name":"","server":"e361b37d.da24","version":1,"debugenabled":false,"service_domain":"switch","service":"{{payload}}","entityId":"{{topic}}","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":780,"y":340,"wires":[[]]},{"id":"c0eb6b88.de9538","type":"presence-faker","z":"7a6ab70e.efbb98","name":"floor lamp 21","onPayload":"turn_on","onPayloadType":"str","onTopic":"switch.floor_lamp_21","offPayload":"turn_off","offPayloadType":"str","offTopic":"switch.floor_lamp_21","windowBegin":"19:00","windowEnd":"08:00","minDurationHours":0,"minDurationMinutes":"30","minDurationSeconds":"0","minDuration":"1800","maxDurationHours":"3","maxDurationMinutes":"0","maxDurationSeconds":0,"maxDuration":"10800","minCount":"5","maxCount":"15","startupBehavior":"onMsg","actionOnDisable":"none","x":450,"y":280,"wires":[["a70609fb.55ffb8","d9e9cb21.6ce218"]]},{"id":"cb627f57.9e6d2","type":"presence-faker","z":"7a6ab70e.efbb98","name":"hallway 71","onPayload":"turn_on","onPayloadType":"str","onTopic":"switch.window_lights_1_71","offPayload":"turn_off","offPayloadType":"str","offTopic":"switch.window_lights_1_71","windowBegin":"19:00","windowEnd":"08:00","minDurationHours":0,"minDurationMinutes":"30","minDurationSeconds":"0","minDuration":"1800","maxDurationHours":"3","maxDurationMinutes":"0","maxDurationSeconds":0,"maxDuration":"10800","minCount":"5","maxCount":"15","startupBehavior":"onMsg","actionOnDisable":"none","x":450,"y":360,"wires":[["a70609fb.55ffb8","d9e9cb21.6ce218"]]},{"id":"40651cda.be3a54","type":"change","z":"7a6ab70e.efbb98","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":160,"y":140,"wires":[["54cd7348.610d0c","c0eb6b88.de9538","cb627f57.9e6d2"]]},{"id":"99122fa6.184d6","type":"change","z":"7a6ab70e.efbb98","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":160,"y":220,"wires":[["54cd7348.610d0c","c0eb6b88.de9538","cb627f57.9e6d2"]]},{"id":"5ed3a675.f335c8","type":"trigger-state","z":"7a6ab70e.efbb98","name":"","server":"e361b37d.da24","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"input_boolean.on_vacation","entityidfiltertype":"exact","debugenabled":true,"constraints":[{"id":"257hq4k0tlh","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","x":210,"y":60,"wires":[["40651cda.be3a54"],["99122fa6.184d6"]]},{"id":"5429c330.12f49c","type":"api-current-state","z":"7a6ab70e.efbb98","name":"","server":"e361b37d.da24","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.on_vacation","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":360,"y":480,"wires":[["a773145d.f73b78"]]},{"id":"dd95c4d4.a7b2c8","type":"inject","z":"7a6ab70e.efbb98","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":400,"wires":[["5429c330.12f49c"]]},{"id":"a773145d.f73b78","type":"debug","z":"7a6ab70e.efbb98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":660,"y":480,"wires":[]},{"id":"e361b37d.da24","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":false}]

csuermann commented 4 years ago

Thank you, @crackers8199! I wasn't able to reproduce the problem yet. I've imported your nodes and they behave like they should on my machine. Could it be a misconfigured time setting after all? Also, which version of the presence-faker do you currently use? Best regards C.

crackers8199 commented 4 years ago

misconfigured time setting how? i clearly have it set from 7pm-8am...

windowBegin "19:00"
windowEnd "08:00"

how do i find the current version? it's likely most recent, i just installed it the other day.

crackers8199 commented 4 years ago

here are some log items showing that it is in fact turning lights on and off outside of the window, from yesterday...there are more than this, but here are a few:

16 Mar 11:29:08 - [info] [debug:a70609fb.55ffb8] 
{ topic: 'switch.christmas_tree_79',
  payload: 'turn_on',
  _msgid: 'e86c4e35.45afc' }
16 Mar 12:10:20 - [info] [debug:a70609fb.55ffb8] 
{ topic: 'switch.window_lights_1_71',
  payload: 'turn_on',
  _msgid: '20654d33.3e42b2' }
16 Mar 12:58:45 - [info] [sun events:30a13910.636e86] [sunevents] Firing event solarNoon for Mon Mar 16 2020 12:58:45 GMT-0700
16 Mar 13:41:04 - [info] [debug:a70609fb.55ffb8] 
{ topic: 'switch.christmas_tree_79',
  payload: 'turn_off',
  _msgid: '68b300ca.7a6ff' }
16 Mar 13:47:57 - [info] [debug:a70609fb.55ffb8] 
{ topic: 'switch.floor_lamp_21',
  payload: 'turn_off',
  _msgid: 'c0ba6d99.1ce2c' }
16 Mar 13:52:09 - [info] [debug:a70609fb.55ffb8] 
{ topic: 'switch.window_lights_1_71',
  payload: 'turn_off',
  _msgid: '2b537831.1eb898' }
16 Mar 14:05:33 - [info] [debug:a70609fb.55ffb8] 
{ topic: 'switch.floor_lamp_21',
  payload: 'turn_on',
  _msgid: 'bad9f60d.bb8b48' }
16 Mar 14:09:16 - [info] [debug:a70609fb.55ffb8] 
{ topic: 'switch.christmas_tree_79',
  payload: 'turn_on',
  _msgid: '39b7aff5.87751' }
16 Mar 14:14:37 - [info] [debug:a70609fb.55ffb8] 
{ topic: 'switch.window_lights_1_71',
  payload: 'turn_on',
  _msgid: 'ccebbc2c.9a2f8' }
16 Mar 15:15:54 - [info] [debug:a70609fb.55ffb8] 
{ topic: 'switch.window_lights_1_71',
  payload: 'turn_off',
  _msgid: 'b0ad543f.e1b108' }
16 Mar 16:00:51 - [info] [debug:a70609fb.55ffb8] 
{ topic: 'switch.window_lights_1_71',
  payload: 'turn_on',
  _msgid: 'd1dec297.f0826' }
16 Mar 16:03:54 - [info] [debug:a70609fb.55ffb8] 
{ topic: 'switch.floor_lamp_21',
  payload: 'turn_off',
  _msgid: '5fad3dd4.654424' }
16 Mar 16:33:32 - [info] [debug:a70609fb.55ffb8] 
{ topic: 'switch.christmas_tree_79',
  payload: 'turn_off',
  _msgid: '9aa8c3d5.8ecc7' }
16 Mar 16:44:48 - [info] [debug:a70609fb.55ffb8] 
{ topic: 'switch.christmas_tree_79',
  payload: 'turn_on',
  _msgid: 'da696855.cfaec8' }
16 Mar 16:52:24 - [info] [debug:a70609fb.55ffb8] 
{ topic: 'switch.window_lights_1_71',
  payload: 'turn_off',
  _msgid: '90f1510f.0113d' }
16 Mar 17:26:07 - [info] [debug:a70609fb.55ffb8] 
{ topic: 'switch.window_lights_1_71',
  payload: 'turn_on',
  _msgid: 'e602bcaa.47ae1' }
16 Mar 17:27:46 - [info] [debug:a70609fb.55ffb8] 
{ topic: 'switch.christmas_tree_79',
  payload: 'turn_off',
  _msgid: 'be8bcb17.769308' }
16 Mar 17:31:58 - [info] [debug:a70609fb.55ffb8] 
{ topic: 'switch.floor_lamp_21',
  payload: 'turn_on',
  _msgid: '56dc8a57.18d5c4' }
16 Mar 18:24:10 - [info] [debug:a70609fb.55ffb8] 
{ topic: 'switch.christmas_tree_79',
  payload: 'turn_on',
  _msgid: 'c3e3d4ca.7a07d8' }
csuermann commented 4 years ago

The version should be displayed in the palette manager.

You can enable verbose logging by adding this to your Node-RED settings.js file:

presenceFakerDebug: true

Maybe this points us to the source of that nasty behavior!?

crackers8199 commented 4 years ago

i still can't find it. i just ran an install again and this is what i see...

where do i find the settings.js file? i'm running nodered in docker...

csuermann commented 4 years ago

v.1.5.7 is indeed the latest version.

https://nodered.org/docs/getting-started/docker also talks about the settings.js file.

My guess is that the problem might stem from some sort of timezone problem. I'll try to investigate further. In the meantime, it would be great to get the verbose log output from you. Thanks!

csuermann commented 4 years ago

I still could not reproduce your issue. Perhaps you could narrow the problem down by configuring one presence-faker node to be active for just one hour and monitoring its activity. I'm guessing that the node behaves like expected but with an offset of x hours, potentially based on your system's timezone settings. Something like below config should help...

[{"id":"8c35c085.64758","type":"presence-faker","z":"7d5e54a0.99feec","name":"test","onPayload":"myOnPayload","onPayloadType":"str","onTopic":"myOnTopic","offPayload":"myOffPayload","offPayloadType":"str","offTopic":"myOffTopic","windowBegin":"09:00","windowEnd":"10:00","minDurationHours":0,"minDurationMinutes":"55","minDurationSeconds":0,"minDuration":"3300","maxDurationHours":0,"maxDurationMinutes":"55","maxDurationSeconds":0,"maxDuration":"3300","minCount":1,"maxCount":1,"startupBehavior":"onStartup","actionOnDisable":"none","x":170,"y":160,"wires":[["73d880a5.7ba3d"]]},{"id":"73d880a5.7ba3d","type":"debug","z":"7d5e54a0.99feec","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","x":330,"y":160,"wires":[]}]

crackers8199 commented 4 years ago

yeah, sorry i haven't been able to get the logs to you. we're home now so the presence faker hasn't really been needed...it freaks the dogs out if lights turn on and off randomly lol

i'll try turning it on tonight if i remember and see what happens.

csuermann commented 4 years ago

I finally managed to reproduce the issue and fixed it in v.1.6.1.

Best regards C.