Since a while, probably the last system update, after inactivity, the screen won't go to sleep. The system itself is configured not to go to sleep, but the screen should, and it should lock then, but it doesn't.
There is a similar question here: My MacBook won't go to sleep anymore
$ pmset -g assertions 2018-01-01 17:22:20 +0100 Assertion status system-wide: BackgroundTask 0 ApplePushServiceTask 0 UserIsActive 1 PreventUserIdleDisplaySleep 1 PreventSystemSleep 0 ExternalMedia 1 PreventUserIdleSystemSleep 0 NetworkClientActive 0 Listed by owning process: pid 111(hidd): [0x00029b5b00099302] 00:00:00 UserIsActive named: "com.apple.iohideventsystem.queue.tickle.4294968026.3" Timeout will fire in 300 secs Action=TimeoutActionRelease pid 574(AirPlayUIAgent): [0x0001717d0005a3c9] 38:38:30 PreventUserIdleDisplaySleep named: "com.apple.airplay.disableUserIdleDisplaySleep" Details: disable user idle display sleep for AirPlay screen pid 61(powerd): [0x0000000600088000] 91:42:44 ExternalMedia named: "com.apple.powermanagement.externalmediamounted" No kernel assertions. Idle sleep preventers: IODisplayWrangler
I've had this problem last week, then decided to restart. This solved the problem, until now. It seems to have to do with Bluetooth? I'm not sure yet.
Update: it is related to Airplay. Whenever I stream to Apple TV, this happens.
How can I get my screen to go to sleep automatically and fix this problem either permanently or temporarily without having to restart?