Author Topic: Last sunday of March check  (Read 732 times)

Offline akbooer

  • Master Member
  • *******
  • Posts: 5753
  • Karma: +246/-69
  • "Less is more"
Re: Last sunday of March check
« Reply #15 on: March 14, 2018, 03:26:01 am »
You appear still to be missing the vital parentheses.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 2x Philips Hue
Razberry, MySensors Arduino, HomeWave, AltUI, DataYours, openLuup, ZWay, ZeroBrane Studio.

Offline tony-park

  • Jr. Member
  • **
  • Posts: 71
  • Karma: +1/-0
Re: Last sunday of March check
« Reply #16 on: March 14, 2018, 05:00:02 am »
Hi AK,

when I put in the ()s, the code fails to run. Without them, it at least attempts to run.  That is the reason.


Thanks
Tony

Offline akbooer

  • Master Member
  • *******
  • Posts: 5753
  • Karma: +246/-69
  • "Less is more"
Re: Last sunday of March check
« Reply #17 on: March 14, 2018, 06:20:08 am »
I don't see a definition of the isBST function in your latest version.

That being the case, then

Code: [Select]
bst=isBST

if bst==0 then ...

will result in bst being nil and the if statement test being false.

Or
Code: [Select]
bst=isBST ()

results in an error, because you are trying to call a nil function.


When testing code, simplify, simplify, simplify.  There's just too many, rather baroque, constructs in there at the moment to see the wood for the trees.

3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 2x Philips Hue
Razberry, MySensors Arduino, HomeWave, AltUI, DataYours, openLuup, ZWay, ZeroBrane Studio.

Offline tony-park

  • Jr. Member
  • **
  • Posts: 71
  • Karma: +1/-0
Re: Last sunday of March check
« Reply #18 on: March 14, 2018, 09:31:52 am »
Hi,

unfortunately the code is as simple as it can possibly be!

I have  function written in an i_...xml file, uploaded.

I have a script which calls the function, and then tests 2 commands which we can see work fine.

I've even tried adjusting the function, to actually return 0 only, and its still showing as true. I've also tried using the commands you provided where the return returns the .isdst variable directly, and still the same.

I don't think what I'm asking is too much, but maybe, something this simple, is just too simple for a home automation system?

Thanks
Tony

Offline tony-park

  • Jr. Member
  • **
  • Posts: 71
  • Karma: +1/-0
Re: Last sunday of March check
« Reply #19 on: March 14, 2018, 09:54:03 am »
   function isBST()
   
      local v_time = os.date ("*t", os.time {year=2018, month=3, day=10})
        local v_dst = (v_time.isdst)

      if v_dst then
         return 1
      else
         return 0
      end
   end