Call service node Data inject msg.payload

Can I piggy back off of this? I need to do the same thing, but I need to send an integer not a string.

If I try {"value":"{{payload}}"} HA complains that extra keys not allowed @ data['0']

If I try {"value":{{payload}}} the node in Node-RED won’t accept it…

1 Like

This has to with you sending more data than the service call was expecting. Make sure you’re not passing any extra data in msg.payload.data for the previous nodes.

I finally managed to work it out. I had to use a template in the end to send the data through to the call service node.

I was actually trying to send the contents of a flow variable, so in my case it was {"data" : { "value" : {{flow.MinCool}} } }

I’m having the same troubles, thanks to this thread I can use a string but having problems with a value.

Say for example I want to call a brightness percentage of 80% my json would be

{"brightness_pct":80}

I have tried all of these with no luck

{"brightness_pct":{{payload}}}
{"brightness_pct":"{{payload}}"}
{"brightness_pct":{ "value" : {{msg.payload}} }
{"brightness_pct": {"data" : { "value" : {{msg.payload}} } }}
{"brightness_pct": "{"data" : { "value" : {{msg.payload}} } }"}

Is there anyone who can point me in the right direction, I simply want to insert a value into the json data field of the “Call Service Node”?

I have tried both string and number and the debug confirms both of these is a value/number.

I’m also happy to use a function of some type but the following doesn’t work due to these " being required for json and mean string in java.

msg.payload="{"brightness_pct":"+msg.payload+"}";
return msg;

and then just have {{payload}} in the data field.

I also tried:

msg.payload='{"brightness_pct":'+msg.payload+'}';
return msg;

and this passes through the correct looking string but back to the following error:

10/2/2019, 4:41:39 PMnode: RGB1 brightnessmsg : string[73]

“Call-service API error. Error Message: extra keys not allowed @ data[‘0’]”

I think I’m having the same type of trouble in this threat

If I find a solution I’ll try posting it here too.

To to this you need to send a data package in the function node:
Then either add the other values to your service call node, or just leave it empty.

newmsg = {}

newmsg.payload = { data: { “brightess_pct”:msg.payload} }

return newmsg;

Is the correct way to have

Msg.Payload
Msg.data.value1
msg.data.value2

or as I think you are writing

msg.payload.data.value1
msg.payload.data.value2

?

You can easily check as well as copy the path to your message using the debug node. Usually it would be msg.data.value1

Hi Wayne

Take a look in the thread I linked earlier, I think I have a solution you might need.

I FOUND IT!!! I’m sure there is an easier way but I can make it work!!

I watched this vid and used the first two functions and got it to work. https://www.youtube.com/watch?v=24ZY3CEsiow&t=970s

Just to explain my test situation…
I have an input slider called “brightness” that goes from 0-100.
I have an event state reading this slider which outputs a string consisting of a number between 0 & 100.
This goes into a function node with the following code. This converts to JSON.

var data={"brightness_pct":+msg.payload};
node.log(typeof data);
msg.payload= JSON.stringify(data);
return msg;

This goes to another function node with the following code. This gets the number back (in a different format???). This is where I think it could be more direct but yet to find a way.

p=JSON.parse(msg.payload);
node.log(typeof p);
msg.payload=p.brightness_pct;
return msg;

Now this gets passed to a call service node and the data field looks like this.

{"brightness_pct":{{payload}}}

And now my slider controls the brightness. The reason behind all this is I have 3 RGB strips in one project and would like the one slider to control all three at the same time, also by doing this I can “sync” patterns across all three.

I hope this helps people out.

1 Like

You are all going to laugh…

I changed the event state reading the slider to output the value (state type) as a number instead of a string…

wired this directly to the call service nodes with the following in the data field

{"brightness_pct":{{payload}}}

AND IT WORKS PERFECTLY!!!

3 Likes

I learned to sync different lights, put them together in a light group, works wonderfull!

But can you link the flow/configs for your slider and nodes? I’d like to see it :slight_smile:

Well I also wanted to have better control over custom patterns that actually sync together and this is the beginning of that.

image

image
Excuse the name, it is just a test at this stage

2 Likes

Truth be told, I use the light group to see if it’s on or off and turn them on individual.

I’ll link what I do later.
At the moment I’m struggling with the correct light color temperature!
Do made a long array with Kelvin colors in that I’m using atm.

Since there is a thread for this I will piggy back.

I’m trying to send a payload (string) from my function node to call service node (telegram) but I’m getting this error:

“Call-service API error. Error Message: required key not provided @ data[‘message’]”

Here is my code from the function node which gets formatted for Pushbullet output (which works it but I’m trying to migrate to Telegram):

// format message for Pushbullet
duration           = 'Total washing time: '+wash_time;
energy_use         = 'Energy Use: '+energy_kwh+' kWh';
total_cost         = 'Total cost: £'+cost+'.';

var new_msg        = duration+'\n'+energy_use+'\n'+total_cost;
msg.payload        = new_msg;

return msg;

JSON format for Call service node:

{"message":"{{payload}}"}

I have another function node with test string and that one works fine, so I’m not sure why I am getting the error:

msg.payload   = "This is a test!";
return msg;

Sorry if this similar to what was above but I’m still fairly new to this and trying to learn.

Hi

I would try in your function block to clear up the msg, like doing return new_msg;

This will make sure nothing of the old msg falls through, it has made some of my blocks fail in the past.

If this dosn’t help, please post an export of your blocks.

Hi,

I tried creating newMsg but I’m still getting the same result. I am able to pass the string (message) to Pushbullet but not to Telegram. Here is my flow, maybe I’m doing something wrong:

[{"id":"863c428c.eece28","type":"tab","label":"Washing Machine","disabled":false,"info":""},{"id":"eccd4cba.dfe6d8","type":"function","z":"863c428c.eece28","name":"Calculate power","func":"var power = msg.data.state;\nvar timer = 5;\n\nvar total = flow.get(\"Total\");\n\nflow.set(\"current_output\", power);\nflow.set(\"timeout\", timer);\n\n//sprawdz czy istnieje zbior mocy\nif(!total || !total.length || total === undefined){\n    total = [];\n}\n\n//dodaj moc do poczatku zbioru\ntotal.unshift(power);\n//remove X elementh\nif(total[timer] === undefined) {\n    \n    flow.set(\"Total\", total);\n}\nelse {\n    total.splice(timer, 1);\n    flow.set(\"Total\", total);\n}\n\n//calculate average\nvar sum = total;\nfunction add(accumulator, a) {\n    return accumulator + a;\n}\nvar average = sum.reduce(add);\n\n//debug\nmsg.powerPerMinute = total;\nmsg.average = average / timer;\nmsg.payload = power;\n\nreturn msg;","outputs":1,"noerr":0,"x":118,"y":589,"wires":[["c3be8535.af26a","71953a3.2a8a444","4032f627.b07b7"]]},{"id":"c83d313f.e627b8","type":"json","z":"863c428c.eece28","name":"JSON","property":"payload","action":"","pretty":false,"x":88,"y":627,"wires":[["eccd4cba.dfe6d8"]]},{"id":"3f35df07.55de28","type":"poll-state","z":"863c428c.eece28","name":"Washing Machine","server":"d21bd910.f50568","version":1,"updateinterval":"60","updateIntervalUnits":"seconds","outputinitially":true,"outputonchanged":true,"entity_id":"sensor.washing_machine_power_use","state_type":"num","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":128,"y":665,"wires":[["c83d313f.e627b8"]]},{"id":"bad2d414.ee3fa8","type":"comment","z":"863c428c.eece28","name":"Washing Machine Notifications","info":"","x":168,"y":1121,"wires":[]},{"id":"39c72d9b.f63dfa","type":"function","z":"863c428c.eece28","name":"Random Naggings","func":"var nagging = [\n    \"Hurry up and get the laundry out of the washing machine\",\n    \"Stop being useless and get the laundry out\",\n    \"Get the laundry out, now!\",\n    \"How many times do I have to tell you to empty the washing machine\",\n    \"Washing machine is not going to empty itself - move your ass!\",\n    \"Remove your laundry or it will smell\",\n    \"Hey, did you hear me? - Get the laundry out! Now!\"\n\n    ];\n\n\nvar random = nagging[Math.floor(Math.random() * nagging.length)];\nmsg.payload = random;\nreturn msg;","outputs":1,"noerr":0,"x":413,"y":1197,"wires":[["1e8d326a.e2ab8e"]]},{"id":"d4ce2ee7.0ad03","type":"delay","z":"863c428c.eece28","name":"","pauseType":"delay","timeout":"60","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1029,"y":1197,"wires":[["8a93bfb6.9baab8"]]},{"id":"ebfd0ada.d780d8","type":"switch","z":"863c428c.eece28","name":"Nagging?","property":"nagging","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":155,"y":1197,"wires":[["39c72d9b.f63dfa"]]},{"id":"8a93bfb6.9baab8","type":"link out","z":"863c428c.eece28","name":"Delay","links":["cc5ee8.9f2a2118"],"x":1136,"y":1197,"wires":[]},{"id":"cc5ee8.9f2a2118","type":"link in","z":"863c428c.eece28","name":"Nagging","links":["8a93bfb6.9baab8"],"x":53,"y":1197,"wires":[["ebfd0ada.d780d8"]]},{"id":"b0f8a14a.d56488","type":"mqtt in","z":"863c428c.eece28","name":"Location","topic":"sensor/Lastmotion","qos":"2","datatype":"auto","broker":"f6099aae.0aa7f","x":763,"y":114,"wires":[["1d4afebe.810971"]]},{"id":"c3be8535.af26a","type":"debug","z":"863c428c.eece28","name":"Average Power","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"average","targetType":"msg","x":403,"y":665,"wires":[]},{"id":"b9d91572.f554f8","type":"state-machine","z":"863c428c.eece28","name":"Washing Machine","triggerProperty":"payload","triggerPropertyType":"msg","stateProperty":"payload","statePropertyType":"msg","outputStateChangeOnly":true,"throwException":false,"states":["off","ready","start","washing rinsing","washing heating","spinning","finishing","water in","heater on","heater off","water out","stopped"],"transitions":[{"name":"ready","from":"off","to":"ready"},{"name":"start","from":"off","to":"start"},{"name":"start","from":"ready","to":"start"},{"name":"rinse","from":"start","to":"water in"},{"name":"spin","from":"water in","to":"heater on"},{"name":"wash","from":"heater on","to":"washing heating"},{"name":"spin","from":"washing heating","to":"heater off"},{"name":"rinse","from":"heater off","to":"washing rinsing"},{"name":"spin","from":"washing rinsing","to":"spinning"},{"name":"rinse","from":"spinning","to":"washing rinsing"},{"name":"start","from":"spinning","to":"finishing"},{"name":"start","from":"washing rinsing","to":"finishing"},{"name":"ready","from":"finishing","to":"stopped"},{"name":"off","from":"stopped","to":"off"},{"name":"off","from":"*","to":"off"}],"x":831,"y":589,"wires":[["56e07247.f6039c","24e4c964.c47cbe"]]},{"id":"71953a3.2a8a444","type":"switch","z":"863c428c.eece28","name":"Switch","property":"average","propertyType":"msg","rules":[{"t":"lt","v":"0.15","vt":"num"},{"t":"btwn","v":"0.15","vt":"num","v2":"0.51","v2t":"num"},{"t":"btwn","v":"0.52","vt":"num","v2":"4","v2t":"num"},{"t":"btwn","v":"4","vt":"num","v2":"200","v2t":"num"},{"t":"btwn","v":"200","vt":"num","v2":"700","v2t":"num"},{"t":"gt","v":"700","vt":"str"}],"checkall":"true","repair":false,"outputs":6,"x":383,"y":589,"wires":[["50d30f5f.e3c728"],["442d1843.07f4e"],["5f887fd8.06cca8"],["586c62fd.d49b4c"],["e503d51b.3bb3f"],["92f3cfb1.f589a"]]},{"id":"442d1843.07f4e","type":"change","z":"863c428c.eece28","name":"ready","rules":[{"t":"set","p":"payload","pt":"msg","to":"ready","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":532,"wires":[["b9d91572.f554f8","add62e99.80666"]]},{"id":"50d30f5f.e3c728","type":"change","z":"863c428c.eece28","name":"off","rules":[{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":494,"wires":[["b9d91572.f554f8","add62e99.80666"]]},{"id":"92f3cfb1.f589a","type":"change","z":"863c428c.eece28","name":"wash","rules":[{"t":"set","p":"payload","pt":"msg","to":"wash","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":684,"wires":[["b9d91572.f554f8","add62e99.80666"]]},{"id":"e503d51b.3bb3f","type":"change","z":"863c428c.eece28","name":"spin","rules":[{"t":"set","p":"payload","pt":"msg","to":"spin","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":646,"wires":[["b9d91572.f554f8","add62e99.80666"]]},{"id":"586c62fd.d49b4c","type":"change","z":"863c428c.eece28","name":"rinse","rules":[{"t":"set","p":"payload","pt":"msg","to":"rinse","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":608,"wires":[["b9d91572.f554f8","add62e99.80666"]]},{"id":"5f887fd8.06cca8","type":"change","z":"863c428c.eece28","name":"start","rules":[{"t":"set","p":"payload","pt":"msg","to":"start","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":570,"wires":[["b9d91572.f554f8","add62e99.80666"]]},{"id":"f96ac16f.e64298","type":"mqtt in","z":"863c428c.eece28","name":"Washing Machine On-Line","topic":"shellies/shelly1pm-washingmachine/online","qos":"2","datatype":"auto","broker":"f6099aae.0aa7f","x":158,"y":114,"wires":[["17870be6.9c845c"]]},{"id":"17870be6.9c845c","type":"debug","z":"863c428c.eece28","name":"Washing Machine On-Line","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":538,"y":114,"wires":[]},{"id":"d5b27269.578dd8","type":"mqtt in","z":"863c428c.eece28","name":"Washing Machine Relay Status","topic":"shellies/shelly1pm-BA53C4/relay/0","qos":"2","datatype":"auto","broker":"f6099aae.0aa7f","x":168,"y":171,"wires":[["b88ace8b.f964"]]},{"id":"b88ace8b.f964","type":"debug","z":"863c428c.eece28","name":"Washing Machine Status","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":528,"y":171,"wires":[]},{"id":"177dbaa0.270d85","type":"mqtt in","z":"863c428c.eece28","name":"Washing Machine Power","topic":"shellies/shelly1pm-BA53C4/relay/0/power","qos":"2","datatype":"auto","broker":"f6099aae.0aa7f","x":148,"y":228,"wires":[["bd354028.e1f478"]]},{"id":"279cd051.5f6a1","type":"mqtt in","z":"863c428c.eece28","name":"Washing Machine Energy","topic":"shellies/shelly1pm-BA53C4/relay/0/energy","qos":"2","datatype":"json","broker":"f6099aae.0aa7f","x":148,"y":285,"wires":[["f01b2ccc.6794d"]]},{"id":"bd354028.e1f478","type":"debug","z":"863c428c.eece28","name":"Wasching Machine Power","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":538,"y":228,"wires":[]},{"id":"f01b2ccc.6794d","type":"debug","z":"863c428c.eece28","name":"Washing Machine Energy","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":538,"y":285,"wires":[]},{"id":"1b8ccaa3.c7d835","type":"mqtt in","z":"863c428c.eece28","name":"Washing Machine Shelly Internal Temp","topic":"shellies/shelly1pm-BA53C4/temperature","qos":"2","datatype":"auto","broker":"f6099aae.0aa7f","x":198,"y":342,"wires":[["9429b726.34c1a8"]]},{"id":"9429b726.34c1a8","type":"debug","z":"863c428c.eece28","name":"Shelly WM Internal Temp","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":528,"y":342,"wires":[]},{"id":"480a4821.f0d76","type":"comment","z":"863c428c.eece28","name":"Washing Machine Shelly 1PM","info":"","x":170,"y":40,"wires":[]},{"id":"485d5d3a.2e6b14","type":"debug","z":"863c428c.eece28","name":"Test","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1053,"y":114,"wires":[]},{"id":"a83e3a2c.dce048","type":"debug","z":"863c428c.eece28","name":"Switch Test","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1030,"y":680,"wires":[]},{"id":"add62e99.80666","type":"rbe","z":"863c428c.eece28","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":790,"y":680,"wires":[["a83e3a2c.dce048"]]},{"id":"14ceedb6.5c9eba","type":"api-call-service","z":"863c428c.eece28","name":"Washing ON!","server":"d21bd910.f50568","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.washing_machine_running","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":118,"y":855,"wires":[["962b24d8.6ce518"]]},{"id":"cfd43d76.7f5dd","type":"function","z":"863c428c.eece28","name":"Controller","func":"// Define\nvar machine_status = msg.payload;\nvar washing_status = flow.get(\"washing_status\");\nvar power          = flow.get(\"current_output\");\n\n// Starting?\nif (machine_status === \"start\"){\n    flow.set(\"washing_status\", \"started\");\n    return[msg, null, null];\n} else if (machine_status === \"finishing\"){\n    flow.set(\"washing_status\", \"finishing\");\n    return[null, null, null];\n} else if ((machine_status === \"stopped\") && (washing_status === \"finishing\")){\n    flow.set(\"washing_status\", \"finished\");\n    flow.set(\"nagging\", true);\n    return[null, msg, null];\n} if ((power === 0) && (washing_status === \"finished\")){\n    flow.set(\"washing_status\", \"off\");\n    flow.set(\"nagging\", false);\n    return [null, null, msg];\n}","outputs":3,"noerr":0,"x":155,"y":931,"wires":[["14ceedb6.5c9eba"],["51d779ee.ff3c4"],["a458fa9c.ac5148"]],"outputLabels":["washing started","washing finished","washing machine off"]},{"id":"f9b2ce04.af0aa8","type":"link in","z":"863c428c.eece28","name":"Washing Controller","links":["24e4c964.c47cbe"],"x":53,"y":931,"wires":[["cfd43d76.7f5dd"]]},{"id":"4032f627.b07b7","type":"debug","z":"863c428c.eece28","name":"Power Debug","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":403,"y":513,"wires":[]},{"id":"a458fa9c.ac5148","type":"api-call-service","z":"863c428c.eece28","name":"Washing OFF!","server":"d21bd910.f50568","version":"1","service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.washing_machine_running","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":118,"y":1007,"wires":[[]]},{"id":"93ef487d.2a6cb","type":"debug","z":"863c428c.eece28","name":"Washing OFF","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":878,"y":855,"wires":[]},{"id":"962b24d8.6ce518","type":"api-current-state","z":"863c428c.eece28","name":"Washing Energy Use","server":"d21bd910.f50568","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.washing_machine_energy_use","state_type":"num","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":423,"y":855,"wires":[["eb0e948e.f1889"]]},{"id":"eb0e948e.f1889","type":"function","z":"863c428c.eece28","name":"Set Start Energy","func":"//get starting energy value\nvar energy              = msg.payload\n//energy_kwh            = Math.round(((energy /1000) /60) * 100) / 100\n\n//store energy in variable\nflow.set(\"start_energy\", energy);\n\n//get starting time\nvar now                 = new Date();\nvar time                = now.getTime();\n\n//store time in variable\nflow.set(\"start_time\", time);\n\n//debug\nmsg.start_energy        = flow.get(\"start_energy\");\nmsg.start_time          = flow.get(\"start_time\");\nmsg.washing_status      = flow.get(\"washing_status\");\nreturn msg;","outputs":1,"noerr":0,"x":660,"y":855,"wires":[[]]},{"id":"51272802.3811c8","type":"function","z":"863c428c.eece28","name":"Total Wash Time","func":"// energy calculation\nvar stop_energy    = msg.payload;\nvar start_energy   = flow.get(\"start_energy\");\nvar energy         = (stop_energy - start_energy);\nvar energy_kwh     = Math.round(((energy /1000) /60) * 100) / 100;\n\n// cost per unit of energy\nvar unit_cost      = 0.1874;\nvar cost           = Math.round((energy_kwh * unit_cost) * 100) / 100;\n\n//check time\nvar now     = new Date();\nvar time    = now.getTime();\nvar year    = now.getFullYear();\nvar month   = now.getMonth()+1; \nvar day     = now.getDate();\nvar hour    = now.getHours();\nvar minute  = now.getMinutes();\nvar second  = now.getSeconds();\n\nif(month.toString().length == 1){\n    month = '0'+month;\n}\nif(day.toString().length == 1){\n    day = '0'+day;\n}   \nif(hour.toString().length == 1){\n    hour = '0'+hour;\n}\nif(minute.toString().length == 1){\n    minute = '0'+minute;\n}\nif(second.toString().length == 1){\n    second = '0'+second;\n}\n\n//store time in variable\nvar start_time = flow.get(\"start_time\");\nvar wash_ms = (time - start_time);\n\nvar miliseconds   = (wash_ms % 1000);\nvar seconds       = Math.floor((wash_ms / 1000) % 60);\nvar minutes       = Math.floor((wash_ms / (60 * 1000)) % 60);\nvar hours         = Math.floor((wash_ms / (3600 * 1000)) % 60);\n\n// set timeformat\nif (hours !== 0){\n    hours = hours.toString();\n    if (minutes.toString().length == 1){\n        minutes   = '0'+minutes;\n    }\n    if (seconds.toString().length == 1){\n        seconds = '0'+seconds;\n    }\n    wash_time = hours+'h '+minutes+'m '+seconds+'s.';\n} else if (minutes !== 0){\n    minutes = minutes.toString();\n    if (seconds.toString().length ==1){\n        seconds = '0'+seconds;\n    }\n    wash_time = minutes+'m '+seconds+'s.';\n} else {\n    seconds   = seconds.toString()\n    wash_time = seconds+'s.';\n}\n\n// change to string\nenergy_kwh       = energy_kwh.toString();\ncost             = cost.toString();\n\n// topic generation for Pushbullet\nvar topic        = year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second+' Washing has finished!';\n\n// format message for Pushbullet\nduration         = 'Total washing time: '+wash_time;\nenergy_use       = 'Energy Use: '+energy_kwh+' kWh';\ntotal_cost       = 'Total cost: £'+cost+'.';\n\nmsg.topic        = topic;\ntime             = duration+'\\n'+energy_use+'\\n'+total_cost;\n\nvar newMsg = { payload: time };\n\nreturn newMsg;\n\n","outputs":1,"noerr":0,"x":660,"y":931,"wires":[["93ef487d.2a6cb","c8843270.1d88c8","75be320f.6e4724","96903c7b.f595f8"]]},{"id":"51d779ee.ff3c4","type":"api-current-state","z":"863c428c.eece28","name":"Washing Energy Use","server":"d21bd910.f50568","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.washing_machine_energy_use","state_type":"num","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":423,"y":931,"wires":[["51272802.3811c8"]]},{"id":"96903c7b.f595f8","type":"pushbullet","z":"863c428c.eece28","config":"825dadf.af6ca5","pushtype":"note","title":"","chan":"","name":"Washing ready!","x":1080,"y":940,"wires":[]},{"id":"c8843270.1d88c8","type":"change","z":"863c428c.eece28","name":"Finished","rules":[{"t":"set","p":"payload","pt":"msg","to":"Your washing is ready!","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":858,"y":1007,"wires":[["1e8d326a.e2ab8e"]]},{"id":"64bf3a7f.6878c4","type":"cast-to-client","z":"863c428c.eece28","name":"Bedroom","url":"","contentType":"","message":"","language":"en","ip":"192.168.1.26","port":"8009","volume":"40","x":839,"y":1159,"wires":[["d4ce2ee7.0ad03"]]},{"id":"b8884e71.a6a318","type":"cast-to-client","z":"863c428c.eece28","name":"Living Room","url":"","contentType":"","message":"","language":"en","ip":"192.168.1.26","port":"8009","volume":"50","x":849,"y":1235,"wires":[["d4ce2ee7.0ad03"]]},{"id":"1e8d326a.e2ab8e","type":"function","z":"863c428c.eece28","name":"Redirect","func":"var location = flow.get(\"last_motion\");\n\nif((location === \"Hall Upstairs\") || (location === \"Bathroom\")){\n    return [msg, null];\n} if((location === \"Kitchen\") || (location === \"Living Room\")){\n    return [null, msg];\n}\n","outputs":2,"noerr":0,"x":630,"y":1197,"wires":[["64bf3a7f.6878c4"],["b8884e71.a6a318"]]},{"id":"1d4afebe.810971","type":"function","z":"863c428c.eece28","name":"Save","func":"var location = msg.payload;\nflow.set(\"last_motion\", location);\n\nreturn msg;","outputs":1,"noerr":0,"x":913,"y":114,"wires":[["485d5d3a.2e6b14"]]},{"id":"3df959d1.587c56","type":"mqtt out","z":"863c428c.eece28","name":"Washing Status","topic":"sensor/washing_status","qos":"2","retain":"true","broker":"f6099aae.0aa7f","x":413,"y":1273,"wires":[]},{"id":"922b4cc0.b4ccf8","type":"function","z":"863c428c.eece28","name":"Status","func":"var status = msg.payload;\n\nif (status === \"off\"){\n    msg.payload = \"OFF\";\n} if (status === \"ready\"){\n    msg.payload = \"READY\";\n} if(status === \"start\"){\n    msg.payload = \"STARTING\";\n} if(status === \"water in\"){\n    msg.payload = \"WATER IN\";\n} if(status === \"heater on\"){\n    msg.payload = \"HEATING WATER\";\n} if(status === \"washing heating\"){\n    msg.payload = \"WASHING / HEATING\";\n} if(status === \"heater off\"){\n    msg.payload = \"HEATER OFF\";\n} if(status === \"washing rinsing\"){\n    msg.payload = \"WASHING / RINSING\";\n} if(status === \"spinning\"){\n    msg.payload = \"SPINNING\";\n} if(status === \"finishing\"){\n    msg.payload = \"FINISHING\";\n} if(status === \"stopped\"){\n    msg.payload = \"STOPPED\";\n}\nreturn msg;","outputs":1,"noerr":0,"x":145,"y":1273,"wires":[["3df959d1.587c56"]]},{"id":"56e07247.f6039c","type":"debug","z":"863c428c.eece28","name":"Washing State","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1040,"y":540,"wires":[]},{"id":"dc164db5.cf953","type":"inject","z":"863c428c.eece28","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":782,"y":247,"wires":[["5f887fd8.06cca8"]]},{"id":"78c5d7b4.be0d68","type":"inject","z":"863c428c.eece28","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":782,"y":287,"wires":[["586c62fd.d49b4c"]]},{"id":"70d2e3be.926bc4","type":"inject","z":"863c428c.eece28","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":782,"y":327,"wires":[["e503d51b.3bb3f"]]},{"id":"daf5112f.1d2e8","type":"inject","z":"863c428c.eece28","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":782,"y":367,"wires":[["92f3cfb1.f589a"]]},{"id":"4c318a9c.b0ee64","type":"inject","z":"863c428c.eece28","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":782,"y":207,"wires":[["442d1843.07f4e"]]},{"id":"f8dbe41a.4246a","type":"inject","z":"863c428c.eece28","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":782,"y":167,"wires":[["50d30f5f.e3c728"]]},{"id":"1fcf2221.d5119e","type":"link in","z":"863c428c.eece28","name":"Status Sensor","links":["24e4c964.c47cbe"],"x":53,"y":1273,"wires":[["922b4cc0.b4ccf8"]]},{"id":"980cb55b.cc3838","type":"comment","z":"863c428c.eece28","name":"Washing Calculations","info":"","x":138,"y":779,"wires":[]},{"id":"db758218.f59c08","type":"comment","z":"863c428c.eece28","name":"Washing Machine Notifications","info":"","x":168,"y":437,"wires":[]},{"id":"ab61dc2d.8d08","type":"inject","z":"863c428c.eece28","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":136,"y":1425,"wires":[["1efbe9e7.93e06e","23b4828d.b6f45e"]]},{"id":"6962732f.3b457c","type":"debug","z":"863c428c.eece28","name":"Telegram","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":630,"y":1425,"wires":[]},{"id":"1efbe9e7.93e06e","type":"function","z":"863c428c.eece28","name":"Test","func":"msg.payload   = \"This is a test!\";\nreturn msg;","outputs":1,"noerr":0,"x":285,"y":1425,"wires":[["32b49290.21700e","611b29ce.a60bc8"]]},{"id":"32b49290.21700e","type":"api-call-service","z":"863c428c.eece28","name":"Telegram Test","server":"d21bd910.f50568","version":1,"debugenabled":false,"service_domain":"telegram_bot","service":"send_message","entityId":"","data":"{\"message\":\"{{payload}}\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":460,"y":1425,"wires":[["6962732f.3b457c"]]},{"id":"9d55a832.59d3f8","type":"inject","z":"863c428c.eece28","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":383,"y":1007,"wires":[["51272802.3811c8"]]},{"id":"24e4c964.c47cbe","type":"link out","z":"863c428c.eece28","name":"Washing Machine State","links":["1fcf2221.d5119e","f9b2ce04.af0aa8","5a608ae9.cb0b6c","d52b594b.5fb358"],"x":975,"y":620,"wires":[]},{"id":"611b29ce.a60bc8","type":"debug","z":"863c428c.eece28","name":"Test","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":430,"y":1501,"wires":[]},{"id":"23b4828d.b6f45e","type":"debug","z":"863c428c.eece28","name":"Timestamp","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":450,"y":1558,"wires":[]},{"id":"75be320f.6e4724","type":"api-call-service","z":"863c428c.eece28","name":"Telegram Test","server":"d21bd910.f50568","version":1,"debugenabled":false,"service_domain":"telegram_bot","service":"send_message","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1080,"y":980,"wires":[[]]},{"id":"d21bd910.f50568","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true},{"id":"f6099aae.0aa7f","type":"mqtt-broker","z":"","name":"MQTT","broker":"192.168.1.7","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"825dadf.af6ca5","type":"pushbullet-config","z":"","name":"Sloma"}]

Thanks.