"A useful and simple way to distinguish between physiological and psychological impotence is to determine whether the patient ever has an erection. If never, the problem is likely to be physiological; if sometimes (however rarely), it could be physiological or psychological. The current diagnostic and statistical manual of mental diseases (DSM-IV) has included a listing for impotence.
….
Nocturnal penile tumescence (NPT)
It is normal for a man to have five to six erections during sleep, especially during rapid eye movement (REM). Their absence may indicate a problem with nerve function or blood supply in the penis. There are two methods for measuring changes in penile rigidity and circumference during nocturnal erection: snap gauge and strain gauge. A significant proportion of men who have no sexual dysfunction nonetheless do not have regular nocturnal erections. Thus presence of NPT tends to signify physically functional systems, but absence of NPT may be ambiguous and not rule out either cause"
Erectile dysfunction - Wikipedia
If lower heart rate is the what allows nocturnal erections, than you should be able to have erections while awake, not they disappear as you open your eyes, like you posted - if you lie in bed and are relaxed, your heart rate is about the same than when sleeping - actually, if I recall correctly, you have nocturnal erections in the REM phases, and your heart rate isn’t necessarily that that low while you dream.
Or more succintly said, if your penis works, than it is not broken. And a psichologic factor doesn’t means ‘patient’s fault’ - not assigning faults here, just trying to understand the problem.
Anyway, we’ll know soon, since your urologist is going to do the required exams.