This page last changed on Apr 13, 2013 by sadgamergeek.

Hi,

I'm very new to OpenRemote. I've set-up the Controller (2.0.1) on my Raspberry Pi, and I'm trying to make some panels for my iPad. So far I've successfully created some buttons that run simple perl scripts to turn on & off my LightWaveRF sockets and wake a server, but now I want to do some monitoring.

I thought I'd start simple, so I've created a very basic script which converts a ping response to "on" or "off" when I call it with a host name:

pi@raspberrypi /usr/local/scripts $ ./ping_on_off.sh sb_dining
off

It also writes a line to a log file so I can see when it has been called.

I've created a command "SB DR on off detect" that runs it using shell execution protocol. I've linked a button to that, and I have confirmed (via the log file) that it successfully runs the script.

I can't work out how to integrate it into a sensor though. I've set a sensor name of "sb_dining" in that command and a polling interval of 2s, then I've created a sensor called "sb_dining". Is that correct? I've tried to use that sensor in a switch and a label, but can't get any sensible output out of them. I can see from the log that the script never even gets called when used with a sensor like this.

The catalina.out log shows this:

Apr 13, 2013 5:45:14 PM org.openremote.controller.utils.Logger error
SEVERE: Attempted to access sensor with id '162' which did not exist in device state cache.

Something else I don't understand is that the controller.xml file hasn't been updated with the last few saves I've made - is that normal?

Here it is, including various objects that I've recently deleted for some reason....

<?xml version="1.0" encoding="UTF-8"?>
<openremote xmlns="http://www.openremote.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openremote.org http://www.openremote.org/schemas/controller.xsd">
  <components>
    <switch id="52">
      <on />
      <off />
    </switch>
    <switch id="142">
      <on>
        <include type="command" ref="146" />
      </on>
      <off>
        <include type="command" ref="147" />
      </off>
      <include type="sensor" ref="162" />
    </switch>
    <button id="102" />
    <button id="136">
      <include type="command" ref="159" />
    </button>
    <button id="100" />
    <button id="116">
      <include type="command" ref="159" />
    </button>
    <button id="114">
      <include type="command" ref="148" />
    </button>
    <button id="110">
      <include type="command" ref="147" />
    </button>
    <button id="108">
      <include type="command" ref="146" />
    </button>
    <button id="122">
      <include type="command" ref="144" />
    </button>
    <button id="104" />
    <button id="120">
      <include type="command" ref="145" />
    </button>
    <image id="118" />
    <image id="112" />
    <image id="106">
      <include type="sensor" ref="161" />
    </image>
    <label id="138">
      <include type="sensor" ref="162" />
    </label>
    <label id="98" />
    <label id="140">
      <include type="sensor" ref="162" />
    </label>
    <label id="128" />
    <label id="134">
      <include type="sensor" ref="162" />
    </label>
  </components>
  <sensors>
    <sensor id="161" name="bob" type="custom">
      <include type="command" ref="160" />
    </sensor>
    <sensor id="162" name="sb_dining" type="switch">
      <include type="command" ref="159" />
      <state name="on" />
      <state name="off" />
    </sensor>
    <sensor id="174" name="ON/OFF_sb_dining" type="switch">
      <include type="command" ref="159" />
      <state name="on" />
      <state name="off" />
    </sensor>
  </sensors>
  <commands>
    <command id="144" protocol="shellexe">
      <property name="commandParams" value="R1D1F0" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Hall lamp OFF" />
    </command>
    <command id="145" protocol="shellexe">
      <property name="commandParams" value="R1D1F1" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Hall lamp ON" />
    </command>
    <command id="146" protocol="shellexe">
      <property name="commandParams" value="R2D1F1" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="SB DR on" />
    </command>
    <command id="147" protocol="shellexe">
      <property name="commandParams" value="R2D1F0" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="SB DR off" />
    </command>
    <command id="148" protocol="shellexe">
      <property name="commandParams" value="R3D1F1" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Kitchen Coffee Maker ON" />
    </command>
    <command id="149" protocol="shellexe">
      <property name="commandParams" value="R3D1F0" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Kitchen Coffee Maker OFF" />
    </command>
    <command id="150" protocol="shellexe">
      <property name="commandParams" value="R3D2F1" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Kitchen HiFi ON" />
    </command>
    <command id="151" protocol="shellexe">
      <property name="commandParams" value="R3D?F0" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Kitchen HiFi OFF" />
    </command>
    <command id="153" protocol="shellexe">
      <property name="commandParams" value="R1D1F0" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Hall Lamp OFF" />
    </command>
    <command id="154" protocol="shellexe">
      <property name="commandParams" value="R?D?F?" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="** dummy LWRF switch" />
    </command>
    <command id="159" protocol="shellexe">
      <property name="commandParams" value="sb_dining" />
      <property name="pollingInterval" value="2s" />
      <property name="sensorNamesList" value="sb_dining" />
      <property name="commandPath" value="/usr/local/scripts/ping_on_off.sh" />
      <property name="name" value="SB DR on off detect" />
    </command>
    <command id="160" protocol="shellexe">
      <property name="commandParams" value="HELLOOOOOOOO" />
      <property name="pollingInterval" value="1s" />
      <property name="sensorNamesList" value="bob" />
      <property name="commandPath" value="/bin/echo " />
      <property name="name" value="test" />
    </command>
    <command id="143" protocol="wol">
      <property name="broadcastIp" value="192.168.0.255" />
      <property name="macAddress" value="00:21:85:f:91:e8" />
      <property name="name" value="Wakeup - HomeServer" />
    </command>
  </commands>
  <config>
    <property name="controller.roundrobin.multicast.port" value="10000" />
    <property name="controller.roundrobin.tcpserver.port" value="20000" />
    <property name="controller.groupname" value="floor20" />
    <property name="multicast.port" value="3333" />
    <property name="controller.groupmember.autodetect.on" value="true" />
    <property name="amx_ni.port" value="50000" />
    <property name="zwave.commLayer" value="" />
    <property name="copy.lircd.conf.on" value="true" />
    <property name="irsend.path" value="/usr/local/bin/irsend" />
    <property name="controller.applicationname" value="controller" />
    <property name="multicast.address" value="224.0.1.100" />
    <property name="Macro.IR.Execution.Delay" value="500" />
    <property name="controller.roundrobin.multicast.address" value="224.0.1.200" />
    <property name="zwave.comPort" value="" />
    <property name="zwave.pad.port" value="7876" />
    <property name="lutron_homeworks.password" value="openremote" />
    <property name="lircd.conf.path" value="/etc/lircd.conf" />
    <property name="lutron_homeworks.port" value="23" />
    <property name="lutron_homeworks.address" value="192.168.1.1" />
    <property name="zwave.pad.host" value="localhost" />
    <property name="lutron_homeworks.username" value="openremote" />
    <property name="webapp.port" value="8080" />
    <property name="protocol.zwave.classname" value="org.openremote.controller.protocol.zwave.ZWaveCommandBuilder" />
    <property name="resource.upload.enable" value="true" />
    <property name="amx_ni.address" value="192.168.1.1" />
    <property name="lagarto_network.broadcast" value="tcp://127.0.0.1:5001" />
  </config>
</openremote>

Can anyone explain what I'm doing wrong please?

Richard

If the controller.xml does not update with controller you can try it manually.

  • In designer export your design as ZIP
  • Extract this zip to directory webapps/controller.

PS: Please include your XML in {code:xml}...{code} tags, tag logs with {code}...{code} for better reading

Posted by pz1 at Apr 13, 2013 21:18

Thanks. I've now edited my original post to include those tags.

I've done the manual export / extract and after doing that subsequent syncs seem to have worked.

I'm still getting the same error though (different IDs now as I've deleted some stuff)

ERROR [HTTP-Thread-12]: CommandException occurs
org.openremote.controller.exception.NoSuchComponentException: No such component in status cache : 159
<?xml version="1.0" encoding="UTF-8"?>
<openremote xmlns="http://www.openremote.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openremote.org http://www.openremote.org/schemas/controller.xsd">
  <components>
    <switch id="52">
      <on />
      <off />
    </switch>
    <switch id="142">
      <on>
        <include type="command" ref="148" />
      </on>
      <off>
        <include type="command" ref="149" />
      </off>
      <include type="sensor" ref="159" />
    </switch>
    <button id="102" />
    <button id="136">
      <include type="command" ref="158" />
    </button>
    <button id="100" />
    <button id="116">
      <include type="command" ref="158" />
    </button>
    <button id="114">
      <include type="command" ref="150" />
    </button>
    <button id="110">
      <include type="command" ref="149" />
    </button>
    <button id="108">
      <include type="command" ref="148" />
    </button>
    <button id="122">
      <include type="command" ref="146" />
    </button>
    <button id="104" />
    <button id="120">
      <include type="command" ref="147" />
    </button>
    <image id="118" />
    <image id="112" />
    <image id="106" />
    <label id="138">
      <include type="sensor" ref="159" />
    </label>
    <label id="98" />
    <label id="140">
      <include type="sensor" ref="159" />
    </label>
    <label id="128" />
    <label id="134">
      <include type="sensor" ref="159" />
    </label>
  </components>
  <sensors>
    <sensor id="159" name="sb_dining" type="switch">
      <include type="command" ref="158" />
      <state name="on" />
      <state name="off" />
    </sensor>
  </sensors>
  <commands>
    <command id="146" protocol="shellexe">
      <property name="commandParams" value="R1D1F0" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Hall lamp OFF" />
    </command>
    <command id="147" protocol="shellexe">
      <property name="commandParams" value="R1D1F1" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Hall lamp ON" />
    </command>
    <command id="148" protocol="shellexe">
      <property name="commandParams" value="R2D1F1" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="SB DR on" />
    </command>
    <command id="149" protocol="shellexe">
      <property name="commandParams" value="R2D1F0" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="SB DR off" />
    </command>
    <command id="150" protocol="shellexe">
      <property name="commandParams" value="R3D1F1" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Kitchen Coffee Maker ON" />
    </command>
    <command id="151" protocol="shellexe">
      <property name="commandParams" value="R3D1F0" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Kitchen Coffee Maker OFF" />
    </command>
    <command id="152" protocol="shellexe">
      <property name="commandParams" value="R3D2F1" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Kitchen HiFi ON" />
    </command>
    <command id="153" protocol="shellexe">
      <property name="commandParams" value="R3D2F0" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Kitchen HiFi OFF" />
    </command>
    <command id="155" protocol="shellexe">
      <property name="commandParams" value="R1D1F0" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Hall Lamp OFF" />
    </command>
    <command id="156" protocol="shellexe">
      <property name="commandParams" value="R?D?F?" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="** dummy LWRF switch" />
    </command>
    <command id="158" protocol="shellexe">
      <property name="commandParams" value="sb_dining" />
      <property name="pollingInterval" value="2s" />
      <property name="sensorNamesList" value="sb_dining" />
      <property name="commandPath" value="/usr/local/scripts/ping_on_off.sh" />
      <property name="name" value="SB DR on off detect" />
    </command>
    <command id="145" protocol="wol">
      <property name="broadcastIp" value="192.168.0.255" />
      <property name="macAddress" value="00:21:85:f:91:e8" />
      <property name="name" value="Wakeup - HomeServer" />
    </command>
  </commands>
  <config>
    <property name="controller.roundrobin.multicast.port" value="10000" />
    <property name="controller.roundrobin.tcpserver.port" value="20000" />
    <property name="controller.groupname" value="floor20" />
    <property name="multicast.port" value="3333" />
    <property name="controller.groupmember.autodetect.on" value="true" />
    <property name="amx_ni.port" value="50000" />
    <property name="zwave.commLayer" value="" />
    <property name="copy.lircd.conf.on" value="true" />
    <property name="irsend.path" value="/usr/local/bin/irsend" />
    <property name="controller.applicationname" value="controller" />
    <property name="multicast.address" value="224.0.1.100" />
    <property name="Macro.IR.Execution.Delay" value="500" />
    <property name="controller.roundrobin.multicast.address" value="224.0.1.200" />
    <property name="zwave.comPort" value="" />
    <property name="zwave.pad.port" value="7876" />
    <property name="lutron_homeworks.password" value="openremote" />
    <property name="lircd.conf.path" value="/etc/lircd.conf" />
    <property name="lutron_homeworks.port" value="23" />
    <property name="lutron_homeworks.address" value="192.168.1.1" />
    <property name="zwave.pad.host" value="localhost" />
    <property name="lutron_homeworks.username" value="openremote" />
    <property name="webapp.port" value="8080" />
    <property name="protocol.zwave.classname" value="org.openremote.controller.protocol.zwave.ZWaveCommandBuilder" />
    <property name="resource.upload.enable" value="true" />
    <property name="amx_ni.address" value="192.168.1.1" />
    <property name="lagarto_network.broadcast" value="tcp://127.0.0.1:5001" />
  </config>
</openremote>
Posted by sadgamergeek at Apr 14, 2013 00:26

I'am afraid I can't help you with this one. My non-expert eye does not spot anything wrong in your XML. Maybe the error is caused by something deeper.
I have done some things with ping myself. I found this thread on using ping and shelexe useful.

Posted by pz1 at Apr 14, 2013 09:33

That's a useful thread, cheers.

I've also made a little bit of progress. When searching the site for "status cache", I noticed that there is a newer release of the controller, 2.0.2, which includes this:

Bug fix: sensor status cache was throwing a runtime exception
   which was not handled if a panel requested a sensor status on
   a sensor which failed to start (due to configuration or
   other errors). The unhandled exception caused the client
   call to fail instead of gracefully falling back to default or
   error value. (Eric Bariaux, ORCJAVA-268)

That sounded like it might be relevant, so I installed it. My sensor still doesn't work, but the logs provide a bit more information now.

This what I see when I open the console now:

Apr 14, 2013 11:12:15 AM org.openremote.controller.utils.Logger error
SEVERE: Requested sensor id '157' was not found. Defaulting to 'N/A'.
Apr 14, 2013 11:12:15 AM org.openremote.controller.utils.Logger info
INFO: Querying changed state from ChangedStatus table...
Apr 14, 2013 11:12:15 AM org.openremote.controller.utils.Logger info
INFO: Found: [device => 27109eff1600a6a5f771dcf8ac7ebc4188fbaebc, sensorIDs => 157] in ChangedStatus table.
Apr 14, 2013 11:12:15 AM org.openremote.controller.utils.Logger info
INFO: DEVICEID:27109eff1600a6a5f771dcf8ac7ebc4188fbaebc sensorID:[157]statusChangedSensorID:[]Waiting...

...and sure enough I see "N/A" in my console now where I'm trying to display the sensor output (previously I was seeing nothing or just label text).

As before, my log tells me the script associated with the sensor is not even being run.

I don't understand why it can't find the sensor though, when it appears in the xml:

  <components>
    <switch id="52">
      <on />
      <off />
    </switch>
    <switch id="142">
      <on>
        <include type="command" ref="146" />
      </on>
      <off>
        <include type="command" ref="147" />
      </off>
      <include type="sensor" ref="157" />
    </switch>
    <button id="102" />
    <button id="136">
      <include type="command" ref="156" />
    </button>
    <button id="100" />
    <button id="116">
      <include type="command" ref="156" />
    </button>
    <button id="114">
      <include type="command" ref="148" />
    </button>
    <button id="110">
      <include type="command" ref="147" />
    </button>
    <button id="108">
      <include type="command" ref="146" />
    </button>
    <button id="122">
      <include type="command" ref="144" />
    </button>
    <button id="104" />
    <button id="120">
      <include type="command" ref="145" />
    </button>
    <image id="118" />
    <image id="112" />
    <image id="106" />
    <label id="138">
      <include type="sensor" ref="157" />
    </label>
    <label id="98" />
    <label id="140">
      <include type="sensor" ref="157" />
    </label>
    <label id="128" />
    <label id="134">
      <include type="sensor" ref="157" />
    </label>
  </components>
  <sensors>
    <sensor id="157" name="sb_dining" type="switch">
      <include type="command" ref="156" />
      <state name="on" />
      <state name="off" />
    </sensor>
  </sensors>
  <commands>
    <command id="144" protocol="shellexe">
      <property name="commandParams" value="R1D1F0" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Hall lamp OFF" />
    </command>
    <command id="145" protocol="shellexe">
      <property name="commandParams" value="R1D1F1" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Hall lamp ON" />
    </command>
    <command id="146" protocol="shellexe">
      <property name="commandParams" value="R2D1F1" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="SB DR on" />
    </command>
    <command id="147" protocol="shellexe">
      <property name="commandParams" value="R2D1F0" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="SB DR off" />
    </command>
    <command id="148" protocol="shellexe">
      <property name="commandParams" value="R3D1F1" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Kitchen Coffee Maker ON" />
    </command>
    <command id="149" protocol="shellexe">
      <property name="commandParams" value="R3D1F0" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Kitchen Coffee Maker OFF" />
    </command>
    <command id="150" protocol="shellexe">
      <property name="commandParams" value="R3D2F1" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Kitchen HiFi ON" />
    </command>
    <command id="151" protocol="shellexe">
      <property name="commandParams" value="R3D2F0" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Kitchen HiFi OFF" />
    </command>
    <command id="153" protocol="shellexe">
      <property name="commandParams" value="R1D1F0" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="Hall Lamp OFF" />
    </command>
    <command id="154" protocol="shellexe">
      <property name="commandParams" value="R?D?F?" />
      <property name="commandPath" value="/usr/local/scripts/LWRF_switch.pl" />
      <property name="name" value="** dummy LWRF switch" />
    </command>
    <command id="156" protocol="shellexe">
      <property name="commandParams" value="sb_dining" />
      <property name="pollingInterval" value="2s" />
      <property name="sensorNamesList" value="sb_dining" />
      <property name="commandPath" value="/usr/local/scripts/ping_on_off.sh" />
      <property name="name" value="SB DR on off detect" />
    </command>
    <command id="143" protocol="wol">
      <property name="broadcastIp" value="192.168.0.255" />
      <property name="macAddress" value="00:21:85:f:91:e8" />
      <property name="name" value="Wakeup - HomeServer" />
    </command>
  </commands>
Posted by sadgamergeek at Apr 14, 2013 12:18

I am afraid the 2.0.1 controller does not include the ShellExe that supports sensors
Try the 2.1.0 Alpha-Snapshot.

Posted by mredeker at Apr 14, 2013 20:52

Excellent - cheers. That made a big difference!

The script associated with the sensor is getting run now.

I'm almost there, but it looks like there is one last (hopefully simple) issue. OR doesn't seem to like the output of my script:

Apr 14, 2013 11:17:34 PM org.openremote.controller.utils.Logger warn
WARNING: Event producer bound to sensor (ID = 157) returned a value that is not consistent with sensor's datatype : 'yes'  setting sensor value to 'N/A'

This happens for yes and no. I've tried it with and without the newline character, but it doesn't seem to like either.

The switch sensor is defined like this:

  <sensors>
    <sensor id="157" name="sb_dining" type="switch">
      <include type="command" ref="156" />
      <state name="on" />
      <state name="off" />
    </sensor>
  </sensors>

...and my simple script looks like this:

#!/bin/bash
onOff=$((ping -c 1 -W 1 $1 >/dev/null && echo yes) || echo no)
printf "${onOff}"
echo `date` $1 $onOff >> /usr/local/scripts/$(basename $0)_log

(currently with no newline but same issue with

printf "${onOff}\n"
)

Posted by sadgamergeek at Apr 15, 2013 00:25

Your script has to return "on" or "off" and not "yes" or "no" if you use a switch sensor.
If you only want to display sensor values, you can use a custom sensor which accepts any text.

Posted by mredeker at Apr 15, 2013 09:37

What an idiot I am!

Yeah, of course you're right Marcus. Stupidly, I knew this, even my script name and variable refer to 'on' & 'off'. For some reason when I made the last "tweak" to it (change from using regular expression to return code) I somehow had a brain fart and replaced on & off with yes & no.

That has fixed that - thanks very much for your patient help.

One other thing (there's always one more thing...). I'm not sure if it was when I went to 2.1, but my linkage between my buttons and commands appears to have got screwed up now. I've got 3 pairs of on & off buttons to turn on and off 3 different devices (LightwaveRF power sockets). Each button calls a different command (which in turn call one script with a unique parameter). I realised last night that all three on buttons are calling the same on command and all three off ones are calling the same off command! They are correct in the UI designer, but I guess the sync is muddling them up somehow. It wouldn't be a big deal to delete the 4 wrong ones and recreate them but I wondered if it might be useful if I / we could work out what was going wrong.

Should I perhaps create a new thread to talk about this? I guess it could be a 2.1 alpha issue....

Posted by sadgamergeek at Apr 15, 2013 10:46

A new thread would make it easier to follow.
Might be an issue in the designer when creating the controller.xml.

Posted by mredeker at Apr 15, 2013 12:38

Cheers. I've now created a new one.

Posted by sadgamergeek at Apr 15, 2013 16:59
Document generated by Confluence on Jun 05, 2016 09:42