If you want to power on the TV You can give this command a try and see if the TV does not kick back an error (see the end of the post for error messages from the TV) It all depends on the API level of the TV
This will allow you to turn the TV on. I set it up so that if the TV is being newly registered to set the WOL mode to enabled right out of the gate. and when a connection is made then to grab that mac address right away this way the power on and off will function properly. I do know that when the TV is in a standby state there are parts of the API that will do nothing or kick back an error. below is how to handle those errors.
The attached file contains all of the errors and related messages that the TV can have. you will need to change the .txt to .py
exception.txt
sample code for using the exceptions. The code only shows how to handle an error that has been returned by the TV
import exception
err = response.get('error', None)
if err:
err_id = err[0]
if err_id in exception.EXCEPTIONS:
raise exception.EXCEPTIONS[err_id](err)
if err_id < 32767:
raise exception.ScalarWebAPISystemError(err)
else:
raise exception.SonyAPIError(err)
The network card stays powered on and the API will still allow for authentication if the TV is in a Powered Off (standby) state.
otherwise the command of
would not be able to respond with
If you want to power on the TV You can give this command a try and see if the TV does not kick back an error (see the end of the post for error messages from the TV) It all depends on the API level of the TV
if that fails then you will want to send this command
and if you do not get this for an answer
then send this command
then You will be able to run this command
which will respond with
be sure to iterate through the result and look for the "WOL". this will give you the MAC address to run this next piece of code.
This will allow you to turn the TV on. I set it up so that if the TV is being newly registered to set the WOL mode to enabled right out of the gate. and when a connection is made then to grab that mac address right away this way the power on and off will function properly. I do know that when the TV is in a standby state there are parts of the API that will do nothing or kick back an error. below is how to handle those errors.
The attached file contains all of the errors and related messages that the TV can have. you will need to change the .txt to .py exception.txt
sample code for using the exceptions. The code only shows how to handle an error that has been returned by the TV
Hope that helps with your power issue