Author Topic: Controlling Fibaro Home Center scenes from Vera  (Read 6236 times)

Offline Ramiii

  • Jr. Member
  • **
  • Posts: 85
  • Karma: +0/-0
Controlling Fibaro Home Center scenes from Vera
« on: March 27, 2014, 12:22:20 pm »
Hello

i just received my HCL a couple of days ago , even though it's interface is better and it's faster but it's limited since it's without LUA and doesn't support all the devices . I got it to control my veralite scenes using this command

GET /data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=42 HTTP/1.10x0D0x0A0x0D0x0A

But i wanted to do other stuff like

- Controlling devices in vera not just scenes ( ON / OFF command should be enough ) i'll use it for my XBMC

- Do the same with HCL , i would like to control it's devices or scenes via HTTP from vera , is that possible ?


Thanks
Rami


Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3891
  • Karma: +482/-12
Re: Controlling Fibaro Home Center scenes from Vera
« Reply #1 on: March 27, 2014, 12:30:25 pm »
Quote
Controlling devices in vera not just scenes ( ON / OFF command should be enough ) i'll use it for my XBMC

See: Luup Requests: action.

Quote
Do the same with HCL , i would like to control it's devices or scenes via HTTP from vera , is that possible ?

You may need to ask that question on the Fibaro forum.

Offline Ramiii

  • Jr. Member
  • **
  • Posts: 85
  • Karma: +0/-0
Re: Controlling Fibaro Home Center scenes from Vera
« Reply #2 on: March 27, 2014, 12:46:21 pm »
@RexBeckett

It worked perfectly , thank you so much

Offline Ramiii

  • Jr. Member
  • **
  • Posts: 85
  • Karma: +0/-0
Re: Controlling Fibaro Home Center scenes from Vera
« Reply #3 on: March 27, 2014, 01:15:51 pm »
@RexBeckett

I found the command on the forum , do you know how i can send an http command from vera ?

it'll be like this

http://admin:admin@hc2_ip/api/callAction?deviceID=60&name=setValue&arg1=100

Thanks
Rami

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3891
  • Karma: +482/-12
Re: Controlling Fibaro Home Center scenes from Vera
« Reply #4 on: March 27, 2014, 01:49:22 pm »
Code: [Select]
local status, response = luup.inet.wget("http://admin:admin@hc2_ip/api/callAction?deviceID=60&name=setValue&arg1=100")
If successful, this will return numeric 0 in status otherwise it will be an error code.

Offline Ramiii

  • Jr. Member
  • **
  • Posts: 85
  • Karma: +0/-0
Re: Controlling Fibaro Home Center scenes from Vera
« Reply #5 on: March 27, 2014, 03:27:59 pm »
@RexBeckett

Sorry for asking too much , but where so i test this ? in scenes ?

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3891
  • Karma: +482/-12
Re: Controlling Fibaro Home Center scenes from Vera
« Reply #6 on: March 27, 2014, 04:07:13 pm »
@RexBeckett

Sorry for asking too much , but where so i test this ? in scenes ?

Well I would recommend using LuaTest but I am rather biased. ;D This would allow you to have print statements to show what happened:

Code: [Select]
local status, response = luup.inet.wget("http://admin:admin@hc2_ip/api/callAction?deviceID=60&name=setValue&arg1=100")
print("status: " .. status)
print("response: " .. response)

You could also just run the wget call in APPS -> Develop Apps -> Test Luup code (Lua) (Click GO to execute it).

Offline Brientim

  • Beta Testers
  • Sr. Hero Member
  • *****
  • Posts: 2497
  • Karma: +77/-7
Re: Controlling Fibaro Home Center scenes from Vera
« Reply #7 on: March 27, 2014, 04:29:45 pm »
Rex,

I gather from the previous question, it may not be completely clear how LuaTest is utilised.

Phase 1 load files.
Phase 2 launch script or add to start up.
Phase 3 test via LuaTest html page.

Being <veraip>:3480/data_request?id=lr_LuaTest.

If you want to generate a specific file name as per your instructions

<veraip>:3480/data_request?id=lr_LuaTest&file=<filename.lua>

If <filename.lua> starts with a / it is assumed to be a full pathname otherwise it will be located in /etc/cmh-ludl/. If you do not provide a filename, the default luatest.lua will be used.

I believe once they have the concept, they will no doubt thank you for the tool you have provided. Of course the ability to quickly get SID without jumping in and out or additional restarts that most users do modifying scene will become memories...

Offline Ramiii

  • Jr. Member
  • **
  • Posts: 85
  • Karma: +0/-0
Re: Controlling Fibaro Home Center scenes from Vera
« Reply #8 on: March 27, 2014, 04:31:52 pm »
Thanks again @RexBeckett

Tried it but it doesn't seem to work , my next question would be how do i make use of it ,

I have no experience in programming and just got my veralite couple of month ago , i don't even know what LUA is , i just got familiar with it from the forums here

HTTP command works fine in the browser though

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3891
  • Karma: +482/-12
Re: Controlling Fibaro Home Center scenes from Vera
« Reply #9 on: March 27, 2014, 05:59:49 pm »
Thanks again @RexBeckett

Tried it but it doesn't seem to work , my next question would be how do i make use of it ,

I have no experience in programming and just got my veralite couple of month ago , i don't even know what LUA is , i just got familiar with it from the forums here

HTTP command works fine in the browser though
If you don't want to learn how to write Lua, just use Vera's built-in test facility. Select the APPS tab, select the Develop Apps sub-tab, select the Test Luup code (Lua) menu item. Now copy paste the code below into the Code box and click GO.

If it works correctly, you can paste the code into the LUUP tab of a scene and set the trigger(s) as required.

Code: [Select]
luup.inet.wget("http://admin:admin@hc2_ip/api/callAction?deviceID=60&name=setValue&arg1=100")

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3891
  • Karma: +482/-12
Re: Controlling Fibaro Home Center scenes from Vera
« Reply #10 on: March 27, 2014, 06:47:35 pm »
Rex,

I gather from the previous question, it may not be completely clear how LuaTest is utilised.

You are almost certainly right, my friend, but I'm not sure how to explain it in a better way...

Offline Ramiii

  • Jr. Member
  • **
  • Posts: 85
  • Karma: +0/-0
Re: Controlling Fibaro Home Center scenes from Vera
« Reply #11 on: March 27, 2014, 07:10:27 pm »
@RexBeckett

It's working now , looks like the problem was the HCL authentication . I don't know what went wrong though , changed the password and it's not good .

As far as i understand these are the only actions i can perform , right ? http://wiki.micasaverde.com/index.php/Luup_Requests#action

So i can't lock and unlock doors or is it the same as ON / OFF COMMAND ?

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3891
  • Karma: +482/-12
Re: Controlling Fibaro Home Center scenes from Vera
« Reply #12 on: March 27, 2014, 07:21:48 pm »
Quote
As far as i understand these are the only actions i can perform , right ?

As long as you specify the appropriate serviceID, action name and argument, you should be able to perform any action.

If you managed to install LuaTest, the Device Action List button will give you a list of all available actions for your devices.

Offline Brientim

  • Beta Testers
  • Sr. Hero Member
  • *****
  • Posts: 2497
  • Karma: +77/-7
Re: Controlling Fibaro Home Center scenes from Vera
« Reply #13 on: March 28, 2014, 03:16:35 am »
Rex, a couple of beers for the work you do...

 

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3891
  • Karma: +482/-12
Re: Controlling Fibaro Home Center scenes from Vera
« Reply #14 on: March 28, 2014, 04:19:25 am »
Rex, a couple of beers for the work you do...

Thanks for the beers. I haven't had a Newkie Brown in years. :D I like your approach to documenting LuaTest. That would no doubt help a lot.
« Last Edit: March 28, 2014, 06:16:30 am by RexBeckett »