Unable to communicate with Mega after uploading with platformIO, stuck at 0.8.1

For your convenience you can keep the platformio.ini file as it is, and create a prod_env.ini with the following content:

[platformio]
default_envs = 
  atmega-rf-ir

[env:atmega-rf-ir]
platform = ${com.atmelavr_platform}
board = megaatmega2560
lib_deps =
  ${com-arduino.lib_deps}
  ${libraries.irremote}
  ${libraries.rc-switch}
  ${libraries.stl}
build_flags =
  ${com-arduino.build_flags}
  '-DZgatewayRF="RF"'
  '-DZgatewayIR="IR"'
  '-DZmqttDiscovery="HADiscovery"'
  '-DsimplePublishing=true'
  '-DGateway_Name="OpenMQTTGateway_ATMEGA_RF_IR"'

This way you just have to fetch the latest update of the code and keep this file into it.