Here you go, finally! Thanks for all the help from the Scene Scripting forum on getting this one to work in the end.
Check The Status Of The Lights
This one will check and tell you if all the lights are off or if one or more are still on.
local LI_DEV1 = 82
local LI_DEV2 = 22
local LI_DEV3 = 53
local AV_DEV = 5
local LS_SID = "urn:micasaverde-com:serviceId:Sonos1"
local SEC_SERV = "urn:upnp-org:serviceId:SwitchPower1"
local livingroomlight = luup.variable_get(SEC_SERV, "Status",LI_DEV2)
local bedroomlight = luup.variable_get(SEC_SERV, "Status",LI_DEV1)
local halllight = luup.variable_get(SEC_SERV, "Status",LI_DEV3)
if ((livingroomlight == "0") and (bedroomlight == "0") and (halllight == "0")) then
luup.log("All light are off")
luup.call_action(LS_SID, "Say", {Text = string.format("All lights are off ")}, AV_DEV)
else
luup.log("One or more lights is on")
luup.call_action(LS_SID, "Say", {Text = string.format("One or more lights are on ")}, AV_DEV)
end