Enigma2 Binding

Good Morning everybody,

I tried to run the 3th party Enigma Binding during the weekend.
Normally, this shouldn´t be a big thing. But whyever, the bundle doesn´t start.

-rwxrw-rw- 1 openhab openhab 32531 Jan 28 16:25 org.openhab.binding.enigma2_2.3.0.SNAPSHOT.jar

This is the ls -la of my addon folder. Rights should be okay? Tried several restarts, but nothing changed. I use Snapshot Build #1195.
What is wrong? Any ideas?

Sebastian

Hmmm.
It is running now. I had another download, and then it worked. Don´t understand the reason…

Can you show me an example for this script?

#!/bin/bash
enigma_ip="10.10.80.110"
openhab_ip="10.10.80.5"
openhab_item="VU_Powerstate"

case $1 in
    getPowerState)
      powerstate="$(curl -s http://$enigma_ip/web/powerstate | grep "\(<\|</\)e2instandby" | tr -d '\n' | sed "s/.*<e2instandby>\(.*\)<\/e2instandby.*/\\1/g")"
        if [ $powerstate == "true" ]; then
          curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "OFF" "http://$openhab_ip:8080/rest/items/$openhab_item"
        else
          curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "ON" "http://$openhab_ip:8080/rest/items/$openhab_item"
        fi
        ;;
    setStandby)
        curl -s http://$enigma_ip/web/powerstate?newstate=5
        ;;
    wakeFromStandby)
        curl -s http://$enigma_ip/web/powerstate?newstate=4
        ;;
    restartEnigma)
        curl -s http://$enigma_ip/web/powerstate?newstate=3
        ;;
    rebootEnigma)
        curl -s http://$enigma_ip/web/powerstate?newstate=2
        ;;
    toogleStandby)
        curl -s http://$enigma_ip/web/powerstate?newstate=1
        ;;
    *)
        echo "Kommando nicht vorhanden!"
        ;;
esac

Rule Example

executeCommandLine("/etc/openhab2/scripts/enigma.sh getPowerState")

executeCommandLine("/etc/openhab2/scripts/enigma.sh setStandby")

executeCommandLine("/etc/openhab2/scripts/enigma.sh wakeFromStandby")

executeCommandLine("/etc/openhab2/scripts/enigma.sh restartEnigma")

executeCommandLine("/etc/openhab2/scripts/enigma.sh rebootEnigma")

executeCommandLine("/etc/openhab2/scripts/enigma.sh toogleStandby")

For getPowerState make a TimeCron Rule to refresh the State if you controll outside openhab the Receiver…

Good Links for many other Commands :slight_smile:

https://dream.reichholf.net/wiki/Enigma2:WebInterface#Client_API

But i only can get the powerstatus, when the reciever is in standby or is powered on?

When the reciever is in deep standby, this rule will stop with an error?

I think in DeepStandby is the Lan Interface down … if I remember correctly :wink:

I don’t use the DeepStandby, because my VU+ is the TV Server for all AppleTVs :wink:

You can also add a function in the script, if an error occurs, for example, if the receiver is in DeepStandby, then an OpenHAB Error Item is switched to On and you get, for example, a telegram message or a voice output.

I´m no script professional :frowning:

Please can you add this to your script from the post above?

It doesn´t matter, if the receiver is off or in deep standby. When there is no connection, i want to get it shown as off.

With the current script i get many errors in openhab.log.

Yes I can add it later (tonight)… post your Errors in Logfile :slight_smile:

If i execute the script with the value getPowerState, then i get this:

(if i only execute the script with no value at the end of the command line, only the first line of the error is shown in the log “file or directory not found…”)

018-01-29 15:26:29.637 [ERROR] [lipse.smarthome.io.net.exec.ExecUtil] - couldn't execute commandLine '/etc/openhab2/scripts/enigma.sh getPowerState'

java.io.IOException: Cannot run program "/etc/openhab2/scripts/enigma.sh": error=2, Datei oder Verzeichnis nicht gefunden

	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) ~[?:?]

	at java.lang.Runtime.exec(Runtime.java:620) ~[?:?]

	at java.lang.Runtime.exec(Runtime.java:450) ~[?:?]

	at java.lang.Runtime.exec(Runtime.java:347) ~[?:?]

	at org.eclipse.smarthome.io.net.exec.ExecUtil.executeCommandLine(ExecUtil.java:65) ~[?:?]

	at org.eclipse.smarthome.model.script.actions.Exec.executeCommandLine(Exec.java:43) ~[?:?]

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]

	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:1085) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:1060) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._invokeFeature(XbaseInterpreter.java:1046) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeFeature(XbaseInterpreter.java:991) ~[?:?]

	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.invokeFeature(ScriptInterpreter.java:141) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:901) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:864) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:223) ~[?:?]

	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:215) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:826) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:263) ~[?:?]

	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:215) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:446) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:227) ~[?:?]

	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:215) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]

	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:189) ~[?:?]

	at org.eclipse.smarthome.model.script.runtime.internal.engine.ScriptImpl.execute(ScriptImpl.java:82) ~[?:?]

	at org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleEngineImpl.lambda$1(RuleEngineImpl.java:310) ~[?:?]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]

	at java.lang.Thread.run(Thread.java:748) [?:?]

Caused by: java.io.IOException: error=2, Datei oder Verzeichnis nicht gefunden

	at java.lang.UNIXProcess.forkAndExec(Native Method) ~[?:?]

	at java.lang.UNIXProcess.<init>(UNIXProcess.java:247) ~[?:?]

	at java.lang.ProcessImpl.start(ProcessImpl.java:134) ~[?:?]

	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ~[?:?]

	... 37 more

OK, found the the time to take a tcpdump. I can see that every 5 seconds the following request is made to the VU WebIf:

HTTP: GET /web/powerstate HTTP/1.1

It seems that this is too much for the little VU Zero & the python main thread does not get release after some time. Changed this value to 30 seconds & will check if the box now behaves normal.

EDIT:

When the receiver is online & TV is active there is the following request from the Openhab server, which is done every 5 seconds allthough I’ve changed the refresh intervall to 30 seconds:

GET /web/epgservice?sRef=1:0:19:283D:3FB:1:C00000:0:0:0: HTTP/1.1

EDIT2

The refresh interval value is reset to 5000ms after an restart of Openhab2 service per systemd

EDIT3

Removed binding, all caches & installed 2.3.0 Snapshot. Deleted things & discovered things again. With the VU Ultimo everthing is fine, the refresh interval set through PaperUI is respected. The VU Zero gets polled every 5 seconds regardless what is set as refresh intervall & that is the reason why I’m alway seeing a spinner. I’m quite clueless.

I think you have not create the Script or at wrong Place … Native German Speaker ? PN me …

For those who have problems with updating the items, here is my solution with a rule! :slightly_smiling_face:
(without the Enigma Binding)

Needed Binding / Transformation Service
– http-binding
– RegEx Transformation
Used Items
– enigma_power_switch <-- Switch
– enigma_power_state <-- String
– enigma_channel_state <-- String
– enigma_event_state <-- String
– enigma_eventdescription_state <-- String

var String enigma_ip = "10.10.80.110"

rule "Enigma2 State"
when
    Time cron "0/30 * * ? * * *"
then
  var String powerStateEnigmaLong = executeCommandLine("curl -s http://" + enigma_ip + "/web/powerstate", 5000)
  var String powerStateEnigma = transform("REGEX", ".*?<e2instandby>\n(.*?)\t</e2instandby>.*", powerStateEnigmaLong)
  var String ChannelStateEnigmaLong
  var String ChannelStateEnigma
  var String EventStateEnigma
  var String EventDescriptionStateEnigma

  if (powerStateEnigma == "false") {
    enigma_power_state.postUpdate("Power ON")
    if (enigma_power_switch.state != ON) enigma_power_switch.postUpdate(ON)
    Thread::sleep(1000)
    ChannelStateEnigmaLong = executeCommandLine("curl -s http://" + enigma_ip + "/web/getcurrent", 5000)
    ChannelStateEnigma = transform("REGEX", ".*?<e2servicename>(.*?)</e2servicename>.*", ChannelStateEnigmaLong)
    EventStateEnigma = transform("REGEX", ".*?<e2eventname>(.*?)</e2eventname>.*", ChannelStateEnigmaLong)
    EventDescriptionStateEnigma = transform("REGEX", ".*?<e2eventdescriptionextended>(.*?)</e2eventdescriptionextended>.*", ChannelStateEnigmaLong)
    enigma_channel_state.postUpdate(ChannelStateEnigma)
    enigma_event_state.postUpdate(EventStateEnigma)
    enigma_eventdescription_state.postUpdate(EventDescriptionStateEnigma)
  } else if (powerStateEnigma == "true") {
      enigma_power_state.postUpdate("Standby")
      if (enigma_power_switch.state != OFF) enigma_power_switch.postUpdate(OFF)
      Thread::sleep(1000)
      ChannelStateEnigmaLong = executeCommandLine("curl -s http://" + enigma_ip + "/web/getcurrent", 5000)
      ChannelStateEnigma = transform("REGEX", ".*?<e2servicename>(.*?)</e2servicename>.*", ChannelStateEnigmaLong)
      EventStateEnigma = transform("REGEX", ".*?<e2eventname>(.*?)</e2eventname>.*", ChannelStateEnigmaLong)
      EventDescriptionStateEnigma = transform("REGEX", ".*?<e2eventdescriptionextended>(.*?)</e2eventdescriptionextended>.*", ChannelStateEnigmaLong)
      enigma_channel_state.postUpdate(ChannelStateEnigma)
      enigma_event_state.postUpdate(EventStateEnigma)
      enigma_eventdescription_state.postUpdate(EventDescriptionStateEnigma)
  } else {
      enigma_power_state.postUpdate("Power OFF")
      if (enigma_power_switch.state != OFF) enigma_power_switch.postUpdate(OFF)
      enigma_channel_state.postUpdate("N/A")
      enigma_event_state.postUpdate("N/A")
      enigma_eventdescription_state.postUpdate("N/A")
  }
end

rule "Enigma2 Power Switch"
when
  Item enigma_power_switch received command
then
  var String ChannelStateEnigmaLong
  var String ChannelStateEnigma
  var String EventStateEnigma
  var String EventDescriptionStateEnigma
    if(receivedCommand == ON) {
      executeCommandLine("curl -s http://" + enigma_ip + "/web/powerstate?newstate=4")
      enigma_power_state.postUpdate("Power ON")
      Thread::sleep(1000)
      ChannelStateEnigmaLong = executeCommandLine("curl -s http://" + enigma_ip + "/web/getcurrent", 5000)
      ChannelStateEnigma = transform("REGEX", ".*?<e2servicename>(.*?)</e2servicename>.*", ChannelStateEnigmaLong)
      EventStateEnigma = transform("REGEX", ".*?<e2eventname>(.*?)</e2eventname>.*", ChannelStateEnigmaLong)
      EventDescriptionStateEnigma = transform("REGEX", ".*?<e2eventdescriptionextended>(.*?)</e2eventdescriptionextended>.*", ChannelStateEnigmaLong)
      enigma_channel_state.postUpdate(ChannelStateEnigma)
      enigma_event_state.postUpdate(EventStateEnigma)
      enigma_eventdescription_state.postUpdate(EventDescriptionStateEnigma)
    } else if(receivedCommand == OFF) {
      executeCommandLine("curl -s http://" + enigma_ip + "/web/powerstate?newstate=5")
      enigma_power_state.postUpdate("Standby")
      Thread::sleep(1000)
      ChannelStateEnigmaLong = executeCommandLine("curl -s http://" + enigma_ip + "/web/getcurrent", 5000)
      ChannelStateEnigma = transform("REGEX", ".*?<e2servicename>(.*?)</e2servicename>.*", ChannelStateEnigmaLong)
      EventStateEnigma = transform("REGEX", ".*?<e2eventname>(.*?)</e2eventname>.*", ChannelStateEnigmaLong)
      EventDescriptionStateEnigma = transform("REGEX", ".*?<e2eventdescriptionextended>(.*?)</e2eventdescriptionextended>.*", ChannelStateEnigmaLong)
      enigma_channel_state.postUpdate(ChannelStateEnigma)
      enigma_event_state.postUpdate(EventStateEnigma)
      enigma_eventdescription_state.postUpdate(EventDescriptionStateEnigma)
    }
end

Play with the Time cron to find the best Solution for your SetUp … the Time cron in this Example corresponds to a refresh interval of 30 seconds

Every 15 seconds

Time cron "0/15 * * ? * * *"

Every 30 seconds

Time cron "0/30 * * ? * * *"

Every 45 seconds

Time cron "0/45 * * ? * * *"

Every 60 seconds

Time cron "0 * * ? * * *"

Hi Kevin,

could you please show how you have defined
– enigma_power_switch <-- Switch
– enigma_power_state <-- String
– enigma_channel_state <-- String
– enigma_event_state <-- String
– enigma_eventdescription_state <-- String

Would be great. Thanks.

Switch enigma_power_switch "VUplus WZ Power"
String enigma_power_state "VUplus WZ Power State"
String enigma_channel_state "VUplus WZ Channel"
String enigma_event_state "VUplus WZ Event"
String enigma_eventdescription_state "VUplus WZ Event Description"

Hi Kevin,
Thank you. I copied the items to my .items file and the rules to my .rules file, and changed the IP-address of my Solo.4K accordingly. By the way: where I have to put in the “var” declaration? But it does not work at all. Can you help me getting it to work? How do you use it in you setup?

Remark: in openhab.log rhe following message occurs regarding the “var” declaration:

2018-02-11 11:10:22.421 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘meine.rules’ has errors, therefore ignoring it: [314,1]: missing EOF at ‘var’

What am I doing wrong here?

Put this Line on the Top of your Rules file … than it work :slight_smile:

var String enigma_ip = "10.10.80.110"

Hm…, now I get these messages:

2018-02-11 17:41:32.318 [WARN ] [lipse.smarthome.io.net.exec.ExecUtil] - Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program “curl” (in directory “.”): CreateProcess error=2, Das System kann die angegebene Datei nicht finden)
2018-02-11 17:42:00.089 [WARN ] [lipse.smarthome.io.net.exec.ExecUtil] - Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program “curl” (in directory “.”): CreateProcess error=2, Das System kann die angegebene Datei nicht finden)
2018-02-11 17:42:30.076 [WARN ] [lipse.smarthome.io.net.exec.ExecUtil] - Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program “curl” (in directory “.”): CreateProcess error=2, Das System kann die angegebene Datei nicht finden)

sudo apt-get install curl

I’m on Windows. Do you have an idea how to install it on Windows?

No … Windows sucks :wink: