We have moved at community.getvera.com

Author Topic: HELP NEEDED, why doesn?t this code work?  (Read 652 times)

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +290/-70
  • "Less is more"
Re: HELP NEEDED, why doesn?t this code work?
« Reply #15 on: March 16, 2019, 10:41:48 am »
I've really no idea what that message means, or whether it's common. 

All I use Vera for these days is a Zwave Bridge.  Everything else, including scenes, runs on a RPi running openLuup.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline Catman

  • Sr. Member
  • ****
  • Posts: 338
  • Karma: +10/-0
Re: HELP NEEDED, why doesn?t this code work?
« Reply #16 on: March 16, 2019, 01:58:06 pm »
Well, this would seem to be the smoking gun...

Code: [Select]
01 03/16/19 12515500.101 LuaInterface::CallFunction_Scene Scene 37 failed attempt to call a nil value <0x7655e520>


Thanks so far for your expertise Akbooer, Ill sent the Vera log file to Vera Support. Probably they can find out what the problem is.
One last question; The problem is the quote above right? The lua should call a nil but it doesn?t ..

Cheers

I am no expert at all, but to me it looks more like nil is not a permitted value to call.....

C

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +290/-70
  • "Less is more"
Re: HELP NEEDED, why doesn?t this code work?
« Reply #17 on: March 16, 2019, 02:03:08 pm »
I am no expert at all, but to me it looks more like nil is not a permitted value to call.....

Yes, indeed. But the question is where, exactly, is that call being made?
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline Catman

  • Sr. Member
  • ****
  • Posts: 338
  • Karma: +10/-0
Re: HELP NEEDED, why doesn?t this code work?
« Reply #18 on: March 16, 2019, 02:11:55 pm »
I am no expert at all, but to me it looks more like nil is not a permitted value to call.....

Yes, indeed. But the question is where, exactly, is that call being made?

Like I said, I'm no expert  ;D

I get what little understanding I have of reading logs when stuff breaks

C

Offline dgb

  • Newbie
  • *
  • Posts: 7
  • Karma: +4/-0
Re: HELP NEEDED, why doesn?t this code work?
« Reply #19 on: March 16, 2019, 04:41:39 pm »

Well, this would seem to be the smoking gun...

Code: [Select]
01 03/16/19 12515500.101 LuaInterface::CallFunction_Scene Scene 37 failed attempt to call a nil value <0x7655e520>

This error means that the code is trying to evaluating something that is a nil value as a function.

The only part of the code that could cause this is the conditional...

Code: [Select]
if (tonumber(Temp1)  > 24 ) then

If the Temp1 variable has a nil or non-numeric value, the tonumber function will evaluate to nil and the code will fail with the "attempt to call a nil value" error.

You can try changing the conditional to:

Code: [Select]
if ((tonumber(Temp1) or 0) > 24 ) then

which will ensure that the left hand side of the conditional will evaluate to a number and not fail.

Then you will need figure out why the variable Temp1 is not numeric...

The luup.variable_get function will only return a nil value or a string. It will return a nil value if the variable does not exist... The SID and Variable you are using is correct... so check that the device id for your temperature sensor is correct. If the variable has never been initialized (ie: new device),  it will return an empty string... and the code change will catch that...

Offline Catman

  • Sr. Member
  • ****
  • Posts: 338
  • Karma: +10/-0
Re: HELP NEEDED, why doesn?t this code work?
« Reply #20 on: March 16, 2019, 07:51:33 pm »
Nice one!

C

Offline BerrytH

  • Sr. Newbie
  • *
  • Posts: 25
  • Karma: +0/-0
Re: HELP NEEDED, why doesn?t this code work?
« Reply #21 on: March 17, 2019, 04:12:21 am »

Well, this would seem to be the smoking gun...

Code: [Select]
01 03/16/19 12515500.101 LuaInterface::CallFunction_Scene Scene 37 failed attempt to call a nil value <0x7655e520>

Thanks DGB,

The Device ID from the temp sensor is correct,
I also adjusted the code but despite without success...
I?ve sent the Vera log files to Vera support, May be they have a solution.

Anyway thanks!!



This error means that the code is trying to evaluating something that is a nil value as a function.

The only part of the code that could cause this is the conditional...

Code: [Select]
if (tonumber(Temp1)  > 24 ) then

If the Temp1 variable has a nil or non-numeric value, the tonumber function will evaluate to nil and the code will fail with the "attempt to call a nil value" error.

You can try changing the conditional to:

Code: [Select]
if ((tonumber(Temp1) or 0) > 24 ) then

which will ensure that the left hand side of the conditional will evaluate to a number and not fail.

Then you will need figure out why the variable Temp1 is not numeric...

The luup.variable_get function will only return a nil value or a string. It will return a nil value if the variable does not exist... The SID and Variable you are using is correct... so check that the device id for your temperature sensor is correct. If the variable has never been initialized (ie: new device),  it will return an empty string... and the code change will catch that...

Offline BerrytH

  • Sr. Newbie
  • *
  • Posts: 25
  • Karma: +0/-0
Re: HELP NEEDED, why doesn?t this code work?
« Reply #22 on: March 24, 2019, 05:27:11 am »
Problem solved !!  :)

thanks everyone and Vera support!
The problem was the ?poll? time from my Fibaro FGK 102 door/temp sensor.
Initially it polled every 10800 sec (3hr), so I lowered the value to 600 sec....that worked!!

THANKS!