What did you do with Vera today?

If the Sony TV is supported by iRule for IP control, I could look them up. Maybe the same as the Bravia linup?

If the Sony TV is supported by iRule for IP control, I could look them up. Maybe the same as the Bravia linup?[/quote]

tv is kdl43w755 2015 Bravia Android, it works via roomie/simple control and does have its own app i have tried many times experimenting with wireshark but never manage to figure it out.

iRule’s database lists “SONY TV - IP Control 2015 Models”, “SONY TV - IP Control 2014 Models”, and “SONY TV - IP Control 2013 Models”, as well as just “SONY Televisions - IP Control”. The notes on the 2014 and 2015 mention the TV Sideview app. Now that I think about it, I use IP control for my Blu-ray player in iRule, but I haven’t tried Lua socket. For example in iRule “Power Toggle” is sent as (add in the IP before this):

/upnp/control/IRCC?<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:X_SendIRCC xmlns:u="urn:schemas-sony-com:service:IRCC:1"><IRCCCode>AAAAAwAAHFoAAAAVAw==</IRCCCode></u:X_SendIRCC></s:Body></s:Envelope>

If I get some time I will test sending in Lua socket to see if this works as-is…

Sony TVs use SOAP and newer models require authentication… Look at this little unix shell script package → HERE

ok so I have my auth code and the IRCC codes and can make it work using the script but am struggling to translate to curl which i can run from vera.

EDIT…

got it, not just to figure out how to run in LUA

curl --silent -XPOST http://192.168.1.xxx/sony/IRCC -d “<?xml version=\"1.0\"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/\” s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/\“><s:Body><u:X_SendIRCC xmlns:u="urn:schemas-sony-com:service:IRCC:1">“AAAAAQAAAAEAAAATAw==”</u:X_SendIRCC></s:Body></s:Envelope>” -H ‘Content-Type: text/xml; charset=UTF-8’ -H ‘SOAPACTION: “urn:schemas-sony-com:service:IRCC:1#X_SendIRCC”’ -H “Cookie: auth=xxx” -o /dev/null

local http = require("socket.http")
local ltn12 = require("ltn12")
local respBody = {}
local SONY_IP = "192.168.1.xxx"
local AUTH_CODE = "yyyy"
local IRCC_CODE = "AAAAAQAAAAEAAAATAw=="
local REQUEST = "<?xml version=\"1.0\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:X_SendIRCC xmlns:u=\"urn:schemas-sony-com:service:IRCC:1\"><IRCCCode>"
REQUEST=REQUEST .. IRCC_CODE
REQUEST = REQUEST.."</IRCCCode></u:X_SendIRCC></s:Body></s:Envelope>"
local SONY_URL = "http://"..SONY_IP.."/local_api.php?getDeviceList=true"

rBody, rCode, rHeaders, rStatus = http.request(
	{
		method = "POST",
		url = SONY_URL,
		headers = { 
			["Content-Type"] = "text/xml; charset=UTF-8",
			["SOAPACTION"] = "urn:schemas-sony-com:service:IRCC:1#X_SendIRCC",
			["Cookie"] = "auth="..AUTH_CODE
		},
		source = ltn12.source.string(REQUEST),
		sink = ltn12.sink.table(respBody),
		redirect = false
	}
)

wow, fantastic, ive never got into the world of functions but have been reading a little recently and think this should be the first one I try to start working with. I get myself confused in the world of if, else, while’s so need something to make my life easier, im a very simple level programmer and never really got the hang of anything too complicated.

so if i try and get this in to function I’m thinking the following,
drop this in to startup.lua

function TV(code)
local http = require("socket.http")
local ltn12 = require("ltn12")
local respBody = {}
local SONY_IP = "192.168.1.xxx"
local AUTH_CODE = "yyyy"
local REQUEST = "<?xml version=\"1.0\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:X_SendIRCC xmlns:u=\"urn:schemas-sony-com:service:IRCC:1\">code"
REQUEST=REQUEST .. IRCC_CODE
REQUEST = REQUEST.."</IRCCCode></u:X_SendIRCC></s:Body></s:Envelope>"
local SONY_URL = "http://"..SONY_IP.."/local_api.php?getDeviceList=true"

rBody, rCode, rHeaders, rStatus = http.request(
	{
		method = "POST",
		url = SONY_URL,
		headers = { 
			["Content-Type"] = "text/xml; charset=UTF-8",
			["SOAPACTION"] = "urn:schemas-sony-com:service:IRCC:1#X_SendIRCC",
			["Cookie"] = "auth="..AUTH_CODE
		},
		source = ltn12.source.string(REQUEST),
		sink = ltn12.sink.table(respBody),
		redirect = false
	}
)
end

then i call it by using

TV("AAAAAQAAAAEAAAAVAw==")

is that right?

Almost…

You remove the line defining the IRCC variable… That was correct…
You then defined the function as “function TV(code)”…

When you call the TV function, the function is executed with the “code” variable set to the IRCC code that you pass in the function call… The variable IRCC_CODE is not defined, and the function will throw an “Attempt to concat a nil value” error…

If you define the function as “function TV(IRCC_CODE)”, the function will run correctly… unless you pass a nil value to the function… So, as the first lines of the function, add:

if (IRCC_CODE == nil) then 
  luup.log("TV function: No IRCC_CODE specified",1)
  return 
end

This will prevent your program from crashing if the function is called with a nil value.

ok - yeah I did update the passed variable in one place but your suggestion is certainly the obvious one :-/

trying to test in stages though and not having much joy, tried to run this in test luup window before playing with the function and not having any joy. just doesn’t seem to do anything

[code]local http = require(“socket.http”)
local ltn12 = require(“ltn12”)
local respBody = {}
local SONY_IP = “192.168.1.225”
local AUTH_CODE = “75071BA72588155AD9FABC47EBDD353BA4ED40D7”
local IRCC_CODE = “AAAAAQAAAAEAAAAUAw==”
local REQUEST = “<?xml version=\"1.0\"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/\” s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/\“><s:Body><u:X_SendIRCC xmlns:u="urn:schemas-sony-com:service:IRCC:1">”
REQUEST=REQUEST … IRCC_CODE
REQUEST = REQUEST…“</u:X_SendIRCC></s:Body></s:Envelope>”
local SONY_URL = “http://”…SONY_IP…“/local_api.php?getDeviceList=true”

rBody, rCode, rHeaders, rStatus = http.request(
{
method = “POST”,
url = SONY_URL,
headers = {
[“Content-Type”] = “text/xml; charset=UTF-8”,
[“SOAPACTION”] = “urn:schemas-sony-com:service:IRCC:1#X_SendIRCC”,
[“Cookie”] = “auth=”…AUTH_CODE
},
source = ltn12.source.string(REQUEST),
sink = ltn12.sink.table(respBody),
redirect = false
}
)[/code]

log looks like

[code]4 02/26/16 19:53:23.130 <0x76b5c520>
08 02/26/16 19:53:26.950 JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunLua <0x7275c520>
08 02/26/16 19:53:26.951 JobHandler_LuaUPnP::HandleActionRequest argument Code=local http = require(“socket.http”)
local ltn12 = require(“ltn12”)
local respBody = {}
local SONY_IP = “192.168.1.225”
local AUTH_CODE = “75071BA72588155AD9FABC47EBDD353BA4ED40D7”
local IRCC_CODE = “AAAAAQAAAAEAAAAUAw==”
local REQUEST = “”
REQUEST=REQUEST … IRCC_CODE
REQUEST = REQUEST…“”
local SONY_URL = “http://”…SONY_IP…“/local_api.php?getDeviceList=true”

rBody, rCode, rHeaders, rStatus = http.request(
{
method = “POST”,
url = SONY_URL,
headers = {
[“Content-Type”] = “text/xml; charset=UTF-8”,
[“SOAPACTION”] = “urn:schemas-sony-com:service:IRCC:1#X_SendIRCC”,
[“Cookie”] = “auth=”…AUTH_CODE
},
source = ltn12.source.string(REQUEST),
sink = ltn12.sink.table(respBody),
redirect = false
}
) <0x7275c520>
04 02/26/16 19:53:38.209 <0x76b5c520>
02 02/26/16 19:53:38.209 Device_Basic::AddPoll 12 poll list full, deleting old one <0x76b5c520>
06 02/26/16 19:53:38.210 Device_Variable::m_szValue_set device: 12 service: urn:micasaverde-com:serviceI[/code]

Add some additional logging at the end of the code to see what it’s doing…

ie:

luup.log("http response - code ["..(rCode or "NIL").."] html ["..(table.concat(respBody,"") or "NIL").."]")

This will tell you if the TV responded, and how it responded.

You guys need to a new thread!

^truth.

Not today, but yesterday, I added a Sonos ZP90 to Vera. I’ve got it plugged into my intercom, so now I have announcements throughout the house.

Fortunately, I didn’t forget to change the zone for my weather forecast from “ALL” to “Kitchen” before I walked downstairs today. Having the weather blasting from the intercom early this morning wouldn’t have gone over well with the wife.

Added Motion dection sensor to door sensor so now I know if the door is opend for inbound or outbound trafig.

Adding the ability to see furnace status remotely.

I have been using z-wave enabled thermostats in my house for years and thought it would be nice to know when the heat/fan is on or off. In the short term I wanted to be able to see this status remotely while in the long term I wanted to track the on/off cycles using something like datamine.

At first it was not clear how to do this so I started poking around and found that the thermostat supported a serviceID [urn:micasaverde-com:serviceId:HVAC_OperatingState1] with a variable called [ModeState]. The mode state is a string that looks to be what the furnace is set to do by the thermostat. Both my thermostats seemed to have a few state strings that were different but the string [Idle] was common.

Next I simply used PLEG to have the device property as an Input and then used that to drive an Action that changes a Virtual switch [SetTarget] to 0/1 based on the string being [Idle] or not.

This provided current state when viewing remotely with the Vera UI. I also added the Virtual Switch to ImperiHome and changed the icon to the fan. This would then show the fan spinning when the furnace was on.

You can also use a counter in PLEG to accumulate the ON time of your furnace.

Thanks,
I think the biggest limitation I have is my imagination or maybe with so much configurability come a certain amount of user paralysis. :slight_smile:

I’m just about finished with my garage control system. There are monoprice door/window sensors on each door to detect whether they are opened or closed. Then I have a raspberry pi connected to some relays that simulate button presses. I just finished re-writing the python and php scripts on the pi. Next step is to re-enable authentication on the Pi and I’m done. Total cost was about $45 for status and control of two doors since I already had the Raspberry Pi handling sprinkler control (with OpenSprinkler).

So now the fun part begins with scenes and tasker. I already updated some of the tasker “go to bed” and security tasks to include checking the garage state and closing the doors. I’ll probably do some “prepare for departure” scripts that open the garage, turn on the garage lights, turn off the interior lights, and lock the exterior doors.

Created a vacation ghost in PLEG.

Used the dataMine2 plug-in to calculate my gas and electricity bill so I could check my supplier got it right (which they don’t always).

If you are doing interesting stuff with either dataMine or dataYours I’d be interested to hear about it here: http://forum.micasaverde.com/index.php/topic,37548.0.html

edit: image attachment added

After finding out last night my youngest GSD has figured out how to open the back door (It has a Schlage Z-Wave lever lock and a manual deadbolt) I created ‘door open’ scenes for all outside doors that use Sonos to tell me if a door is opened if on mode Home or Night. (I already get notifications on my phone in Away/Vacation mode) Luckily the oldest GSD barked at her and alerted me to the event. It seems I forgot to flip the deadbolt to locked. 8) Puppy girl had heard something in the back yard and decided she needed to check it out by jumping up and looking out the window in the door. Seems her paw pushed the lever down and unlocked the door with her weight against the door opening it for her as it opens outwards. shaking head. No way she can do that to the front door as that has no lever but an egg shaped knob and a Schlage z-wave deadbolt. After this, there is no way I will replace that knob with a lever.

I replaced all round knobs a year or so back as I am getting older and levers are easier to use than round knobs especially when I have both hands full. (also in case I ever develop arthritis.)