Query my sat-receiver only when it`s online

hi,
I query my VU+ SATreceiver via http:
items:
String VU_Sendung “Aktuelle Sendung [%s]” (VU)|{ http="<[http://192.168.1.150:80/web/getcurrent:3000:REGEX(.?(.?).)]" }
String VU_Kanal “Sender [%s]” (VU)|{ http="<[http://192.168.1.150:80/web/getcurrent:3000:REGEX(.
?(.?).)]" }
this is working great, but most of the time the VU+ is offline, so the events.log from openhab is filled with errormessages…

finding some hints in the forum, I could use a virtual switch to check whether the VU+ is on or offline.

Switch SATreceiver “vu” {channel=“network:pingdevice:192_168_1_150:online”}

so, but how do I implement a rule that continiously runs as long as the VU+ is online?
the rule just fires once when the receiver turns on, but if I switch the channel the rule somehow has to run again to get updates.

rule “VU auslesen”

when
Item SATreveicer received update ON

then
var Sendung = http="<[http://192.168.1.150:80/web/getcurrent:3000:REGEX(.?(.?).)]“
var Kanal = http=”<[http://192.168.1.150:80/web/getcurrent:3000:REGEX(.
?(.?).)]"

end

can someone help me on the correct items and rules to get my usecase done?
thanks

please use code fences (one of the buttons on the right) - makes it easier to read rules and items.

Do I understand correctly, that your usecase is to query the SatReceiver on the current channel and current segment to be written in a String? I guess, the Receiver isn’t capable of sending those information “onchange” by itself - so you have to make a rule, which makes that querys periodically-

  1. Change the trigger of the rule to a cron interval of your Needs
  2. place the SATreceiver == ON in a if clause within the then section
  3. your good to go!

thanks, one step further but still not there

rule "VU auslesen"

when 
        Time cron "0 0/5 * * * ?"  //every 5 minutes

then 
        if (SATreceiver.state == ON) {
        var Sendung = http="<[http://192.168.1.150:80/web/getcurrent:3000:REGEX(.*?<e2eventname>(.*?)</e2eventname>.*)]" 
        var Kanal = http="<[http://192.168.1.150:80/web/getcurrent:3000:REGEX(.*?<e2servicename>(.*?)</e2servicename>.*)]" }
        VU_Sendung.postUpdate(Sendung)
        VU_Kanal.postUpdate(Kanal)
end

I changed the items to

String  VU_Sendung  "Aktuelle Sendung [%s]"     (VU)
String  VU_Kanal    "Sender [%s]"               (VU)

how do I convert the result from the variable to the item so I can display it in the sitemap?

you already done this in the rule. it should be present in sitemap also.but please, fill in some debug-messages and tell us, what’s in the logs:

rule "VU auslesen"

when 
        Time cron "0 0/5 * * * ?"  //every 5 minutes

then 
        if (SATreceiver.state == ON) {
                var Sendung = http="<[http://192.168.1.150:80/web/getcurrent:3000:REGEX(.*?<e2eventname>(.*?)</e2eventname>.*)]" 
                var Kanal = http="<[http://192.168.1.150:80/web/getcurrent:3000:REGEX(.*?<e2servicename>(.*?)</e2servicename>.*)]" }
                logInfo("satrule", "Sendung und Kanal: " + Sendung + ", " + Kanal)
                VU_Sendung.postUpdate(Sendung)
                VU_Kanal.postUpdate(Kanal)
        }
end

hint: My guess is, you missed the last } for the if-clause.
Therefore: Rule #1 always, always check the logs if you changed something.

the error shows:
2018-02-22 10:55:00.646 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule ‘VU auslesen’: An error occurred during the script execution: Couldn’t invoke ‘assignValueTo’ for feature JvmVoid: (eProxyURI: VUnotification.rules#|::0.2.1.2.0.0.1.0.0.2::0::/1)

I tried to replace var with val without success. can you decipher that message?

at first - see var/val: but that’s irrelevant in this context.

As you wrote, the rule worked for you, I didn’t look any further, but the Syntax

                var Kanal = http="<[http://192.168.1.150:80/web/getcurrent:3000:REGEX(.*?<e2servicename>(.*?)</e2servicename>.*)]" }

can’t work for two reasons:

  1. you’re using Ìtem syntax in a rule
  2. you have a } which doesn’t belong at the end of that line.

ad 1)
within a rule, you can’t just use the Syntax from a binding. if you’d like to have http-functionality within a rule - you have to use http-action: https://docs.openhab.org/addons/actions.html#http-actions
in your case:

  1. sendHttpGetRequest(String url)
  2. use var temperature = transform("JSONPATH", "$.temperature", jsonstring) to transform your JSON (https://docs.openhab.org/addons/transformations.html#usage)

ad 2)
just remove it: