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

Help combining 2 LUA scripts onto one!


Question

Posted

Hi,

 

Still new to LUA.. I have created two scenes to simple notify me when a door is opened and closed. Surely there is a cleaner way to have this running in a single scene?

 

Scene 1:

 

 

local startSource = fibaro:getSourceTrigger();
if (
 ( tonumber(fibaro:getValue(377, "value")) > 0 )
or
startSource["type"] == "other"
)
then
    fibaro:call(2, "sendDefinedEmailNotification", "342");
    api.post('/mobile/push', {["mobileDevices"]={373}, ["message"]=[[The gun safe door is OPEN]], ["title"]='GunSafe_Open', ["category"]='RUN_CANCEL', ["data"]={["sceneId"]=9}});
end

 

 

Scene 2:

 

 

local startSource = fibaro:getSourceTrigger();
if (
 ( tonumber(fibaro:getValue(377, "value")) == 0 )
or
startSource["type"] == "other"
)
then
    fibaro:call(2, "sendDefinedEmailNotification", "343");
    fibaro:call(373, "sendDefinedPushNotification", "343");
end

 

 

 

 

 

 

 

Thank you

5 answers to this question

Recommended Posts

  • 0
Posted
10 minutes ago, JamieSonegoAus said:

The gun safe door is OPEN


??? only in Australia (almost)

  • 0
Posted

Hi, i believe this should work

 

Please login or register to see this code.

 

  • 0
Posted
12 hours ago, SmartHomeEddy said:


??? only in Australia (almost)

On topic, but off topic... just to ensure a correct view of us Aussies:

 

3% of Australians own a gun (these must be kept in a gun safe)

30% of Americans own a gun (these seem to be kept in ones back pocket or the car glovebox, ready for immediate use)

 

I know where I'd rather live!! ?

  • Like 1
  • 0
Posted
5 hours ago, Tim__ said:

On topic, but off topic... just to ensure a correct view of us Aussies:

 

3% of Australians own a gun (these must be kept in a gun safe)

30% of Americans own a gun (these seem to be kept in ones back pocket or the car glovebox, ready for immediate use)

 

I know where I'd rather live!! ?

Yes, just that riffle holders for your bed is a thing in the US tells a lot ;-) 

Please login or register to see this link.

 

  • Like 3
  • 0
Posted

hi

here is the simple solution:

 

--[[
%% properties
377 value
%% events
%% globals
--]]
 
 
local door = fibaro:getValue(377, "value")
 
if (door == '1') then
fibaro:call(2,'sendPush','The Gun Safe Door is Open')
fibaro:call(373,'sendPush','The Gun Safe Door is Open')
 
end
 
if (door == '0') then
fibaro:call(2,'sendPush','The Gun Safe Dor is Closed')
fibaro:call(373,'sendPush','The Gun Safe Door is Closed')
 
end

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