Getting a devices current D state...

What is the easiest way to get the D state of a given device? I’m wanting to tell if my monitor is on or off while I am remotely accessing the machine. And if the monitor is on I am wanting to turn it off(I am not physically at the machine) Is there any UI that does this now? Thanks.