Witam, jak w tytule... Wszystko mi działa po napisaniu, ale wywala mi błąd i nie potrafię ogarnąć bo pisze jedynie coś takiego [19.02.2024] [16:10:07] [ERROR] [SCENE822]:
A to kod:
local denon_salon = 779
local denon_glos = 0
local przyciskValue = sourceTrigger.value
if przyciskValue.keyId == 1 and przyciskValue.keyAttribute == "Pressed" then
hub.call(333, 'toggle')
elseif przyciskValue.keyId == 1 and przyciskValue.keyAttribute == "HeldDown" then
hub.call(601, 'open')
elseif przyciskValue.keyId == 1 and przyciskValue.keyAttribute == "Released" then
hub.call(601, 'stop')
elseif przyciskValue.keyId == 3 and przyciskValue.keyAttribute == "HeldDown" then
hub.call(601, 'close')
elseif przyciskValue.keyId == 3 and przyciskValue.keyAttribute == "Released" then
hub.call(601, 'stop')
elseif przyciskValue.keyId == 4 and przyciskValue.keyAttribute == "Pressed" then
hub.call(543, 'turnOff')
elseif przyciskValue.keyId == 2 and przyciskValue.keyAttribute == "Pressed" then
hub.call(543, 'turnOn')
hub.setTimeout(40000, function()
hub.call(691, 'sync')
end)
hub.setTimeout(100000, function()
hub.call(779, 'play')
hub.setGlobalVariable('ciszejglradiosalon', '1')
end)
end
if przyciskValue.keyId == 2 and przyciskValue.keyAttribute == "HeldDown" then
denon_glos = hub.getValue(denon_salon, "volume")
for i=1, 100 do
denon_glos =
denon_glos + 1
hub.call(denon_salon, 'setVolume', denon_glos)
hub.sleep(200)
end
elseif przyciskValue.keyId == 4 and przyciskValue.keyAttribute == "HeldDown" then
denon_glos = hub.getValue(denon_salon, "volume")
for i=1, 100 do
denon_glos =
denon_glos - 1
hub.call(denon_salon, 'setVolume', denon_glos)
hub.sleep(200)
end
end
Tak jak pisałem, problem leży w kodzie głośności...
local denon_salon = 779 local denon_glos = 0 local przytrzymanieValue = sourceTrigger.value if przytrzymanieValue.keyId == 1 and przytrzymanieValue.keyAttribute == "HeldDown" then denon_glos = hub.getValue(denon_salon, 'volume') for i=1, 100 do denon_glos = denon_glos + 1 hub.call(denon_salon, 'setVolume', denon_glos) hub.sleep(200) end end
I niby wszystko w porządku...
Ustaw sobie print("a") jako debugger.
W pierwszej linijce i wykonaj, potem przesuń do drugiej i wykonaj i zobacz ktora linia sie nie wykonuje.
Wg mnie moze byc tak ze zmienna przyciskValue od jakiegoś pola -atrybutu nie istnieje, a ty odnosisz sie do tych pol przez przez zapis "."
Bezpieczniej było by przez ten zapis ["pole"] bo jak nie bedzie danego pola/atrybutu istnieć to kod sie nie wywali.