The Vera Community forums have moved!

General => Remote Control => SQ Remote / Square Connect (iOS) => Topic started by: mbairhead on October 23, 2010, 03:05:26 pm

Title: Vera + Puck would = :) mbairhead
Post by: mbairhead on October 23, 2010, 03:05:26 pm
So is their any word on who (if anyone) is working on getting Vera and the Puck together? If so, how's it coming?
Title: Re: Vera + Puck would = :) mbairhead
Post by: SquareConnectMat on October 23, 2010, 03:06:53 pm
MiCasaVerde are working on this.... I can not speak for them on when this will be available

Mat
Title: Re: Vera + Puck would = :) mbairhead
Post by: mbairhead on October 24, 2010, 11:21:25 am
Wow...ask and ye shall receive. Thanks guessed, I'll try this out later today.
Title: Re: Vera + Puck would = :) mbairhead
Post by: strangely on October 24, 2010, 10:08:48 pm

d) The code hasn't been tested in a while, and @strangely reports a few kinks in using it lately...  I'd love to hear more details
e) The code hasn't been updated to the latest SQBlaster API's, and uses a legacy throwback API that might be causing (d)


Haven't really looked into this but despite the blaster being able to receive the Vera commands pronto codes (I can see in the syslog), only very rarely does one register on the two devices I'm trying to blast to. If I get some time I'll perhaps try to capture what it sends with the old USB-UIRT on my PC.

@mbairhead, it'll be interesting to see your mileage with it?
Also if you had another device already like a USB-UIRT or a GC100 etc then you can just re-assign the IODevice number that the Puck represents (obviously have to add it first) to your old plugin in the IODevice field and save.
Title: Re: Vera + Puck would = :) mbairhead
Post by: fall-line on November 16, 2010, 05:28:12 pm
Apologies if I am being dense, but I think I need a little help to utilize this plugin. I installed it as instructed, which went well. I then added a couple of devices that were actually found just fine in the internal database, such as my Denon Receiver (which uses D_DENONAVR889.xml.lzo) and my Sharp Aquos TV (D_Aquos.xml.lzo). When adding the devices I was able to send Test codes to them via the Test buttons next to the actions, and control worked just fine. However, now that I have gone ahead and added them, I see the new devices (called _TV and _Receiver) showing up in my devices list, but am unsure how to actually control them.

The reading I've done referring to the use of manually programmed pronto codes seems to not apply to me since both of these devices were already defined, correct? I would have thought that the actions which I was able to test during the device setup, would then be available under the device once added, and could therefore be added to scenes, etc.

Thanks again!
Title: Re: Vera + Puck would = :) mbairhead
Post by: guessed on November 16, 2010, 07:51:42 pm
Ok, so you have two Plugin files (D_DENONAVR889.xml and D_Acquos.xml) that have been "auto" built for you by Vera, based upon it's IR Database. 

In turn, Vera has used these Plugin files to build Vera Devices, specifically _TV and _Receiver.  These Device stubs are meant to represent the physical "TV" and "Receiver".  The "_" is just there to remind you to rename them, and place them into Rooms that make sense.

It's this Physical Device that has a setting to "know" which IR Device it needs to use.  If you have the Puck, and the SQBlaster Plugin, then you'd set the TV and Receiver devices to use the SQBlaster as the "IR" Transmitter.

Now you have the Device stubs in Vera, and you've let Vera know to use the SQBlaster for their IR Control, you can use "Advanced" Scenes (the Advanced Tab) to perform IR Actions against those devices.

The primary use-case for doing all this "dance" is to do things like "Power Off" from Vera, as a part of a larger "Goodnight" type scene where various devices around the house are shutdown.  Obviously, the Advanced Scenes in MiOS lets you do any of the IR actions that the specific Plugin exposes ("ChannelUp", "ChannelDown", "VolumeUp", etc, etc) but it's far more likely that you'd do that directly between SQRemote and SQBlaster. 

That said, you could use it to turn on TV's (etc) whilst you're on vacation, to make the house look more lived in.


and yes, there's a reason that it's being more tightly integrated... to avoid all these discrete setup steps ;)
Title: Re: Vera + Puck would = :) mbairhead
Post by: fall-line on November 16, 2010, 08:12:26 pm
Got it - thank you @guessed!

The bit I was missing was going back and setting the recently created devies to be controlled via the IR transmitter, and then adding the control via the Advanced tab in my scenes. The use case you suggest is exactly what I want to do (well, that and a Power on and set input for an audio scene) so this should do nicely. I've looked at the process again and it makes sense to me now. I'll give it a test when I get home.

Thank you again for your help, and the work that you've put into this.
Title: Re: Vera + Puck would = :) mbairhead
Post by: guessed on November 16, 2010, 10:45:28 pm
You're welcome.  That was the easiest of Plugins to write, since it really just proxy's over to SQBlaster....  The real work was done in the Puck development.

The "more integrated" one is looking to use mDNS to find the Puck, the same way that SQRemote does.  That alone will be a ton of value (I played for a while to make an mDNS-compatible Lua Library, and it was tough going)
Title: Re: Vera + Puck would = :) mbairhead
Post by: woodsby on November 18, 2010, 03:23:38 pm
Thanks so much @guessed... I needed this for remote control outside of my wifi network.

And, using snippets of your code, I created a Logitech PS3 adapter device that has discrete power codes that first ping the PS3 to check power status before turning it on/off.  Since the Playstation button is part of both the on and off sequences, if the PS3 is off and you hit "power off" using the sqblaster directly from sqremote, it turns the PS3 back on... finally, I have solved this problem.
Title: Re: Vera + Puck would = :) mbairhead
Post by: guessed on November 18, 2010, 04:11:39 pm
@woodsby, now that's a creative usage of the IR "plugins".  Hadn't considered that one.  I have my Logitech Revue now, so it'll be interesting to see how it can be controlled in these setups as well.
Title: Re: Vera + Puck would = :) mbairhead
Post by: woodsby on November 18, 2010, 05:24:15 pm
I am going to do the same for my TV to avoid the 14 second delay before setting the input if the TV is already on.  I was going to bug Mat again for the API, but your plugin gave me all I need.

I wonder if there is a way to make use of the repeat and delay functionality in your plugin.  I'd rather the community work on this than MCV, quite honestly - to avoid distracting them from their priorities.
Title: Re: Vera + Puck would = :) mbairhead
Post by: guessed on November 18, 2010, 08:49:04 pm
I wonder if there is a way to make use of the repeat and delay functionality in your plugin.
I'm not 100% on what you're looking for here.  In the current MiOS API's, there's very little scope to handle real IR - the stuff where you get to pressDown, hold, and Release - with corresponding auto-repeat based upon the cycle used.

Are you looking to extend this somehow?

The SQBlaster supports that notion, but I have to dumb it down for the MiOS IR routines.  Hopefully this is something they fix more systematically with their more integrated model.
Title: Re: Vera + Puck would = :) mbairhead
Post by: woodsby on November 19, 2010, 06:31:34 am
I noticed in your code, you have repeat=0 in the sqblaster http call. So if I want to run a scene to control a device that needs to have a button press repeat twice (using sqblaster's repeat functionality to simulate a button hold), do you think there is a way to do this with the sqblaster plugin?  Also, for delays I had to use os.execute(sleep 2) between IR codes. This of course, doesn't allow fractions of seconds. I am wondering if this is something that can also be handled by the sqblaster plugin. What I envision is being able to create macros in the scene advanced tab, rather than hardcoded into the av device plugin. But, I haven't seen the API for the blaster yet, so I don't know.
Title: Re: Vera + Puck would = :) mbairhead
Post by: fall-line on November 19, 2010, 12:59:11 pm
I too had to do quite a bit of fiddling with delays and repeats to get a couple of simple IR commands working, but am happy to report that it is working.

I'm happy to be able to shut off my AV gear as a part of my All Off/Good Night scenes from Vera now, as well as being able to turn on and set the correct input on my AV Receiver as a part of my scenes that utilize my poor man's (iTunes based) whole house audio config. As @guessed as mentioned, more advanced control than these uses will likely be much easier once the official SQ Blaster plugin is available.

Thanks again for the help!
Title: Re: Vera + Puck would = :) mbairhead
Post by: guessed on November 19, 2010, 02:05:52 pm
Can you lads publish examples of the specific tweaks you're doing?  I want to see them, concretely.

I don't want to exec(sleep) as that would be bad (blocking call), but can achieve it in more elegant manners as required.

It's likely to do what you're looking for that a few API calls will need to be added, then you'd have to do "odd" things in the scene to call these API's to set-or-reset delays prior to making the associated IR callout.


... mostly because these aren't "parameters" within the existing MiOS IR Framework.  Having examples might help us to help-them, to "evolve" these API's tho...
Title: Re: Vera + Puck would = :) mbairhead
Post by: woodsby on November 19, 2010, 04:23:46 pm
My imp file functions and actionlist:

   <functions>
      function PS3Startup(lul_device)
         socket = require("socket")
         http = require("socket.http")
         local IRDevNum = luup.variable_get("urn:micasaverde-com:serviceId:HaDevice1","IODevice",lul_device)
         if (IRDevNum == nil) then
            luup.log("No IR Blaster selected for PS3 control")
            luup.variable_set("urn:micasaverde-com:serviceId:HaDevice1","IODevice","1",lul_device)
         end
         IRDevIP = luup.devices[tonumber(IRDevNum)].ip
         PS3IP = luup.devices[lul_device].ip
            if (IRDevIP == nil or IRDevIP == "") then
                luup.log("IP Address is required in IR Device Advanced settings")
            else
            if (PS3IP == nil or PS3IP == "") then
               luup.log("IP Address is required in PS3 Device Advanced settings")
            else
               luup.log("PS3 IP Address is " .. PS3IP .. "; IR IP Address is " .. IRDevIP .. ".")
            end
         end
      end
      function SendCode(IRCode,IRRepeat)
         local startTime = socket.gettime()
         response, status = http.request("http://" .. IRDevIP .. "/docmnd.xml","&lt;docommand repeat= \"" .. IRRepeat .. "\" ir_data=\"" .. IRCode .. "\"/&gt;")
         local endTime = socket.gettime()
         if (response == nil) then
            luup.log("Web request returned no response ProntoCode=" .. IRCode .. " in " .. math.floor((endTime - startTime) * 1000) .. "ms", 1)
         end
      end
      function CheckPowerStatus()
         local PingStatus
         PingStatus = os.execute("ping -c 1 -W 1 " .. PS3IP)
         if (PingStatus == 0) then
            luup.log("PS3 is on")
            return 1
         else
            luup.log("PS3 is off")
            return 0
         end
      end
   </functions>
   <startup>PS3Startup</startup>
   <actionList>
      <action>
         <serviceId>urn:micasaverde-com:serviceId:DiscretePower1</serviceId>
         <name>Off</name>
         <run>
            local PS3Status
            PS3Status = CheckPowerStatus()
            if (PS3Status == 1) then
               SendCode("P8bc4 e625 72b1 b3b1 7a69 46f1 da28 651f 2d47 d68f e61c 2274 001f d848 efce e679 b426 e8ff 85a7 cfba 233c cf99 1090 a06a 1fff 2a6c f7da 5c7e d1ba 155e 93d9 3bde f468 2237 73a9 4c55 6771 bf7b d9da 0193 aec3 cc87 e70c 9f58 b1cf a943 30e8 5213 d68e af8c 548c c6e0 4f81 b918 aa97 a392  ","3")
               os.execute("sleep 1")
               SendCode("P8bc4 e625 72b1 b3b1 7a69 46f1 da28 651f 2d47 d68f e61c 2274 001f d848 efce e679 b426 e8ff 85a7 cfba 233c cf99 1090 a06a 1fff 2a6c f7da 5c7e d1ba 155e 93d9 3bde f468 2237 73a9 4c55 6771 bf7b d9da 0193 aec3 cc87 e70c 9f58 b1cf a943 30e8 5213 d68e af8c 548c c6e0 4f81 b918 aa97 a392  ","10")
               os.execute("sleep 2")
               SendCode("Pd47d 909f c488 f243 2c6f 982e 882f 468b 5525 617e b0ca 87b0 4672 f738 3fd6 7621 0e9a dacf 8561 5329 37d5 7f26 e456 386f ddc2 3435 2c62 0ea6 9d25 d28d fb81 7e73 c52a 4b93 03f0 8ea6 91b5 d48d a146 d96a 4123 c470 fa84 1213 af63 27ed c747 8676 31bf 56f2 d616 f626 a09e c4f7 348b 32bc  ","0")
               os.execute("sleep 2")
               SendCode("Pd47d 909f c488 f243 2c6f 982e 882f 468b 5525 617e b0ca 87b0 4672 f738 3fd6 7621 0e9a dacf 8561 5329 37d5 7f26 e456 386f ddc2 3435 2c62 0ea6 9d25 d28d fb81 7e73 c52a 4b93 03f0 8ea6 91b5 d48d a146 d96a 4123 c470 fa84 1213 af63 27ed c747 8676 31bf 56f2 d616 f626 a09e c4f7 348b 32bc  ","0")
            end
         </run>
      </action>
      <action>
         <serviceId>urn:micasaverde-com:serviceId:DiscretePower1</serviceId>
         <name>On</name>
         <run>
            local PS3Status
            PS3Status = CheckPowerStatus()
            if (PS3Status == 0) then
               SendCode("P8bc4 e625 72b1 b3b1 7a69 46f1 da28 651f 2d47 d68f e61c 2274 001f d848 efce e679 b426 e8ff 85a7 cfba 233c cf99 1090 a06a 1fff 2a6c f7da 5c7e d1ba 155e 93d9 3bde f468 2237 73a9 4c55 6771 bf7b d9da 0193 aec3 cc87 e70c 9f58 b1cf a943 30e8 5213 d68e af8c 548c c6e0 4f81 b918 aa97 a392  ","0")
            end
         </run>
      </action>
Title: Re: Vera + Puck would = :) mbairhead
Post by: woodsby on November 19, 2010, 04:56:22 pm
@guessed... one more note... I thought about call_delay instead of os.execute("sleep #"), but as far as I know, call_delay doesn't allow you to pass more than one argument to the function it is calling... and i need to pass both the pronto code and the repeat variables.
Title: Re: Vera + Puck would = :) mbairhead
Post by: fall-line on November 19, 2010, 08:06:21 pm
wow. Nice work woodsby. I bet there are several other PS3 owners out there who will be your new biggest fans.

My fiddling was much more pedestrian than that, but I can share if it'll help guessed. I simply had problems getting my Denon AV receiver and Sharp Aquos TV to receive the commands issued in the advanced tab of my scenes. I knew the IR codes were correct because I was able to test them (as mentioned before) when selecting devices, but once the devices were created I couldn't get them to work. It was simply a matter of delay and repeat experimentation, which I believe must be done manually.

As such here is an example of my Play iTunes on the Stereo's advanced tab. The Denon AV receiver is using the AVR2309CI template since it had the best available selection of commands, though mine is a different model number.

Denon AV: On
Delay 1s
Denon AV: On
Denon AV: On
Delay 8s
Denon AV: Input1
Delay 1s
Denon AV: Input1
Denon AV: Input1
Delay 1s

I tried several combinations of using only a single repeat, or only a single delay with mixed success. As strange as the above sequence seems, it is what works for me reliably.

I used the same approach with my TV, though it seemed to be less finicky.

Title: Re: Vera + Puck would = :) mbairhead
Post by: woodsby on November 20, 2010, 05:17:10 am
Very crude, and should be cleaned up, but it was a quick first attempt and it works fine. I actually don't have a scene calling this yet. I just have my on and off buttons and macros in sqremote calling this.
Title: Re: Vera + Puck would = :) mbairhead
Post by: SquareConnectMat on November 30, 2010, 09:00:06 pm
Gents...

1) The draft API is almost complete... please feel free to bug John!

2) This is really interesting stuff...

3) You can take the hex codes straight out of the device definitions we store up in box.net and I would imagine easily add them to the Vera IR xml files... Alternatively, I am open to anyone who wants to build a web service around our database to connect and see what we can do.

4) I am open to ways to make the discovery 'Lua friendly' if anyone has suggestions

A community based solution would certainly get a good plug in quicker, it seems...


Title: Re: Vera + Puck would = :) mbairhead
Post by: woodsby on December 01, 2010, 06:06:20 am
Mat, downloading the XML from box is exactly how I got my ps3 codes for the above code. I appreciate how easy that is.
Title: Re: Vera + Puck would = :) mbairhead
Post by: SquareConnectMat on December 01, 2010, 09:32:32 pm
Cool. Now that I look at the codes, they would have to be from SQ.

Title: Re: Vera + Puck would = :) mbairhead
Post by: shady on December 09, 2010, 06:38:14 pm
Mat, downloading the XML from box is exactly how I got my ps3 codes for the above code. I appreciate how easy that is.

Great job on this bit of code @Woodsby, so you are pinging the PS3 and if it doesn't respond it must be off?  Could this work for XBOX360 easily?
Title: Re: Vera + Puck would = :) mbairhead
Post by: woodsby on December 10, 2010, 05:35:04 pm
That's the concept @Shady. It basically allows you to create discrete power commands when they don't exist; if you assign a static IP on the device, and if it responds to pings anytime it's on, but not when it's off. But, you can do the same to check power status for devices that have a long power on delay, like TV's; which is what I plan on doing next - when I get back to this.
Title: Re: Vera + Puck would = :) mbairhead
Post by: guessed on February 18, 2011, 10:49:20 pm
I've split out the bits of the discussion surrounding the SQBlaster Plugin to make it easier to find, and to avoid the "hijack" I did on your thread here, since it's diverged somewhat from your original stuff.
Title: Re: Vera + Puck would = :) mbairhead
Post by: dmorar on August 25, 2011, 11:32:51 pm
Hi all,

i want to share this with you. It is not complete, but it definitely speeds up the process of IR/remote creation using input from SQBlaster xml file (as stored in box.net).

Hope this works for you as good as it works for me. If you improve this in any way, please send it back so we can all benefit from it.


Cheerz!

http://www.insite.com.co/downloads/SAMSUNG_UN55C6500VF.zip


Title: Re: Vera + Puck would = :) mbairhead
Post by: guessed on August 25, 2011, 11:54:46 pm
@dmorar,
Great, love seeing new ways of getting the files converted over.

You might want to take a look at the I_SQBlasterController* files in code.mios.com under the SQBlaster driver.  It has all of the logic needed to read the *.map file, and help generate both the impl and decl files (using Lua, but would be easy enough to Port to Python)

I ran into problems with getting it working under MiOS (weird things) so folks cannot use that specific plugin, just it's older brother the SQBlaster.

Anyhow, the *.map file, contains most of the mapping rules for going from the device.xml XML over to it's counterpart I_xxxx.xml file.

http://code.mios.com/trac/mios_sqblaster/browser/trunk/I_SQBlasterController1.xml
http://code.mios.com/trac/mios_sqblaster/browser/trunk/D_SQBlasterController.map

Hi all,

i want to share this with you. It is not complete, but it definitely speeds up the process of IR/remote creation using input from SQBlaster xml file (as stored in box.net).

Hope this works for you as good as it works for me. If you improve this in any way, please send it back so we can all benefit from it.


Cheerz!

http://www.insite.com.co/downloads/SAMSUNG_UN55C6500VF.zip



Title: Re: Vera + Puck would = :) mbairhead
Post by: dmorar on August 29, 2011, 05:01:16 pm
Hi, i wonder if its easier/cleaner to generate a new S file for actions. Since, it will use the same names in SQBlaster and MCV. It is even easier and cleaner to code. :)
Title: Re: Vera + Puck would = :) mbairhead
Post by: guessed on August 29, 2011, 11:53:06 pm
@dmorar,
Maybe, but I built it with the expectation that other Control points would eventually be able to call MCV's AV functions.  If you want this to work, then you need to use the standard API's (S_xxxx.xml files) that are part of the AV suite of interfaces.

Of course, that might change, or maybe no-one else will implement the Remote Control hooks in the UI as SQRemote does...

That doesn't stop us from adding one in addition to whatever comes with MCV, but it wouldn't remove the need to "map" SQBlaster functions to the existing MCV set, it would just give you an extra Service/Interface to implement "side-by-side" with the existing ones.

Hi, i wonder if its easier/cleaner to generate a new S file for actions. Since, it will use the same names in SQBlaster and MCV. It is even easier and cleaner to code. :)
Title: Re: Vera + Puck would = :) mbairhead
Post by: teonebello on December 19, 2011, 10:41:41 pm
Hi guessed,

I search in all the forum and in the code.mios.com for a step by step instruction to generate the XML file starting from the box.net file.

Could you explain us?

Should we load your file to Vera, then load the box.net files and Vera automatically will generate the XML file to create the ir device?

Thank you very much!

Regards,
Matteo


@dmorar,
Great, love seeing new ways of getting the files converted over.

You might want to take a look at the I_SQBlasterController* files in code.mios.com under the SQBlaster driver.  It has all of the logic needed to read the *.map file, and help generate both the impl and decl files (using Lua, but would be easy enough to Port to Python)

I ran into problems with getting it working under MiOS (weird things) so folks cannot use that specific plugin, just it's older brother the SQBlaster.

Anyhow, the *.map file, contains most of the mapping rules for going from the device.xml XML over to it's counterpart I_xxxx.xml file.

http://code.mios.com/trac/mios_sqblaster/browser/trunk/I_SQBlasterController1.xml
http://code.mios.com/trac/mios_sqblaster/browser/trunk/D_SQBlasterController.map

Hi all,

i want to share this with you. It is not complete, but it definitely speeds up the process of IR/remote creation using input from SQBlaster xml file (as stored in box.net).

Hope this works for you as good as it works for me. If you improve this in any way, please send it back so we can all benefit from it.


Cheerz!

http://www.insite.com.co/downloads/SAMSUNG_UN55C6500VF.zip



Title: Re: Vera + Puck would = :) mbairhead
Post by: guessed on December 20, 2011, 12:38:14 am
@teonebello,
Looks like I made the link stale in the Wiki when I broke out this discussion on the transformation process:
    http://forum.micasaverde.com/index.php/topic,5734.0.html

There should be enough in there to get your conversions done.  I've updated the wiki to point to that page for the XSLT references...


Separately, I had built a variant plugin that actually did the transformation, after uploading the SQRemote .xml files to Vera along with the instantiation of all the required SQBlaster Devices, and "wiring" them all together.  But I ran into too many problems that, in all honesty, I didn't figured would get addressed so I took it no further.

The basics were working, in a "pure Lua" implementation, it would have greatly simplified the usage.... pity.


NOTE: I haven't tested this Plugin on UI5/Vera3 yet.