Instead, it tells you if the entity is connected to an electric network that has an energy source.
I.e.
Calling this on the assembler returns false, even though it is clearly connected to an electric network.

If i now then add an electrical source like an accumulator or a steam engine, now it will return true regardless if there is any electricity in it or not.

This seems like a bug because even though it is connected to an electric network, the flashing alert icon says it's not connected to anything, even though it is.