const s = declare(“DeviceID.SerialNumber”, {value: 1});
The whole DeviceID structure is one created by GenieACS for internal purposes, it does not exist on the device. Doing this const s = declare("DeviceID.SerialNumber").value[0]; will allow you to read the serial number the device has sent over neutral of whether the device is using TR-069 or TR-181.
The {value: 1} parameter also tells GenieACS that you wish to refresh that value if its copy is older than the value given. The value is in Unix epoch.