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

LUA scene comparing the value of two devices.


Question

Posted

Hello everyone,


I'm approaching LUA scenes that I've never done before (so advanced for me).

 

Premise:
Photovoltaic system with storage

 

Action:
Turn on the electric boiler (via fibaro switch),

when:
a) The battery is full (99/100%);

and

b) The panels' production is active (electricity production).
c) Internal home consumption is less than panel production in point b.

 

I created a block scene with the devices and then transformed it into lua and this is the conversion.

 

id 567 =battery;

id 561 = Panels;

id 563 = internal consumption

 

id 534 = Switch (Boiler)

 

DECLARATIONS (Conditions/Triggers)

Please login or register to see this code.

 

ACTIONS

 

Please login or register to see this code.

 

 

 

How can I create a Lua scenario from scratch and check the value of the two devices b and c?

 

thanks in advance.

Fab...

2 answers to this question

Recommended Posts

  • 0
Posted (edited)

Hello
i have similar kind 
can anyone help out like Room Temp =( Set temp-1) DEGREE THEN FAN MODE 
Room Temp >=( Set temp-2)  OFF MODE 
Room Temp <=( Set temp) THEN COOL MODE

i need LUA code for above condition execution

Edited by Nadeem
  • 0
Posted (edited)

As a newbie it has been very good (for me at least) to use for instance Chatgpt for LUA-code generation. 
I asked the AI from this thread and this is what i got as response. Please do not hold it against me as I did not test the code and I only posted to suggest getting help from todays very accessible AI services...

 

First triggers:
 

Please login or register to see this code.

 

then the actions
 

Please login or register to see this code.

 

Finally some explanation:

Detailed Explanation

Key Functions

  1. getDeviceValue(deviceID)

    • Retrieves the current value of a device using Fibaro's API.
    • Checks if the device has the required value property and converts it to a number.
  2. isBatteryFull()

    • Checks if the battery value is greater than or equal to 99.
  3. isPanelProductionActive()

    • Ensures that the panels are actively producing energy (value > 0).
  4. isConsumptionLow()

    • Compares internal consumption (563) with panels' production (561).
    • Returns true if consumption is less than or equal to production.
  5. controlBoiler()

    • Evaluates the three conditions:
      • If all conditions are true: Turns on the boiler.
      • If any condition is false: Logs a message and ensures the boiler is off.

Final Steps

  1. Save the Script:
    • Paste the triggers and action script into a Lua Scene in Fibaro HC3.
  2. Test the Logic:
    • Simulate changes in the devices' values to verify behavior.
  3. Debugging:
    • Debug messages are included to track execution in the Fibaro HC3 console.
Edited by Whswede

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