We have moved at community.getvera.com

Author Topic: [ CODE ] Fritz!Box call log plugin v0.3  (Read 12146 times)

Offline hek

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
[ CODE ] Fritz!Box call log plugin v0.3
« on: November 30, 2012, 06:31:27 pm »
The Fritz!Box is a router with build in VOIP and Dect functionality.  With this plugin you can trigger scenes on incoming calls, outgoing calls and hangup.

Code and documentation:
http://code.mios.com/trac/mios_fritzbox/

« Last Edit: December 12, 2012, 07:56:28 am by hek »

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: [ CODE ] Fritz!Box call log plugin
« Reply #1 on: December 01, 2012, 12:13:03 am »
@hek,
I'd recommend you start with a working set of files, and then modify them incrementally to add the stuff you need.

The nearest, and simplest, I could find would be this:
      http://code.mios.com/trac/mios_monoprice-hdmi-switch/browser/trunk/I_MonopriceMatrixSwitch1.xml

With the substitutions for <incoming> tag, along with the luup.io.write calls and the <protocol> declaration (as you've already done) along with any needed changes for ServiceId's, DeviceTypes (etc).

The Plugin needs both a D_ file and an I_ file (minimally).  Others will come later as you add UI (etc).

Once you've uploaded the Plugin files to Vera, you need to instantiate a Device [a Plugin instance of sorts] from them.  This is also exposed via the Apps/Develop Apps menu/area, but is [roughly] described in this:
    http://wiki.micasaverde.com/index.php/Install_LUUP_Plugins

On that device, a small number of attributes exist, like "ip" (the ipAddress that the Monoprice example code uses to connect).... these can be configured once the Device has been created from the Plugin [files]

PS: When something is installed from apps.mios.com, it's basically installing the Plugin [files] and creating the "first" Device [instance] for you in a single step.

Offline hek

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: [ CODE ] Fritz!Box call log plugin
« Reply #2 on: December 01, 2012, 04:26:32 am »
Thanks @guessed. The D_FritzBox.xml did the trick. Also I didn't know that I needed to create the device manually.

It started logging incoming/outgoing calls now!

If I would like create events that scenes can trigger on. How do I do that?  Or what is the best strategy?


Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3260
  • Karma: +192/-9
[ CODE ] Fritz!Box call log plugin
« Reply #3 on: December 01, 2012, 05:59:40 am »
If I would like create events that scenes can trigger on. How do I do that?  Or what is the best strategy?

Events happen when a variable changes on the device. You will need to make your implementation call luup.variable_set() to set a variable. You choose which variable.

The plugin's static JSON file contains a list of events, and which variable that the Luup engine should watch, and what value the variable should take.

It's best to look at source code of existing plugins that have events to see how they are coded. Look at one of the alarm panel plugins for something vaguely similar to what you are looking to do.

Offline hek

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: [ CODE ] Fritz!Box call log plugin
« Reply #4 on: December 05, 2012, 06:11:26 pm »
Ok, i've come a little bit further. Plese guide me.

When the "Action" and "Phone" variables changes it doesn't show in UI. What am I doing wrong?

I can select to trigger on my "Action" in scenes but they never gets triggered... something is not connected correctly..

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3260
  • Karma: +192/-9
[ CODE ] Fritz!Box call log plugin
« Reply #5 on: December 06, 2012, 12:24:16 am »
It could be a ton of things. Most likely you have a typo or you haven't followed an example closely enough. Post your D_*.* files, but all we can do is give them a visual inspection, and it's easy to miss the real error.

Offline hek

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: [ CODE ] Fritz!Box call log plugin
« Reply #6 on: December 06, 2012, 01:04:02 am »
I have posted everything in the top post.

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3260
  • Karma: +192/-9
Re: [ CODE ] Fritz!Box call log plugin
« Reply #7 on: December 06, 2012, 02:19:35 am »
One problem I see is that your spelling of the service ID in the device XML file:
Code: [Select]
<serviceId>urn:hek:serviceId:FitzBox</serviceId>doesn't match the spelling in the device JSON file:
Code: [Select]
"Service": "urn:hek:serviceId:FritzBox1"
Attention to detail is very important in getting these files right.  Vera is utterly unforgiving of typos.

Offline hek

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: [ CODE ] Fritz!Box call log plugin
« Reply #8 on: December 06, 2012, 03:02:06 am »
great thanks.. i'll try it tonight.

Offline hek

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: [ CODE ] Fritz!Box call log plugin v0.1
« Reply #9 on: December 06, 2012, 05:01:07 pm »
Found some more typos... But I finally got it working. Triggering scenes works good. I still have a couple of questions.

Has anyone documented how layout works of texts/buttons in json file on dashboard (using top,x,left:y etc) ?

What happends if the connection "goes down"? Will vera/plugin try to establish a new connection again by itself?

How do I get a mios svn and "market" account to upload the plugin?


Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3260
  • Karma: +192/-9
Re: [ CODE ] Fritz!Box call log plugin v0.1
« Reply #10 on: December 06, 2012, 05:27:37 pm »
Has anyone documented how layout works of texts/buttons in json file on dashboard (using top,x,left:y etc) ?

There's a couple of wiki pages: http://wiki.micasaverde.com/index.php/UI4_UI5_Migration http://wiki.micasaverde.com/index.php/Luup_plugins:_Static_JSON_file

That's all I know.

Quote
What happends if the connection "goes down"? Will vera/plugin try to establish a new connection again by itself?

I don't think so.  I've had to restart the Luup engine a few times because the LAN fell over; it wouldn't surprise me if it was because it just gives up on a dropped connection.

Quote
How do I get a mios svn and "market" account to upload the plugin?

One of the MCV people does them.

Offline parkerc

  • Beta Testers
  • Sr. Hero Member
  • *****
  • Posts: 2479
  • Karma: +35/-48
  • Life Moves Pretty Fast....
Re: [ CODE ] Fritz!Box call log plugin v0.1
« Reply #11 on: December 06, 2012, 05:45:37 pm »
Hi @hek

Very interesting stuff.. I'm looking at the Fritz!Box web page now.. ;)

As i mention in our Sonos plugin thread exchange earlier on; the reason i was so curious about your plans to integrate your phone with Sonos was because, I have freePBX running and was looking at the Google TTS plugin for that (https://github.com/phwhite/texttospeech) hence I was curious if you we're doing a similar thing.

I'd have love to integrate my FreePBX and VoIP line into Vera, but sadly lack the skills to do it.
« Last Edit: December 06, 2012, 05:50:36 pm by parkerc »

Offline hek

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: [ CODE ] Fritz!Box call log plugin v0.1
« Reply #12 on: December 06, 2012, 05:58:33 pm »
You must first identify an integration point to freePBX where you can get inbound/outbound calling information. 
The Fritz!Box is pretty simple to interact with (just open a connection and listen to port 1012).

You will probably learn a bit by looking at my code. It is pretty minimalistic right now.

 

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: [ CODE ] Fritz!Box call log plugin v0.1
« Reply #13 on: December 07, 2012, 11:20:47 am »
Quote
What happends if the connection "goes down"? Will vera/plugin try to establish a new connection again by itself?

It should restart.  There are cases where it doesn't detect the situation, but I've not seen those since the newer UI5 releases where we had them add Keep-Alive timeouts to those connections.

It's possible, even with the KA timeouts, to "loose" data due to it not being detected in time.

In general, it's probably better to periodically "poll", over the internal connection, the remote device by sending it something.  This will also help to force a reconnect when it detects the dead connection.

Quote
How do I get a mios svn and "market" account to upload the plugin?

I created you a space, you should see an announcement notice from the system shortly.

Offline hek

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: [ CODE ] Fritz!Box call log plugin v0.1
« Reply #14 on: December 07, 2012, 03:00:11 pm »
Quote from: guessed
I created you a space, you should see an announcement notice from the system shortly.

Great!

Added wikipage and source to the SVN repo.

How do I deploy to the Vera market thing? Is it possible to create a custom icon when adding plugin through market?

Could you add it to plugin wiki index page (where all plugin are being listed)?
« Last Edit: December 07, 2012, 04:04:39 pm by guessed »