semester

Hjälp varandra att vara kreativa för att göra hemmet mer bekvämt.
Post Reply
nohed
Medlem
Posts: 88
Joined: 20 Apr 2013, 14:10
11

Kan man fixa ihop en smart semester "Lua kod" som tänder och släcker lampor efter solnedgång, slumpvis både hur länge de är tände och när de tänds
jompa68
Proffsmedlem
Posts: 735
Joined: 12 Aug 2012, 08:53
12
Location: Hofors

Enligt önskemål, bara att importera den virtuella enheten som ligger med.
Simulate_presence.zip
(2.36 KiB) Downloaded 551 times
så här ser main loop koden ut alternativt ha koden i en scen som körs

Code: Select all

--[[
%% autostart
%% properties 
%% globals
Simu_presence
--]] 


-- LUA - Presence Simulator V1.0.1 
-- 
-- Modified by Jonny Larsson (jompa68) - 2014-01-24
-- Changed from fixed START TIME to sunsetHour and to STOP Hour and Minute. 
-- 
--
-- Simulate a presence when you're on vacation. 
-- A part of code is reused, it can found here. Thanx to Richo: http://forum.fibaro.com/viewtopic.php?t=1892&postdays=0&postorder=asc&highlight=presence&start=15 
-- and here thx to Krikroff http://forum.fibaro.com/viewtopic.php?t=1656
-- 


-- USER SETTINGS -- 

-- Timestamp when you want stop simulation --
local stop_hour = 23;								-- Hour when you want simulation to stop
local stop_minute = 00;								-- Minute of the hour you want simulation to stop
---------------------------------------------
local rndmaxtime = 20                          --random time of light change in minutes --> here each device is on max 20min 
local ID_devices_lights = {246,252}              --IDs of lights to use in simulation 
local numbers_lights = #ID_devices_lights       --numbers of light devices listed above 
local activated_push = true;                    --activate push when simulation starts and stops 
local ID_Smartphone = 229;                        --ID of your smartphone 
local simu = fibaro:getGlobal("Simu_presence"); --value of the global value: simulation is on or off 
local debug = true;                             --activate the debug mode 

-- USER SETTINGS END --

-- DO NOT EDIT THE CODE BELOW (except to suit your needs) --
local simu = fibaro:getGlobal("Simu_presence"); --value of the global value: simulation is on or off 
local start_simu = fibaro:getValue(1, "sunsetHour"); --Start simulation when sunset
local minute = 60000 --in milliseconds
local start = os.date("%H:%M")
local time = os.time() 
local date = os.date("*t", time)
local year = date.year
local month = date.month
local day = date.day
local endtime = os.time{year=year, month=month, day=day, hour=stop_hour, min=stop_minute, sec=sec}


SimulatorPresenceEngine = { 
  version = "1.0.1" 
}; 

-- function to switch off devices in the list 
function SimulatorPresenceEngine:TurnOff(group) 
  local name, id; 
  local ID_devices_group = group; 
       for i=1, #ID_devices_group do 
    id = tonumber(ID_devices_group[i]); 
    fibaro:call(id, "turnOff"); 
        if (debug) then 
         name = fibaro:getName(id); 
             if (name == nil or name == string.char(0)) then 
            name = "Unknown" 
              end 
          fibaro:debug("Device:" .. name .. " Off "); 
        end 
      end 
end 

-- function to simulate a presence 
function SimulatorPresenceEngine:Launch() 

if (debug) then fibaro:debug("Simulation will stop: "..stop_hour..":"..stop_minute) end

if (time >= endtime) or (simu == "Off") then
  if (debug) then fibaro:debug("Simulation stopped") end end 
  if (activated_push) then 
    fibaro:call(ID_Smartphone, 'sendPush', "Lights simulation started") ;    --send push notification 
    if (debug) then fibaro:debug("push start sent") end 
    end 
    while ((os.time() <= endtime) and (simu == "On")) do
    fibaro:debug(os.time())
    if time == endime then fibaro:debug("same value") end
        local random_light = tonumber(ID_devices_lights[math.random(numbers_lights)]) --choose a random light in the list 
        local lightstatus = fibaro:getValue(random_light, 'value') --get the value of the random light in the list 
        -- turn on the light if off or turn off if on 
        if  tonumber(lightstatus) == 0 then fibaro:call(random_light, 'turnOn') else fibaro:call(random_light, 'turnOff') end 
          fibaro:sleep(1000) ; --necessary to get back the new status, because HC2 is too fast :-) 
        lightstatus = fibaro:getValue(random_light, 'value') --get the value of the random light after his update 
        if (debug) then fibaro:debug('light ID:'..random_light..' status:'..lightstatus) end 
        local sleeptime = math.random(rndmaxtime*minute) --random sleep 
        fibaro:sleep(sleeptime) 
  
        local sleeptimemin = math.abs(sleeptime/60000) 
        if (debug) then fibaro:debug('sleeptime:'..sleeptimemin) end 
        simu = fibaro:getGlobal("Simu_presence"); --verify the global value, if the virtual device is deactivated, the scene stops. 

    end 
    
    --turn Off all lights 
    SimulatorPresenceEngine:TurnOff(ID_devices_lights);
  	if (activated_push) then
    fibaro:call(ID_Smartphone, 'sendPush', "Lights simulation stopped"); --send push notification 
  	if (debug) then fibaro:debug("push stop sent") end   
  	end
  	sunset = 0
    fibaro:sleep(60000); 
end


-- Condition to start simulation
if fibaro:getValue(1, "sunsetHour") == true then
	sunset = 1 else sunset = 0
end

if (debug) and (simu == "On") then 
    fibaro:debug("Time is now: "..start)
	fibaro:debug("Todays sunset: "..fibaro:getValue(1, "sunsetHour"))
end
if ((simu == "On") and os.time() <= endtime and sunset == 1 ) then 
--fibaro:getValue(1, "sunsetHour") 
  SimulatorPresenceEngine:Launch(); --launch the simulation when virtual device is on, and the current time is triggered. 
	elseif sunset == 0 then
  	fibaro:debug("Simu_presence will not be activated before sunset")
  	elseif os.time() >= endtime then
  	fibaro:debug("After simu_presences stop time")
end 

if (simu == "Off") then
  fibaro:debug("Simulation is deactivated")
end
  
MrMike
Ny medlem
Posts: 6
Joined: 26 Jan 2014, 14:49
10

jompa68 wrote:Enligt önskemål, bara att importera den virtuella enheten som ligger med.
Simulate_presence.zip
så här ser main loop koden ut alternativt ha koden i en scen som körs

Code: Select all

--[[
%% autostart
%% properties 
%% globals
Simu_presence
--]] 


-- LUA - Presence Simulator V1.0.1 
-- 
-- Modified by Jonny Larsson (jompa68) - 2014-01-24
-- Changed from fixed START TIME to sunsetHour and to STOP Hour and Minute. 
-- 
--
-- Simulate a presence when you're on vacation. 
-- A part of code is reused, it can found here. Thanx to Richo: http://forum.fibaro.com/viewtopic.php?t=1892&postdays=0&postorder=asc&highlight=presence&start=15 
-- and here thx to Krikroff http://forum.fibaro.com/viewtopic.php?t=1656
-- 


-- USER SETTINGS -- 

-- Timestamp when you want stop simulation --
local stop_hour = 23;								-- Hour when you want simulation to stop
local stop_minute = 00;								-- Minute of the hour you want simulation to stop
---------------------------------------------
local rndmaxtime = 20                          --random time of light change in minutes --> here each device is on max 20min 
local ID_devices_lights = {246,252}              --IDs of lights to use in simulation 
local numbers_lights = #ID_devices_lights       --numbers of light devices listed above 
local activated_push = true;                    --activate push when simulation starts and stops 
local ID_Smartphone = 229;                        --ID of your smartphone 
local simu = fibaro:getGlobal("Simu_presence"); --value of the global value: simulation is on or off 
local debug = true;                             --activate the debug mode 

-- USER SETTINGS END --

-- DO NOT EDIT THE CODE BELOW (except to suit your needs) --
local simu = fibaro:getGlobal("Simu_presence"); --value of the global value: simulation is on or off 
local start_simu = fibaro:getValue(1, "sunsetHour"); --Start simulation when sunset
local minute = 60000 --in milliseconds
local start = os.date("%H:%M")
local time = os.time() 
local date = os.date("*t", time)
local year = date.year
local month = date.month
local day = date.day
local endtime = os.time{year=year, month=month, day=day, hour=stop_hour, min=stop_minute, sec=sec}


SimulatorPresenceEngine = { 
  version = "1.0.1" 
}; 

-- function to switch off devices in the list 
function SimulatorPresenceEngine:TurnOff(group) 
  local name, id; 
  local ID_devices_group = group; 
       for i=1, #ID_devices_group do 
    id = tonumber(ID_devices_group[i]); 
    fibaro:call(id, "turnOff"); 
        if (debug) then 
         name = fibaro:getName(id); 
             if (name == nil or name == string.char(0)) then 
            name = "Unknown" 
              end 
          fibaro:debug("Device:" .. name .. " Off "); 
        end 
      end 
end 

-- function to simulate a presence 
function SimulatorPresenceEngine:Launch() 

if (debug) then fibaro:debug("Simulation will stop: "..stop_hour..":"..stop_minute) end

if (time >= endtime) or (simu == "Off") then
  if (debug) then fibaro:debug("Simulation stopped") end end 
  if (activated_push) then 
    fibaro:call(ID_Smartphone, 'sendPush', "Lights simulation started") ;    --send push notification 
    if (debug) then fibaro:debug("push start sent") end 
    end 
    while ((os.time() <= endtime) and (simu == "On")) do
    fibaro:debug(os.time())
    if time == endime then fibaro:debug("same value") end
        local random_light = tonumber(ID_devices_lights[math.random(numbers_lights)]) --choose a random light in the list 
        local lightstatus = fibaro:getValue(random_light, 'value') --get the value of the random light in the list 
        -- turn on the light if off or turn off if on 
        if  tonumber(lightstatus) == 0 then fibaro:call(random_light, 'turnOn') else fibaro:call(random_light, 'turnOff') end 
          fibaro:sleep(1000) ; --necessary to get back the new status, because HC2 is too fast :-) 
        lightstatus = fibaro:getValue(random_light, 'value') --get the value of the random light after his update 
        if (debug) then fibaro:debug('light ID:'..random_light..' status:'..lightstatus) end 
        local sleeptime = math.random(rndmaxtime*minute) --random sleep 
        fibaro:sleep(sleeptime) 
  
        local sleeptimemin = math.abs(sleeptime/60000) 
        if (debug) then fibaro:debug('sleeptime:'..sleeptimemin) end 
        simu = fibaro:getGlobal("Simu_presence"); --verify the global value, if the virtual device is deactivated, the scene stops. 

    end 
    
    --turn Off all lights 
    SimulatorPresenceEngine:TurnOff(ID_devices_lights);
  	if (activated_push) then
    fibaro:call(ID_Smartphone, 'sendPush', "Lights simulation stopped"); --send push notification 
  	if (debug) then fibaro:debug("push stop sent") end   
  	end
  	sunset = 0
    fibaro:sleep(60000); 
end


-- Condition to start simulation
if fibaro:getValue(1, "sunsetHour") == true then
	sunset = 1 else sunset = 0
end

if (debug) and (simu == "On") then 
    fibaro:debug("Time is now: "..start)
	fibaro:debug("Todays sunset: "..fibaro:getValue(1, "sunsetHour"))
end
if ((simu == "On") and os.time() <= endtime and sunset == 1 ) then 
--fibaro:getValue(1, "sunsetHour") 
  SimulatorPresenceEngine:Launch(); --launch the simulation when virtual device is on, and the current time is triggered. 
	elseif sunset == 0 then
  	fibaro:debug("Simu_presence will not be activated before sunset")
  	elseif os.time() >= endtime then
  	fibaro:debug("After simu_presences stop time")
end 

if (simu == "Off") then
  fibaro:debug("Simulation is deactivated")
end
  

Tusen tack!
jens
Medlem
Posts: 329
Joined: 22 Apr 2013, 17:09
11

Får inte detta att fungera :(


Sent from my iPad using Tapatalk HD
jompa68
Proffsmedlem
Posts: 735
Joined: 12 Aug 2012, 08:53
12
Location: Hofors

Vad är det som inte fungerar för dig Jens?


Jonny sent this from his iPhone using Tapatalk
jens
Medlem
Posts: 329
Joined: 22 Apr 2013, 17:09
11

jompa68 wrote:Vad är det som inte fungerar för dig Jens?


Jonny sent this from his iPhone using Tapatalk

DEt står bara så här när jag kör debug...

Så här har jag lagt in...


--[[
%% autostart
%% properties
%% globals
Simu_presence
--]]


-- LUA - Presence Simulator V1.0.1
--
-- Modified by Jonny Larsson (jompa68) - 2014-01-24
-- Changed from fixed START TIME to sunsetHour and to STOP Hour and Minute.
--
--
-- Simulate a presence when you're on vacation.
-- A part of code is reused, it can found here. Thanx to Richo: http://forum.fibaro.com/viewtopic.php?t ... e&start=15
-- and here thx to Krikroff http://forum.fibaro.com/viewtopic.php?t=1656
--


-- USER SETTINGS --

-- Timestamp when you want stop simulation --
local stop_hour = 23; -- Hour when you want simulation to stop
local stop_minute = 40; -- Minute of the hour you want simulation to stop
---------------------------------------------
local rndmaxtime = 20 --random time of light change in minutes --> here each device is on max 20min
local ID_devices_lights = {175,76,134,27,173,27,33,34,35,66} --IDs of lights to use in simulation
local numbers_lights = #ID_devices_lights --numbers of light devices listed above
local activated_push = true; --activate push when simulation starts and stops
local ID_Smartphone = 212; --ID of your smartphone
local simu = fibaro:getGlobal("Simu_presence"); --value of the global value: simulation is on or off
local debug = true; --activate the debug mode

-- USER SETTINGS END --

-- DO NOT EDIT THE CODE BELOW (except to suit your needs) --
local simu = fibaro:getGlobal("Simu_presence"); --value of the global value: simulation is on or off
local start_simu = fibaro:getValue(1, "sunsetHour"); --Start simulation when sunset
local minute = 60000 --in milliseconds
local start = os.date("%H:%M")
local time = os.time()
local date = os.date("*t", time)
local year = date.year
local month = date.month
local day = date.day
local endtime = os.time{year=year, month=month, day=day, hour=stop_hour, min=stop_minute, sec=sec}


SimulatorPresenceEngine = {
version = "1.0.1"
};

-- function to switch off devices in the list
function SimulatorPresenceEngine:TurnOff(group)
local name, id;
local ID_devices_group = group;
for i=1, #ID_devices_group do
id = tonumber(ID_devices_group);
fibaro:call(id, "turnOff");
if (debug) then
name = fibaro:getName(id);
if (name == nil or name == string.char(0)) then
name = "Unknown"
end
fibaro:debug("Device:" .. name .. " Off ");
end
end
end

-- function to simulate a presence
function SimulatorPresenceEngine:Launch()

if (debug) then fibaro:debug("Simulation will stop: "..stop_hour..":"..stop_minute) end

if (os.time() >= endtime) or (simu == "Off") then
if (debug) then fibaro:debug("Simulation stopped") end end
if (activated_push) then
fibaro:call(ID_Smartphone, 'sendPush', "Lights simulation started") ; --send push notification
if (debug) then fibaro:debug("push start sent") end
end
while ((os.time() <= endtime) and (simu == "On")) do
fibaro:debug(os.time())
if time == endtime then fibaro:debug("same value") end
local random_light = tonumber(ID_devices_lights[math.random(numbers_lights)]) --choose a random light in the list
local lightstatus = fibaro:getValue(random_light, 'value') --get the value of the random light in the list
-- turn on the light if off or turn off if on
if tonumber(lightstatus) == 0 then fibaro:call(random_light, 'turnOn') else fibaro:call(random_light, 'turnOff') end
fibaro:sleep(1000) ; --necessary to get back the new status, because HC2 is too fast :-)
lightstatus = fibaro:getValue(random_light, 'value') --get the value of the random light after his update
if (debug) then fibaro:debug('light ID:'..random_light..' status:'..lightstatus) end
local sleeptime = math.random(rndmaxtime*minute) --random sleep
fibaro:sleep(sleeptime)

local sleeptimemin = math.abs(sleeptime/60000)
if (debug) then fibaro:debug('sleeptime:'..sleeptimemin) end
simu = fibaro:getGlobal("Simu_presence"); --verify the global value, if the virtual device is deactivated, the scene stops.

end

--turn Off all lights
SimulatorPresenceEngine:TurnOff(ID_devices_lights);
if (activated_push) then
fibaro:call(ID_Smartphone, 'sendPush', "Lights simulation stopped"); --send push notification
if (debug) then fibaro:debug("push stop sent") end
end
sunset = 0
fibaro:sleep(60000);
end


-- Condition to start simulation
if fibaro:getValue(1, "sunsetHour") == true then
sunset = 1 else sunset = 0
end

if (debug) and (simu == "On") then
fibaro:debug("Time is now: "..start)
fibaro:debug("Todays sunset: "..fibaro:getValue(1, "sunsetHour"))
end
if ((simu == "On") and os.time() <= endtime and sunset == 1 ) then
--fibaro:getValue(1, "sunsetHour")
SimulatorPresenceEngine:Launch(); --launch the simulation when virtual device is on, and the current time is triggered.
elseif sunset == 0 then
fibaro:debug("Simu_presence will not be activated before sunset")
elseif os.time() >= endtime then
fibaro:debug("After simu_presences stop time")
end

if (simu == "Off") then
fibaro:debug("Simulation is deactivated")
end
Attachments
Skärmavbild 2014-03-02 kl. 20.53.20.png
Skärmavbild 2014-03-02 kl. 20.53.20.png (443.17 KiB) Viewed 30159 times
jompa68
Proffsmedlem
Posts: 735
Joined: 12 Aug 2012, 08:53
12
Location: Hofors

Om du kört igång den efter solnedgång så kommer den bli aktiv förrän nästa dag.
jens
Medlem
Posts: 329
Joined: 22 Apr 2013, 17:09
11

Har testat det oxå men inget händer... :(


Sent from my iPad using Tapatalk HD
jens
Medlem
Posts: 329
Joined: 22 Apr 2013, 17:09
11

jompa68 wrote:Om du kört igång den efter solnedgång så kommer den bli aktiv förrän nästa dag.
Någon lösning på mitt problem Jompa :)
jompa68
Proffsmedlem
Posts: 735
Joined: 12 Aug 2012, 08:53
12
Location: Hofors

Jag kan koppla upp mig mot din hc2 och kika


Jonny sent this from his iPhone using Tapatalk
jens
Medlem
Posts: 329
Joined: 22 Apr 2013, 17:09
11

jompa68 wrote:Jag kan koppla upp mig mot din hc2 och kika


Jonny sent this from his iPhone using Tapatalk
När funkar det för dig??
jompa68
Proffsmedlem
Posts: 735
Joined: 12 Aug 2012, 08:53
12
Location: Hofors

Ikväll kan jag, efter 18:00
jens
Medlem
Posts: 329
Joined: 22 Apr 2013, 17:09
11

jompa68 wrote:Ikväll kan jag, efter 18:00
Det kör jag gärna på!! :)

Skickar PM med koden Team Wiewer...

//Jens
jens
Medlem
Posts: 329
Joined: 22 Apr 2013, 17:09
11

jens wrote:
jompa68 wrote:Ikväll kan jag, efter 18:00
Det kör jag gärna på!! :)

Skickar PM med koden Team Wiewer...

//Jens
Du har det i din in korg nu...
kappnet
Medlem
Posts: 38
Joined: 09 Sep 2013, 12:12
11

Fick ni detta att fungera? Jag har inte heller fått simuleringen att starta...
jompa68
Proffsmedlem
Posts: 735
Joined: 12 Aug 2012, 08:53
12
Location: Hofors

Jens, kan du dela din sista kod ändring jag gjorde åt dig?


Jonny sent this from his iPhone using Tapatalk
jens
Medlem
Posts: 329
Joined: 22 Apr 2013, 17:09
11

jompa68 wrote:Jens, kan du dela din sista kod ändring jag gjorde åt dig?


Jonny sent this from his iPhone using Tapatalk
Så här gjorde Jompa

Code: Select all

--[[ 
%% autostart 
%% properties 
%% globals 
Simu_presence 
--]] 


-- LUA - Presence Simulator V1.0.1 
-- 
-- Modified by Jonny Larsson (jompa68) - 2014-01-24 
-- Changed from fixed START TIME to sunsetHour and to STOP Hour and Minute. 
-- 
-- 
-- Simulate a presence when you're on vacation. 
-- A part of code is reused, it can found here. Thanx to Richo: http://forum.fibaro.com/viewtopic.php?t=1892&postdays=0&postorder=asc&highlight=presence&start=15 
-- and here thx to Krikroff http://forum.fibaro.com/viewtopic.php?t=1656 
-- 


-- USER SETTINGS -- 

-- Timestamp when you want stop simulation -- 
local stop_hour = 23;                                -- Hour when you want simulation to stop 
local stop_minute = 20;                                -- Minute of the hour you want simulation to stop 
--------------------------------------------- 
local rndmaxtime = 20                          --random time of light change in minutes --> here each device is on max 20min 
local ID_devices_lights = {76,183,41,134,199,27,66,33,34,35}              --IDs of lights to use in simulation 
local numbers_lights = #ID_devices_lights       --numbers of light devices listed above 
local activated_push = true;                    --activate push when simulation starts and stops 
local ID_Smartphone = 212;                        --ID of your smartphone 
local simu = fibaro:getGlobal("Simu_presence"); --value of the global value: simulation is on or off 
local debug = true;                             --activate the debug mode 

-- USER SETTINGS END -- 

-- DO NOT EDIT THE CODE BELOW (except to suit your needs) -- 
local simu = fibaro:getGlobal("Simu_presence"); --value of the global value: simulation is on or off 
local start_simu = fibaro:getValue(1, "sunsetHour"); --Start simulation when sunset 
local minute = 60000 --in milliseconds 
local start = os.date("%H:%M") 
local time = os.time() 
local date = os.date("*t", time) 
local year = date.year 
local month = date.month 
local day = date.day 
local endtime = os.time{year=year, month=month, day=day, hour=stop_hour, min=stop_minute, sec=sec} 


SimulatorPresenceEngine = { 
  version = "1.0.1" 
}; 

-- function to switch off devices in the list 
function SimulatorPresenceEngine:TurnOff(group) 
  local name, id; 
  local ID_devices_group = group; 
       for i=1, #ID_devices_group do 
    id = tonumber(ID_devices_group[i]); 
    fibaro:call(id, "turnOff"); 
        if (debug) then 
         name = fibaro:getName(id); 
             if (name == nil or name == string.char(0)) then 
            name = "Unknown" 
              end 
          fibaro:debug("Device:" .. name .. " Off "); 
        end 
      end 
end 

-- function to simulate a presence 
function SimulatorPresenceEngine:Launch() 

if (debug) then fibaro:debug("Simulation will stop: "..stop_hour..":"..stop_minute) end 

if (os.time() >= endtime) or (simu == "Off") then 
  if (debug) then fibaro:debug("Simulation stopped") end end 
  if (activated_push) then 
    fibaro:call(ID_Smartphone, 'sendPush', "Lights simulation started") ;    --send push notification 
    if (debug) then fibaro:debug("push start sent") end 
    end 
    while ((os.time() <= endtime) and (simu == "On")) do 
    fibaro:debug(os.time()) 
    if time == endtime then fibaro:debug("same value") end 
        local random_light = tonumber(ID_devices_lights[math.random(numbers_lights)]) --choose a random light in the list 
        local lightstatus = fibaro:getValue(random_light, 'value') --get the value of the random light in the list 
        -- turn on the light if off or turn off if on 
        if  tonumber(lightstatus) == 0 then fibaro:call(random_light, 'turnOn') else fibaro:call(random_light, 'turnOff') end 
          fibaro:sleep(1000) ; --necessary to get back the new status, because HC2 is too fast :-) 
        lightstatus = fibaro:getValue(random_light, 'value') --get the value of the random light after his update 
        if (debug) then fibaro:debug('light ID:'..random_light..' status:'..lightstatus) end 
        local sleeptime = math.random(rndmaxtime*minute) --random sleep 
        fibaro:sleep(sleeptime) 
  
        local sleeptimemin = math.abs(sleeptime/60000) 
        if (debug) then fibaro:debug('sleeptime:'..sleeptimemin) end 
        simu = fibaro:getGlobal("Simu_presence"); --verify the global value, if the virtual device is deactivated, the scene stops. 

    end 
    
    --turn Off all lights 
    SimulatorPresenceEngine:TurnOff(ID_devices_lights); 
      if (activated_push) then 
    fibaro:call(ID_Smartphone, 'sendPush', "Lights simulation stopped"); --send push notification 
      if (debug) then fibaro:debug("push stop sent") end    
      end 
      sunset = 0 
    fibaro:sleep(60000); 
end 


-- Condition to start simulation 
if fibaro:getValue(1, "sunsetHour") == true or fibaro:getGlobal("NightTime") == "1" then 
    sunset = 1 else sunset = 0 
end 

if (debug) and (simu == "On") then 
    fibaro:debug("Time is now: "..start) 
    fibaro:debug("Todays sunset: "..fibaro:getValue(1, "sunsetHour")) 
end 
if ((simu == "On") and os.time() <= endtime and sunset == 1 and fibaro:getGlobal("hemma") == "0" ) then 
--fibaro:getValue(1, "sunsetHour") 
  SimulatorPresenceEngine:Launch(); --launch the simulation when virtual device is on, and the current time is triggered. 
    elseif sunset == 0 then 
      fibaro:debug("Simu_presence will not be activated before sunset") 
      elseif os.time() >= endtime then 
      fibaro:debug("After simu_presences stop time") 
end 

if (simu == "Off") then 
  fibaro:debug("Simulation is deactivated") 
end 
fibaro:sleep(30000) 
kappnet
Medlem
Posts: 38
Joined: 09 Sep 2013, 12:12
11

Tack!
Jag lägger in koden och testar.

;-)
djesko
Medlem
Posts: 91
Joined: 10 Feb 2014, 22:50
10
Location: Trelleborg

Hej

Försöker få denna scen att fungera men det vill sig inte.

Ska jag klistra in koden som en scen eller ska jag ladda ner och importera virtuella filen ?

Har klistrat in koden som en scen och tryckt på run men inget händer dagen efter , debug säger
[DEBUG] 11:03:17: Simu_presence will not be activated before sunset

Någon har lust att ge mig lite tips ?

tack

Niklas
Post Reply