We have moved at community.getvera.com

Author Topic: Vera + Puck would = :) mbairhead  (Read 20482 times)

Offline woodsby

  • Beta Testers
  • Sr. Member
  • *****
  • Posts: 466
  • Karma: +1/-0
Re: Vera + Puck would = :) mbairhead
« Reply #15 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>
Vera1 (1.1142), Vera2 (1.1182), VRI06 (12), VRS15 (3), VRS05 (2), VRF01 (2), VRCS4 (2), ZRW113, ZRF113 (2), 45602, 45603, TZMT400 (2), FE599 (2), 99100, Thinkstick, Harmony 890Pro (2), Harmony RF Extender, Nevo S70, Nevo NC-50, Minimote, SQ Remote, SQ Blaster, EtherRain-8, Cliste ActiveRFID, TED5002

Offline woodsby

  • Beta Testers
  • Sr. Member
  • *****
  • Posts: 466
  • Karma: +1/-0
Re: Vera + Puck would = :) mbairhead
« Reply #16 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.
Vera1 (1.1142), Vera2 (1.1182), VRI06 (12), VRS15 (3), VRS05 (2), VRF01 (2), VRCS4 (2), ZRW113, ZRF113 (2), 45602, 45603, TZMT400 (2), FE599 (2), 99100, Thinkstick, Harmony 890Pro (2), Harmony RF Extender, Nevo S70, Nevo NC-50, Minimote, SQ Remote, SQ Blaster, EtherRain-8, Cliste ActiveRFID, TED5002

Offline fall-line

  • Full Member
  • ***
  • Posts: 247
  • Karma: +1/-0
Re: Vera + Puck would = :) mbairhead
« Reply #17 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.


Offline woodsby

  • Beta Testers
  • Sr. Member
  • *****
  • Posts: 466
  • Karma: +1/-0
Re: Vera + Puck would = :) mbairhead
« Reply #18 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.
Vera1 (1.1142), Vera2 (1.1182), VRI06 (12), VRS15 (3), VRS05 (2), VRF01 (2), VRCS4 (2), ZRW113, ZRF113 (2), 45602, 45603, TZMT400 (2), FE599 (2), 99100, Thinkstick, Harmony 890Pro (2), Harmony RF Extender, Nevo S70, Nevo NC-50, Minimote, SQ Remote, SQ Blaster, EtherRain-8, Cliste ActiveRFID, TED5002

Offline SquareConnectMat

  • Moderator
  • Full Member
  • *****
  • Posts: 248
  • Karma: +0/-0
Re: Vera + Puck would = :) mbairhead
« Reply #19 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...



Offline woodsby

  • Beta Testers
  • Sr. Member
  • *****
  • Posts: 466
  • Karma: +1/-0
Re: Vera + Puck would = :) mbairhead
« Reply #20 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.
Vera1 (1.1142), Vera2 (1.1182), VRI06 (12), VRS15 (3), VRS05 (2), VRF01 (2), VRCS4 (2), ZRW113, ZRF113 (2), 45602, 45603, TZMT400 (2), FE599 (2), 99100, Thinkstick, Harmony 890Pro (2), Harmony RF Extender, Nevo S70, Nevo NC-50, Minimote, SQ Remote, SQ Blaster, EtherRain-8, Cliste ActiveRFID, TED5002

Offline SquareConnectMat

  • Moderator
  • Full Member
  • *****
  • Posts: 248
  • Karma: +0/-0
Re: Vera + Puck would = :) mbairhead
« Reply #21 on: December 01, 2010, 09:32:32 pm »
Cool. Now that I look at the codes, they would have to be from SQ.


Offline shady

  • Hero Member
  • *****
  • Posts: 1331
  • Karma: +11/-0
  • This monkey knows his Window Coverings!
Re: Vera + Puck would = :) mbairhead
« Reply #22 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?
Vera3 1.5.346, Schlage (3)DB (2)Lever, Kwikset (1)Lever, RCS TZ43 Thermo, (2) Vizia RZI06-1LX 600W Dimmers, (17) Monster (Leviton) Dimmers (6) Monster (Leviton) IWC Scene Controllers (1) Etherrain-8, (3) HSM 100's (1)GE 3-Way set

Offline woodsby

  • Beta Testers
  • Sr. Member
  • *****
  • Posts: 466
  • Karma: +1/-0
Re: Vera + Puck would = :) mbairhead
« Reply #23 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.
Vera1 (1.1142), Vera2 (1.1182), VRI06 (12), VRS15 (3), VRS05 (2), VRF01 (2), VRCS4 (2), ZRW113, ZRF113 (2), 45602, 45603, TZMT400 (2), FE599 (2), 99100, Thinkstick, Harmony 890Pro (2), Harmony RF Extender, Nevo S70, Nevo NC-50, Minimote, SQ Remote, SQ Blaster, EtherRain-8, Cliste ActiveRFID, TED5002

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Vera + Puck would = :) mbairhead
« Reply #24 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.

Offline dmorar

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: Vera + Puck would = :) mbairhead
« Reply #25 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



Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Vera + Puck would = :) mbairhead
« Reply #26 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




Offline dmorar

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: Vera + Puck would = :) mbairhead
« Reply #27 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. :)

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Vera + Puck would = :) mbairhead
« Reply #28 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. :)

Offline teonebello

  • Sr. Member
  • ****
  • Posts: 405
  • Karma: +0/-0
  • Macs, Home Automation, Bikers
Re: Vera + Puck would = :) mbairhead
« Reply #29 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