How do I capture data from the logs for a particular device?

Shameless request here. I am using the app IP2IR Telnet (available here) to control my Russound AV receiver using webcore. If I send the command
GET C[1].Z[6].volume

in the logs I get

I would like to be able to capture the parse S response, in this case that the volume is "0".
Any suggestions on how I might be able to capture the "0" in webcore? I want to be able to capture the data from multiple different commands. I don't know anything about Groovy. I sent a PM to the author of IP2IR Telnet for assistance, but no response.

I might be off the mark here... But if you want to look for a prefix in a log....

Is there a way to capture the log response programmatically? Ideally, I would like to for app to have a "response" attribute. Then I could parse that with Webcore. I don't think that the app supports that at present.

Not sure exactly what you are asking.... Are you saying you have a driver / app that produces a log you would like to target / capture through your own code / configuration? i.e. outside of what the app/driver provides?

Sorry, yes. The DRIVER (not app) does not have a "response" attribute. I think it would be easy to add it to the code. I just don't know how to do that. I THINK that the log indicates that a response from the command is given. I just do not currently have a way to capture and use that response.

Hmm.... Still not entirely sure how best to respond... plus probably best for others more alert than me to respond....

If you have the driver code available to you, you can hopefully find the code where the log is generated.... Then go from there.... Or Bryan can re-write the driver... :wink:

You send this after I went to bed, it's now only 7:44am. Come on! Give me a break.

I'll stop here before I say something 'bad' and get the 'flag' stick. :roll_eyes: Gshhhh.

4 Likes

Wimp.... :wink:

1 Like

Hmmm... I know there's something I should be doing.... :wink:

Sorry, no offense intended. I am just eager to get this solved.

1 Like

NOW I NEED MORE COFFEE (I spit mine out when that came up) lol

Too funny

1 Like

Yes, night owls, like me, often forget that people actually sleep during the night....

3 Likes

I'll try to take a look at this later today but to be honest I have a busy day today and I haven't looked at that code in over a year. :grin: I don't use it anymore, everything i have Is controlled over IP address now.

2 Likes

Any help would be greatly appreciated. Thanks!

That's what I read... not sure what Bryan was saying after this... but I expect he'll give you the great service we have come to expect. Now I can sleep easy.... :slight_smile:

1 Like

@Pantheon , Okay I have no idea if this will work or not since I don't have the device setup. :grin:

In the Driver make the following changes...

In Metadata - add the lastMsg and volume:

        attribute "telnet", ""
        attribute "lastMsg", ""
        attribute "volume", ""

Replace the parse code with this:

def parse(String msg) {
    if(logEnable) log.debug "parse ${msg}"
	sendEvent(name: "telnet", value: "Connected")
    if (msg == "busyIR,1:1,1") {
        runIn(1, resend)
    } else {
        sendEvent(name: "lastMsg", value: msg)
        if(msg.contains("volume")) {
            def regexformat = "(?<=\")*(?=\")"
            if(logEnable) log.debug "Pulled out Volume: ${regexformat}"
            sendEvent(name: "volume", value: regexformat)
        }
    }
}

Let me know how it goes!

3 Likes

It works!! You sir, are a rock star! Thank you so very much!

2 Likes

Thanks!

This should work with any command that kicks back a value. Just add another Attribute and a matching "if(msg.contains("thCommand")) {" block.

1 Like