adm105
(hjs)
November 28, 2022, 2:57am
1
Hello,
The Channel Call List from Binding TR 064 provides this information after the end of a connection and expands the 7-day list that is stored in openHAB 3 as item ‘FritzBox_CallList7’:
2022-11-25 15:41:15.966 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'FritzBox_CallList7' changed from [{"localNumber":"654321","remoteNumber":"0301234567","date":"2022-11-24T18:21:00+01","type":3,"duration":5},
{"localNumber":"654321","remoteNumber":"01727654321","date":"2022-11-24T18:19:00+01","type":1,"duration":2},
....
]
The list is sorted in descending order, most recent connection first.
How can I now filter out the values “type” and “duration” of the last connection within a rule in order to then transfer them to existing items?
I hope you can help me.
rossko57
(Rossko57)
November 28, 2022, 10:44am
2
“Last” meaning “most recent” i.e. first in the list?
Raw data appears to be JSON, so I’d use transform JSONPATH in a rule with something like $.[0].type
adm105
(hjs)
November 28, 2022, 1:18pm
3
“Last” means “last connection” and you got it right, it’s the newest one in the list.
However, I am not familiar with JSONPATH. Could she complete the following rule?
rule "Anruf beendet"
when
Item fritzCallRinging changed from DIALING to IDLE
then
here your idea please!
end
rossko57
(Rossko57)
November 28, 2022, 1:28pm
4
Suggested examples
Yes.
If you want to use the JSONPATH transformation, you’ll probably do one element at a time, because the transformation only returns one string.
Examples
You can get it to return a single string that looks like an array “[blah, bleh]” which you can parse further in your rule (e.g. split on commas) but likely easier to get one at a time.
Complex example doing that
The openHAB JSONPATH Transformation Service is an optional add-on, you will need to install it.