I am trying to add my Sony kd=55x9005c tv from my Vera - only simple Turn ON and Turn OFF Commands. I have all the settings on the TV as per other threads and Sony’s instructions and I can control the TV from an app on the phone.
I have searched numerous threads on this topic but cannot get the TV to either Wake on Lan using a WOL Plugin nor turn on or off using LUA code.
TBH, I thought this would have been very simple to add the HTTP Post code to a LUA script in a scene which could be triggered by a switch or a timer etc.
I believe that part of the problem may be that the post you referenced has incorrectly formatted code, which means that double quotes have been converted to inverted commas, which will cause a syntax error in Lua.
I’'m fixing the formatting of your post, and will go to the referenced thread and try to fix things there.
You need to quote code properly in this new forum for things to work correctly.
Thanks for the response. Before I got home to check what you had suggested I found some code on another site and tried adapting it to control the TV and low and behold it worked!!!
To turn the TV on I used this:
function VeraAlert(host, port, Msg)
local socket = require("socket")
local tcp = socket.tcp()
tcp:settimeout(3)
if (tcp:connect(host, port)) then
if (tcp:send(Msg)) then
else
luup.log("Error Sending Msg")
end
else
luup.log("Error Opening Socket")
end
tcp:close(socket)
end
VeraAlert("192.168.0.30", 20060, "*SCPOWR0000000000000001\n")
--PowerON
And to turn it off I replaced the VeraAlert Line with a 0 instead of a 1 at the end of the SCPOWR text.
Obviously 192.168.0.30 should be replaced with the IP address of your TV.
Thanks to a forum entry by @RichardTSchaefer
I hope this is useful to others.