HDMI wakeup fails

I have a samsung ue55js9000 which I have a apple tv connected to. I only wanna use one remote to master it all. So I use the apple tv remote which has the nice touchpad. I dont wanna have a harmony. Now my problem the ATV only manged to start the tv about 80 % of the time on hdmi wakeup. The other times I manually need to get the samsung remote to wake it up. Any suggestions how I can check if the tv is on and then send ir ON from esp etc? Or how to troubleshoot that the hdmi wakeup only works sometimes? I have replaced the hdmi cable with no luck. Latest firmware on the tv.

Make sure HDMI CEC is turned on on both TV and Apple TV.
But since it works sometimes I assume they are on.

Does the TV have USB ports? Get out the multimeter and see if there is always power or only when the TV is on.
If it’s only when the TV is on then you can build a voltage divider and feed it to an ESP as a boolean.

Ok, I will check that. Can you send IR command on only or does the ir power toggle on/off?

Most are only toggle, but there are some TVs that have distinct on and off commands.
The problem is to find those codes because the remotes do not have them.

Allright, do you know any way of monitoring the power state of apple tv?

Try ping sensors on both

Also there are issues with ‘some’ Samsung TV’s switching off with the remote can loose WiFi passwords and one time all the hdmi ports stopped working.
Disconnect from wall power socket, wait 10 mins, plug back in.

The ATV responds to ping when sleeping.

Ah !
Does it display on HA as a media player ?
If so what are it’s attributes?
Has it got an entity_id assigned to it ?