I was having the same problem then I figured out an alternative way.
In your page template right after the page template name definition which is usually a comment. use this code:
update_option('current_page_template','write the page template name here');
once you do that wordpress saves this value in it’s database.
Now next thing you already know just to get this value to use it as your body id, in my case I used class.
Many wordpress developers know this but I’m writing here just for convenience.
Use the following code in header.php to know the current template:
<body id="<?php echo get_option('current_page_template'); ?>">
I’d be happy if this helps.