ASH 2200 with USB-WDE1-2 supported?

Hi all,

I’m currently looking for a tool to realize my current, very basic, home automation and to extend it in the future.

As I read, openHAB is currently supporting intertechno actors, which is very nice, as I’m going to extend my home automation with actors for my alectric shutters.

But the first step would be to integrate my temperature and humidity sensors: ELV ASH 2200. I have three of them (living, bed and bath room) and currently read them with a very native script on my raspberry pi, self-written in python. The script works 90% of the time but sometimes breaks and was mainly written for testing.

I read the sensor data with an ELV USB-WDE1-2 box that was connected to the raspberry pi via usb.

Is it possible to read the data with openHAB, too? What I didn’t understand in the documentation: Does openHAB also provide an “anlysis view”? I mean, I cannot make any adjustments on my temperature / humidity values like switching something on or off at the sensors, but only want to see the current values or perhaps a chart for each room.

Hopefully you got, what I mean. Would be kind, if you could let me know - also if this is natively supported or by an add-on.

Thanks and kind regards,

Dirk

OH supports Persistence which will save an item’s state to a database. It also supports simple graphing. For more complex graphing and and analysis search the forum for “influxdb+grafana”.

You can use the exec binding to call your script. I don’t know if there is a binding for this service.

Hello rlkoshak,

thanks for your response. Using my script with OpenHab’s exec binding seems to be an option.

One additional question:

  • Is there some kind of scheduler which I can use to run my script every 10 milliseconds or as an endless loop?

The problem is, that the sensors are “stupid” and it’s not possible to access them via the receiver, but the receiver must wait until the sensors send their temperature / humidity values and so I’m not sure, when exactly the info is available. That’s why and endless loop must run and check for for new sensor values.

I’d like to clarify this questions before re-installing my raspberry pi with OpenHabian.

Thanks and kind regards,

Dirk

So the answer is a qualified yes.

10 milliseconds is a really short time for OH rules. 100 milliseconds is a little more doable but still really short and will potentially drive up the CPU utilization and potentially cause other resource problems.

Personally, I would move the loop to your python script and have the python script push the data into OH using the REST API or MQTT. I use this approach to get remotely hosted sensor data into OH. See:

I use the rpiGPIOSensor module to check the GPIO pins every 10 msec and only report changes to OH using MQTT, though there is a REST publisher as well which I think still works with OH 2. If not and you want to use it let me know and I can quickly fix it.

Having said all of that, one can trigger the execution of Rules using a cron trigger but the lowest resolution there is every second. Inside of a rule, you have the full range of programming options and can create forever loops and sleeps and such, though I’m not sure what impact it would have to tie up a rule’s thread forever like that which is why I recommend putting the loop in your python script.

Thanks a lot for your response.
Wouldn’t be a bigger issue to run the endless loop from my script and to check e.g. every five minutes via OpenHab Scheduler, if the script is still running or to restart it.

I’d try as next steps to install OpenHabian on my Raspberry Pi (hopefully next week).

Thanks and kind regards,

Dirk

I don’t understand this statement.

If you are worried about making sure OH knows your script is still running, then there are lots of ways it can figure that out without needing to poll for its online status, particularly if you used MQTT.

I use the following to determine and alert when my external scripts and services go offline:

First I created a Group:

Group:Switch:AND(ON, OFF) gSensorStatus

Then I create an Online Item to track the online status of a single server or device I care about. When I’m receiving messages via MQTT then I just subscribe to the same topic and any message received on the topic will set the online status to ON. then I use an exipre binding config to make the Item turn OFF when it hasn’t been updated after a certain period of time.

Switch vCerberos_SensorReporter_Online "Cerberos sensorReporter [MAP(admin.map):%s]"
    <network> (gSensorStatus)
    { mqtt="<[mosquitto:status/sensor-reporters:command:OFF:.*cerberos sensorReporter is dead.*],<[mosquitto:status/cerberos/heartbeat/string:command:ON]", expire="11m,command=OFF" }

The above Item subscribes to one of the topics sensorReporter (see link above) publishes to periodically and expires when no message is received for 11 minutes.

If you can’t do something like this you will need a rule to update the Online Item. See the Generic Is Alive Deisgn Pattern for one approach.

Then I have the following rules which will send an alert to me when any member of gSensorStatus goes OFF along with an alert when OH restarts and in the morning listing all the offline devices.

import java.util.concurrent.locks.ReentrantLock
import java.util.Map

val ReentrantLock statusLock = new ReentrantLock
val Map<String, Timer> timers = newHashMap

rule "A sensor changed its online state"
when
	Item gSensorStatus received update
then
    try {
    	statusLock.lock
    	Thread::sleep(100)
    	val recentUpdates = gSensorStatus.members.filter[sensor|sensor.lastUpdate("mapdb") != null && sensor.lastUpdate("mapdb").isBefore(now.minusSeconds(1).millis)]

    	recentUpdates.forEach[sensor|
    		val alerted = gOfflineAlerted.members.filter[a|a.name==sensor.name+"_Alerted"].head
    		if(alerted == null) logError("admin", "Cannot find Item " + sensor.name+"_Alerted")
    		
    		if(alerted != null && alerted.state == sensor.state && timers.get(sensor.name) == null){
    			val currState = sensor.state
    			// wait a few seconds and check again before sending alert
    			timers.put(sensor.name, createTimer(now.plusSeconds(15), [|
    				if(sensor.state == currState) {
		    			aInfo.sendCommand(transform("MAP", "admin.map", sensor.name) + " is now " + transform("MAP", "admin.map", sensor.state.toString) + "!")
		    			alerted.postUpdate(if(sensor.state == ON) OFF else ON)   					
    				}
    			]))
    		}
    	]
    }
    catch(Exception e){
    	logError("admin", "Error processing an online status change: " + e.toString)
    }
    finally {
    	statusLock.unlock
    }
end
 
rule "Reminder at 08:00 and system start"
when
	Time cron "0 0 8 * * ? *" or
	System started
then
    val message = new StringBuilder 
    
    val offline = gSensorStatus.members.filter[sensor|sensor.state != ON]
    if(offline.size > 0) {
    	message.append("The following sensors are offline: ")
    	offline.forEach[sensor|
    		message.append(transform("MAP", "admin.map", sensor.name))
    		message.append(", ")
            gOfflineAlerted.members.filter[a|a.name==sensor.name+"_Alerted"].head.postUpdate(ON)
    	]
    	message.delete(message.length-2, message.length)
    	aInfo.sendCommand(message.toString)
    }
end 

Everything is event driven and therefore requires no polling.

Could you please share the code you created ?

Thanks
Michael