I recently upgraded from OH 2.2 branch to OH 3.1.0. By doing so, I lost the ability to control my Denkovi relay.
I’ve asked for support from the relay manufacturer as they have necessary items, rules, transform and sitemap files to work with previous OH versions, but they are completely ignoring me - so I’m not expecting any help from there.
I would like to stick with the OH3 and before going back to OH2.2 I decided to ask for help.
The relay has ability to use HTTP (GET) and SNMP in reading the status and altering the outputs.
So far I’ve tried creating things, items via UI and by textual input, but seems I’m way too stupid to make it work.
By using the SNMP, I was able to retrieve the state, but not change the output state, and by using HTTP I didn’t get anything out, or in for that matter…
So as I obviously was closer by using SNMP, I’ll take that as base point how to make it work.
I currently have this as .things file:
Thing snmp:target:smartden [ hostname="192.168.2.200", port="1610", community="private", protocol="v2c" ] {
Channels:
Type string : Relay1 [ oid=".1.3.6.1.4.1.42505.8.2.3.1.13.0", mode="READ_WRITE", datatype="UINT32", onvalue="ON", offvalue="OFF" ]
Type string : Temp1 [ oid=".1.3.6.1.4.1.42505.8.2.2.1.10.4", mode="READ" ]
Type number : RelayState [ oid=".1.3.6.1.4.1.42505.8.3.2.0", mode="READ" ]
}
Items:
Switch Relay1 "Rantavalo" {channel="snmp:target:smartden:Relay1"}
String Temp1 "Takakuistin lämpötila" {channel="snmp:target:smartden:Temp1"}
Number RelayState {channel="snmp:target:smartden:RelayState"}
Rules:
// Imports
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.eclipse.smarthome.model.sitemap.*
rule "DIState"
when
Item DI received update
then
if((DI.state as DecimalType).intValue.bitwiseAnd(0x01)==0x01) DI1.postUpdate("ON") else DI1.postUpdate("OFF")
if((DI.state as DecimalType).intValue.bitwiseAnd(0x02)==0x02) DI2.postUpdate("ON") else DI2.postUpdate("OFF")
if((DI.state as DecimalType).intValue.bitwiseAnd(0x04)==0x04) DI3.postUpdate("ON") else DI3.postUpdate("OFF")
if((DI.state as DecimalType).intValue.bitwiseAnd(0x08)==0x08) DI4.postUpdate("ON") else DI4.postUpdate("OFF")
if((DI.state as DecimalType).intValue.bitwiseAnd(0x10)==0x10) DI5.postUpdate("ON") else DI5.postUpdate("OFF")
if((DI.state as DecimalType).intValue.bitwiseAnd(0x20)==0x20) DI6.postUpdate("ON") else DI6.postUpdate("OFF")
if((DI.state as DecimalType).intValue.bitwiseAnd(0x40)==0x40) DI7.postUpdate("ON") else DI7.postUpdate("OFF")
if((DI.state as DecimalType).intValue.bitwiseAnd(0x80)==0x80) DI8.postUpdate("ON") else DI8.postUpdate("OFF")
end
rule "RelayState"
when
Item RelayState received update
then
logInfo("Relay received update","Relay received update")
if((Relay.state as DecimalType).intValue.bitwiseAnd(0x01)==0x01) Relay1.postUpdate(ON) else Relay1.postUpdate(OFF)
end
I would expect the switch item to work as I made the text files as per the SNMP binding documentation. But the item says NULL.
If I change the item type to string, it shows the actual state (1 or 0).
I then tried the EXEC profile (and whitelisted the commands) and used snmpset -v1 -c private 192.168.2.200 .1.3.6.1.4.1.42505.8.2.3.1.13.0 i 1 or snmpset -v1 -c private 192.168.2.200 .1.3.6.1.4.1.42505.8.2.3.1.13.0 i 0, both worked. I then tried snmpset -v1 -c private 192.168.2.200 .1.3.6.1.4.1.42505.8.2.3.1.13.0 i %s, changed the channel type to switch and added onvalue 1 and offvalue 0. Then nothing.
At best, the log says "Item ‘Relay1’ received command ON → PREDICTED to become ON → changed from OFF to ON
Here is the link to Denkovi example files that work with 2.2: SNMPv1 RAR package
Here is HTTP example files.
I don’t care if it would be SNMP or HTTP, I just would like it to work without installing the old version of OH…
I tried to search for different topics about this, found many, but I don’t seem to have the brain power to iterate the findings to suit the Denkovi box…