With this script I can turn of my Samsung TV in the kitchen. Control codes are included for other functions like changing channels, volume or input. The only thing it cannot do is turn on a TV. Wake On Lan was available a short time but Samsung disabled that possibility in a firmware upgrade.
All credits go to the good folks at the Samygo forum who disected the iPhone/Android remote app.
Use in an action (server script/python)
Turn of TV, change channel, change input, control AllShare playback, etc. E.g. make it part of a Turn Of All command, or lower the volumen when the doorbell is pressed or tune i to your favorite channel at a fixed time (e.g. the news in the morning).