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

Count scene


Question

Posted

I need a scene that counts if the wall plug goes on.

I dont know how this works.

Can anybody help?

15 answers to this question

Recommended Posts

  • 0
Posted (edited)

What do you mean with “counts if wall plug goes on”?

Edited by kevin
  • 0
Posted

Here's a suggestion to get you started:

Create a global variable called PlugCount

Create an LUA scene

- set a trigger in the header, of a change in your device's status

- IF your wall plug device is ON

- THEN PlugCount = PlugCount + 1

- print PlugCount value to the debug screen

 

You can also then read the PlugCount value in other scenes.

  • 0
  • Inquirer
  • Posted

    It doesnt work for me.

    Fibaro said: 

    Attempt to perform arithmetic on global xxxxx(a nil value)

    • 0
    Posted
    2 minutes ago, xxJAREKxx said:

    Attempt to perform arithmetic on global xxxxx(a nil value)

    Hi @xxJAREKxx, show your code, than we can see what's wrong.

    • 0
    Posted
    4 hours ago, xxJAREKxx said:

    Attempt to perform arithmetic on global xxxxx(a nil value)

    Nil value means the global variable is blank.  Aside from showing us your code, did you set the global variable to "0" in the variables panel?  LUA uses variables that have no types, so it should recognise the value as a number.  If not, you can try the function "tonumber".

    • Like 1
    • 0
  • Inquirer
  • Posted

    This is what i have

    Please login or register to see this attachment.

    • 0
    Posted

    Having seen your code, I think you might need to better define what PlugCount is for the script. I suggest you create a dummy block scene that uses your global variable and then convert it to LUA, so you can see the correct syntax for this.

    • 0
    Posted (edited)

    The PlugCount part will not work. If PlugCount is your defined global variable and holds the last count, then: 

     

    a = fibaro:getGlobalValue(“PlugCount”) + 1 

    fibaro:setGlobal(“PlugCount”, a)

     

     

    Edited by SmartHomeEddy
    added quotes
    • Like 1
    • 0
  • Inquirer
  • Posted

    Hmm i m not good in lua and i dont understand it

    Please login or register to see this attachment.

    • 0
    Posted

    Sorry, it needs some quotes “...” 

    • 0
  • Inquirer
  • Posted

    Thx but i give up

    • 0
  • Inquirer
  • Posted

    Ok solved

    • 0
    Posted

    Congrats, you solved it @xxJAREKxx!

     

    Do post your code back here so others can benefit.

    • 0
  • Inquirer
  • Posted

    Please login or register to see this attachment.

    Please login or register to see this attachment.

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