I have a printer located in a closet about 25ft from my desk and I constantly print using letterhead and other tutors of paper.
This means I constantly load printer paper to go back to my laptop to hit the ENTER button to start printing.
Is there a way in HA that would allow me to simulate the pressing of the enter Key on my Mac keyboard? I can use any smart button to initiate this request so I am not concerned with that part.
I looked around the community and did not see any use case like this.
Also I host HA on a VM on a Synology NAS so the keyboard I need access to is not on the host machine.
It won’t be in HA but if you have a spare apple remote control you could do something with Eventscripts. It can fire a script (e.g. one that presses the enter key) on a system event. I use it write a text file which an HA command line sensor reads to know when a Mac is unlocked. It’s only really good for Mac->HA communication, to go the other way like you want to do I think you’d have to use a key on the Apple remote as your trigger.
If you have an SSH connection between your Home Assistant instance and your Mac you can use that to run Terminal commands on the mac. I used this guide from the forums and this guide from siytek.com (He has a couple typos in his guide… but it is pretty good)
Where the siytek.com guide has you create a new script, in Terminal on your Mac you can use something like:
#!/bin/bash
osascript -e 'tell application "**Your Application***" to activate' -e 'tell application "System Events" to key code 36'
The first “tell” isn’t absolutely necessary, it just brings your chosen application to the front. You can leave it off as long as you remember to leave the print dialog box activate on the desktop when you leave to go to the printer. The second “tell” is emulating pressing the Return key.
For me, the Home Assistant shell command configuration syntax that works is as follows: