scripts: fix event:get_data() usage in apply-profile

event:set_data() coerces Lua tables to properties, so that keys and
values become strings.  Take into account that profile.index is a string
due to this.

Fixes WP setting the profile, even though it is already the active one.
This commit is contained in:
Pauli Virtanen
2024-04-27 17:47:12 +03:00
parent b302ebd6ab
commit 42370f0547

View File

@@ -33,7 +33,7 @@ AsyncEventHook {
for p in device:iterate_params ("Profile") do
local active_profile = cutils.parseParam (p, "Profile")
if active_profile.index == profile.index then
if active_profile.index == tonumber(profile.index) then
log:info (device, "Profile " .. profile.name .. " is already set on " .. dev_name)
transition:advance ()
return
@@ -42,7 +42,7 @@ AsyncEventHook {
local param = Pod.Object {
"Spa:Pod:Object:Param:Profile", "Profile",
index = profile.index,
index = tonumber(profile.index),
}
log:info (device, "Setting profile " .. profile.name .. " on " .. dev_name)
device:set_param ("Profile", param)