Scene not working oddness

Hi all

I have written some Lua to give me some TTS as to where my wife is and how long she’s going to be (not as creepy as it sounds I promise)

The Lua works perfectly when I run it from the Test Lua windows, but when I execute it in a scene:

|08|02/07/20 19:19:05.382|JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunScene <0x723bc520>|
|---|---|---|
|08|02/07/20 19:19:05.382|JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1 <0x723bc520>|
|08|02/07/20 19:19:05.383|JobHandler_LuaUPnP::HandleActionRequest argument action=RunScene <0x723bc520>|
|08|02/07/20 19:19:05.383|JobHandler_LuaUPnP::HandleActionRequest argument SceneNum=84 <0x723bc520>|
|08|02/07/20 19:19:05.383|JobHandler_LuaUPnP::HandleActionRequest argument rand=0.012212348495252767 <0x723bc520>|
|08|02/07/20 19:19:05.383|Scene::RunScene running 84 Where Rachel <0x723bc520>|
|01|02/07/20 19:19:05.383|LuaInterface::CallFunction_Scene Scene  84 failed attempt to call a nil value <0x723bc520>|

Here’s the Lua

local RachelDistance = math.floor(luup.variable_get("urn:upnp-org:serviceId:IPhoneLocator1", "Distance", 250))
local RachelSpeed = math.floor(luup.variable_get("urn:upnp-org:serviceId:IPhoneLocator1", "RTSpeed", 250))
local RachelETA = math.floor((luup.variable_get("urn:upnp-org:serviceId:IPhoneLocator1", "ETA", 250))/60)
luup.call_action("urn:dlna-org:serviceId:DLNAMediaController1", "Say", {Text="Rachel is currently"..RachelDistance.."kilometers away. Her Speed is " ..RachelSpeed.. " kilmoters per hour and her ETA is" ..RachelETA.. " minutes",Volume=40,GroupZones="Living_Room_dot"}, 167)

What on earth am I doing wrong?

C

I think your vera thought this was too creepy and rejected your code… :grin:

Seriously though… It is possibly some data corruption. (or copy paste error?) Try reloading luup and try again. I see no nil value in your code.

1 Like

Luup has reloaded. I’ve deleted and recreated the scene (with a slightly different name)
Copied and pasted the Lua both to and from the test windows.

Same issue.

Too creepy? :wink:

C

It seems to say that the scene does not exists. Do you only have luup code in that scene?

Yes. Manually triggered. I have a couple of scenes like this

Oh and hitting the run button reports success

C

So hitting run reports success from inside the scene editor but launching the scene from outside the editor fails? I think there could be an error in how the scene is being saved. It may not have the right identifier…

No, sorry

From the normal UI hitting the run (or play) states success, but we see this error in the log.

Worth trying to create it again?

C

yeah create another one with some action in the editor. first make sure that it is saved, test it and see that it works. Then go back into the editor and put your lua code.
When the log says it fails, did it actually execute?

OK it gets more bizarre

Created a test scene with a toggle on a switch.

Tested that and it worked fine.

Added the Lua:

|8|02/07/20 20:12:42.347|JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunScene <0x70aa0520>|
|---|---|---|
|08|02/07/20 20:12:42.348|JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1 <0x70aa0520>|
|08|02/07/20 20:12:42.348|JobHandler_LuaUPnP::HandleActionRequest argument action=RunScene <0x70aa0520>|
|08|02/07/20 20:12:42.348|JobHandler_LuaUPnP::HandleActionRequest argument SceneNum=85 <0x70aa0520>|
|08|02/07/20 20:12:42.348|JobHandler_LuaUPnP::HandleActionRequest argument rand=0.7853837452427863 <0x70aa0520>|
|08|02/07/20 20:12:42.348|Scene::RunScene running 85 WhereRachelTest <0x70aa0520>|
|01|02/07/20 20:12:42.349|LuaInterface::CallFunction_Scene Scene  85 failed attempt to call a nil value <0x70aa0520>|
|08|02/07/20 20:12:42.349|JobHandler_LuaUPnP::HandleActionRequest device: 191 service: urn:micasaverde-com:serviceId:HaDevice1 action: ToggleState <0x70aa0520>|

This is exactly what is in my clipboard right now. Copied from the AltUI test Lua window and confirmed to work when I hit ‘Submit’

Bafffled!

C

Ok did the TTS execute though?

Nope

Nor did the switch toggle!

C

Are you sure these work in a test lua screen when you execute?
I get the feeling that you are running mathfloor functions on strings, You may need to convert them with a tonumber function right after the variable get.

Totally positive! I get all the speech correct, I can take a video if you want!

50 02/07/20 20:26:33.312 luup_log:0: ALTUI: runLua(local RachelDistance = math.floor(luup.variable_get("urn:upnp-org:serviceId:IPhoneLocator1", "Distance", 250))

local RachelSpeed = math.floor(luup.variable_get("urn:upnp-org:serviceId:IPhoneLocator1", "RTSpeed", 250))

local RachelETA = math.floor((luup.variable_get("urn:upnp-org:serviceId:IPhoneLocator1", "ETA", 250))/60)

luup.call_action("urn:dlna-org:serviceId:DLNAMediaController1", "Say", {Text="Rachel is currently"..RachelDistance.."kilometers away. Her Speed is " ..RachelSpeed.. " kilometers per hour and her ETA is" ..RachelETA.. " minutes",Volume=40,GroupZones="Living_Room_dot"}, 167)) <0x70ec2520>

08 02/07/20 20:26:33.313 JobHandler_LuaUPnP::HandleActionRequest device: 167 service: urn:dlna-org:serviceId:DLNAMediaController1 action: Say <0x70ec2520>

08 02/07/20 20:26:33.313 JobHandler_LuaUPnP::HandleActionRequest argument Text=Rachel is currently3kilometers away. Her Speed is 0 kilometers per hour and her ETA is8 minutes <0x70ec2520>

08 02/07/20 20:26:33.314 JobHandler_LuaUPnP::HandleActionRequest argument GroupZones=Living_Room_dot <0x70ec2520>

08 02/07/20 20:26:33.314 JobHandler_LuaUPnP::HandleActionRequest argument Volume=40 <0x70ec2520>

50 02/07/20 20:26:33.314 luup_log:167: VeraAlexa: TTS added to queue for 167 <0x70ec2520>

50 02/07/20 20:26:34.969 luup_log:0: ALTUI: Evaluation of lua code returned: nil <0x70ec2520>

C

catman is tts working?

Yes! Perfectly!

C

Even better
Re-purposed a virtual switch
Created condition in a reactor
Run the Lua from there
Still works perfectly!

Have we discovered a new and exciting bug?

C

try this. I suspect that it should fix it.

local RachelDistance = tonumber(luup.variable_get("urn:upnp-org:serviceId:IPhoneLocator1", "Distance", 250))
RachelDistance = math.floor(RachelDistance)
local RachelSpeed = tonumber(luup.variable_get("urn:upnp-org:serviceId:IPhoneLocator1", "RTSpeed", 250))
RachelSpeed = math.floor(RachelSpeed)
local RachelETA = tonumber(luup.variable_get("urn:upnp-org:serviceId:IPhoneLocator1", "ETA", 250))
RachelETA = math.floor(RachelETA/60)
luup.call_action("urn:dlna-org:serviceId:DLNAMediaController1", "Say", {Text="Rachel is currently"..RachelDistance.."kilometers away. Her Speed is " ..RachelSpeed.. " kilmoters per hour and her ETA is" ..RachelETA.. " minutes",Volume=40,GroupZones="Living_Room_dot"}, 167)

Thanks but 'fraid not:

|08|02/07/20 21:22:44.268|JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunScene <0x71558520>|
|---|---|---|
|08|02/07/20 21:22:44.269|JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1 <0x71558520>|
|08|02/07/20 21:22:44.269|JobHandler_LuaUPnP::HandleActionRequest argument action=RunScene <0x71558520>|
|08|02/07/20 21:22:44.269|JobHandler_LuaUPnP::HandleActionRequest argument SceneNum=85 <0x71558520>|
|08|02/07/20 21:22:44.269|JobHandler_LuaUPnP::HandleActionRequest argument rand=0.995818678389315 <0x71558520>|
|08|02/07/20 21:22:44.269|Scene::RunScene running 85 WhereRachelTest <0x71558520>|
|01|02/07/20 21:22:44.270|LuaInterface::CallFunction_Scene Scene  85 failed attempt to call a nil value <0x71558520>|
|08|02/07/20 21:22:44.270|JobHandler_LuaUPnP::HandleActionRequest device: 191 service: urn:micasaverde-com:serviceId:HaDevice1 action: ToggleState <0x71558520>|
|06|02/07/20 21:22:44.270|Device_Variable::m_szValue_set device: 191 service: urn:upnp-org:serviceId:SwitchPower1 variable: Target was: 1 now: 0 #hooks: 0 upnp: 0 skip: 0 v:0xe44ab8/NONE duplicate:0 <0x71558520>|
|06|02/07/20 21:22:44.357|Device_Variable::m_szValue_set device: 191 service: urn:upnp-org:serviceId:SwitchPower1 variable: Status was: 1 now: 0 #hooks: 0 upnp: 0 skip: 0 v:0xe44a68/NONE duplicate:0 <0x76bb3520>|

Although now it does toggle the switch…

C

try commenting out the last line? It is likely in there. I suspect an undeclared service for your device. Maybe @therealdb can take a look at it.

Thanks, @rafale77

You mean comment out this:

luup.call_action("urn:dlna-org:serviceId:DLNAMediaController1", "Say", {Text="Rachel is currently"..RachelDistance.."kilometers away. Her Speed is " ..RachelSpeed.. " kilmoters per hour and her ETA is" ..RachelETA.. " minutes",Volume=40,GroupZones="Living_Room_dot"}, 167)

?

But having deleted that line from the scene Lua, still:

|08|02/07/20 21:46:54.304|JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunScene <0x70bcb520>|
|---|---|---|
|08|02/07/20 21:46:54.304|JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1 <0x70bcb520>|
|08|02/07/20 21:46:54.304|JobHandler_LuaUPnP::HandleActionRequest argument action=RunScene <0x70bcb520>|
|08|02/07/20 21:46:54.304|JobHandler_LuaUPnP::HandleActionRequest argument SceneNum=85 <0x70bcb520>|
|08|02/07/20 21:46:54.305|JobHandler_LuaUPnP::HandleActionRequest argument rand=0.181444474917708 <0x70bcb520>|
|08|02/07/20 21:46:54.305|Scene::RunScene running 85 WhereRachelTest <0x70bcb520>|
|01|02/07/20 21:46:54.305|LuaInterface::CallFunction_Scene Scene  85 failed attempt to call a nil value <0x70bcb520>|

Makes no sense to me that the LuaTest works, the Lua works in the reactor (which will do for now) but not in a scene

C