Http item without result

i’ve defined:
Number TramMP1 “next Tram [%s]” {

Text item=TramMP1

the http result may be:
[[“3”,“Wilder Mann”,“5”],[“3”,“Coschütz”,“14”]]

The TramMP1 result should be 5, but it will show -, why? The openhab.log shows no error.

Does somebody has any idea?

Did you review a debug log? That should be the first step.

But I don’t think you can include double quotes inside the binding string.

Your regex seems to be OK, but like @namraccr pointed out with the double quotes I think there could also be a problem with what Openhab returns when regex returns groups. Never the less… there is an alternative solution. I´ve used it in a similar situation before and I´ve modified it to your data. It is just a MESSY hint, but you can test out the following in a rule.

        // get the results from the widget (simulated)
        var jsonResult = "[[\"3\",\"Coschütz\",\"3\"],[\"3\",\"Wilder Mann\",\"4\"],[\"3\",\"Coschütz\",\"12\"],[\"3\",\"Wilder Mann\",\"14\"],[\"3\",\"Coschütz\",\"20\"],[\"3\",\"Wilder Mann\",\"24\"],[\"3\",\"Coschütz\",\"29\"],[\"3\",\"Wilder Mann\",\"34\"],[\"3\",\"Coschütz\",\"39\"],[\"3\",\"Wilder Mann\",\"44\"]]"

        // get the number of returned elements
        var Number numres = Integer.parseInt(transform("JSONPATH","$.length()",jsonResult))
        var Number i = 0
        var jsonPath = ""
        var first_tram = ""
        var found = 0
        // loop through until found or end of items
        while ((i < numres) && (found == 0))
                jsonPath = String::format("$[%s][1]",i.toString())

                if (transform("JSONPATH",jsonPath,jsonResult) == "Wilder Mann")
                        jsonPath = String::format("$[%s][2]",i.toString())
                        first_tram = transform("JSONPATH",jsonPath,jsonResult)
                        found = 1

                i = i + 1

        logInfo("The first tram is :",first_tram)

@MartinKo Thank you for this suggestion. That’s the solution - it works as intended.


Text item=TramData


String TramData "Nächste Bahn in die Stadt in [%s Min.]"
String TramRawData "[%s]" {


rule "Next Tram"
    Item TramRawData changed
    var jsonResult = TramRawData.state.toString 

Cool. Thanks for sharing how you put it all together