Z-wave Clock Command

@chris. I just saw that the CLOCK command was merged to the 1.9 branch. I have a CT-100 thermostat and would like to update the time. How is this accomplished? What does the item look like and do I need a rule to do the updating? There is a comment in the 2.0 branch that the time is automatically updated when it drifts. This does not appear to be happening in 1.9 branch. I don’t mind doing the updating in a rule, but what I’ve been trying so far has yet to work.

Here is what I currently have for an item:
DateTime Heat_FF_Clock "FF Clock" <clock> (ALL, Heating) {zwave="34:command=CLOCK"}

And this is what is in my rule:
Heat_FF_Clock.postUpdate(new DateTimeType());

This hasn’t been fully tested yet since my test device on my dev network that implements the CLOCK command died so I’ve got a new one coming. However the OH1 implementation isn’t automated in the same way as OH2. What I implemented was to send a switch command and the binding will set the current time.

I will try and test this over the next day or so if I get the new device.

@chris, I just tried testing with the switch command like you said, but I had no luck so I tried debugging it. I was fumbling around a bit since I don’t really know the code. The first issue I had was that the command class ZWaveClockCommandClass.class was not defined in ZWaveCommandClass so I made the change on my local repo. The next problem I had was that clock command was not listed as a supported command for my device so I added the following to the node xml file (again, not really knowing what I’m doing here):

<entry>
      <commandClass>CLOCK</commandClass>
      <basicCommandClass>
        <version>1</version>
        <instances>1</instances>
        <isGetSupported>true</isGetSupported>
      </basicCommandClass>
    </entry>

After updating the node xml I stopped getting a warning in the log, but it didn’t seem like it was sending the correct command:

2016-06-20 23:27:00.573 [DEBUG] [z.i.p.c.ZWaveBasicCommandClass:150 ]- NODE 34: Creating new message for application command BASIC_SET
2016-06-20 23:27:00.573 [DEBUG] [o.b.z.i.protocol.SerialMessage:113 ]- NODE 34: Creating empty message of class = SendData (0x13), type = Request (0x00)
2016-06-20 23:27:00.573 [DEBUG] [b.z.i.protocol.ZWaveController:947 ]- Callback ID = 188
2016-06-20 23:27:00.573 [DEBUG] [b.z.i.protocol.ZWaveController:632 ]- Enqueueing message. Queue length = 1
2016-06-20 23:27:00.573 [DEBUG] [WaveController$ZWaveSendThread:1241]- Took message from queue for sending. Queue length = 0
2016-06-20 23:27:00.573 [DEBUG] [o.b.z.i.protocol.SerialMessage:243 ]- Assembled message buffer = 01 0A 00 13 22 03 20 01 63 25 BC 1C 
2016-06-20 23:27:00.573 [DEBUG] [WaveController$ZWaveSendThread:1301]- NODE 34: Sending REQUEST Message = 01 0A 00 13 22 03 20 01 63 25 BC 1C 
2016-06-20 23:27:00.580 [DEBUG] [eController$ZWaveReceiveThread:1530]- Receive Message = 01 04 01 13 01 E8 
2016-06-20 23:27:00.581 [DEBUG] [eController$ZWaveReceiveThread:1446]- Receive queue ADD: Length=1
2016-06-20 23:27:00.581 [DEBUG] [b.z.i.protocol.ZWaveController:1194]- Receive queue TAKE: Length=0
2016-06-20 23:27:00.581 [DEBUG] [o.b.z.i.protocol.SerialMessage:243 ]- Assembled message buffer = 01 04 01 13 01 E8 
2016-06-20 23:27:00.581 [DEBUG] [b.z.i.protocol.ZWaveController:1195]- Process Message = 01 04 01 13 01 E8 
2016-06-20 23:27:00.581 [DEBUG] [b.z.i.protocol.ZWaveController:194 ]- Message: class = SendData (0x13), type = Response (0x01), payload = 01 
2016-06-20 23:27:00.581 [DEBUG] [b.z.i.p.s.SendDataMessageClass:38  ]- NODE 34: Sent Data successfully placed on stack.

Since it is sending a BASIC command, I’m guessing I did something wrong or there is something wrong with the code. Anyways, I know that you said your dev device died so I’m just trying to give you some testing feedback. I understand you have plenty of other things you are working on now.

Thanks - I’ll take a look. It looks like you’ve added the basic command class to the XML, so that can only result in bad stuff happening.

Why did you have to add the lines to the XML though? Was the command class not discovered during discovery? If not, maybe it’s not actually supported by your device?

Oh man, should have seen that basicCommandClass xml tag. I didn’t want to have to re-include the device so I was just editing the XML directly. I ended up re-including and the CLOCK command was correctly added. I found that the ZWaveClockConverter was not added to the ZWaveConverterHandler. Once I added this, things started working! I still got a warning “No converter found for item” at the end (possibly from poll), but everything is good!

2016-06-21 08:26:00.001 [DEBUG] [z.i.p.c.ZWaveClockCommandClass:95 ]- NODE 65: Creating new message for command CLOCK_SET 2016-06-21 08:26:00.001 [DEBUG] [o.b.z.i.protocol.SerialMessage:113 ]- NODE 65: Creating empty message of class = SendData (0x13), type = Request (0x00) 2016-06-21 08:26:00.002 [DEBUG] [z.i.p.c.ZWaveClockCommandClass:76 ]- NODE 65: Creating new message for command CLOCK_GET 2016-06-21 08:26:00.002 [DEBUG] [o.b.z.i.protocol.SerialMessage:113 ]- NODE 65: Creating empty message of class = SendData (0x13), type = Request (0x00) 2016-06-21 08:26:03.224 [DEBUG] [WaveController$ZWaveSendThread:1301]- NODE 65: Sending REQUEST Message = 01 0B 00 13 41 04 81 04 48 1A 25 C9 99 2016-06-21 08:26:03.232 [DEBUG] [b.z.i.p.s.SendDataMessageClass:38 ]- NODE 65: Sent Data successfully placed on stack. 2016-06-21 08:26:04.481 [DEBUG] [b.z.i.p.s.SendDataMessageClass:73 ]- NODE 65: SendData Request. CallBack ID = 201, Status = Transmission complete and ACK received(0) 2016-06-21 08:26:04.481 [DEBUG] [WaveController$ZWaveSendThread:1364]- NODE 65: Response processed after 1257ms/2726ms. 2016-06-21 08:26:04.481 [DEBUG] [WaveController$ZWaveSendThread:1301]- NODE 65: Sending REQUEST Message = 01 09 00 13 41 02 81 05 25 CA CD 2016-06-21 08:26:04.489 [DEBUG] [b.z.i.p.s.SendDataMessageClass:38 ]- NODE 65: Sent Data successfully placed on stack. 2016-06-21 08:26:04.505 [DEBUG] [b.z.i.p.s.SendDataMessageClass:73 ]- NODE 65: SendData Request. CallBack ID = 202, Status = Transmission complete and ACK received(0) 2016-06-21 08:26:04.814 [DEBUG] [ApplicationCommandMessageClass:40 ]- NODE 65: Application Command Request (ALIVE:DONE) 2016-06-21 08:26:04.814 [DEBUG] [ApplicationCommandMessageClass:58 ]- NODE 65: Incoming command class CLOCK 2016-06-21 08:26:04.814 [DEBUG] [z.i.p.c.ZWaveClockCommandClass:122 ]- NODE 65: Received CLOCK command V1 2016-06-21 08:26:04.814 [DEBUG] [z.i.p.c.ZWaveClockCommandClass:131 ]- NODE 65: Received clock report: Tuesday 08:26 2016-06-21 08:26:04.814 [DEBUG] [.z.internal.ZWaveActiveBinding:466 ]- NODE 65: Got a value event from Z-Wave network, endpoint = 0, command class = CLOCK, value = Tue Jun 21 08:26:04 EDT 2016 2016-06-21 08:26:04.814 [WARN ] [.o.b.z.i.c.ZWaveClockConverter:74 ]- NODE 65: No converter found for item = Heat_FF_Clock, endpoint = 0, ignoring event. 2016-06-21 08:26:04.814 [DEBUG] [WaveController$ZWaveSendThread:1364]- NODE 65: Response processed after 333ms/2726ms.

This is awesome! Thanks so much for putting this in!

You don’t need to reinclude the device - just delete the XML and restart the binding. It will cause the binding to do the discovery phase again, but it’s not the same as inclusion.

Ok - thanks. I’ll update this tonight.

Good to know.

There were two small changes. Including diff in case you missed the change from my first comment:
`— a/bundles/binding/org.openhab.binding.zwave/src/main/java/org/openhab/binding/zwave/internal/converter/ZWaveConverterHandler.java
+++ b/bundles/binding/org.openhab.binding.zwave/src/main/java/org/openhab/binding/zwave/internal/converter/ZWaveConverterHandler.java
@@ -73,6 +73,7 @@ public class ZWaveConverterHandler {
converters.put(CommandClass.THERMOSTAT_FAN_STATE,
new ZWaveThermostatFanStateConverter(controller, eventPublisher));
converters.put(CommandClass.BATTERY, new ZWaveBatteryConverter(controller, eventPublisher));

  •    converters.put(CommandClass.CLOCK, new ZWaveClockConverter(controller, eventPublisher));
       converters.put(CommandClass.SWITCH_BINARY, new ZWaveBinarySwitchConverter(controller, eventPublisher));
       converters.put(CommandClass.SWITCH_ALL, new ZWaveSwitchAllConverter(controller, eventPublisher));
       converters.put(CommandClass.SWITCH_MULTILEVEL, new ZWaveMultiLevelSwitchConverter(controller, eventPublisher));
    

diff --git a/bundles/binding/org.openhab.binding.zwave/src/main/java/org/openhab/binding/zwave/internal/protocol/commandclass/ZWaveCommandClass.java b/bundles/binding/org.openhab.binding.zwave/src/main/java/org/openhab/binding/zwave/internal/protocol/commandclass/ZWaveCommandClass.java
index b8876d7…31abb5f 100644
— a/bundles/binding/org.openhab.binding.zwave/src/main/java/org/openhab/binding/zwave/internal/protocol/commandclass/ZWaveCommandClass.java
+++ b/bundles/binding/org.openhab.binding.zwave/src/main/java/org/openhab/binding/zwave/internal/protocol/commandclass/ZWaveCommandClass.java
@@ -443,7 +443,7 @@ public abstract class ZWaveCommandClass {
REMOTE_ASSOCIATION_ACTIVATE(0x7C, “REMOTE_ASSOCIATION_ACTIVATE”, null),
REMOTE_ASSOCIATION(0x7D, “REMOTE_ASSOCIATION”, null),
BATTERY(0x80, “BATTERY”, ZWaveBatteryCommandClass.class),

  •    CLOCK(0x81, "CLOCK", null),
    
  •    CLOCK(0x81, "CLOCK", ZWaveClockCommandClass.class),
       HAIL(0x82, "HAIL", ZWaveHailCommandClass.class),
       WAKE_UP(0x84, "WAKE_UP", ZWaveWakeUpCommandClass.class),
       ASSOCIATION(0x85, "ASSOCIATION", ZWaveAssociationCommandClass.class),
    

`

Chris any way to merge this with the latest Z-Wave security code? I would love to try it, but I have 6 working Yale locks in my network along with all my CT100s that need CLOCK.

I’ll try and do this if I can grab Daves security branch. Unfortunately I’m again stuck with French air traffic control strikes so I’ve limited access or time at the moment. Hopefully I’ll be back tomorrow if everything sorts itself out and I’ll see if I can merge them then.

Cheers
Chris

I use the new binding 1260 for OH1 und some danfoss living connect.
In the log i get the new error:

> NODE 48: Unsupported Command 5 for command class CLOCK (0x81).

It looks like the device is sending a CLOCK_GET command. You can ignore this.

@sipvoip can you email me and I’ll send you a binding to try which should update Daves security code with the latest binding.

Were you able to get that to work? I am using something similar:

import org.openhab.core.library.types.*

rule  "Set Z-Wave Clocks"
when
      Time cron "0 * * * * ?"
then
    logInfo("Z-Wave","Setting Z-Wave Clocks")
    Clock?.members.forEach[clock|
      clock.postUpdate(new DateTimeType())
    ]
end

It looks like it is working from the log, but the clocks don’t change.

2016-07-03 13:28:07.554 [INFO ] [runtime.busevents             ] - Second_Floor_Tstat_Clock state updated to 2016-07-03T13:28:07
2016-07-03 13:28:07.555 [INFO ] [runtime.busevents             ] - Great_Room_Tstat_Clock state updated to 2016-07-03T13:28:07
2016-07-03 13:28:07.559 [INFO ] [runtime.busevents             ] - Emma_Bedroom_Tstat_Clock state updated to 2016-07-03T13:28:07
2016-07-03 13:28:07.562 [INFO ] [runtime.busevents             ] - Joshua_Bedroom_Tstat_Clock state updated to 2016-07-03T13:28:07
2016-07-03 13:28:07.575 [INFO ] [runtime.busevents             ] - Breezeway_Tstat_Clock state updated to 2016-07-03T13:28:07
2016-07-03 13:28:07.577 [INFO ] [runtime.busevents             ] - Apartment_Tstat_Clock state updated to 2016-07-03T13:28:07
2016-07-03 13:28:07.578 [INFO ] [runtime.busevents             ] - Mom_Bedroom_Tstat_Clock state updated to 2016-07-03T13:28:07
2016-07-03 13:28:07.579 [INFO ] [runtime.busevents             ] - Dad_Bedroom_Tstat_Clock state updated to 2016-07-03T13:28:07

It does work. You have to send a switch on command though.

Switch on vs sending the date/time? Sorry, confused.

In your example it would be clock.sendCommand(ON). This just sets the time to the current time.

It’s the same concept as the reset command for meters - except this sets the time to the current time, rather than resetting the meter to 0.

should clock be defined as a switch item or a datetime item?

thanks

It doesn’t really matter since this item simply triggers the setting of time on the device. However, if you make the item a switch you can manually force the time to get set when you toggle the switch. Or you could just have a rule that send the on command once a day to keep the clock from drifting.

thanks James and the prior posters, finally got it working.

for the record my thermostat is a Remotec ZTS-110.
I had to update to the 1.9 snapshot and delete the etc/zwave/nodexx.xml file.

I had also put my sendCommand in a “system started” rule. It seems that happens before Z-wave is initialized.
Since I made it a button, turning it on succeeded in setting the thermostat time.
Now I’m going to put the command in a CRON job.

thanks again.