Page 1 of 1

devicechanged is nil

Posted: Friday 10 February 2017 20:09
by jrich523
so i was trying to see what sort of message/data my scene remote would send so i can try and capture the button events, so i jsut setup a very simple test,

Code: Select all

commandArray = {}

print ("we're going to check the state of the button");

if (devicechanged['R1B2s'] == 'On') then
    print("captured change to On");
end

print("change tested");

return commandArray
It seems to think that the devicechanged is nil
attempt to index global 'devicechanged' (a nil value)
which i guess could maybe be possible but i firgured the whole reason the event triggered in the first place was because there was a changed device.
I think i recall having an issue with devicechanged before, and it doesnt show up in the intellisense.

is this object still valid? what am i missing?

Re: devicechanged is nil

Posted: Friday 10 February 2017 20:17
by Westcott
Is it by any chance a 'time' script?

Re: devicechanged is nil

Posted: Friday 10 February 2017 20:21
by jrich523
so I would guess so because im noticing the time stamp on the errors are all on the minute (give or take a few ms)

I dont see anything that defines it as a 'time' script? how would i make it an 'event' script vs 'time' script?

Re: devicechanged is nil

Posted: Friday 10 February 2017 20:26
by SweetPants
jrich523 wrote:I dont see anything that defines it as a 'time' script? how would i make it an 'event' script vs 'time' script?
If file based, it's in the filename. If written usign Domoticz Editor, below eventname you have LUA and below that you can select All, Device, Security, Time, UserVariable. You should select device if using devicechanged

Re: devicechanged is nil

Posted: Friday 10 February 2017 20:37
by jrich523
oh, interesting!
I guess i never really look at that box since "all" seemed like a fine value to leave things at. So i've changed it to device but now its not triggering. I wonder if because its looking for a state change and not incoming events?

The "switch" (buttons show up as a switch device) but they are always on. there is no way to shut it off (it cant send the command so it fails) and it doesnt seem to be picking up a "device" event when i push the button.

The log does detect that the button was pressed though.
2017-02-10 11:33:59.555 (Z-Stick) Light/Switch (R1B2s)
so its capturing the event, but not triggering the script because, well, i dont know why, but i assume because the state goes from "on" to "on" and dom over looks it?

Re: devicechanged is nil

Posted: Friday 10 February 2017 20:57
by SweetPants
jrich523 wrote:I wonder if because its looking for a state change and not incoming events?
Yep, It's looking for a change from Off to On of your device
jrich523 wrote:so its capturing the event, but not triggering the script because, well, i dont know why, but i assume because the state goes from "on" to "on" and dom over looks it?

See above, it has to change from Off to On

Re: devicechanged is nil

Posted: Friday 10 February 2017 21:11
by jrich523
well thats a bummer, is there any way to do this? A timer seems bad since it triggers every minute and that would be way to slow response wise.

Re: devicechanged is nil

Posted: Friday 10 February 2017 22:03
by Westcott
Make sure it is a 'device' script, and try this to see what has triggered it -

Code: Select all

commandArray = {}
print ("we're going to check the state of the trigger")
for deviceName,deviceValue in pairs(otherdevices) do
    print(deviceName..' = '..deviceValue)
end
print("change tested")
return commandArray

Re: devicechanged is nil

Posted: Friday 10 February 2017 22:46
by jrich523
yeah the "device" event type doesnt get triggered in this case so i cant get it to list the devices.

Its a scene controller so maybe i could create a scene with virtual switches and try that.