Can't get rpi5 home assistant to simulate a key press via SSH onto my Mac

Hi all, been struggling for hours on this

I want to press keys from my HAOS (raspberry 5) to my mac.

  1. I’ve create the script Mac which works.
  2. I created the no auth connection on the rpi5 to the Mac, copied the private key, etc, it works too
  3. via HASS terminal, I can successfully run it runs as expected

ssh -o StrictHostKeyChecking=no user@targetIP "osascript /Users/path/key_press.scpt"

  1. I managed to create the command-line and entity in the Configuration.yaml:

command_line:
- switch: name: Simulate Key
unique_id: switch.simulate_key
command_on: 'ssh -o StrictHostKeyChecking=no user@targetIP "osascript /Users/path/key_press.scpt"'
command_off: 'ssh -o StrictHostKeyChecking=no user@targetIP "osascript /Users/path/key_press.scpt"'

  1. I then move to creating a button on the dashboard but the button is unresponsive. It shows “off” but never turns on upon clicking it. Here’s its code:

type: button
show_name: true
show_icon: true
name: Simulate Key Press
tap_action:
action: perform-action
perform_action: switch.toggle
target:
entity_id: switch.simulate_key_press_3
data: {}
show_state: true
entity: switch.simulate_key_press_3
hold_action:
action: toggle

Can you help?

Did you lose some indentation when you copy-pasted that code?
It does not look correct as it is there.

1 Like

I started from the beginning and manage to make it all work just now!

As of today, when I put my iPad back to charge on its Magic Keyboard, it turns wakes the Mac which I control via the iPad.

It was the rsa and pub keys, they were located elsewhere by default