scripts/device: avoid crashing if the device.name is not set

This should never happen, but there are odd cases with broken
configuration where such a device may appear and the least we can do
is not crash, at least not when the device.name is only used for
debug messages. In state-profile and other places where the name
really matters, we actually have checks in place.

Fixes: #674
This commit is contained in:
George Kiagiadakis 2024-06-17 09:13:16 +03:00
parent 31806862b0
commit 47ec81408e
2 changed files with 2 additions and 2 deletions

View file

@ -23,7 +23,7 @@ AsyncEventHook {
execute = function (event, transition)
local device = event:get_subject ()
local profile = event:get_data ("selected-profile")
local dev_name = device.properties ["device.name"]
local dev_name = device.properties ["device.name"] or ""
if not profile then
log:info (device, "No profile found to set on " .. dev_name)

View file

@ -28,7 +28,7 @@ SimpleEventHook {
end
local device = event:get_subject ()
local dev_name = device.properties["device.name"]
local dev_name = device.properties["device.name"] or ""
local off_profile = nil
local best_profile = nil
local unk_profile = nil