Run script when computer sleeps

When I leave my office room in the evening and have left my iMac and rooms lights on is there a way to run s script when my computer triggers sleep mode to turn off the lights?

Or am I just being stupidly lazy now?

[quote=“Plucker, post:1, topic:191582”]When I leave my office room in the evening and have left my iMac and rooms lights on is there a way to run s script when my computer triggers sleep mode to turn off the lights?

Or am I just being stupidly lazy now? PROBABLY ;D[/quote]

Just a guess but would ping sensor work?

Sorry, should have said - VeraPlus/UI7 - Ping Sensor doesn’t seem to install correctly

My mistake - it’s throwing some errors about language but it is working fine! I set the ping sensor to monitor the IP address of the iMac and once I’d worked out I had to set it to “tripped=0” or “Ping sensor is not tripped” it started working.

Thank you Slartibartfast! PS Do you know Douglas Adams’ original name for your character that he couldn’t use?

Would you by any chance mean ‘Phartiphukborlz’ - Not for me thanks.