Help with the Presence Faker node in a Home Assistant Install

Total Node-RED newb here. I have created some basic flows in my home assistant install, but I am having a hard time with the presence faker node. I am not sure what to enter in for the On/Off Topic and On/Off Payload. I have tried a few different options, but nothing seems to work. Any assistance on what I should be using to integrate a home assistant light would be greatly appreciated.

Thanks in advance.

Show/share the Node-RED flow you have made so far

Thank you. Here is what I have been testing with so far.

[{"id":"74dd77.6e80b288","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"8645b4cc.59f0a8","type":"server-state-changed","z":"74dd77.6e80b288","name":"Check Vacation","server":"a84d8bc7.13e838","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.vacation","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":220,"y":240,"wires":[["e755dcc2.e296a"],[]]},{"id":"e755dcc2.e296a","type":"presence-faker","z":"74dd77.6e80b288","name":"Guest Light","onPayload":"ON","onPayloadType":"str","onTopic":"{ 'entity_id': 'light.guest' }","offPayload":"OFF","offPayloadType":"str","offTopic":"{ 'entity_id': 'light.guest' }","windowBegin":"16:20","windowEnd":"18:20","minDurationHours":0,"minDurationMinutes":"4","minDurationSeconds":"25","minDuration":"265","maxDurationHours":0,"maxDurationMinutes":"7","maxDurationSeconds":0,"maxDuration":"420","minCount":"1","maxCount":"5","startupBehavior":"onStartup","actionOnDisable":"off","x":430,"y":260,"wires":[["5145a061.5aac1"]]},{"id":"5145a061.5aac1","type":"debug","z":"74dd77.6e80b288","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":260,"wires":[]},{"id":"a84d8bc7.13e838","type":"server","z":"","name":"Home Assistant"}]

Looking at the "topic" fields; you are using json payload in those, does not look correct. Topics are not required.

Thanks for your assistance. I tried to enter "light.guest" in the ON/OFF Payload and nothing in the topic and that has not worked. I tried a ton of other variations and so far have not been able to get it to work.

Hi @mattparker, in a typical use-case you'd put something like "on" or boolean 'true' as on/off payload and something like "lights/guest" as topic, but of course that all depends on your own setup.

What problem are you facing exactly?

Best regards
Cornelius

Cornelius,

Thank you. The main issue was that I had no idea what to enter to pass the proper information to homeassistant to actually control the lights. With a little help from the HA community, I finally figured it out, but have not had a chance to come in and update this topic until now.

Thanks everyone for their suggestions and assistance.

Here is what I needed to do:

  1. Set the ON payload to “turn_on”
  2. Set the OFF payload to “turn_off”
  3. Set both ON and OFF topic to “light.guest”
  4. Add HA service node, and set:
    a. Domain to “homeassistant” (this should auto complete)
    b. Service to "{{payload}}
    c. Entity_ID to “{{topic}}”
    c. In data enter “{}”

Here is what the Presence Faker and HA Service nodes look like when configured.

1 Like

Glad to hear you could resolve it. Thanks for updating the thread here.

1 Like

Hi Matt, I am traying to make this work with no luck. Do you have a diagram to share and tell me if this works to you?
I am a new on this :frowning:
Thanks in advance

Hello nicopag,

Here is what is working for me. It first checks if there is a vacation entry on a shared calendar and then activates a series of lights using the presence faker node. Let me know if this does not help. I am a beginner as well, but I will do what I can to assist.

[{"id":"a41d9b31.610738","type":"debug","z":"cecd0f38.c5b31","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":870,"y":300,"wires":[]},{"id":"8bbde663.b0b528","type":"api-call-service","z":"cecd0f38.c5b31","name":"Toggle","version":1,"debugenabled":true,"service_domain":"homeassistant","service":"{{payload}}","entityId":"{{topic}}","data":"{}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":670,"y":300,"wires":[["a41d9b31.610738"]]},{"id":"aedd9ffc.64eb2","type":"presence-faker","z":"cecd0f38.c5b31","name":"Guest Light Evening","onPayload":"turn_on","onPayloadType":"str","onTopic":"light.guest","offPayload":"turn_off","offPayloadType":"str","offTopic":"light.guest","windowBegin":"17:30","windowEnd":"23:00","minDurationHours":0,"minDurationMinutes":"15","minDurationSeconds":"15","minDuration":"915","maxDurationHours":"2","maxDurationMinutes":"2","maxDurationSeconds":"2","maxDuration":"7322","minCount":"1","maxCount":"5","startupBehavior":"onMsg","actionOnDisable":"none","x":420,"y":40,"wires":[["8bbde663.b0b528"]]},{"id":"4b8d7797.988608","type":"presence-faker","z":"cecd0f38.c5b31","name":"Living Ceiling Morning","onPayload":"turn_on","onPayloadType":"str","onTopic":"switch.living_ceiling","offPayload":"turn_off","offPayloadType":"str","offTopic":"switch.living_ceiling","windowBegin":"06:00","windowEnd":"08:30","minDurationHours":0,"minDurationMinutes":"1","minDurationSeconds":"1","minDuration":"61","maxDurationHours":0,"maxDurationMinutes":"1","maxDurationSeconds":"2","maxDuration":"62","minCount":"1","maxCount":"4","startupBehavior":"onMsg","actionOnDisable":"none","x":420,"y":100,"wires":[["8bbde663.b0b528"]]},{"id":"def236d7.4492c8","type":"presence-faker","z":"cecd0f38.c5b31","name":"Living Ceiling Evening","onPayload":"turn_on","onPayloadType":"str","onTopic":"switch.living_ceiling","offPayload":"turn_off","offPayloadType":"str","offTopic":"switch.living_ceiling","windowBegin":"17:00","windowEnd":"22:56","minDurationHours":0,"minDurationMinutes":"1","minDurationSeconds":"1","minDuration":"61","maxDurationHours":0,"maxDurationMinutes":"1","maxDurationSeconds":"2","maxDuration":"62","minCount":"2","maxCount":"5","startupBehavior":"onMsg","actionOnDisable":"none","x":420,"y":160,"wires":[["8bbde663.b0b528"]]},{"id":"dfc567dd.6fc628","type":"presence-faker","z":"cecd0f38.c5b31","name":"Laurie's Lamp Mornning","onPayload":"turn_on","onPayloadType":"str","onTopic":"light.laurie_s_lamp","offPayload":"turn_off","offPayloadType":"str","offTopic":"light.laurie_s_lamp","windowBegin":"06:00","windowEnd":"08:30","minDurationHours":0,"minDurationMinutes":"45","minDurationSeconds":"1","minDuration":"2701","maxDurationHours":"2","maxDurationMinutes":"1","maxDurationSeconds":"2","maxDuration":"7262","minCount":"1","maxCount":"3","startupBehavior":"onMsg","actionOnDisable":"none","x":430,"y":220,"wires":[["8bbde663.b0b528"]]},{"id":"afffa159.00b95","type":"presence-faker","z":"cecd0f38.c5b31","name":"Laurie's Lamp Evening","onPayload":"turn_on","onPayloadType":"str","onTopic":"light.laurie_s_lamp","offPayload":"turn_off","offPayloadType":"str","offTopic":"light.laurie_s_lamp","windowBegin":"17:00","windowEnd":"23:45","minDurationHours":0,"minDurationMinutes":"50","minDurationSeconds":"1","minDuration":"3001","maxDurationHours":"4","maxDurationMinutes":"1","maxDurationSeconds":"2","maxDuration":"14462","minCount":"2","maxCount":"8","startupBehavior":"onMsg","actionOnDisable":"none","x":420,"y":280,"wires":[["8bbde663.b0b528"]]},{"id":"1b694de8.fccdf2","type":"presence-faker","z":"cecd0f38.c5b31","name":"Matt's Lamp Evening","onPayload":"turn_on","onPayloadType":"str","onTopic":"switch.matts_lamp","offPayload":"turn_off","offPayloadType":"str","offTopic":"switch.matts_lamp","windowBegin":"17:00","windowEnd":"23:45","minDurationHours":0,"minDurationMinutes":"5","minDurationSeconds":"1","minDuration":"301","maxDurationHours":"1","maxDurationMinutes":"1","maxDurationSeconds":"2","maxDuration":"3662","minCount":"1","maxCount":"3","startupBehavior":"onMsg","actionOnDisable":"none","x":420,"y":400,"wires":[["8bbde663.b0b528"]]},{"id":"3d574a.760c48b6","type":"presence-faker","z":"cecd0f38.c5b31","name":"Matt's Lamp Morning","onPayload":"turn_on","onPayloadType":"str","onTopic":"switch.matts_lamp","offPayload":"turn_off","offPayloadType":"str","offTopic":"switch.matts_lamp","windowBegin":"06:15","windowEnd":"08:30","minDurationHours":0,"minDurationMinutes":"8","minDurationSeconds":"1","minDuration":"481","maxDurationHours":0,"maxDurationMinutes":"50","maxDurationSeconds":"2","maxDuration":"3002","minCount":"1","maxCount":"3","startupBehavior":"onMsg","actionOnDisable":"none","x":420,"y":340,"wires":[["8bbde663.b0b528"]]},{"id":"f54842a1.68d2b","type":"time-range-switch","z":"cecd0f38.c5b31","name":"Evening Time","startTime":"23:12","endTime":"23:46","startOffset":0,"endOffset":0,"x":400,"y":580,"wires":[["3d9382ca.555dde"],[]]},{"id":"3d9382ca.555dde","type":"api-call-service","z":"cecd0f38.c5b31","name":"Living Lamp Off","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"switch.living_room_lamp","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":700,"y":580,"wires":[[]]},{"id":"39b8c069.05f6f","type":"presence-faker","z":"cecd0f38.c5b31","name":"Master Ceiling Morning","onPayload":"turn_on","onPayloadType":"str","onTopic":"switch.master_light","offPayload":"turn_off","offPayloadType":"str","offTopic":"switch.master_light","windowBegin":"05:45","windowEnd":"07:56","minDurationHours":0,"minDurationMinutes":"15","minDurationSeconds":"1","minDuration":"901","maxDurationHours":"2","maxDurationMinutes":"1","maxDurationSeconds":"2","maxDuration":"7262","minCount":"1","maxCount":"3","startupBehavior":"onMsg","actionOnDisable":"none","x":430,"y":460,"wires":[["8bbde663.b0b528"]]},{"id":"6b776527.3c2e1c","type":"presence-faker","z":"cecd0f38.c5b31","name":"Master Ceiling Evening","onPayload":"turn_on","onPayloadType":"str","onTopic":"switch.master_light","offPayload":"turn_off","offPayloadType":"str","offTopic":"switch.master_light","windowBegin":"18:10","windowEnd":"23:10","minDurationHours":0,"minDurationMinutes":"30","minDurationSeconds":"1","minDuration":"1801","maxDurationHours":"3","maxDurationMinutes":"1","maxDurationSeconds":"2","maxDuration":"10862","minCount":"2","maxCount":"4","startupBehavior":"onMsg","actionOnDisable":"none","x":430,"y":520,"wires":[["8bbde663.b0b528"]]},{"id":"78b2abf.6fe9754","type":"server-state-changed","z":"cecd0f38.c5b31","name":"Check Vacation","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.vacation","entityidfiltertype":"exact","outputinitially":true,"state_type":"habool","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":101,"y":320,"wires":[["aedd9ffc.64eb2","4b8d7797.988608","def236d7.4492c8","dfc567dd.6fc628","afffa159.00b95","3d574a.760c48b6","1b694de8.fccdf2","39b8c069.05f6f","6b776527.3c2e1c","f54842a1.68d2b"]]}]
1 Like

thanks Matt. I will try that today

hi Matt, I am trying to test this with a simple lamp, and when I inject a true to the fake node, it turns on the lamp, but never turn it off in random time.
this is my basic test:


with this conf:

What I am doing wrong?
Thanks

The only thing I see that is different between my set up and yours is that your set up does not have '{}' in the Data on your call service node. Now, I am a complete beginner as well so that may not be it, but it is worth a try.

thanks Matt! that make this works!
I have a question. What happens when the timer is off? Does this script turn off all the lights that randomly was turning on in that period?
Thanks

Yes, I believe that is what happens. During my testing all lights were always off at the end of the defined period.

This thread has been very helpful for me as well.
I apologize for hijacking, but I'm trying to make a presence faker dependent of an input.bolean state, meaning that the presnce faker should only run or should only pass messages, if this state is true.
I'm using the current state node.

Regards

Could you use node-red-contrib-simple-gate to act as a gateway to pass or block messages?

NOTE - node-red-contrib-simple-gate will convert your boolean state message to a string value, and test it against the command definition.
So if you input boolean state false as a control message, and the config is looking for a string "false", then the gate will be blocked.
The same with true === "true" will result in the gate being opened.

You are probably right, but since I'm new to node red that doesn't really make sense to me. I hoped for a more "simple building block" kind of solution.
I can get both big timer and presence faker switch light groups, but I can't make it dependent of this state.

In fact looking at the node-red-contrib-presence-faker readme, I see that it can be enabled or disabled via an input msg, and the node's example flow shows you how to do it.

Have you tried the example flow, why doesn't it do what you are requesting? can you be more specific.