We have moved at community.getvera.com

Author Topic: [Script] AutoRemote / Android / Tasker - How to  (Read 1165 times)

Offline konradwalsh

  • Hero Member
  • *****
  • Posts: 566
  • Karma: +19/-6
[Script] AutoRemote / Android / Tasker - How to
« on: February 03, 2014, 11:43:26 am »
This may be of use to others. I spent a couple of days getting this right.

It uses the amazing AutoRemote app to keep me updated and in control remotely. I use if for the heating system but you can easily change its use.
The easiest way to do this is open YOUR autoremote link - http://goo.gl/XXXXX and fill in a box. Then copy the code on the right. Break it down and put it in here..

Yes, I know you could just keep it all as one string.. but this way I one set of LUUP code and I can reuse it without much effort..

Code: [Select]
--Get Current Temps from VTemp Controller
local tUpCurrent = tonumber((luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature",223)))
tUpCurrent = tUpCurrent .. "?"
local tDownCurrent = tonumber((luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature",191)))
tDownCurrent = tDownCurrent .. "?"

--Controller Mode - ECO/Normal
local dn_mode = luup.variable_get("urn:upnp-org:serviceId:HVAC_UserOperatingMode1","EnergyModeStatus", 118)
local up_mode = luup.variable_get("urn:upnp-org:serviceId:HVAC_UserOperatingMode1","EnergyModeStatus", 182)

--Build HTTP String

local httpstart = "https://autoremotejoaomgcd.appspot.com/sendnotification?"
local httpkey = "key=[YOUR-KEY-HERE]"
local httptitle = "&title=Heating%20System&text=Updated%20Information"
local notice_sound = "&sound=7" --Chosen Sound File from Settings of App
local httpsoundvib = notice_sound .. "&vibration=10,120," -- Vibration Pattern
local httpid = "&id=60001" --Constant ID for Notification so the same one is upadated
local httpiconled = "&icon=[YOUR-URL-OF-IMAGE]&led=yellow&ledon=150&ledoff=50" -- Icon on Left and LED Colour

--Set up the buttons
--Check Downstairs to set up the right icon
local httpactions1 = "&action1=down&action1name=Dn%20-" .. tDownCurrent -- Concat the result for the button name
local down_status = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status", 39)
local httpactionsicon1 = null
if (down_status == "1") then
httpactionsicon1 = "&action1icon=presence_online" --use the built in icons
else
httpactionsicon1 = "&action1icon=presence_invisible" --use the built in icons
end

--Check Upstairs to set up the right icon
local httpactions2 = "&action2=up&action2name=Up%20-" .. tUpCurrent -- Concat the result for the button name
local up_status = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status", 38)
local httpactionsicon2 = null
if (up_status == "1") then
httpactionsicon2 = "&action2icon=presence_online" --use the built in icons
else
httpactionsicon2 = "&action2icon=presence_invisible" --use the built in icons
end

--Check Boiler to set up the right icon
local httpactions3 = "&action3=water&action3name=Water"
local boiler_status = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status", 229)
local httpactionsicon3 = null
if (boiler_status == "1") then
httpactionsicon3 = "&action3icon=presence_online" --use the built in icons
else
httpactionsicon3 = "&action3icon=presence_invisible" --use the built in icons
end
local httpsubtext = "&subtext=Down%20" .. tDownCurrent .. "%20-%20" .. dn_mode .. "%20|%20Up%20" .. tUpCurrent .. "%20-%20" .. up_mode
local httpsender = "&sender=Vera"

local httpfinal = "&sender=Vera&persistent=2&statusbaricon=ic_action_home&ticker=Home%20System%20Update"

local httpcommand = httpstart .. httpkey .. httptitle .. httpsoundvib .. httpid .. httpiconled .. httpactions1 .. httpactionsicon1 .. httpactions2 .. httpactionsicon2 .. httpactions3 .. httpactionsicon3 .. httpsubtext .. httpsender  .. httpfinal
luup.inet.wget(httpcommand)