Trouble with an using a for each

Temporarily add the real device in the statement so the attribute will show up, then you can remove it after your statement is complete.