Zwave Commander Protocol

Forum to discuss Lightswitch/ZWave Commander iPhone/iPod/iPad/Android home automation application

Zwave Commander Protocol

Postby Melloware » Mon Jan 11, 2010 12:15 pm

Many have asked about the Zwave Commander protocol to add support for their server from the iPhone client without the need for our .NET server app.

Basically it is TCP connection over Port 6004

As for what ZWave commander does from the iPhone...

1. Connect to IP:PORT of server.

2. Client sends the word IPHONE exactly. If any other text is sent I immediately log your session out.

3. If IPHONE is received a Response is sent back COOKIE:1234 where 1234 is an MD5 Hashcode cookie.

4. Clients sends back PASSWORD~XXX where XXX is "1234:Password" but hashed in MD5 String.

See the conversation below. C is for client S is for Server response. I connect then send back a list of all available devices, zones, and scenes.

Then I turn a device ON and then OFF by its NodeID in the network. So ON is Power Level 255 and OFF is Power level 0. Dimming is sending 1-99 for intensity. Anything above 99 is consider 255 for ON. If the type has the word "Binary" in it the the dimmer selector in the UI is disabled. If it has the word "Thermostat" in it then you get the Thermostat UI when you select that item.

S = Server, C=Client

Code: Select all
S: 6004 ZWaveCommander Server (Connections 1)
C: IPHONE
S: COOKIE~40821
C: PASSWORD~D81387E508E299AD988080A485064605
S: VER~1.1.3290.16502
C: ALIST
S: DEVICE~01 Garage Light~7~0~BinarySwitch
S: DEVICE~02 Front Door~3~255~BinarySwitch
S: DEVICE~03 Living Room~5~0~MultilevelSwitch
S: DEVICE~04 Living Room2~6~0~BinarySceneSwitch
S: DEVICE~05 Deck~8~0~BinarySceneSwitch
S: DEVICE~06 Office Lamp~2~0~MultilevelSceneSwitch
S: DEVICE~07 Third Deck~4~0~BinarySwitch
S: SCENE~Office Scene Off~1
S: SCENE~Office Scene On~2
S: SCENE~ZWave Scene 003~3
S: SCENE~ZWave Scene 004~4
S: SCENE~ZWave Scene 005~5
S: ZONE~Sunset Zone~1
S: ZONE~Office Zone~2
S: ENDLIST
C: DEVICE~2~255~MultilevelSceneSwitch
S: MSG~ZWave Node=2 Level=255
C: DEVICE~2~0~MultilevelSceneSwitch
S: MSG~ZWave Node=2 Level=0


*** IPHONE APP -> ZWAVE COMMANDER SERVER REQUEST

DEVICE~<NAME>~<NODE_ID>~<LEVEL>~<DEVICE_TYPE>[LF]

*** ZWAVE COMMANDER SERVER -> IPHONE APP REPLY

MSG~ZWave Node=<NODE_ID> Level=<NODE_LEVEL>[CR][LF]

So in the above example I turned Device ID 2 ON (Level 255) then turned it OFF (Level 0). The server response MSG is any message you want displayed on the iPhone.

The command ALIST returns a list of all Devices, Scenes, and Zones. I think in other terms Zones are described as "Rooms".

To activate Scenes and Zones...

To activate a scene you will send...

Code: Select all
SCENE~12


Where 12 = the unique SCENE ID. This simply activates this Scene id.

For Zones you send a Zone and a power level.

Code: Select all
ZONE~2~0  (turn Zone 2 OFF)
ZONE~2~255 (turn Zone 2 ON)


Update: Lightswitch has been released on the Android Market! Android is becoming the world most popular smart phone and embedded device platform in the world so supporting it is vital.

API Updates:

1.The ENDLIST at the end of transmission of the Scenes,Zones,Devices list is critical to provide a smooth Android UI experience.

2. Device Types. The device recognizes 6 unique device types.

THERMOSTAT - Full UI for controlling a thermo like the iPhone has
THERMOMETER - Ready only temperature sensor
SENSOR - Read only sensor like a motion detector that you just display text for.
BINARY_SWITCH a lightswitch that does not have a dimmer so only ON/OFF displayed
WINDOWCOVERING is an electric blind that displays only UP/DOWN buttons
STATUS read-only device type for displaying a status of something. Our one manufacturer uses this to display something like "Away Mode Active" or something like that.
ANY OTHER DEVICE TYPE = A normal lighswitch with ON/OFF/DIMMER slider

3. You can also now send updates asynchronously after connection.

Update has the exact same format as DEVICE just with the word Update like...

UPDATE~Garage Light~1~0~BinarySwitch

It must be followed by ENDLIST.

Code: Select all
UPDATE~Garage Light~1~0~BinarySwitch
UPDATE~Bedroom~2~100~BinarySwitch
ENDLIST


That way you can send multiple updates and then trigger a UI update with ENDLIST. This way if a user takes action on the server side or an event happens you can update all connected clients.

4. Bonjour support. IF you would like your server auto discovered we have Bonjour support to discover all Lightswitch servers on the network. An example of an exact Bonjour broadcast from the server is below. This is .NET code but if your language has Bonjour/ZeroConf support it is all the same.
Code: Select all
private void PublishBonjourService()
{

String type = "_lightswitch._tcp.";
String name = "Zwave Commander " + Environment.MachineName;
_publishService = new NetService("", type, name, 6004);
_publishService.AllowMultithreadedCallbacks = true;
_publishService.DidPublishService += new NetService.ServicePublished(publishService_DidPublishService);
_publishService.DidNotPublishService += new NetService.ServiceNotPublished(publishService_DidNotPublishService);

/* TXT RECORD */
System.Collections.Hashtable dict = new System.Collections.Hashtable();
dict.Add("txtvers", "1");
dict.Add("ServiceName",name);
dict.Add("MachineName",Environment.MachineName);
dict.Add("OS",Environment.OSVersion.ToString());
dict.Add("IPAddress", Preferences.LocalIpAddress);
dict.Add("Version", Preferences.Version());
_publishService.TXTRecordData = NetService.DataFromTXTRecordDictionary(dict);
_publishService.Publish();
}
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11031
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Zwave Commander Protocol

Postby Brandt » Sun Nov 21, 2010 5:38 pm

Thermostat:

H0=node id

When thermostat device selected:
THERMMODE~H0~99~Thermostat

Off:
THERMMODE~H0~0~Thermostat

Auto:
THERMMODE~H0~1~Thermostat

Heat:
THERMMODE~H0~2~Thermostat

Cool:
THERMMODE~H0~3~Thermostat

Fan:
THERMMODE~H0~4~Thermostat

CoolPoint:
THERMTEMP~H0~3~0~Thermostat

46C CoolPoint:
THERMTEMP~H0~3~46~Thermostat

HeatPoint:
THERMTEMP~H0~2~0~Thermostat

46C HeatPoint:
THERMTEMP~H0~2~46~Thermostat

Comfort:
THERMMODE~H0~7~Thermostat

Efficient:
THERMMODE~H0~6~Thermostat
Brandt
 
Posts: 7
Joined: Tue Nov 16, 2010 11:51 am

Re: Zwave Commander Protocol

Postby mikee » Tue Jun 19, 2012 11:48 pm

Hi, I am new to Lightswitch and have written a server supporting the ZWave Commander protocol. Most things work as expected. I have a couple questions about the display of temperature/luminance sensors (i.e. ExpressControls motion sensor). They show the temp icon but no actual temp values. Are there any special values that need to be returned in the DEVICE or UPDATE strings for a display of the actual temp ?

If I return the type as THERMOSTAT the UI that opens does show the temp I send in the DEVICE/UPDATE but it would be nice to see the value with the icon as a THERMOMETER.

The luminance sensor is of limited visual value but would be nice to see a grade rather than the on/off sensor display shown. Not a big deal though.

Thanks for the control app, works very nicely.
mikee
 
Posts: 5
Joined: Tue Jun 19, 2012 11:23 pm

Re: Zwave Commander Protocol

Postby Melloware » Wed Jun 20, 2012 5:34 am

Mike,

First of all nice work! Do you want your app listed on our homepage? I would be more than happy to add your project and link to it!

I think you want the device type THERMOMETER instead of THERMOSTAT which is a read only temperature sensor like people have in Hot Tubs etc.

Or am I not understanding what you want?
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11031
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Zwave Commander Protocol

Postby mikee » Wed Jun 20, 2012 9:18 am

Thanks for the quick response! The server was pretty easy to build. It is controlling an HS2 setup. I implemented scenes and zones as manually triggered events. For the zones I just read the event actions and execute the on or off in the server for each. Seems to work well enough. Why no icons for the scenes and zones ? I really like the big icons (I am using a XOOM tablet).

Yes, for the sensor I want the app to display the temp. If I return a THERMOMETER type all I get is a button with the thermometer icon. If I press it it says "Device is READ-ONLY". I can't see the actual temperature. I have tried returning different values in the value field.

The same behavior applies for STATUS and the motion sensor. I am reporting the battery level using STATUS and look at the level in the server and return a 1/0 value to light the icon. It would be nice to have some sort of value indication on the app screen. The motion sensor display is fine as it really is binary.

I am not using the MSG response.

Oh, not a big deal for me but the Fan button on the thermostat doesn't seem to work. It doesn't send a command and does not dismiss the screen like the other buttons.
mikee
 
Posts: 5
Joined: Tue Jun 19, 2012 11:23 pm

Re: Zwave Commander Protocol

Postby Melloware » Wed Jun 20, 2012 9:23 am

What is HS2?


OK so the Thermometer and Status devices are readonly so instead of sending a value just use the name as the value.

So what people will send it .

"MyName 36 degrees F" or whatever the temp is and same with the Status type use the name. So for Status it could be anything you want like

"Alarm ON"

"Alarm OFF"

of if its a Motion Sensor like "Motion Sensor TRIPPED!".

So you send the Temperature for Thermometer as the name string. The reason we did it this way was for flexibility as to what those read-only devices might be like Motion Senser, Water Pressure Gauages" etc.

I will look into the Fan issue!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11031
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Zwave Commander Protocol

Postby mikee » Wed Jun 20, 2012 9:36 am

Ahh, makes sense. Thanks. HS2 is HomeSeer's platform.
mikee
 
Posts: 5
Joined: Tue Jun 19, 2012 11:23 pm

Re: Zwave Commander Protocol

Postby Melloware » Wed Jun 20, 2012 9:45 am

Nice! I would love to add HomeSeer as an option on my home page. Do you plan on publishing your work?

also I just fixed the Fan button issue and published a new version to the Android Market if you want to test once released.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11031
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Zwave Commander Protocol

Postby mikee » Wed Jun 20, 2012 10:05 am

I'm not sure I want to publish since I can imagine all sorts of support issues, kinda like me :mrgreen:

The temp and battery level in the name field works great. Also, I am now using MSG to send the log entries to the screen. It is not mentioned in the protocol description but it appears this is not specifically a command reponse but can be issued at any time. Would be nice to be able to specify the screen message flash time in the MSG repsonse but it works well enough as is.

I'll try the new version once it shows up in the market.

One other question, does the license cover all my devices linked to my google account or do I need one per device ? I also have a droidX but haven't tried it yet.

Thanks again for your help!
mikee
 
Posts: 5
Joined: Tue Jun 19, 2012 11:23 pm

Re: Zwave Commander Protocol

Postby Melloware » Wed Jun 20, 2012 10:20 am

I am 99% sure that as long as your Android device is logged into the same Google Account you won't get charged again so it should work on all your devices.

Please do an Android Market review if you can! I can use all the word of mouth publicity I can get.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11031
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Zwave Commander Protocol

Postby mikee » Wed Jun 20, 2012 12:30 pm

I downloaded 2.4.5.1 on the DroidX and it works as expected. The first time i started it said it was not licensed. The second time it worked. I saw your other posts about this issue.

I verified the Fan button now sends the command as documented.

I was seeing very odd behavior from the client. I kept getting the following exceptions on the server:

Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

I rebooted the XOOM and all is well again. Not sure what this is all about. I'll keep an eye on it.

Thanks!
mikee
 
Posts: 5
Joined: Tue Jun 19, 2012 11:23 pm

Re: Zwave Commander Protocol

Postby Melloware » Wed Jun 20, 2012 12:32 pm

Let me know if you are interested in sharing your HS2 code I could always make it available here as a download and use this support forum or make it publicly available on Google Code or something like that. No pressure though it is up to you.

Glad the new version fixed the FAN issue! Yeah that License check issue happens once in a while and then it will re-up with the Google Servers and correct itself. It is all part of the Google Licensing API.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11031
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Zwave Commander Protocol

Postby garman » Wed Feb 13, 2013 7:01 pm

Hello, I am trying to consume the api and woudld like help in pulling thermostat statuses from the thermostat.
All I have been able to pull from the thermostat is:
"DEVICE~First Floor HVAC~14~68~GeneralThermostatV2"

for example I would like get the following:
- is the thermostat in Econ or Comfort mode
- is the thermostat in Heat or Cooling mode
- is the Thermostat current running (heating or cooling)
- what are the values of the set points

Thanks in advance for you help
garman
 
Posts: 8
Joined: Tue Jul 21, 2009 7:29 am

Re: Zwave Commander Protocol

Postby Melloware » Thu Feb 14, 2013 6:29 am

I believe the current status is returned in the MSG response whenever you change the thermostat values etc.

I can send you the server side code if you like? Or you could look at the zVirtualScenes implementation of Lightswitch?

http://code.google.com/p/zvirtualscenes ... hPlugin.cs
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11031
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Zwave Commander Protocol

Postby garman » Thu Feb 14, 2013 8:16 am

Thanks for the quick reply, I looked at the code at
http://code.google.com/p/zvirtualscenes%20...%20hPlugin.cs but that wasn't too helpful, so could you please send me the server code.
To let you know what I am trying to do; I have build a Server that run as a windows service that listens for request coming from my account at http://www.twilio.com/, I send a SMS message to my Twillio number ($12/yr) and it forwards the request to my Server. So from my iPhone I can send a text like "away mode" or "turn on the Landscape Lights," my server receives the requests parses it and executes the request and sends a reply back by SMS.
It work really well for my dimmers and switches, but Thermostat operation are unreliable, especially figuring out is the thermostat is in Econ or Comfort mode or if the Thermostat is running.
Once i got that working my next step is to build a SiriProxy plugin https://github.com/plamoni/SiriProxy so that I can control my devices by voice, like so http://www.howtogeek.com/98512/siriproxy-harnesses-siris-voice-processing-to-control-thermostats-and-more/
garman
 
Posts: 8
Joined: Tue Jul 21, 2009 7:29 am

Next

Return to Lightswitch/ZWave Commander

Who is online

Users browsing this forum: No registered users and 1 guest