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

get value and store in global variable


Question

Posted

I want to get a value from my Arduino Yun. The idea was simple:

Please login or register to see this code.

The html page look like this: 21.3

Please login or register to see this code.

This label however is always nil. I tried a lot of variations but it never worked.

Am I missing something?

Btw. Why can't I see these variables when making a new graphic scene?

I used the virtual device since the scenes didn't work well with the html part. Why is this?

Thanks!

6 answers to this question

Recommended Posts

  • 1
Posted

Try making it look like a json string, i.e.

{"value":23.1}

And then get the hc2 to parse the json. That should return an array with a single value.

Just make sure that the html has absolutely no other code in it. If you open the source in a browser, it should look exactly like the json.

  • 0
Posted

Please login or register to see this image.

/emoticons/default_icon_redface.gif" alt=":oops:" />

Please login or register to see this image.

/emoticons/default_icon_redface.gif" alt=":oops:" />
  • 0
Posted

isnt the syntax

fibaro:getGlobalValue("pc_state") == "active"

?

You are using getglobal without Value.

and did you declare the variable?

eg

--[[

%% autostart

%% properties

%% globals

pc_state

--]]

Be warned Value is with a capital letter hope it helps

  • 0
Posted

You don't need to declare a global in the triggers section. That section will just make the scene trigger if the global variable pc_state changes. You only need to do:

Please login or register to see this code.

The global variable has already been declared (you did that when you created it in your variables panel).

And if it is a number you want to use as a floating point or integer, the code should look like:

Please login or register to see this code.

Local is not strictly necessary, but variables should be declared with the correct attributes. "tonumber" parses the global (which is for some reason always returned as a string) into a floating point number so it can be used arithmetically.

  • 0
  • Inquirer
  • Posted

    I only use getGlobal and it works as expected. Not sure if there is any issues by doing that but I didn't experience any.

    Anyway the solution to my task was really simple. No need for JSON in that case as the Arduino passes a straight number.

    Please login or register to see this code.

    • 0
    Guest samuelboerhoop
    Posted

    What is the arduino source code of this project?

     

    I am trying to have an input(s) connected on an arduino nano then sent to the fibaro HC2.

     

    How to do so? 

    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...