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

Controlling variables within HC3 Block Mode


Question

Posted

Is it possible to increment or decrement variables within Block Mode, or can this only be done via Lua, and thanks for help on forum policy

Regards Ron

Recommended Posts

  • 0
Posted (edited)

@Joep

I tried a completely new scene, I played with it a bit and I think I solved it this way. I will see if it will work as I need.

 

 

local hitCounter = hub.getSceneVariable("hitCounter")
local lastHitTime = hub.getSceneVariable("lastHitTime")
local notified   = hub.getSceneVariable("notified")
local currentTime = os.time(os.date("!*t"))
local pumpPower = tonumber(hub.getValue(187"power"))
 
 hub.debug("scene692", hitCounter)
 hub.debug("Scene692", pumpPower)
 hub.debug("Scene692", notified)
 
 if lastHitTime == nil or currentTime - lastHitTime >= 60 then
     hitCounter = 0
     hub.setSceneVariable("hitCounter", hitCounter)
 end
 
 if pumpPower >= 1000 then
     if hitCounter == 0 then
       lastHitTime = currentTime
       hub.setSceneVariable("lastHitTime", currentTime)
     end
     hitCounter = hitCounter + 1
     hub.setSceneVariable("hitCounter", hitCounter)
 
     if hitCounter >= 5 and notified == 0 then
        hub.alert("simplePush", {1026}, "Pump is hunting!"false"")
        notified = 1
        hub.setSceneVariable("notified", notified)
    end
else
     notified = 0
     hub.setSceneVariable("notified", notified)
end
Edited by Riki
  • 0
Posted (edited)

I am deleting this text. I put the same thing twice

Edited by Riki
  • 0
Posted
12 hours ago, Riki said:

I played with it a bit and I think I solved it this way.

Good news, I hope it works, have a nice day!

  • 0
Posted

Hello, I have a similar application but I stuck at setting and reading the value of the global variable. The value printed is always Nil. Why?

 

This is the only code in the LUA scene.

 

Please login or register to see this code.

 

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