[ CODE ] Fritz!Box call log plugin v0.3

@j.hoekstra.
You should probably update to version 0.3 when it has been approved on mios market (or download from source now)… 0.1 version had a bug related to incoming phone number.

Will update then.
In principle the Fritzbox has the number info ready and seems to pass it on via the callmonitor cause other apps using the same mechanism seem to pick it up.
Connection with an adressbook seems to be done locally afaict, for me the number would just be fine :slight_smile:

Unfortunately the frizbox call log does not log the name (if it exists in Fritz!Box adressbook) only number is passed.
I’ve seen Fritz!Box integrations where developers has done a regular Web Interface login to fetch adressbook from the Fritz!Box UI. But that is a bit too hacky for my taste.

For me the numbers are just fine, I’ll check how I can get the number(see you made nice example on the trac-page) and pass it on to be spoken via TTS from the Karotz-plugin :slight_smile:

Has this stopped working (possibly due to firmware updates) or is it just me? :slight_smile:

Firmware update of Vera or Fritz!Box?

Fritz :wink: The plugin doesn’t seem to be receiving any data from the fritz anymore (I have a 7390 on 06.03. I’ve double checked the port is open).

Mine is on 06.06 and everything is working fine here.

Hmm. What’s the best way to troubleshoot? I’ll reinstall the plugin, see if that helps.

EDIT: Yeah, that fixed it, sorry to bother :smiley:

Hi hek,

I know you haven’t needed up update this in ages as it all just works, but if you find yourself bored one day and fancy adding a feature, a new variable to show the name of the person calling would be handy (pulled from the fritz address book).

I’ve no idea how hard that would be to implement, and it may be more trouble than it’s worth, but I could make good use of it. Basically I have a scene that pauses whatever I’m watching in XBMC and pops up a notification to show the number of whoever is calling. It’d be a lot more useful if it showed the name instead. I could do it in the luup code, but it would get out of control pretty quickly if I have to add logic to convert every number :smiley:

Anyway, just a thought.

Thanks :slight_smile:

The name is not coming through the fritz-API. You would have to login the web-way and pick up the number via screen-scraping. Much too complicated to do from lua.

I do a name-lookup in luup (from a swedish public web-service) and say name in our sonos speakers when someone calls in.

[quote=“hek, post:34, topic:173458”]The name is not coming through the fritz-API. You would have to login the web-way and pick up the number via screen-scraping. Much too complicated to do from lua.

I do a name-lookup in luup (from a swedish public web-service) and say name in our sonos speakers when someone calls in.[/quote]

Ah ok, yep fair enough.

Honestly most calls come through my mobile nowadays, so there’s probably only 3 or 4 people who would call the home phone. I can just added some if/then’s into the luup for my scene to hardcode the names. Just thought I’d check anyway.

Thanks for the response :slight_smile:

I’ve trying to run an action in a scene if a specific number is calling. What I tried so far is:

local action = luup.variable_get( ‘urn:hek:serviceId:FritzBox1’, “Action”, 9)

if (action == “RING”) then
if (luup.variable_get( ‘urn:hek:serviceId:FritzBox1’, “Number”, 9) == “0788788780”) then
return true
else
return false
end
else
return false
end

Is there any short example of where and how to do this in UI7?

The device itself seems to work just fine as I can see different state changes when the number is calling …

The code looks ok…

Hi,

I’m trying to get my LED blinking on/off while the phone is ringing. Here’s the code I’m trying:

local delay = 1
local function IncomingCall()
local action = luup.variable_get( ‘urn:hek:serviceId:FritzBox1’, “Action”, 9)
luup.call_delay(luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = “0”}, G_Wohnzimmer),delay) – RGB Green
luup.call_delay(luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = “100”}, G_Wohnzimmer),delay) – RGB Green
luup.call_delay(luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = “0”}, G_Wohnzimmer),delay) – RGB Green
if action ~= “RING” Then
return
end
IncomingCall()
end

But the code fails at:

local action = luup.variable_get( ‘urn:hek:serviceId:FritzBox1’, “Action”, 9)

Any suggestions to get this working?

A few things here…

First, to format your code properly on the forums, if you are posting a multi-line code block, put three back-ticks (```) on a line by itself, then your code, and then three back-ticks again (```) on a line by itself.

-- Then it looks like this
-- This preserves indents and (importantly) quotes, and uses a more readable typeface for code.
local delay = 1
local function IncomingCall()
    local action = luup.variable_get( ‘urn:hek:serviceId:FritzBox1’, “Action”, 9)
-- ...etc...

If you are formatting a single line of code or putting a code fragment inline, enclose it in a single back-tick ` (before and after) and it will look like this.

To your code… the call_delay()/call_timer() functions take a string as its first argument, and that is the name of a (global-scoped) function that is to be executed when the delay expires. You cannot pass a function reference directly, and your code as shown isn’t even doing that, it’s executing call_action() immediately and passing the result returned from that call into call_delay(), which isn’t going to get you where you want to go.

The correct usage of call_delay() specifically to blink a light has been covered in many other threads, so I won’t rehash it here. Here’s a link to one such thread that I think is a good match: Blink Light Program, is recursion necessary? - Scene Scripting - Ezlo Community

Also, be aware that there is no guaranteed timing when communicating with Z-Wave, ZigBee, or plugin devices. If Vera is busy doing something else when your delay is expected to end, your blink may not happen as scheduled, it will happen when Vera gets around to it. If the Z-Wave network is busy, same deal. The shorter your delay is, the less likely the blinking will happen accurately on your timing. While it should be theoretically possible for you to get a series of Z-Wave commands out to a device in a chain all one second apart, practically speaking, it isn’t likely to happen, at least not consistently. Remember that your light is not connected to a pin directly controlled by a microcontroller. In the case of any Z-Wave device, it’s on the far end of a wireless network that may likely rely on nodes between to relay signals back and forth, adding latency and round-trip time on top of whatever processing the device itself will need to do when it finally gets the message and how quickly it does it.

Thanks for the hint. I’ll try to quote my code with this method.

Before we go for details I’ need help reading the phone status.

The last example I tried was:

local action = luup.variable_get( ‘urn:hek:serviceId:FritzBox1’, “Action”, 9)

I’ve also tried:

local action = luup.variable_get( ‘urn:hek:serviceId:FritzBox:1’, “Action”, 9)

But I only get “Failed to test code” error. Notifications from “Fritz!Box Call Log” are running fine.

The first example is most correct. Change the quotes to straight quotes (ASCII 34)–wherever you copied that code from/through has bitten you with a typographical change. Make sure the single quotes are just the keyboard single quotes as well (you can change them all to either keyboarded single quotes or keyboarded double quotes; either will work, but be consistent throughout).

local action = luup.variable_get( "urn:hek:serviceId:FritzBox1", "Action", 9)
1 Like

That was the error! Now it works as expected.

The next step I’m trying to realize is to turn on a LED while the phone is ringing and to turn off the LED if the call is either accepted or the ringing stops.

I’ve created a scene which starts whenever a call is recognized (“Incoming call”). This scene starts the following code:

R_LED_Value(3) -- set LED level to 3
while (FritzboxAction == "RING") do
  FritzboxAction = luup.variable_get( "urn:hek:serviceId:FritzBox1", "Action", Fritzbox)
end
R_LED_Value(0) -- set LED level to 0

The LED is turned on correctly if a call is recognized, but the problem seems to be that if the ringing is cancelled or accepted the action stays still at “RING” so the loop never stops and the LED stays on.

How can i realize that the LED ist turned off when the the ringing stops? Another two scenes which are triggered by “Connect” or “Call ended” could work but maybe there is a more elegant way.