Try this instead:

xrandr | grep 'HDMI1 connected' &&
    xrandr --output eDP1 --auto --output HDMI1 --auto --left-of eDP1

That will run the xrandr command only if the HMDI1 screen is connected. I don't know the details of the format of .3/config (although I do know it will ignore anything after the exec line, are you sure you want this with exec?), so if that doesn't work just put it in a script and call the script from config.