Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Sending CURL commands from a LUA coded scene


svossepoel

Question

Hi experts,

 

Sorry to bother you with this newbie question. Well, at least I think it is ;-) I am trying to get some data from my Fibaro devices and pushing that data to an InFluxDB by running a scene on my HC2.

 

Can someone tell me how to code the following CURL statement in a LUA scene:

 

curl -i -XPOST 'http://localhost:8086/write?db=hc2' --data-binary 'cpu_load_short,host=server02,region=us-west value=0.64 1434055562000000000'

 

I tried a POST through HTTP, but that doesn't work (most likely because of the InFluxDB version), but when using above CURL command from a Terminal session it perfectly works, but now I need to know how to do this in LUA.

 

Many thanks in advance, Sjaak

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

This is example of scene called from another scene  or VD for GET, POST data to/from others system from HC2. Is no problem implement the code direct in yours scene (this is function) or call as external.

IFor use returned data is needed to add code for use it in this scene itself or put in global variable or write ex. to source scene debug message and after it retrieve, any method is good

If you need it function http:call(method, url, user, pwd , content, datas) return all necessary data add data, status_id, err_id =  http:call(method, url, user, pwd , content, datas) in place of http:call(method, url, user, pwd , content, datas) at end of code.

data - returned_data(many time s json object/table)

status_id - status of call from server (if success return 200)

err_id - error number from called server (ex 401 - no authorised)

 

Please login or register to see this code.

 

Edited by drboss
Link to comment
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...