Jump to content
  • 0

Why will this scene not run when the HC2 starts ?


Question

I have a lua scene that I want when the HC2 starts up.  But it will not run.

 

--[[
%% properties
%% events
%% globals
--]]
local message = 'HC2 restarted'
-- Rohit
fibaro:call (4, "sendEmail", message, message)
-- Rajan
fibaro:call (304, "sendEmail", message, message)

 

 

The properties are as in the image.  Any idea why ?

 

Background - I have had continuous problems for 6 months now with all versions of firmware where the HC just does not run some scenes sometimes.  The debug shows that its not busy at all.  So I now have a scene that reboots it every morning at 4am.  It sends me an email telling me its about to reboot.  I would like one above to tell me that it has rebooted.

Screenshot 2018-04-20 08.28.34.png

Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hi!

 

add autostart to a header

 

--[[
%% properties
%% events
%% globals

%% autostart
--]]

 

--[[
%% properties
%% events
%% globals
%% autostart
--]]

local sourceTrigger = fibaro:getSourceTrigger();
if (sourceTrigger["type"] == "autostart") then

	local message = 'HC2 restarted'
	-- Rohit
	fibaro:call (4, "sendEmail", message, message)
	-- Rajan
	fibaro:call (304, "sendEmail", message, message)
 
 end
 

 

Link to post
Share on other sites
  • 0

Scene lanched on my hc2 on start time, only one time  (modified scene from domotique-fibaro.fr):

--[[
%% autostart
%% properties
%% events
%% globals
--]] 
sourceTrigger = fibaro:getSourceTrigger() 
if (sourceTrigger["type"] == "autostart") then
  
  -- check curent time and time of run hc2
    local ct = os.date ("%d/%m/%Y à %H:%M:%S")	
    local hc2 = api.get('/settings/info')    
	local data=tostring(os.date("%d %m %Y %X"))
 

local email={2,205} -- users for send email
local pmsg={1205} -- users for push message

    --run in first 15 minutes after start
if os.time() - hc2.serverStatus <= 15 * 60 then 
    
fibaro:setGlobal("last_start", "HC2 started at: "..data)
fibaro:sleep( 60 *1000 )  
for i=1, #email do
    	if email[i] ~= nil then
        fibaro:debug('Wysłano email do '..email[i]) 
    	fibaro:call(email[i], "sendEmail", "Start HC2", "HC2 started at: "..data)
		end
end
        
    for i=1, #pmsg do
    	if pmsg[i] ~= nil then
        fibaro:debug('Push send to '..pmsg[i]) 
	    fibaro:call(pmsg[i], 'sendPush', "Start HC2")
		end
    end

  fibaro:debug('HC2 start checked') 
  -- place for one time run commands on start hc2
    
  print('end')

  
  
end
  
else
print("Bypass not autostart")
end

 

Edited by drboss
Link to post
Share on other sites
  • 0

Thanks guys,  I dont understand why I have to put it but it works.  And the @drboss.  That gives me further ideas to enhance it as this script - I was just testing the concept.  I wanted to do push but I decided not too as you have to send to a mobile (not the person) and that's going to change every 18 months as I get a new phone.  Or is my understanding wrong ?

Link to post
Share on other sites
  • 0
6 hours ago, RohitNz said:

Thanks guys,  I dont understand why I have to put it but it works.  And the @drboss.  That gives me further ideas to enhance it as this script - I was just testing the concept.  I wanted to do push but I decided not too as you have to send to a mobile (not the person) and that's going to change every 18 months as I get a new phone.  Or is my understanding wrong ?

 

function doNotifyAll(title, msg)
      local response, status = api.get("/iosDevices")
    for k, dev in ipairs(response) do
        fibaro:call(dev.id, "sendPush", title .. " : ".. msg);                
    end
end

let's SPAM :)

 

doNotifyAll("Warning!", "HC2 was rebooted")

 

 

Link to post
Share on other sites
  • 0

Thanks, I couldn't do that because there are about 30 mobiles in the list. But maybe I can look at the data saved on each one to filter them out. For instance there are guest mobiles and alarm monitoring mobiles.

 

I know how to get all the data from the api url.

Link to post
Share on other sites

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