uppdaterat 4.81 sen sluta denna funka

Post Reply
Systemfel
Medlem
Posts: 384
Joined: 14 Jan 2015, 01:02
9

Hejsan skulle behöva lite hjälp med denna scenen den har bara slutat fungerat i samband med man uppdaterade till 4.081 beta detta är inte min kod och det är original koden. Den funkar när man trycker på kör i hc2 men med sensorn funkar den inte alls är rätt id på sensorn tror det har något med event mm som jag enu inte riktigt förstått

Code: Select all

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

-- REFERENCE
-- forum.fibaro.com, lua.org, domotique-fibaro.fr,www.gronahus.se 
-- Thanks to Richo, stevenvd, Steven for good LUA functions code.

-- SCENE SCENARIO
-- You wake up and need to go up to bathroom during the night
-- Sensor is triggered in bathroom, lights will only dim to 10%
-- and turnOff after "endTimer" has stop.
-- Its saturday night and you have freinds at home. Your "TimeOfDay"
-- variable have already been set to "Night". Now you dont want to
-- light up the bathroom to only 10%. So if any of the "lights2Check" 
-- is on, it will set dim value to 100% and turnOff after "endTimer" 
-- has stop.
-- If sensor is triggered again during the "endTimer" period, 
-- the "endTimer" period will start over.



-- FEATURES
--

-- UPDATES
-- 0.0.4 	- 	Change in checkLights function. from == "1" to ~= "0"
-- 0.0.5 	- 	possible to add a binarySwitch light and if not Night or
-- 		-	other lights are turnOn it will also turnOn the binarySwitch
--


-------------------- USER SETTINGS -----------------------
lights2Check = {206,114,284}; 	-- If any of those lights is ON then set dimmer value to 100%
lights = {223}; 		-- LightId
sensor = 62 			-- SensorId
nightdimValue = "10"   		-- Dimmer value to set during night
endTimer = 30 			-- How long to keep lights on, in seconds
varName = "TimeOfDay" 		-- Variable name
varNightvalue = "Natt"   	-- varName predefined value
debug = true 			-- set debug to true or false
-----------------------------------------------------------

------------- DO NOT CHANGE LINES BELOW -------------------
startSource = fibaro:getSourceTrigger();
version = "0.0.5"

-- Give debug a fancy color
Debug = function ( color, message )
  fibaro:debug(string.format('<%s style="color:%s;">%s</%s>', "span", color, message, "span")); 
end

-- Kill new instance of this scene
if (fibaro:countScenes() > 1) then
  Debug( "red", "Abort, count scene = "..fibaro:countScenes());
  fibaro:abort();
end


-- Scene was triggered, function
SceneTriggered = function()
checkLights();
turnLightOn();
startTimer();
end

-- Timer, function
startTimer = function ()
if debug then
   Debug( "green", "Timer started and will be active for: "..endTimer.."sec"); 
end
local counter = endTimer
while(counter > 0)
    do
        counter = counter - 1
        fibaro:sleep(1000)
    if
        tonumber(fibaro:getValue(sensor, "value")) > 0 then 
      counter = endTimer;
        end
    end
  if debug then
    Debug( "green", "Timer stopped"); 
end
  for i = 1,#lights do
lightItems = lights[i];
    fibaro:call(lightItems, "turnOff");
    end
end

-- TurnOn lights, functions
turnLightOn = function()
oneTimeDebugOnly = true
for i = 1,#lights do
lightItems = lights[i];
	--if fibaro:getType(lightItems) ~= "com.fibaro.binarySwitch" then
		if fibaro:getGlobal(varName) == varNightvalue and lightsOff then
      		if oneTimeDebugOnly then
  			Debug( "grey", "Night time, dim to 10%");
        	oneTimeDebugOnly = false end
      		fibaro:call(lightItems, "setValue", nightdimValue)
		else
    		fibaro:call(lightItems, "setValue", "100")
      		if fibaro:getType(lightItems) == "com.fibaro.binarySwitch" then
      		fibaro:call(lightItems, "turnOn")
        	end
      		if oneTimeDebugOnly then        
      		Debug( "grey", "Not night or other lights are on");
        	oneTimeDebugOnly = false end
    	end
    --end
end
end

checkLights = function()
Debug( "grey", "Check if lights is ON");
for i = 1,#lights2Check do
lightItems = lights2Check[i];
status = fibaro:getValue(lightItems, "value")
if status ~= "0" then lightsOff = false break 
    else lightsOff = true end
end
end

------------------ START OF SCENE ----------------------
if ( startSource["type"] == "other" ) then
    SceneTriggered();
elseif ( startSource["type"] == "property" ) then
  SceneTriggered();
end


Debug( "orange", "Lights & Motion Scene - LUA Scripting by Jonny Larsson 2015" );
Debug( "orange", "Version: "..version);
Last edited by Systemfel on 05 Apr 2016, 22:24, edited 1 time in total.
kör Hc3 och det fungerar bättre och bätttre sakta men säkert :D
Robert
Medlem
Posts: 346
Joined: 17 Oct 2013, 22:40
11

Du hittar felet här. http://forum.fibaro.com/index.php?/topi ... 4081-beta/

Jag har flera scener som inte fungerar efter uppgraderingen till 4.081. Fibaro är medvetna om felet och ska åtgärda det till nästa uppdatering.
Systemfel
Medlem
Posts: 384
Joined: 14 Jan 2015, 01:02
9

Robert wrote:Du hittar felet här. http://forum.fibaro.com/index.php?/topi ... 4081-beta/

Jag har flera scener som inte fungerar efter uppgraderingen till 4.081. Fibaro är medvetna om felet och ska åtgärda det till nästa uppdatering.
Hittar ju bara en rad med Propertys får fan inte det att funka endån..
Från ...............................................................................................
------------------ START OF SCENE ----------------------
if ( startSource["type"] == "other" ) then
SceneTriggered();
elseif ( startSource["type"] == "property" ) then
SceneTriggered();
end

Till...............................................................................

------------------ START OF SCENE ----------------------
if ( startSource["type"] == "other" ) then
SceneTriggered();
elseif ( startSource["type"] == "event" ) then
SceneTriggered();
end

något mer jag ska ändra???? blir inte klok på alla kommentarerna på det forumet
kör Hc3 och det fungerar bättre och bätttre sakta men säkert :D
SirMaggot
Medlem
Posts: 441
Joined: 18 Aug 2013, 10:36
11

from:

Code: Select all

if (startSource["type"] == "property") then

startSourceID = tonumber(startSource['deviceID']);

to:

Code: Select all

if (startSource["type"] == "event") then 
  startSourceID = tonumber(startSource['event']['data']['id']);
Systemfel
Medlem
Posts: 384
Joined: 14 Jan 2015, 01:02
9

SirMaggot wrote:from:

Code: Select all

if (startSource["type"] == "property") then

startSourceID = tonumber(startSource['deviceID']);

to:

Code: Select all

if (startSource["type"] == "event") then 
  startSourceID = tonumber(startSource['event']['data']['id']);
den koden har jag redan testat funkar inte .. Vad är ['data'] för något ? det finns ju ingen annanstans ??
kör Hc3 och det fungerar bättre och bätttre sakta men säkert :D
Post Reply