System.Stats.batteryInDays is null

I try to test System.Stats.batteryInDays in the sim with vivoactive 4 device - although the sim is set to have a value of 5 it returns null - is the sim not working yet with the new Connect IQ System 5? Docs are not saying anything about a possible null value either...

SIM, devices are up to date...

  • Same issue in 2025.

    I've just received an ERA `Unexpected Type Error` when trying to format `batteryInDays` on a venusq 3.60 even though I was already checking `has :batteryInDays` so am hoping the additional null check fixes it on the physical device.

  • I don't think so. If it was null then I think you would get another error. My guess is that there's a Float and your code assumes a Number or something like that 

  • I've just received an ERA `Unexpected Type Error` when trying to format `batteryInDays`
    If it was null then I think you would get another error

    At run time, I think the error would indeed be "Unexpected Type Error" if you try to call format [for example] on a null object.

    I built that code with type checking disabled btw. If type checking is enabled, the compile-time error is probably closer to what you were expecting:

    > Cannot find symbol ':format' on type 'Null'.

  • My guess is that there's a Float and your code assumes a Number or something like that 

    Both Float and Number have the format method. And ofc they both support the same arithmetical operators [so it's not possible that using "+", "-", "/", or "*" is going to cause that error]

    But just for the sake of argument, here's what happens if you try to call a function that doesn't exist on a given object:

    So if it was really an issue of expecting one type and getting another (non-null) type, then trying to call a function that doesn't exist on the actual type, I think the run-time error would be "Symbol Not Found".