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

Scene keeps quitting on error


Question

Posted

I have this scene to turn mu outside lights on and off at night, but I keep getting this error which stops the script. and it is exactly the same error line every time

 

[DEBUG] 16:51:57: Outside Light Script started at Sat Oct 1 16:51:57 2016
[DEBUG] 20:47:00: line 35: unexpected character @ character: 1 0:1 [�] line:
[DEBUG] 20:47:00: �

 

 

This is the script. I commented out line 35 but it made no difference 

 

--[[
%% autostart
%% properties
%% globals
--]]
local debug = true;

local function log(str) if debug then fibaro:debug(str); end; end

local sourceTrigger = fibaro:getSourceTrigger();

 
  -- check script instance count in memory
  if (tonumber(fibaro:countScenes()) > 1) then
    log("Script already running.");
    fibaro:abort();
  end

  log("Outside Light Script started at " .. os.date());

 while true do
    local TODFlag = fibaro:getGlobalValue("itisnight")
     --log("Time of day is :" ..TODFlag );
    local lightstate = (fibaro:getValue(232, "value"))
     --log("The light is :" ..lightstate );

    if TODFlag == "1"
    then
      if 
        lightstate == "1"
      then
        -- do nothing
      else 
        fibaro:call(232, "turnOn");
--          log("Outside Lights on at ".. os.date());   -This was line 35 till I commented it out 
      end  
    else -- means it is not night
      if 
        lightstate == "0" -- lights are off
      then
        -- do nothing
      else 
        -- turn lights off    
        fibaro:call(232, "turnOff");
--          log("Outside Lights off at ".. os.date());
      end
  end
end

 

 

Can anyone tell me where I am going wrong, or point me in the right direction.

 

 

8 answers to this question

Recommended Posts

  • 0
Posted (edited)

proper command is

Please login or register to see this code.

but you can't use it in scenes only in virtual devices.

In scenes you can use:

Please login or register to see this code.

and it will show in debug window of the scene for you to check.

Edited by Sankotronic
  • 0
  • Inquirer
  • Posted (edited)

    Hi Sankotronic

     

    I believe I take care of that with this line

     

    local function log(str) if debug then fibaro:debug(str);

     

    however as the line is commented out - it shouldn't have any impact.

     

    Still doesn't explain the error

     

    [DEBUG] 16:51:57: Outside Light Script started at Sat Oct 1 16:51:57 2016
    [DEBUG] 20:47:00: line 35: unexpected character @ character: 1 0:1 [�] line:
    [DEBUG] 20:47:00: �

     
     
    Anybody get any idea's

     

     

    Edited by andyp
    • 0
    Posted

    Sorry, i didn't carefully check your code.

     

    I just tested it. It is probably problem in comment that is put between If then. But anyway it is not needed for this scene to check time of day every second of the day all day because it will definitely put some load on HC. I think it is enough that change of the global variable "itisnight" trigger this scene to turn outside light On or Off. Try following code:

     

    Please login or register to see this code.

    I suppose that you have another scene which is changing global variable "isitnight" because if you do, then whenever this global variable change value it will trigger this scene and depending on value "1" it is nignt will turn light on if it was off at that time, and "0" it is day will turn off light if it was On at that time.

    • 0
  • Inquirer
  • Posted

    Thanks for the revised code.

     

    If I understand it correctly  because you put the global variable at the top, the scene will be aware if that variable changes and trigger it. Have I got that correct.

     

    However when I try and start the script I get

     

    [DEBUG] 17:18:53: Outside Light Script started at Mon Oct 3 17:18:53 2016
    [DEBUG] 17:18:53: line 150: Assertion failed: Expected string

     
     
    There isn't a line 150 so any idea's ?
    • 0
    Posted

    I have had the same problem with a couple of scene's... been looking at them for hours.

    The problem in debugging the code is that the error occurred at random times and after a random amount of loops.

     

    Finally "fixed" it with an additional script to check if the scripts are still running, if not I'll restart them...

    If you like to have a copy of my code let me know.

    • 0
  • Inquirer
  • Posted

    Hi Sve

     

    I would love a copy of the code you are using. I have several scripts that keep stopping 

     

    Thanks

    • 0
    Posted

    Here u go

     

    Make sure the scene's that you check have the %% autostart definition otherwise you might end up that unwanted scene's are restarting...

     

    The table "SceneIDTable" contains the id's of the scene's that you want to check for running, if they return "0" the scene is restarted and sends some output to the debug screen to let you know what has happend

     

    I hope you can make good use of the code

     

    Please login or register to see this code.

     

    • 0
  • Inquirer
  • Posted

    Thanks SVE - This works great just what I needed.

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