Jump to content
  • 0

Send Global variable value from Node-Red


Question

Hi can anyone help me please? I want to send a  value from my Node-red and assign it to a Global variable value on my HC2.

 

The Global variable i wish to update is "message" and the value is "Connection established".

 

Tried some flows from here but always get JSON error.

Hop someone can help ... Thanks

Link to post
Share on other sites

9 answers to this question

Recommended Posts

  • 0

100500 was answered by me

1) only via admin user

2) easy do this via VD. node-red -> call your VD ->VD change or update globals

[{"id":"c4cdbe4c.c1dba","type":"http request","z":"66b2aa16.b03184","name":"HC2: set global","method":"PUT","ret":"obj","url":"http://192.168.1.36/api/globalVariables/{{{topic}}}","tls":"","x":660,"y":320,"wires":[["5b95809f.d03c"]]},{"id":"5b95809f.d03c","type":"debug","z":"66b2aa16.b03184","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":850,"y":320,"wires":[]},{"id":"264c340d.44157c","type":"change","z":"66b2aa16.b03184","name":"do not touch","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.name","pt":"msg","to":"topic","tot":"msg"},{"t":"set","p":"payload.value","pt":"msg","to":"value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":320,"wires":[["c4cdbe4c.c1dba"]]},{"id":"aa1ac1c7.272a9","type":"inject","z":"66b2aa16.b03184","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":320,"wires":[["b14bb006.b56ff"]]},{"id":"b14bb006.b56ff","type":"change","z":"66b2aa16.b03184","name":"change me!","rules":[{"t":"set","p":"topic","pt":"msg","to":"Test","tot":"str"},{"t":"set","p":"value","pt":"msg","to":"Ololo","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":320,"wires":[["264c340d.44157c"]]}]

 

do not forget

 

image.png.70b28a574a9c14e77c59dee0a8de252d.png

Link to post
Share on other sites
  • 0

Hi 10der thank you for you quick answer. Can you explain more about the VD route that sounds promising ?.

 

 

Link to post
Share on other sites
  • 0

Hi 10der me again!!

your flow works perfectly and updates the global variable but scenes triggered by the global do not run ? am i missing something here?

 

im sure you will know ;)

 

Len

Link to post
Share on other sites
  • 0
9 hours ago, magicman said:

but scenes triggered by the global do not run ?

I do not have HC2 plus sclerosis ;) 

1sh it’s right behavior as for Fibaro 

if you want trigger scenes by global parameters we should provide key in POST - but sclerosis;) 

try google this forum as far as I remember I was wrote about this 2 y ago 

Edited by 10der
Link to post
Share on other sites
  • 0

@magicman

jakub.jezek @

  • Expert 

That "invokeScenes" statment is available with REST API. See Bugzilla ticket 3483.

So if you change variable with REST API and not with fibaro:setGlobal(), than you can use "invokeScenes".

 

In JSON body it will be {"value":"xyz","invokeScenes":true}.

 

You can use it in LUA. I used it with HCL, so i had to made virtual device, that uses REST API.

 

@Fibaro: You could implement "invokeScenes" into setvariable in Block scenes and in LUA scenes and set it to true by default.

Edited by 10der
Link to post
Share on other sites
  • 0
2 minutes ago, magicman said:

Thank you 10der i will investigate these options

nothing investigate here :)

just add (chage) my flow

 

image.png.35945aed702399dfe0acd8a8cc95cde8.png

Link to post
Share on other sites
  • 0
On 6/2/2020 at 8:47 PM, 10der said:

100500 was answered by me

1) only via admin user

2) easy do this via VD. node-red -> call your VD ->VD change or update globals


[{"id":"c4cdbe4c.c1dba","type":"http request","z":"66b2aa16.b03184","name":"HC2: set global","method":"PUT","ret":"obj","url":"http://192.168.1.36/api/globalVariables/{{{topic}}}","tls":"","x":660,"y":320,"wires":[["5b95809f.d03c"]]},{"id":"5b95809f.d03c","type":"debug","z":"66b2aa16.b03184","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":850,"y":320,"wires":[]},{"id":"264c340d.44157c","type":"change","z":"66b2aa16.b03184","name":"do not touch","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.name","pt":"msg","to":"topic","tot":"msg"},{"t":"set","p":"payload.value","pt":"msg","to":"value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":320,"wires":[["c4cdbe4c.c1dba"]]},{"id":"aa1ac1c7.272a9","type":"inject","z":"66b2aa16.b03184","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":320,"wires":[["b14bb006.b56ff"]]},{"id":"b14bb006.b56ff","type":"change","z":"66b2aa16.b03184","name":"change me!","rules":[{"t":"set","p":"topic","pt":"msg","to":"Test","tot":"str"},{"t":"set","p":"value","pt":"msg","to":"Ololo","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":320,"wires":[["264c340d.44157c"]]}]

 

do not forget

 

image.png.70b28a574a9c14e77c59dee0a8de252d.png

 

 

Hello

I'm trying to get this to work but always have a JSON parse error.

What is this virtual device required? I have been trying most of the day to get the MQTT broker working with fibaro and node-red and that seems to be working now but i cannot get node red to change any of the variables in the variable panel in fibaro using this node-red string. 

 

My MQTT is working as i can get device info in node-red fine, It's just the other way (node-red to fibaro)

 

Thanks for the good work!

 

Regards

Mathew

 

Edit, I'm not new. I lost my account when the forum upgraded!

Edited by M4TVW
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...