You really should tell JSOnata which scope context to look in, as in [ ]
you are in $ scope context local loop. But payload is not in that context it is in Base scope context $$
That is why i always add the context, people think I am crazy, but if you had you would of come up with
$$.roominfo.dimmers[$.device_ieee = $$.payload.event.device_ieee].type
which would have worked straight off
Notice i let JSONata know where it should be looking, even if it is not required.
Looking at expression you can see where in scope context things are.
It will save you a lot of head scratching in the future.