Bindings avmfritz and TR 064 only deliver UNDEF

What kind of Items have you linked these to?

I hope this screenshot helps you further

I would like to take part in solving the problem. What do the experts think, does a setting in the Fritzbox have to be changed or is it due to the formatting of the item or is something wrong with my configuration? Where should I start? And does UNDEF actually stand for undefined?

Yes. Items are born with NULL state. Getting UNDEF indicates that ‘something’ has at least tried to update them, usually a binding. UNDEF often indicates something has gone wrong - a communications problem, or more likely here something like an unexpected or out-of-range value.

Hence my question about types - trying to stuff Call channel into Number type Item would mess up, for example.

Note that UNDEF isn’t necessarily a fault - some device might not support this data Item, or it might not be valid in current circumstances e.g. there is no current call. But I don’t know what to expect from this binding.

That sounds more complicated than I thought. A test call (from the cell phone) showed no change. However, I also saw that in the example of @cweitkamp (Christoph Weitkamp, Maintainer) several “UNDEF” issues were also displayed.
Perhaps there will still be someone with a working configuration that could be adopted.
Question: is it perhaps more expedient to create the whole thing text-based?

I can‘t comment on avmfritz, but for tr064 textual Config is NOT recommended.

Thanks very much

Hi @adm105 ,

Did you enable the call monitor on your FRITZ!Box by dialing #965 on a connected phone?

Otherwise can you create a TRACE log? To enable TRACE logging do the following steps:

  • open the Karaf console: The Console | openHAB
  • set the logging level to TRACE for binding ( log:set TRACE org.openhab.binding.avmfritz )
    Logging | openHAB
  • view log with log:tail or log:tail org.openhab.binding.avmfritz

You might want to send it via PM to me to avoid leaking sensitive data.

Hello,
i am faceing the same issue. When no call is incomming or outgoing or ongoing the item always show “UNDEF” which in my point of view should not be the case. To show the name of the caller i also use the “PHONEBOOK” profile at the respective channel to get the name from the phonebook.

Here how it looks before and after the call:

and here during an incomming call:

an here the entries in the log for the binding with trace:

2021-10-28 20:28:55.509 [DEBUG] [itz.internal.callmonitor.CallMonitor] - Received raw call string from FRITZ!Box: 28.10.21 20:28:55;RING;0;01123456;654321;SIP3;
2021-10-28 20:29:02.525 [DEBUG] [itz.internal.callmonitor.CallMonitor] - Received raw call string from FRITZ!Box: 28.10.21 20:29:02;CONNECT;0;11;01123456;
2021-10-28 20:29:15.035 [DEBUG] [itz.internal.callmonitor.CallMonitor] - Received raw call string from FRITZ!Box: 28.10.21 20:29:15;DISCONNECT;0;10;

would be fine to get rid of this UNDEF as it looks not good on a page.

You can put there any text you want to via transformation:

Item label:

"FB - Active Call[MAP(phone.map):%s]"

/transform/phone.map:

UNDEF=unbekannt

Of course you need to install the map transformation service first.

1 Like

Sorry for late reply, but it took some time to do some testing with different approaches.
result is that it is not working at all! Neither with MAP in item pattern nor with MAP in widgets.
I am running OH3 M3.1 on a Raspi installed with Openhabian.

MAP-Transformation was already installed and i use it e.g. for the MAC-online status (ON=daheim, OFF=weg) and it is working quite well. In this case the MAP is done in the stateDescription / pattern of the item.

i tried the same for FB9xyz_AusgehenderAnrufName

{
  "link": "http://ohshd:8080/rest/items/FB9xyz_AusgehenderAnrufName",
  "state": "anrufer name",
  "transformedState": "",
  "stateDescription": {
    "pattern": "MAP(fritzcall.map):%s",
    "readOnly": true,
    "options": []
  },
  "editable": true,
  "type": "String",
  "name": "FB9xyz_AusgehenderAnrufName",
  "label": "FB  Angerufener Name",
  "category": "",
  "tags": [
    "Point"
  ],
  "groupNames": [
    "FB9xyz"
  ]
}

and the result is (list items):
grafik

for FB9xyz_EingehenderAnruf i tried a different approach: no MAP at the item-level

{
  "link": "http://ohshd:8080/rest/items/FB9xyz_EingehenderAnruf",
  "state": "UNDEF",
  "stateDescription": {
    "pattern": "%2$s",
    "readOnly": true,
    "options": []
  },
  "editable": true,
  "type": "Call",
  "name": "FB9xyz_EingehenderAnruf",
  "label": "FB Eingehender Anruf Nr.",
  "category": "",
  "tags": [
    "Point"
  ],
  "groupNames": [
    "FB9xyz",
    "gPersInfluxDB"
  ]
}

but in the widget:
i tried several different ways for MAP / =MAP etc. , none of them was working.

component: oh-label-cell
config:
  item: FB9xyz_EingehenderAnruf
  icon: f7:phone
  title: wer ruft an
  label: testlabel [MAP(fritzcall.map):%s]

label-cell
grafik

So far, i have not found a way to get rid of the UNDEF state.

Persistence for UNDEF state
Maybe it is linked to another issue i am facing: for the UNDEF-item state i don’t get this state in the persistence service (MAPDB). After a restart i only get the latest value <> UNDEF.

i have no further idea how to solve this UNDEF - problem

Sorry, I have no idea how this works with widgets as I am using openHAB3 with sitemaps and BasicUI.

That’s right, none of the persistence services store UNDEF (or NULL) by design.

That’s right, that is just what restore-on-startup is intended to do. Maybe you don’t want old values restored at boot, that’s a persistence configuration issue.

You’ll want the displayState here (coupled with MAP in your Item metadata ‘pattern’).

What’s in your secret MAP file?
I don’t think a MAP will deliver what you want though, if you don’t know all the other possible values in advance.
This might help

After some testing this was also my assumtion. Maybe it is worth to add this to the description of the persistence service (at least i have not found it there).
How to force bindings to use the correct status for items e.g. in this case with the avmfritz binding i think it is not ok to use UNDEF if no call is incomming / outgoing.

This is then logical as UNDEF/NULL are not persist. Again the root cause is that the item should not be UNDEF/NULL (see above)
I use mapdb to persist all item status and get them back on startup:

* : strategy = everyChange, restoreOnStartup

Works fine except for those unintentional UNDEF/NULL cases.

very simple content:

UNDEF=-

i now also adopted your Passthrough not mapped proposol to may case

(function(i) {
    var state = ""
    var value = i
    if(value == "UNDEF") {
    state = "-";
    } else {
    state = value;
    }
    return state;
})(input)

It works fine if i apply this as profile in a channel

For the same thing but another channel i use the phonebook (Telefonbuch) profile and i see as expected UNDEF as long as no call is done.

Therefore i use the JS in the Pattern of the stateDescription based on the assumtion that i can use only one transformation at a channel.

Unfortunately nothing changes for those cases, i still see the UNDEF!

Thanks to rossko57 some progress made but still not all issues solved.

based on another post from rossko57
OH3: Item state UNDEF → convert to zero
i also learned that

  • transformation applied on a channel really change the state
  • transformation applied on items metadata keep the state but change how the state is display.

Each day i learn more about OH what you can’t find in the documentation.

If there is no incoming or outgoing call at this moment, then there is no incoming or outgoing caller number. This seems perfectly reasonable to me. You’ve just got a cosmetic display issue.

That’s your choice. Seems completely illogical to me, what is the purpose of restoring current incoming call? (As opposed to, say, last incoming call)
It’s a bit like restoring a clock setting - why would you do that? The time now is of interest.

I don’t know what you’re showing us in that screenshot. Some widget? Is it displaying Item state, or displayState? You have a choice in widgets - real Item state or formatted/transformed version.

here i have a bit different view as i found today also in the OH Community:

I would use UNDEF rather than NULL because they have slightly different meanings in openHAB
NULL = hasn’t been set up yet
UNDEF = something wrong or unexpected

which is locigal for me. Therefore if there is no call it should be 0 or OFF as it should be a defined state and not UNDEF = something wrong or unexpected

I have choosen this approach to get all items into a defined state after a reboot of the system or restart of openhab. It should be the state as it was before the reboot / restart took place which usually take only a view minutes. But this is a minor topic for me as a reboot / restart should be an exceptional case.

Sorry was not clear for others.
Yes its part of a widget of a page.


and this is the code extract, nothing done here to change the format of the item state.
I usually try to get the display part for an item state right on the item itself e.g using pattern because then you always get the same view to an item independed where it’s displayed.

config:
  label: Fritzbox
  sidebar: true
  layoutType: responsive
  order: "2"
blocks:
  - component: oh-block
    config: {}
    slots:
      default:
        - component: oh-grid-row
          config: {}
          slots:
            default:
              - component: oh-grid-col
                config: {}
                slots:
                  default:
                    - component: oh-list-card
                      config: {}
                      slots:
                        default:
                          - component: oh-label-item
                            config:
                              item: FB9xyz_Anrufzustand
                              title: FB Anrufzustand
                              fallbackIconToInitial: true
                          - component: oh-label-item
                            config:
                              item: FB9xyz_AktiverAnruf
                              title: FB laufendes Gespräch
                              fallbackIconToInitial: true
                              icon: f7:phone_fill_arrow_right
                          - component: oh-label-item
                            config:
                              item: FB9xyz_EingehenderAnruf
                              title: FB Eingehender Anruf Nr.
                              fallbackIconToInitial: true
                              icon: f7:phone_fill_arrow_down_left
                          - component: oh-label-item
                            config:
                              item: FB9xyz_EingehenderAnrufName
                              title: FB Anrufer Name
                              fallbackIconToInitial: true
                              icon: f7:phone_fill_arrow_down_left
                          - component: oh-label-item
                            config:
                              item: FB9xyz_AusgehenderAnruf
                              title: FB Ausgehender Anruf Nr.
                              fallbackIconToInitial: true
                              icon: f7:phone_fill_arrow_up_right
                          - component: oh-label-item
                            config:
                              item: FB9xyz_AusgehenderAnrufName
                              title: FB Angerufener Name
                              fallbackIconToInitial: true
                              icon: f7:phone_fill_arrow_up_right

Here i am a bit puzzled with Item state, or displayState?
Item state is for me the state of on Item like ON/OFF or temperature value.
but what is displayState? Is it the item state after appling e.g. patterns via metadata?

I also thought that in widgets i usually get the state of items after appling metadata like patterns (if there are any for an item). But maybe this assumption is wrong.

One question is still open:
Why the JS in the Metadata - stateDescription - Pattern of the item is not apllied in case a profile is already used at the channel (in this case the phonebook profile)?
At least as i understood how OH works is that with the profile you can change the item state value and afterwords you still can change the display part with e.g. stateDescription - pattern

Don’t take things too literally out of context.
UNDEF just means Undefined, not valid.
When we are expecting some data, then it would indeed usually mean there is a problem.

Here, in your specific case, when there is no incoming call then there is no incoming caller number. It doesn’t exist. It is undefined.

Another case where you might get UNDEF which is no error; At the North Pole in midwinter, the sun does not rise. Astro binding “Sunrise” DateTime channel will set state UNDEF. There is simply no sunrise that day. Setting 00:00 would be a misleading falsity.

That just exchanges one “magic word” for another. How is OFF a more sensible value to represent a non-existent number? What if you have an old-fashioned switchboard and 0 is for operator?

If you really must do this, you have already found the means to do it using a transformation. Remember your replacement value has to be a valid state for the particular Item type (NULL and UNDEF are valid for all Item types)

Yes.
You might have a Number Item with state 3.1417, and ‘pattern’ “%.1f bananas”
In your widget, you can choose to show “3.1417” or to show “3.1 bananas”

See above.

That will change the state of the Item.

1 Like

Thanks rossko57 and sorry to bother you again as i still have some open questions

maybe 0 or OFF was not a good example it could be also idle. UNDEF gives the impression something ist not working or defined but in this case it’s just waiting for a call. But fine let’s stop this here.

That’s obvious for me, but infortunately i haven’t found the type “Call” for an item in the documentation even if you can select it for an item type in the UI. My assumtion is that it is a string just with the numbers of the call.

Here i am a bit puzzled because when i read the

https://www.openhab.org/docs/tutorial/item_widgets.html
in the section State Representation
it says

Note that the label field of an Item's definition in a .items file or the label set on the Item is not used by MainUI.

To customize the state of the Item, the "State Description" metadata must be configured. This metadata lets you define the format and any transformations to apply to the Item's state before it is displayed. When this metadata is defined, it will be used by default everywhere in MainUI.

It says as by default it should be used everywehre in MainUI an therefore i thought that the result of the State Description / pattern should be shown in a page which is not the case.
If i try to add any kind of standard widget to the metadata of an item there is also no option to select the state / display state.
Where in a widget i could select which item state should be displayed (state / displayState)?

I think it was invented specifically for Fritz and is otherwise little-used, certainly poorly documented.

Pretty sure its some kind of List.

No idea, I don’t use MainUI and glean this from others struggles.
Here’s the same trail of tears

Thanks rossko57, looks like at least for the time being i have to live with