I’m in the process of moving from openHAB2 using the openHAB1 onewire binding to the newer onewire binding. I’m using a DS2408 to monitor several momentary push button switches. By using the activity latch feature of the DS2408, I can capture a quick push of the button with relatively slow polling of the device. To reset the latch, I need to write any value to the devices latch property. But the new binding’s direct access type is read-only.
I can read the latch using the owfs-number direct access type.
.things
…
Channels:
Type owfs-number : latchByte [path="/29.EEF307000000/latch.BYTE", refresh=1]
}
.items
Number latchByte “Latch Byte [%d]” {channel=“onewire:owserver:mything:latchByte” }
The latchByte read works great. The problem comes when it’s time to reset the latch. The reset is accomplished by writing any value to the latch.
I can do this from owfs with
$ owwrite /29.EEF307000000/latch.BYTE 0
But the onewire binding direct access type is read only, so a rule with “'latchByte.sendCommand(0)” does nothing.
Is it possible to make the direct access type read/write?
Is there some other way to write a value to the DS2408’s latch?
2022-04-06 18:12:47.897 [DEBUG] [or.internal.metrics.EventCountMetric] - Received event on topic openhab/items/latchByte/state.
2022-04-06 18:12:48.966 [DEBUG] [or.internal.metrics.EventCountMetric] - Received event on topic openhab/items/latchByte/state.
Then I push the physical button and the rule is triggered.
022-04-06 18:13:01.251 [INFO ] [ore.model.script.system button.rules] - latchByte changed to 64
2022-04-06 18:13:01.254 [INFO ] [ore.model.script.system button.rules] - before latchByte Clear
2022-04-06 18:13:01.262 [INFO ] [ore.model.script.system button.rules] - after latchByte Clear
2022-04-06 18:13:01.263 [DEBUG] [or.internal.metrics.EventCountMetric] - Received event on topic openhab/items/latchByte/command.
2022-04-06 18:13:01.264 [DEBUG] [e.automation.internal.RuleEngineImpl] - The rule 'button-1' is executed.
2022-04-06 18:13:01.271 [DEBUG] [nternal.profiles.ProfileCallbackImpl] - Delegating command '0' for item 'latchByte' to handler for channel 'onewire:owserver:hottub:latchByte'
2022-04-06 18:13:01.275 [DEBUG] [.internal.common.CombinedClassLoader] - Loaded class "org.openhab.core.thing.binding.ThingHandler" by classloader "org.eclipse.osgi.internal.loader.EquinoxClassLoader@8c17e[org.openhab.core.thing:3.2.0(id=212)]" for "[interface org.openhab.core.thing.binding.ThingHandler]"
2022-04-06 18:13:01.278 [DEBUG] [.internal.common.CombinedClassLoader] - Loaded class "org.openhab.core.thing.binding.ThingHandlerCallback" by classloader "org.eclipse.osgi.internal.loader.EquinoxClassLoader@8c17e[org.openhab.core.thing:3.2.0(id=212)]" for "[interface org.openhab.core.thing.binding.ThingHandler]"
2022-04-06 18:13:01.281 [DEBUG] [.internal.common.CombinedClassLoader] - Loaded class "org.openhab.core.thing.Thing" by classloader "org.eclipse.osgi.internal.loader.EquinoxClassLoader@8c17e[org.openhab.core.thing:3.2.0(id=212)]" for "[interface org.openhab.core.thing.binding.ThingHandler]"
2022-04-06 18:13:01.282 [DEBUG] [est.sitemap.internal.SitemapResource] - Sent sitemap event for widget 0012 to subscription efc207e5-2e65-4cde-b093-9abf6736cd38.
2022-04-06 18:13:01.284 [DEBUG] [.internal.common.CombinedClassLoader] - Loaded class "org.openhab.core.thing.ChannelUID" by classloader "org.eclipse.osgi.internal.loader.EquinoxClassLoader@8c17e[org.openhab.core.thing:3.2.0(id=212)]" for "[interface org.openhab.core.thing.binding.ThingHandler]"
2022-04-06 18:13:01.286 [DEBUG] [or.internal.metrics.EventCountMetric] - Received event on topic openhab/items/latchByte/state.
2022-04-06 18:13:01.287 [DEBUG] [.internal.common.CombinedClassLoader] - Loaded class "org.openhab.core.thing.ThingStatusInfo" by classloader "org.eclipse.osgi.internal.loader.EquinoxClassLoader@8c17e[org.openhab.core.thing:3.2.0(id=212)]" for "[interface org.openhab.core.thing.binding.ThingHandler]"
2022-04-06 18:13:01.298 [DEBUG] [d4j.internal.RRD4jPersistenceService] - Stored 'latchByte' as value '0.0' in rrd4j database
2022-04-06 18:13:01.305 [DEBUG] [ab.core.ui.icon.internal.IconServlet] - Requested icon category number provided by no icon provider
2022-04-06 18:13:01.306 [DEBUG] [est.sitemap.internal.SitemapResource] - Sent sitemap event for widget 0012 to subscription efc207e5-2e65-4cde-b093-9abf6736cd38.
2022-04-06 18:13:01.309 [DEBUG] [e.automation.internal.RuleEngineImpl] - The trigger '0' of rule 'button-1' is triggered.
2022-04-06 18:13:01.311 [DEBUG] [time.internal.engine.DSLScriptEngine] - Script uses context 'button-1'.
2022-04-06 18:13:01.321 [DEBUG] [.monitor.internal.metrics.RuleMetric] - Rule button-1 RUNNING - updating metric.
2022-04-06 18:13:01.321 [DEBUG] [nternal.common.InvocationHandlerSync] - Already in a safe-call context, executing 'ThingHandler.handleCommand()' directly on 'org.openhab.binding.onewire.internal.handler.OwserverBridgeHandler@1875985'.
2022-04-06 18:13:01.329 [DEBUG] [e.automation.internal.RuleEngineImpl] - The rule 'button-1' is executed.
2022-04-06 18:13:01.330 [DEBUG] [ab.core.ui.icon.internal.IconServlet] - Requested icon category number provided by no icon provider
2022-04-06 18:13:01.905 [DEBUG] [or.internal.metrics.EventCountMetric] - Received event on topic openhab/items/latchByte/state.
2022-04-06 18:13:01.914 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/latchByte.rrd': null
2022-04-06 18:13:01.918 [DEBUG] [est.sitemap.internal.SitemapResource] - Sent sitemap event for widget 0012 to subscription efc207e5-2e65-4cde-b093-9abf6736cd38.
2022-04-06 18:13:01.918 [DEBUG] [e.automation.internal.RuleEngineImpl] - The trigger '0' of rule 'button-1' is triggered.
2022-04-06 18:13:01.921 [DEBUG] [time.internal.engine.DSLScriptEngine] - Script uses context 'button-1'.
2022-04-06 18:13:01.923 [DEBUG] [.monitor.internal.metrics.RuleMetric] - Rule button-1 RUNNING - updating metric.
2022-04-06 18:13:01.935 [DEBUG] [ab.core.ui.icon.internal.IconServlet] - Requested icon category number provided by no icon provider
2022-04-06 18:13:01.941 [INFO ] [ore.model.script.system button.rules] - latchByte changed to 64
2022-04-06 18:13:01.946 [INFO ] [ore.model.script.system button.rules] - before latchByte Clear
2022-04-06 18:13:01.953 [INFO ] [ore.model.script.system button.rules] - after latchByte Clear
2022-04-06 18:13:01.955 [DEBUG] [or.internal.metrics.EventCountMetric] - Received event on topic openhab/items/latchByte/command.
2022-04-06 18:13:01.956 [DEBUG] [e.automation.internal.RuleEngineImpl] - The rule 'button-1' is executed.
2022-04-06 18:13:01.961 [DEBUG] [nternal.profiles.ProfileCallbackImpl] - Delegating command '0' for item 'latchByte' to handler for channel 'onewire:owserver:hottub:latchByte'
2022-04-06 18:13:01.966 [DEBUG] [.internal.common.CombinedClassLoader] - Loaded class "org.openhab.core.thing.binding.ThingHandler" by classloader "o
OpenHAB records the value of latchByte as 0, When we read it from the oneWire device it is still 64. Which opehHAB sees as a change, which triggers the rule again. It only stops when I manually clear the latchByte with an owwrite command.
Here is the rule
rule "Buttons "
when
Item latchByte changed
then
if (latchByte.state != 0) {
logInfo("system button.rules","latchByte changed to " + latchByte.state)
// Check which pio channel is latched and do stuff here when the button is pushed
logInfo("system button.rules","before latchByte Clear")
latchByte.sendCommand(0)
logInfo("system button.rules","after latchByte Clear")
// This is an exec with a owwrite command which can serve as a work around
//owClearLatch.sendCommand(ON)
}
end
Here are the things
Bridge onewire:owserver:hottub [network-address="127.0.0.1"] {
Thing basic 8Ch_Switch_A [id="29.EEF307000000"]
{
Channels:
Type dio : digital0 [mode="output"]
Type dio : digital1 [mode="output"]
Type dio : digital2 [mode="output"]
Type dio : digital3 [mode="output"]
Type dio : digital4 [mode="output"]
Type dio : digital5 [mode="output"]
Type dio : digital6 [mode="input"]
Type dio : digital7 [mode="input"]
}
Channels:
Type owfs-number : crc8errors [path="statistics/errors/CRC8_errors"]
Type owfs-number : latchByte [path="/29.EEF307000000/latch.BYTE", refresh=1]
}
Thing exec:command:owClearLatch [command="/usr/bin/owwrite /29.EEF307000000/latch.BYTE 0", interval=0, autorun=false]