VoxCommando

New Features and Feature Requests => Feature Requests => Topic started by: jamesst on July 22, 2014, 11:36:57 AM

Title: Fibaro Home Center 2
Post by: jamesst on July 22, 2014, 11:36:57 AM
Hi,

I have been using voxcommando succesfully for years now, both with eventghost and Mediaportal and eventghost Rfxcom plugin. Now I am planig to move on z-wave devices as hoping that will be more reliable and will know devices status.
I am very tempted to go with Fibaro Home Center, but I certnaly don't wont louse my voxcommando funcionality.
So,is there any possibility that vox will be having plugin fot hc2?

Thanks for your toughts.
Title: Re: Fibaro Home Center 2
Post by: nime5ter on July 22, 2014, 11:52:20 AM
Hello jamesst,

You might be interested to read the comments about Fibaro that took place on youtube recently:


In theory, it should be possible to use the existing scrape actions in VC with the Fibaro controller. http://voxcommando.com/mediawiki/index.php?title=Home_Automation

If you have any follow-up questions, let us know.
Title: Re: Fibaro Home Center 2
Post by: nime5ter on July 22, 2014, 01:43:11 PM
Here are some example commands that should work in theory, if the documentation provided here is correct: http://forum.fibaro.com/viewtopic.php?t=1252

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.0.0.0-->
<commandGroup open="True" name="Fibaro untested commands based on documentation only" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="261" name="dim {1} to {2}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="{1} - payload 1 provides the device ID for a dimmable device.&#xD;&#xA;{2} - payload 2 provides the value that you want to dim the light to (e.g. 50).">
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>http://Your HC2 ip address/api/callAction?deviceID={1}&amp;name=setValue&amp;arg1={2}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>dim</phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">fibaro_dimmables.xml</payloadFromXML>
    <phrase>to</phrase>
    <payloadRange>10,100</payloadRange>
    <phrase optional="true">percent</phrase>
  </command>
  <command id="267" name="activate scene" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="{1} is the scene ID. You can create a payload xml file that associates this ID with a &quot;friendly name&quot; for your scene, such as &quot;going to work&quot; or &quot;TV time&quot;.">
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>http://&lt;HC2 ip address&gt;/api/sceneControl?id={1}&amp;action=start </param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>activate scene</phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">fibaro_scenes.xml</payloadFromXML>
  </command>
</commandGroup>

You should also be able to use their "get json status" examples to retrieve information. Again, you can use the scrape action. The data from Fibaro will then be stored in {LastResult}. You may need to use some regular expressions to isolate the data that you want.
Title: Re: Fibaro Home Center 2
Post by: jitterjames on July 22, 2014, 01:51:38 PM
If you want to use Z-Wave with VoxCommando I would consider going with a Vera controller.

A Fibaro plugin for VoxCommando is highly unlikely.
Title: Re: Fibaro Home Center 2
Post by: Kalle on July 22, 2014, 02:45:52 PM
and by the way, it is also possible your rfxcom stuff with the vera controller  ;)

http://de.slideshare.net/mobile/domoticadavinci/quick-start-vera-tith-rfxcom (http://de.slideshare.net/mobile/domoticadavinci/quick-start-vera-tith-rfxcom)
Title: Re: Fibaro Home Center 2
Post by: jamesst on July 22, 2014, 02:50:58 PM
Thank you nime5ter for your fast replay, at the moment that looks too complicated to me. Can you get device status or sensor temperatures in voxcommando with this?
 Plugin was something I hopped for. The reason why I was looking at Fibaro because I wonted a controller that would be usable to everyone in my family (nice and friendly ipad UI). At the moment i do have fun with my setup at home but others (wife) don't get much use out of it.
Is there a reason why the plugin is highly unlikely?

Thanks Kalle, I know there is a that possibility, I guess i shoud go for vera after all.
Title: Re: Fibaro Home Center 2
Post by: Kalle on July 22, 2014, 03:07:26 PM
I use a VeraLite controller for which is also a iOS and Android app available or you can use the web UI. The advantage for a Vera is the cost for the controller (VeraLite / 150 EUR or Vera 3 / 230 EUR) and the great VC- plugin  ;)
Title: Re: Fibaro Home Center 2
Post by: jitterjames on July 22, 2014, 03:09:33 PM
Is there a reason why the plugin is highly unlikely?

Because:
* Making a plugin like this is a lot of work.
* There is only one of me and my time is limited
* Not enough people desire this plugin to make it worth while
* I don't have the hardware that I would need to create it, and I'm not interested in buying it.
Title: Re: Fibaro Home Center 2
Post by: nime5ter on July 22, 2014, 03:16:22 PM
Also, apart from the product being extremely expensive -- 3x the cost of a Vera, it is not even available in Canada as far as I know.

If you know programmer in your own country who can program in C# and has access to a Fibaro, perhaps they will be willing to develop a VC plugin for you.
Title: Re: Fibaro Home Center 2
Post by: jamesst on July 22, 2014, 03:24:53 PM
Yes, I figured it would be lot of work, thank you for your explanaton.
The funny thing is that vera lite is not in stock on any european webshop that i googled at the moment.
They don't even  have estimate when it will be on stock.

I' am convinced, will look for vera in the next days.

Thanks
Title: Re: Fibaro Home Center 2
Post by: nime5ter on July 22, 2014, 03:35:56 PM
Have you tried http://smarterhome.sk/ ?

They seem to have the VeraLite in stock. I don't know about the other ones.
Title: Re: Fibaro Home Center 2
Post by: jamesst on July 22, 2014, 03:41:48 PM
Thanks nime5ter, no haven't looked there.
Title: Re: Fibaro Home Center 2
Post by: Kalle on July 22, 2014, 03:59:04 PM
and maybe here: http://www.zwave4u.com/Z-Wave-Controller/Control-Centres/Z-Wave-Gateway-VERA-lite::12255.html (http://www.zwave4u.com/Z-Wave-Controller/Control-Centres/Z-Wave-Gateway-VERA-lite::12255.html)
Title: Re: Fibaro Home Center 2
Post by: jamesst on August 15, 2014, 10:05:33 AM
Hi again,

It may sound stupid but at the end I have purchased the both controllers. Fibaro is much faster but at the end I find them both a bit disappointing.
Anyway I have been for now using HC2 Api as Nime5ter has kindly posted. I have managed with this great new Regex Tool to isolate the temperatures and other usefull data + devices states. RFxCom part I left with eventghost.
It is working just fine and off course with voxcommando it is a completely different experience ! Only thing I miss is getting HC2 events to Eventghost. From eventgost using webserver is possible to control HC2 trough API.

Any way just wanted to say thanks to Nime5ter for showing me this possibility.

Title: Re: Fibaro Home Center 2
Post by: nime5ter on August 15, 2014, 10:31:58 AM
Thanks for posting this update. That's great to hear.

I think it should be possible to control your HC2 directly from VC, without using Eventghost, if you're interested.

The same "scrape" method is used. Based on the documentation I posted above from the Fibaro forum, here is a command for dimming your dimmable lights to a certain level.

[EDIT: I see now that I posted this example above as well, so nevermind. :) Sorry for the confusion]

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.0.0.6-->
<command id="290" name="Dim {1} to {2} percent" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="{1} is the device ID for your dimmable devices. If you can find out those IDs, you can put them in a payload xml file like the example I have attached.&#xD;&#xA;{2} is the dim level, from 1-100">
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>http://your HC2 ip address/api/callAction?deviceID={1}&amp;name=setValue&amp;arg1={2}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Dim</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\fibaro_dimmables.xml</payloadFromXML>
  <phrase>to</phrase>
  <payloadRange>1,100</payloadRange>
  <phrase optional="true">percent</phrase>
</command>

You will need to create your own payload xml file using your actual device IDs and device names of your choice. I have attached an example of what it would look like, but obviously this file won't work for you.

It sounds as though you have already figured out how to get device information from your Fibaro, so hopefully you can do this.
Title: Re: Fibaro Home Center 2
Post by: jamesst on August 15, 2014, 11:06:33 AM
Yes, that exactly how I use it, trough scrape action directly from VC. I have created fibaro.xml so that's fine.
Your command tree from the post up before works just fine.

 The eventghost part i need because of mediaportal events that I get to  trigger the scene in HC2 trough http commands.
But to close the circle I need to figure out how to get events form HC2 in the eventghost, but I will probably need to look elsewhere for that.

So in short VC works fine with fibaro HC2 this way.

Thanks
Title: Re: Fibaro Home Center 2
Post by: jitterjames on August 15, 2014, 01:53:06 PM
But to close the circle I need to figure out how to get events form HC2 in the eventghost, but I will probably need to look elsewhere for that.

Since we don't own Fibaro or have access to HC2 it is difficult to suggest how you can do this.

If events in HC2 can be configured to perform some kind of custom macros within HC2 then maybe you can send the events to either EventGhost or VoxCommando using TCP, HTTP, or UDP.  But I don't know what kind of HC2 events you are talking about, nor what is possible within that system.
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 04, 2015, 11:17:00 AM
Thanks for posting this update. That's great to hear.

I think it should be possible to control your HC2 directly from VC, without using Eventghost, if you're interested.

The same "scrape" method is used. Based on the documentation I posted above from the Fibaro forum, here is a command for dimming your dimmable lights to a certain level.

[EDIT: I see now that I posted this example above as well, so nevermind. :) Sorry for the confusion]

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.0.0.6-->
<command id="290" name="Dim {1} to {2} percent" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="{1} is the device ID for your dimmable devices. If you can find out those IDs, you can put them in a payload xml file like the example I have attached.&#xD;&#xA;{2} is the dim level, from 1-100">
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>http://&lt;HC2 ip address&gt;/api/callAction?deviceID={1}&amp;name=setValue&amp;arg1={2}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Dim</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\fibaro_dimmables.xml</payloadFromXML>
  <phrase>to</phrase>
  <payloadRange>1,100</payloadRange>
  <phrase optional="true">percent</phrase>
</command>

You will need to create your own payload xml file using your actual device IDs and device names of your choice. I have attached an example of what it would look like, but obviously this file won't work for you.

It sounds as though you have already figured out how to get device information from your Fibaro, so hopefully you can do this.

I'm trying to figure out how to get nime5ter's scrap tool to work so I can send commands to my Fibaro HC2 controller.  I purchased Voxcommando sometime ago, however I haven't played with it much so I'm a novice.

Can someone point me in the right direction where I can find instructions? 

So far I copied the provided code into an xml file and imported it to the voicecommands xml menu with a xml showing one of my lights using its z-wave ID25.

When I speak a command, Voxcommando recognises it ok but the light doesn't switch on.  I need to trouble shoot this but I don't know where to start.

If it helps, to switch light 25 on to say 50% here is the http command I would send from a brower -

http://admin:admin@192.168.0.155/api/callAction?deviceID=25&name=setValue&arg1=50

Any help would be appreciated.

Steve
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 04, 2015, 11:44:23 AM
Hi Steve,

In terms of instructions, it sounds as though you would benefit from watching a couple of the key VC video tutorials to help you understand some of the fundamentals of how to use VC and xml you find on the forum etc., as it will save you a lot of time and headache in the long run.

First, an important tip is that you should not need to save xml you find in a code box on the forum to a file and then import it. You can actually just select that text, and copy and paste it directly into your command tree (http://voxcommando.com/mediawiki/index.php?title=XML_on_the_forum). 

Also, not all xml posted as message *attachments* are commands. Often these attachments are payload xml files that are used with a posted command. This should be evident from the context of the post.

Second, it will be important for your Fibaro needs to learn about how payloads work, and how to construct/edit commands in general.

For a quick start to learn about commands similar to what you want to do with the Fibaro, I recommend you watch the Vera video tutorial (http://www.youtube.com/watch?v=-M7htWfF3tQ). The concepts discussed there will be generally applicable to the Fibaro, except that you'll be using the Scrape action instead of the Vera actions.

It's also important for all new users to watch at least the first Editing & Building Commands (http://www.youtube.com/watch?v=lPyfxpXRr9Q) tutorial, though watching both of the "Editing Commands" tutorials will go a long way.
http://voxcommando.com/mediawiki/index.php?title=Video_Tutorials

You will ideally want to create a payload XML file that contains the IDs for your different dimmable lights associated with whatever phrase you want to use for each (25 --> living room light).

You will understand how this works much better by watching the Vera video.

However, you can start by directly copying and pasting the command URL you mention above into the Scrape commmand and hitting "save and execute". That should test whether the command effectively dims or brightens your light with ID 25 to 50% brightness.

As a starting point, I've attached an annotated image of the command I posted as well.
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 04, 2015, 01:08:06 PM
Hi Steve,

As a starting point, I've attached an annotated image of the command I posted as well.

Thank you for your reply and the links to the video's.  I'll make sure I study them to get up to speed.

I did try the quick test option you mentioned, by editing the url in the Scrape command and hit the "save and execute" button but unfortunately the light didn't switch on. (command I used is as below)

http://admin:admin@192.168.0.155/api/callAction?deviceID={25}&name=setValue&arg1={50}

When I paste the same command in a browser (without the curly brackets around the light number and level number it switches the light on ok.

I'm not sure if it's relevent but I am aware that the lua firmware/software has recently had a big rework on the Fibaro HC2 I wonder if that could be the reason its not working?.

Thanks again..... I'm off to watch these videos

Steve
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 04, 2015, 01:12:49 PM
Yes. :)

Exactly. You should not use curly brackets if you are "hard coding" the device ID and dim level.

{} is VC syntax. It is used for variables, including payload values.

For this reason, you should watch the videos I mention. You need to learn what payloads are.
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 04, 2015, 01:16:08 PM
Yes. :)

Exactly. You should not use curly brackets if you are "hard coding" the device ID and dim level.

{} is VC syntax. It is used for variables, including payload values.

For this reason, you should watch the videos I mention. You need to learn what payloads are.

Yes I guess that was the case, hence I tried it both ways in the scrape command box without success.  This makes me wonder if it will work at all?
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 04, 2015, 01:36:55 PM
The "admin:admin@" looks new, compared to what the documentation used to say.

If you can post a link to (current) Fibaro documentation you are using, I can take a look.

Also, turn on logging in VC (if it's not already on), save and execute the VC command using

Code: [Select]
http://admin:admin@192.168.0.155/api/callAction?deviceID=25&name=setValue&arg1=50
And then attach your VC log here, and I'll see if that can help us to diagnose the problem. There are a couple possibilities.

I don't think it's impossible, but I can't say for sure.
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 04, 2015, 01:49:36 PM
In the meantime, you could also try the following variation to see if it makes a difference (just a guess):

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.8-->
<command id="425" name="Dim device 25 to 50 percent" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape.Get</cmdType>
    <params>
      <param>http://admin:admin@192.168.0.155/api/callAction?deviceID=25&amp;name=setValue&amp;arg1=50</param>
      <param>application/x-www-form-urlencoded</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Dim device 25 to 50 percent</phrase>
</command>

You can copy and paste the above xml directly into a command group in your command tree.
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 04, 2015, 02:19:48 PM
In the meantime, you could also try the following variation to see if it makes a difference (just a guess):

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.8-->
<command id="425" name="Dim device 25 to 50 percent" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape.Get</cmdType>
    <params>
      <param>http://admin:admin@192.168.0.155/api/callAction?deviceID=25&amp;name=setValue&amp;arg1=50</param>
      <param>application/x-www-form-urlencoded</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Dim device 25 to 50 percent</phrase>
</command>

You can copy and paste the above xml directly into a command group in your command tree.

I tried your new code as instructed but still the light does not turn on from within VC.  I have attached the log file

The
Code: [Select]
admin:admin relates to-

User name: admin
Password: admin

Doc's are here:-
http://www.fibarouk.co.uk/support/lua/

Thanks

Steve

Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 04, 2015, 02:43:56 PM
Thanks. It looks like you only tested the new shot-in-the-dark command I posted, is that correct?

Can you please also test the original command that we know has previously worked for other users and send me the log again?
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 04, 2015, 02:47:41 PM
Thanks. It looks like you only tested the new shot-in-the-dark command I posted, is that correct?

Can you please also test the original command that we know has previously worked for other users and send me the log again?

Yes you are correct. sorry, I will do it now...
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 04, 2015, 02:54:35 PM
Log attached, whilst using your original code by hitting the save and execute button.

Steve
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 04, 2015, 02:58:59 PM
It seems they've added some authentication requirements so we're getting an "unauthorized" error.

I've done a bit of online searching on their authentication requirements. There may be some trial and error here, so bear with me.

For your next test, try the following:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.8-->
<command id="425" name="New test: Dim device 25 to 50 percent" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape.Get</cmdType>
    <params>
      <param>http://192.168.0.155/api/callAction?deviceID=25&amp;name=setValue&amp;arg1=50</param>
      <param />
      <param />
      <param />
      <param />
      <param>Authorization: Basic YWRtaW46YWRtaW4=</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Dim device 25 to 50 percent</phrase>
</command>
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 04, 2015, 03:11:52 PM
Thanks for your help its much appreciated...

I tried the latest code still no go yet.  Log also attached.
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 04, 2015, 03:15:21 PM
Sorry. I just noticed that you're using VC 2.1.2.7.

For me to be able to effectively help you, you'll need to download a more recent version of VC.

The Scrape.Get action that we've been using was only added in version 2.1.3.6.

http://voxcommando.com/mediawiki/index.php?title=ChangeLog#Version_2.1.3.6

(To handle authentication we need to be able to add a header, which can't be done with the older Scrape action.)

Do you know how to update your version? (Just download the installer from the VC downloads page, into your existing VC directory, and run it.)
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 04, 2015, 03:18:19 PM
Sorry. I just noticed that you're using VC 2.1.2.7.

For me to be able to effectively help you, you'll need to download a more recent version of VC.

The Scrape.Get action that we've been using was only added in version 2.1.3.6.

http://voxcommando.com/mediawiki/index.php?title=ChangeLog#Version_2.1.3.6

(To handle authentication we need to be able to add a header, which can't be done with the older Scrape action.)

Do you know how to update your version? (Just download the installer from the VC downloads page, into your existing VC directory, and run it.)
Yes I'm ok with that.  I will; do it now.
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 04, 2015, 03:31:55 PM
It seems they've added some authentication requirements so we're getting an "unauthorized" error.

I've done a bit of online searching on their authentication requirements. There may be some trial and error here, so bear with me.

For your next test, try the following:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.8-->
<command id="425" name="New test: Dim device 25 to 50 percent" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape.Get</cmdType>
    <params>
      <param>http://192.168.0.155/api/callAction?deviceID=25&amp;name=setValue&amp;arg1=50</param>
      <param />
      <param />
      <param />
      <param />
      <param>Authorization: Basic YWRtaW46YWRtaW4=</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Dim device 25 to 50 percent</phrase>
</command>

Yes.... now I updated to version 2.1.3.6  this code works.  It switches the light on.

Great.....
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 04, 2015, 03:38:57 PM
Ha. OK. So, for any commands, you'll need to use Scrape.Get, with the special header parameter exactly as I provided in the example:

Code: [Select]
Authorization: Basic YWRtaW46YWRtaW4=
The weird string is your username and password encoded in Base64. (I used this tool to convert admin:admin to B64 http://www.motobit.com/util/base64-decoder-encoder.asp)

Anyhow. Getting back to the original command: you can now use the original one with the 2 payloads so that it will be more flexible (allowing you to control different dimmable lights with one command, and different brightness values).

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.8-->
<command id="290" name="Dim {1} to {2} percent" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="{1} is the device ID for your dimmable devices. If you can find out those IDs, you can put them in a payload xml file like the example I have attached.&#xD;&#xA;{2} is the dim level, from 1-100">
  <action>
    <cmdType>Scrape.Get</cmdType>
    <params>
      <param>http://192.168.0.155/api/callAction?deviceID={1}&amp;name=setValue&amp;arg1={2}</param>
      <param />
      <param />
      <param />
      <param />
      <param>Authorization: Basic YWRtaW46YWRtaW4=</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Dim</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\fibaro_dimmables.xml</payloadFromXML>
  <phrase>to</phrase>
  <payloadRange>1,100</payloadRange>
  <phrase optional="true">percent</phrase>
</command>


Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 04, 2015, 03:42:04 PM
If you haven't yet done so, you'll need to create your own payload xml for your dimmable lights as in my original example if you want to use the command as it is written.

So, now might be the time to review those videos I mentioned, and then test out some other commands that are working in your browser for you.

Title: Re: Fibaro Home Center 2
Post by: Stealth on February 04, 2015, 03:44:04 PM
Ok will do....  Thanks again for your help.

Steve
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 04, 2015, 03:55:16 PM
Ha. OK. So, for any commands, you'll need to use Scrape.Get, with the special header paramter exactly as I provided in the example:

Code: [Select]
Authorization: Basic YWRtaW46YWRtaW4=
The weird string is your username and password encoded in Base64. (I used this tool to convert admin:admin to B64 http://www.motobit.com/util/base64-decoder-encoder.asp)

Anyhow. Getting back to the original command: you can now use the original one with the 2 payloads so that it will be more flexible (allowing you to control different dimmable lights with one command, and different brightness values).

You lost me with the encoding bit, but it works and that's good for me. I will look at the video's to get up to speed.

Thanks so much for your help tonight...

Steve
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 04, 2015, 03:57:37 PM
Cheers. Have fun.
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 04, 2015, 05:40:49 PM
Hopefully you caught this on your own, but when I re-posted the Dim {1} to {2} percent command with your specific IP etc. there was a typo. I've fixed the command above, but basically I had a // instead of a single / after the IP address.

It should be:
Code: [Select]
http://192.168.0.155/api/callAction?deviceID={1}&amp;name=setValue&amp;arg1={2}
And not:

Code: [Select]
http://192.168.0.155//api/callAction?deviceID={1}&amp;name=setValue&amp;arg1={2}
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 05, 2015, 08:18:09 AM
Hopefully you caught this on your own, but when I re-posted the Dim {1} to {2} percent command with your specific IP etc. there was a typo. I've fixed the command above, but basically I had a // instead of a single / after the IP address.

It should be:
Code: [Select]
http://192.168.0.155/api/callAction?deviceID={1}&amp;name=setValue&amp;arg1={2}
And not:

Code: [Select]
http://192.168.0.155//api/callAction?deviceID={1}&amp;name=setValue&amp;arg1={2}

No I missed the
Code: [Select]
// strange thing is it worked with it as also?...

I can now dim lights and switch them on/off with feedback.  The only thing I need to resolve is the TTS.SpeakSync is saying 'Turning Test Light 1' rather than saying 'Turn Test Light On'

I'm not sure I will be able to get check status working though.

Many thanks

Steve
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 05, 2015, 08:40:17 AM
Not that strange -- I just didn't want to be the one potentially breaking working commands with a typo, given that I have no way to test my guesses from here. :)

If you run out of ideas for how to get your commands working, you can post your command xml so we can see what you've tried (and ideally also the VC log so we can see what Fibaro says is happening when you run them).
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 05, 2015, 08:50:41 AM
Thanks,

The part I'm struggling with at the moment is the TTS.SpeakSync is saying 'Turning Test Light 1' rather than saying 'Turn Test Light On'.  I'm looking through videos at the moment trying to find something on

If 1 convert on On ect...  Files are attached FYI
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 05, 2015, 09:33:14 AM
The part I'm struggling with at the moment is the TTS.SpeakSync is saying 'Turning Test Light 1' rather than saying 'Turn Test Light On'.

Actually, the example you need is directly in the command you're trying to fix.

Your command uses 2 payload XML files. You didn't attach those files above, but based on what you're saying I will guess that the second payload XML file has values "1"--> "On", and maybe "0" --> "Off"?

The phrases that are associated with values are your "friendly payloads".

http://voxcommando.com/mediawiki/index.php?title=Payloads#Syntax

So you want {PF.2} in your TTS actions, not {2}.

----------------------

The log that you posted does not indicate that either of these commands were issued, by the way. In the future, whenever we ask for a log please make sure you have issued the voice commands we are trying to test before uploading the log. The log can't show us anything about behaviour that hasn't occurred. ;)

... With regard to getting status from your devices. I'm not seeing any command attempts for that yet. I guess I can look at the documentation online and suggest some guesses for you to try. That will take a bit of time.

Just as an aside: I did happen to see that you're trying to use the Our Groceries commands. Those won't work until you've entered your Our Groceries login info where indicated in the "update payload XML master list" command -- your email address and password need to replace the RoboB.SetText placeholders [[your login email address]] etc. You should enter that data without any square brackets (assuming you have an OurGroceries account already set up).
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 05, 2015, 09:55:43 AM
For your light status, please try the following (hardcoded for your device with ID 25). It will probably return a bunch of information, if it works at all.

Then I'll need to make some tweaks to the command based on that information, in order to isolate just the light status for you. To do that, I'll again need the VC log after you've issued the command.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.8-->
<command id="316" name="Method 1: Get status of {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="Later, you'll be changing the hard-coded device ID 25 to {1} and using a devices payload xml file with all your devices in it.">
  <action>
    <cmdType>Scrape.Get</cmdType>
    <params>
      <param>http://192.168.0.155/api/devices?id=25</param>
      <param />
      <param />
      <param />
      <param />
      <param>Authorization: Basic YWRtaW46YWRtaW4=</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>{LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Get status of device number 25</phrase>
</command>
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 05, 2015, 10:26:39 AM
Thanks the TTS actions are now speaking on rather than 1. That's another one sorted.  Much appreciated...

Log File
Sorry about that I understand now..

Our Groceries
On a side issue (we can park this for now if you wish?) I have problems with the auto login of Our Groceries. I do use it but I have to manually login via the browser first.  I have again reinserted my login details as you describe but its still not working for me in the version.  If I select the option to show the browser I can see data is getting dropped into the password field and the check box for save login gets checked but nothing is going in the email field?

Status Requests
I ran the new code and I have attached the log file.

Steve
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 05, 2015, 10:37:33 AM
I have uploaded another log file.  As I am not sure the z-wave device was powered on.  This log was with it powred on.
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 05, 2015, 10:54:38 AM
It's good to have the log documenting both states, thanks.

So, the following should hopefully work for you, as long as Fibaro and VC are properly communicating with one another.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.8-->
<command id="316" name="Get status of {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape.Get</cmdType>
    <params>
      <param>http://192.168.0.155/api/devices?id={1}</param>
      <param />
      <param />
      <param />
      <param />
      <param>Authorization: Basic YWRtaW46YWRtaW4=</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>"value":"(\d)"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)==(B)</ifType>
    <ifParams>{Match.1}&amp;&amp;0</ifParams>
    <then>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>The light is off.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>The light is on.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <phrase>Get status of the</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\fibaro_dimmables.xml</payloadFromXML>
</command>

Test it out and let me know if it's working.

If you want to teach yourself a bit about regular expressions, over time you may be able to get more status information about your devices by expanding on this method.

It may take a while to learn it, but in the long you may find it worth it.

... wrt the Our Groceries problem, we should address that in a separate thread. So, try entering your login info as we discussed, save and close your tree, test the commands and post the log, and we'll see what we can learn.




Title: Re: Fibaro Home Center 2
Post by: Stealth on February 05, 2015, 12:01:19 PM
That's fantastic.  The get status code is working great.

Many thanks.

Ok I will open a new thread for the Our Grocery issue shortly.
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 08, 2015, 02:14:01 PM
Ha. OK. So, for any commands, you'll need to use Scrape.Get, with the special header parameter exactly as I provided in the example:

Code: [Select]
Authorization: Basic YWRtaW46YWRtaW4=
The weird string is your username and password encoded in Base64. (I used this tool to convert admin:admin to B64 http://www.motobit.com/util/base64-decoder-encoder.asp)

UPDATE FOR EVERYONE:

I spoke to James, and he says that the username and password parameters in the regular Scrape action are doing the same thing behind the scenes as the special gobbledy gook header solution I posted above for Stealth.

That is, if you look at our documentation for the Scrape action (http://voxcommando.com/mediawiki/index.php?title=Actions#Scrape) in VoxCommando, it includes optional parameters for a username and password. (The Scrape.Get action also includes these parameters, along with a few others.)

Rather than using a URL of the form:
Code: [Select]
http://username:password@yourFibaroIP/api/callAction?etc.
You can instead put your username and password in the specified fields:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.8-->
<command id="425" name="Alternate test: Dim device 25 to 50 percent" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>http://yourFibaroIPaddress/api/callAction?deviceID=25&amp;name=setValue&amp;arg1=50</param>
      <param>yourusername</param>
      <param>yourpassword</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Dim device 25 to 50 percent</phrase>
</command>

So, the above is equivalent to using a Scrape.Get action with a special header Authorization: Basic gobbledygookbase64encodedusernamepassword ... but much more user friendly obviously!

Thanks also to user Stealth for verifying that this is the case.
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 19, 2015, 01:12:52 PM
Thanks for all the help provided by nime5ter previously on this topic....

I have now completed the migration of my Z-Wave controller from Vera to Fibaro HC2. 

I have now come back to finish the Voxcommando xmls with device names, ID's and phrases.

Unfortunately I am having problems. For example If I say switch porch light on or off it works ok.  If I say switch Garage Light on Voxcommando recognizes it but the light does not switch on.  If I ask if the 'is the garage light is on' Voxcommando responds with the device is on?

I'm also not having any luck with phrases  like 'set porch light to 52%'. Voxcommando recognizes it but the command is not sent?

Attached is my xml and log file.  If anyone could cast their eyes over it and give me any pointers that would be appreciated.

Thanks

Steve
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 19, 2015, 04:33:28 PM
Unfortunately I am having problems. For example If I say switch porch light on or off it works ok.  If I say switch Garage Light on Voxcommando recognizes it but the light does not switch on.  If I ask if the 'is the garage light is on' Voxcommando responds with the device is on?

Your garage light seems to be some other kind of switch that requires a different syntax. The command you currently use sets a value of "0" for off and "1" for on. The garage light doesn't respond to that.

I have found another option online that may work for both. I can't promise anything, but in the revised commands below I have replaced your old "Switch x light on/off" with a new one. Give it a whirl.

For the same reason, you can't get the status of the garage light with the command I made for you previously. The garage light responds with very different information, and I honestly can't tell in what I'm reading what part of that is the status (if anything). It would be better for you to post your query on a Fibaro forum. (I'll write a follow-up post telling you what information you should give them.)

Quote
I'm also not having any luck with phrases  like 'set porch light to 52%'. Voxcommando recognizes it but the command is not sent?

You have been using the "hard-coded" command macro that I asked you to test earlier. That command specifically set one particular light with an ID value of 25 to 50 percent brightness. It was just a test command, in which I eliminated potentially problematic variables by making sure we were using a known device ID.

The Scrape action in that test command used as its URL:

Code: [Select]
http://192.168.0.155/api/callAction?deviceID=25&name=setValue&arg1=50
As you can see, there are no payload variables there. It clearly shows a device ID of "25", and the "arg1=50" is what specifies the brightness value.

I'm not sure whether you've had a chance to watch the videos I mentioned or look at the wiki entry about payloads?

In order for your command to make use of the 2 types of payloads that you have in your voice command (i.e. the payload XML file that contains all your device ID values, and the payload range of 1,100 %), you need to tell the command macro where those values go:

Code: [Select]
http://192.168.0.155/api/callAction?deviceID={1}&name=setValue&arg1={2}
That is what allows the command to use *any* device ID, and *any* brightness level between 1 and 100 (in this case).

It's important to distinguish between VC understanding what you are saying (the command trigger), and VC knowing what it is supposed to do when you say what you say.

--------
Anyhow, here is your command group cleaned up, including the one revised command that *may*(?) solve the problem with your garage light not turning on and off.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.8-->
<commandGroup open="True" name="Fibaro Basic" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="310" name="new - Switch{1} {2}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="{1} refers to payload 1, which you can see in the command tree is the payload list of your switchable devices.&#xD;&#xA;(2) refers to payload 2, which you can see in the command tree refers to the on_off payload xml file">
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>http://192.168.0.155/api/callAction?deviceID={1}&amp;name=turn{2}</param>
        <param>admin</param>
        <param>admin</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Turning {PF.1} {2} </param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>1000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>Turning {PF.1} {2}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Turn, Switch</phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">Fibaro\switchable.xml</payloadFromXML>
    <payloadList>On,Off</payloadList>
  </command>
  <command id="316" name="Get status of {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>http://192.168.0.155/api/devices?id={1}</param>
        <param>admin</param>
        <param>admin</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>"value":"(\d)"</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{Match.1}&amp;&amp;0</ifParams>
      <then>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>The device is off.</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>The device is on.</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <phrase>Are the, Is the, Get status of the</phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">Fibaro\switchable.xml</payloadFromXML>
    <phrase optional="true">on, off</phrase>
  </command>
  <command id="425" name="Set {1} to {2}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>http://192.168.0.155/api/callAction?deviceID={1}&amp;name=setValue&amp;arg1={2}</param>
        <param>admin</param>
        <param>admin</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>Setting {PF.1} to {2} %.</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Dim, Brighten, Set</phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">Fibaro\Dimmable.xml</payloadFromXML>
    <phrase>to</phrase>
    <payloadRange>1,100</payloadRange>
    <phrase>Percent</phrase>
  </command>
</commandGroup>
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 19, 2015, 04:46:35 PM
Here is what I would say if I were seeking help on an appropriate Fibaro forum:

I have been querying the status of my garage light using a get request:http://user:pwd@myFibaroIPaddress/api/devices?id=22 (where ID 22 is my garage light).

I was hoping to use this query to find out if the light is on or off. I get the following information back:

{"id":22,"name":"Garage Light","roomID":10,"type":"com.fibaro.binarySwitch","baseType":"com.fibaro.actor","enabled":true,"visible":true,"isPlugin":false,"parentId":21,"remoteGatewayId":0,"interfaces":["zwave","zwaveProtection"],"properties":{"parameters":[],"associationSet":[{"devices":[1],"groupID":1}],"associationView":[{"devices":[1],"groupID":1}],"zwaveCompany":"","zwaveInfo":"6,3,42","zwaveVersion":"1.0","pollingTimeSec":0,"RFProtectionState":"0","RFProtectionSupport":"0","configured":"true","dead":"false","deviceControlType":"20","deviceIcon":"2","emailNotificationID":"0","emailNotificationType":"0","endPointId":"0","liliOffCommand":"","liliOnCommand":"","localProtectionState":"0","localProtectionSupport":"0","log":"","logTemp":"","manufacturer":"","markAsDead":"true","model":"","nodeId":"12","parametersTemplate":"0","productInfo":"1,84,17,0,0,1,1,0","protectionExclusiveControl":"0","protectionExclusiveControlSupport":"false","protectionState":"0","protectionTimeout":"0","protectionTimeoutSupport":"false","pushNotificationID":"0","pushNotificationType":"0","remoteGatewayId":"0","saveLogs":"true","smsNotificationID":"0","smsNotificationType":"0","useTemplate":"false","userDescription":"","value":"false"},"actions":{"reconfigure":0,"turnOff":0,"turnOn":0},"created":1424279322,"modified":1424279322,"sortOrder":23}

Does anyone know where the device state information is in the above? Nothing is jumping out at me. Or is there a better query I can use to figure out if the light is on or off?
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 20, 2015, 07:36:15 AM

You have been using the "hard-coded" command macro that I asked you to test. It was just a test command for a known device ID.

In order for your command to make use of the 2 types of payloads that you have in your voice command (i.e. the payload XML file that contains all your device ID values, and the payload range of 1,100 %), you need to tell the command macro where those values go:

Code: [Select]
http://192.168.0.155/api/callAction?deviceID={1}&name=setValue&arg1={2}
That is what allows the command to use *any* device ID, and *any* brightness level between 1 and 100 (in this case).

I have watched the tutorial video's but I think I need to look at them again. However think I understand now...

Quote
Anyhow, here is your command group cleaned up, including the one revised command that *may*(?) solve the problem with your garage light not turning on and off.

Thank you for the code.  Early testing is showing good results with switching all types of lights on and off ok. (i.e. dimming devices and relay devices on/off)

Just to confirm, as you already mentioned the garage (on/off type device) is still not working with the correct status when asked if its on or off.

I have posted the question as you have asked on the Fibaro forum and have fingers crossed for an answer.

http://forum.fibaro.com/index.php?/topic/17830-device-status-via-api/


Again many thanks for your help.

Edit 20/02/2015
We have just received a reply on the Fibaro forum -

"That would be the part that says "value":"false" at the end. True is on and false is off"
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 20, 2015, 08:42:55 AM
Perfect. That's what we needed. So, if you delete your current "Get status of {1} " command and replace it with the following, it should work with both types of switches.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.8-->
<command id="316" name="Get status of {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>http://192.168.0.155/api/devices?id={1}</param>
      <param>admin</param>
      <param>admin</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>"value":"(\w.*?)"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>0,false&amp;&amp;{Match.1}</ifParams>
    <then>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>The device is off.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>The device is on.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <phrase>Are the, Is the, Get status of the</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">Fibaro\switchable.xml</payloadFromXML>
  <phrase optional="true">on, off</phrase>
</command>

I'll try to explain this command. The first thing we do is send an HTTP "get request" (http://www.w3schools.com/tags/ref_httpmethods.asp) (the Scrape action) to the Fibaro asking it for information about a device.

If you look in your log file (or even roll over the Scrape action in the history window), you will see the information that the Fibaro responds with. That is the info you posted on the Fibaro forum. Fibaro's response is now our {LastResult}.

In the next line we use a regular expression to capture just the information we care about from our Result -- the light's on/off state -- within that giant pile of information.

Code: [Select]
Results.RegEx - "value":"(\d)"
scans the data for the string pattern "value":"digit" . By putting round brackets around \d I was telling it to capture that digit as a match. (So we can use it later.)

Then we use a simple If/Else logic block to say, if the match == 0 the device is off, otherwise the device is on.

Your other switches report a value of "1" if they are on and "0" if off. So my regular expression, which was based on previous logs you'd sent me, worked. But the garage light reports a value of "false" if off and "true" if on. Obviously looking for a digit will not work, so the logic block always evaluated to "The device is on".

In the new version of the command:

1. We need a more versatile regular expression that can capture a value of either 0 or false, or 1 or true.

Code: [Select]
Results.RegEx - "value":"(\w*?)"
Regular expressions use their own kind of representative language. \w means any word character including numbers. *? just tells it to keep grabbing subsequent word characters until, in this case, it hits a " . Again, putting this pattern in parentheses captures the pattern as a match.

2. So now our regular expression should capture anything that appears in quotations after the string "value": .

This means, however, that we need to change how we evaluate the match in our If/Else.

Instead of If {Match.1} == 0, device is off, we instead say, If this string A " 0,false " CONTAINS string B {Match.1}, then the device is off.

In other words, if {Match.1} is 0, the condition will be true, and if {Match.1} is false, the condition will also be true.

... Ideally we should also catch when the regular expression can't find any correct value at all, and have the command tell you that. I haven't done that here because I didn't want to complicate things. Hopefully this command will work for you most of the time.

Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 20, 2015, 09:24:40 AM
P.S. Sorry to subject you to the snarky comments over on the Fibaro forum. :)

They're quite right, the correct problem-solving technique would have been to compare the feedback when the light was on and off (as we did with the other switch). I was trying to save myself some time, and also wanted to know if there was a different way to query the switch.
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 20, 2015, 02:06:49 PM
Thanks nime5ter,

Thats brilliant, the latest code reads the garage light just fine. I also appreciate your detailed explanations...

Don't worry about the comments on the Fibaro forum it's not a problem.  I appreciate they may get frustrated from time to time with what may seem like dumb questions.

I expect I'm pushing my luck now but I'm sure you won't blame me for asking.... It would be nice if the last two Vera xmls could also be ported for the Fibaro. That way Voxcommando then has support for both devices.  I have attached the XML's for your perusal/comments.

Kindest regards

Steve

 
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 20, 2015, 02:32:44 PM
I expect I'm pushing my luck now but I'm sure you won't blame me for asking.... It would be nice if the last two Vera xmls could also be ported for the Fibaro. That way Voxcommando then has support for both devices.  I have attached the XML's for your perusal/comments.

I don't really know what you mean by "ported for the Fibaro", or why you need VC to "support both devices", which implies you're still using the Vera as well as the Fibaro (??). If so, you can simply use your Vera commands to do those things.

In any case, for the Fibaro, if it's possible to do those things, they all involve changing the Vera.whatever actions in each command with the appropriate Scrape action. You should be able to use the commands I've already made for you as a starting point.

Experiment with the URL examples posted here: http://forum.fibaro.com/index.php?showtopic=12399 (which we linked to at the beginning of this thread).

That is all I would be doing anyhow. They are using slight shorthand, but it should be fairly obvious at this point.

e.g. when they give the example http:///api/callAction?deviceID=4&name=turnOff , they actually mean http://yourIPaddress/api/etc.

I do not have a Fibaro and it is not clear to me how you would be controlling Vera scenes with your Fibaro controller. I would have thought that you would need to create new Fibaro scenes.

To get your temperature, you probably do the same thing we did already with getting your light status. But you'd have to isolate the temperature info using a regular expression instead of looking for on/off state.




Title: Re: Fibaro Home Center 2
Post by: Stealth on February 20, 2015, 02:51:20 PM
I don't really know what you mean by "ported for the Fibaro", or why you need VC to "support both devices", which implies you're still using the Vera as well as the Fibaro (??). If so, you can simply use your Vera commands to do those things.

I was using a Vera controller with Voxcommando but decided to move to the Fibaro (mainly for the better user interface for the rest of the family). However I wanted Voxcommando to work with the Fibaro controller as the Vera did.  My Vera has been removed from my setup now that the Fibaro is working.

Now if I can mimic the last two Vera xml's for use with the Fibaro controller, (Scenes and Temperatures) then Voxcommando will work with both controllers and Voxcommando users have a choice on Z-Wave controllers to use.

Thanks to all your coding efforts it's pretty much complete.  I will take a look at those videos again and try to workout the final xml's.

Kindest regards

Steve
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 20, 2015, 03:26:33 PM
Now if I can mimic the last two Vera xml's for use with the Fibaro controller, (Scenes and Temperatures) then Voxcommando will work with both controllers and Voxcommando users have a choice on Z-Wave controllers to use.

In fact, the great thing about VC is that users already do have a choice of Z-Wave controllers to use -- Vera, Fibaro, a system running Domoticz (http://voxcommando.com/forum/index.php?topic=1433), among others.

There's a reason we refer to VoxCommando as "a tinkerer's delight". It's basically the computer equivalent of a Meccano set with massive potential for play and expansion. For a token amount, non-programmers can avail themselves to a programmer's set of tools. Then, all that is needed is time and the inclination to learn new things. On the forum, we try to support that process.
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 20, 2015, 04:14:03 PM
I agree it's a superb program....


Steve
Title: Re: Fibaro Home Center 2
Post by: Stealth on February 21, 2015, 12:24:07 PM
For those interested in using Voxcommando with the Fibaro HC2 and following this thread. 

Attached is the latest xml, now incorporating 'Scene Control'. 

Next on to temperature sensor reading and thermostat control.  I think this maybe a lot harder though!.

Commands already included in the attached xml -

1) Switch device # to level ###
2) Switch device # On/Off
3) Start scene #
4) Stop scene #
5) Get current status of device #
Title: Re: Fibaro Home Center 2
Post by: nime5ter on February 21, 2015, 03:44:27 PM
Thanks for posting the new commands. At some point it would be good to list all of the commands that are in the command group, so that it's not a "mystery download".

re: controlling the thermostat -- I think you could try a URL that is similar to what you use to set dim levels for lights:

http://yourIPaddress/api/callAction?deviceID=7&name=setValue&arg1=39

However, instead of setValue, you should try setTargetLevel

Of course, you'd use the device ID for your thermostat and then try putting the desired temperature value after the "arg1=".

I'm basing that guess on the link you posted previously: http://www.fibarouk.co.uk/support/lua/actions-use-fibarocall-api/

If you run out of luck, they should definitely be able to help you on the Fibaro forum with those 2 commands. In VoxCommando, you can use http get, put, or post requests (http://voxcommando.com/mediawiki/index.php?title=Actions#Scrape).

Title: Re: Fibaro Home Center 2
Post by: Stealth on February 22, 2015, 04:51:08 AM
Thanks nime5ter,

I can't try your syntax yet as I'm waiting for my Z-Wave thermostat to arrive.  I hope should be here within the next two weeks so I can complete the integration.  I will reportback as soon as I can.
Title: Re: Fibaro Home Center 2
Post by: Stealth on March 05, 2015, 01:56:38 PM
Whilst I am waiting for my Z-Wave thermostats to arrive I have hooked up some temperature sensors and I would like to ask Voxcommando to report the temperatures on command.

i.e "What is the Lounge temperature"

I am using this http command for a scrape report

http://192.168.0.155/api/devices?id={1}

{1} = Z-Wave node ID 81

This http command delivers the following dump -

{"id":81,"name":"Lounge Brass 75.5","roomID":4,"type":"com.fibaro.temperatureSensor","baseType":"com.fibaro.multilevelSensor","enabled":true,"visible":true,"isPlugin":false,"parentId":75,"remoteGatewayId":0,"interfaces":["zwave"],"properties":{"parameters":[{"id":1,"lastSetValue":0,"size":2,"value":0},{"id":2,"lastSetValue":0,"size":2,"value":0},{"id":3,"lastSetValue":1,"size":1,"value":1},{"id":4,"lastSetValue":1,"size":1,"value":1},{"id":5,"lastSetValue":255,"size":1,"value":255},{"id":6,"lastSetValue":255,"size":1,"value":255},{"id":7,"lastSetValue":255,"size":1,"value":255},{"id":8,"lastSetValue":255,"size":1,"value":255},{"id":9,"lastSetValue":0,"size":1,"value":0},{"id":10,"lastSetValue":20,"size":1,"value":20},{"id":11,"lastSetValue":200,"size":1,"value":200},{"id":12,"lastSetValue":8,"size":1,"value":8},{"id":13,"lastSetValue":0,"size":1,"value":0},{"id":14,"lastSetValue":0,"size":1,"value":0}],"associationSet":[{"devices":[],"groupID":1},{"devices":[],"groupID":2},{"devices":[1],"groupID":3}],"associationView":[{"devices":[],"groupID":1},{"devices":[],"groupID":2},
{"devices":1],"groupID":3}],"zwaveCompany":"Fibargroup","zwaveInfo":"3,3,52","zwaveVersion":"2.1","pollingTimeSec":0,"configured":"true","dead":"false",
"deviceControlType":"0","deviceIcon":"30","emailNotificationID":"0","emailNotificationType":"0","endPointId":"5","liliOffCommand":"","liliOnCommand":"","log":"","logTemp":"",
"manufacturer":"","markAsDead":"true","model":"","nodeId":"22","offset":"0.00","parametersTemplate":"85","productInfo":"1,15,5,1,16,2,2,1",
"pushNotificationID":"0","pushNotificationType":"0","remoteGatewayId":"0","saveLogs":"true","showFireAlarm":"true","showFreezeAlarm":"false",
"smsNotificationID":"0","smsNotificationType":"0","unit":"C","useTemplate":"true","userDescription":"","value":"20.00"},"actions":{"reconfigure":0},"created":1425556131,"modified":1425556131,"sortOrder":45}


I don't know how to filter out the "value":"20.00" which is the current temperature.

I believe I need to update nime5ter's previous syntax
Code: [Select]
"value":"(\w.*?)" that was used when checking if a node was on but I don't know where I can find any help documents on this.  Unfortunately videos didn't help me either. Forgive me if I'm totally off the mark with this.

Thank you in advance.

Steve

Title: Re: Fibaro Home Center 2
Post by: nime5ter on March 05, 2015, 02:02:30 PM
If 20.00 is the data you want, then the syntax from earlier should work as is.

The pattern is exactly the same. "value":"(what you want)".
Title: Re: Fibaro Home Center 2
Post by: Stealth on March 05, 2015, 02:14:05 PM
I'm obviously missing something.  Sorry to be dim

I use this syntax?

"value":"()"

What about the If statement part?


 
Title: Re: Fibaro Home Center 2
Post by: nime5ter on March 05, 2015, 03:12:58 PM
You can use exactly the same regular expression action that you're already using to get the status of your light switches.

The regular expression that you already quoted above:
Code: [Select]
"value":"(\w.*?)"is what you need to use.

The result of this is stored as {Match.1}. The question is what you want to do with the information after that.

If you just want to ask VC, "What's the current temperature" and have a TTS announcement telling you the temperature, then that's all you do with it. 

1. Scrape. --> URL that you need to scrape
2. Results.Regex --> "value":"(\w.*?)"
3. TTS.Speak --> The current temperature is {Match.1} degrees Celsius.

If you want to do different things depending on what the temperature reading is, that may involve using a logic block.
Title: Re: Fibaro Home Center 2
Post by: nime5ter on March 05, 2015, 03:33:10 PM
I would just

1. Clone your "Get status of {1}" command (right-click on the command in your tree and click "clone"),

2. Edit the name of the cloned command to "Get temperature" or whatever you like

3. Delete the logic block

4. Add the TTS action
Title: Re: Fibaro Home Center 2
Post by: Stealth on March 05, 2015, 04:16:56 PM
I would just

1. Clone your "Get status of {1}" command (right-click on the command in your tree and click "clone"),

2. Edit the name of the cloned command to "Get temperature" or whatever you like

3. Delete the logic block

4. Add the TTS action

Thanks thats just the job.  One last tweak would be good i.e. Rather that report 20.68  degrees celsius how do I tweak the syntax to only report to one decimal place i.e. 20.6 degrees celsius?

Title: Re: Fibaro Home Center 2
Post by: nime5ter on March 05, 2015, 04:21:41 PM
Code: [Select]
"value":"(.*?)."
Title: Re: Fibaro Home Center 2
Post by: Stealth on March 05, 2015, 04:29:04 PM
Code: [Select]
"value":"(.*?)."

Thats fantastic, thanks alot. 

You are great! ;)

Once I have the thermostat and have it working with Voxcommando I will upload a clean group of Fibaro xmls.

Cheers

Steve