more G-Labs products

Author Topic: Zwave Thermostat  (Read 21850 times)

June 22, 2014, 10:52:54 PM
Read 21850 times

miket

  • **
  • Information
  • Jr. Member
  • Posts: 40
I just got the honeywell zwave thermostat.  I'm going to start working on adding functionality to the zwave thermostat module.

If anyone has put work into this already, please let me know and I'd be more than happy to help with your effort instead.   Gene-  if you have a preference for how you'd like it to work, let me know as well.  I'll put all of the work in a fork in github.

I'm going to start by adding the command classes to the zwave interpreter, then add front end stuff one at a time.   I'm probably going to begin with just status, then work through to sending commands.   

If anyone wants to help with this, please let me know.  If anyone knows of a good command reference for thermostats, let me know as well.   

June 23, 2014, 02:43:08 AM
Reply #1

miket

  • **
  • Information
  • Jr. Member
  • Posts: 40
Gene-

Wondering if you had a roadmap for this.  I saw that you deprecated the thermostat module.  My plan was to build on top of that in order to integrate the thermostat.  But let me know what you were thinking.  We have a couple of functions- it works as a sensor, but there is also going to be a special kind of switch.  I think the functionality is specific enough to warrant a special module, but let me know if  you thought differently.

Thanks,
Mike

June 23, 2014, 07:04:51 PM
Reply #2

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Hi Mike,

some tips about implementing Thermostat in ZWaveLib:

1) add missing command classes here:
     https://github.com/genielabs/HomeGenie/blob/master/MIG/Support%20Libraries/ZWaveLib/Devices/CommandClass.cs#L53
2) add code for handling Thermostat specific messages (from node to the controller) here:
     https://github.com/genielabs/HomeGenie/blob/master/MIG/Support%20Libraries/ZWaveLib/Devices/ZWaveNode.cs#L222
3) complete the current Thermostat driver here:
     https://github.com/genielabs/HomeGenie/blob/master/MIG/Support%20Libraries/ZWaveLib/Devices/ProductHandlers/Generic/Thermostat.cs#L30

In order to add the missing code to the Thermostat.cs class you need to override these methods:

Code: [Select]
namespace ZWaveLib.Devices.ProductHandlers.Generic
{
    public class Thermostat : Sensor
    {

public override bool HandleRawMessageRequest(byte[] message)
{
return false;
}

public override bool HandleBasicReport(byte[] message)
{
return false;
}

public override bool HandleMultiInstanceReport(byte[] message)
{
return false;
}

    }
}

In general the Thermostat node will answer with a Basic report or a Multiinstance one. If other message types are sent, the you can still take advantage of the HandleRawMessageRequest.

One last step to complete the ZWaveLib thermostat support, is to add methods for commands sent from the controller to the thermostat node, like you can see it happen for other command classes here:

https://github.com/genielabs/HomeGenie/blob/master/MIG/Support%20Libraries/ZWaveLib/Devices/ZWaveNode.cs#L531

You don't need to implement Sensor related stuff into Thermostat.cs since it already inherits the Sensor class.

Once finished with ZWaveLib, you may want to add thermostat commands to MIG service ZWave interface:

https://github.com/genielabs/HomeGenie/blob/master/MIG/MIG/Interfaces/HomeAutomation/ZWave.cs#L50
https://github.com/genielabs/HomeGenie/blob/master/MIG/MIG/Interfaces/HomeAutomation/ZWave.cs#L243

this will enable new http web service commands for interacting with a thermostat node.

After that a specific Thermostat widget should be created for the UI. There is already a dummy widget for that here:

https://github.com/genielabs/HomeGenie/tree/master/HomeGenie/HomeGenieUI/html/pages/control/widgets/homegenie/generic

To enable this widget you will have to uncomment this line:

https://github.com/genielabs/HomeGenie/blob/master/HomeGenie/HomeGenieUI/html/pages/configure/groups/listmodules.html#L126

that will re-enable the thermostat type selection in the module configuration and that is associated to that widget.

Hope this helps!

Cheers,
g.




June 23, 2014, 07:16:47 PM
Reply #3

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
One more thing.
To ensure that you thermostat device is recognized as a Thermostat device, put a break point here:

https://github.com/genielabs/HomeGenie/blob/master/MIG/Support%20Libraries/ZWaveLib/Devices/ZWaveNode.cs#L503

this is the code where the generic driver for a node is selected.
If this break point is not triggering then it means that your thermostat is sending another type for the generictype field, so you have to initially force the selection of the Generic Thermostat handler by adding some hard-coded lines.
When the generic thermostat handler is completed, then you can remove the hard-coded selection of the generic driver and add a specific handler for your device here:

https://github.com/genielabs/HomeGenie/tree/master/MIG/Support%20Libraries/ZWaveLib/Devices/ProductHandlers

by extending the Thermostat class and adding the proper manufacturer ID for your product as it happen for other devices, for example see:

https://github.com/genielabs/HomeGenie/blob/master/MIG/Support%20Libraries/ZWaveLib/Devices/ProductHandlers/Aeon/MultiSensor.cs#L37

Cheers,
g.
« Last Edit: June 23, 2014, 07:19:00 PM by Gene »

June 24, 2014, 04:20:27 AM
Reply #4

miket

  • **
  • Information
  • Jr. Member
  • Posts: 40
Awesome- thank you Gene!  I'll let you know when I have a working beta.  Some other users volunteered to test so that we can make sure it works before sending it to other users.   

July 01, 2014, 06:49:36 PM
Reply #5

miket

  • **
  • Information
  • Jr. Member
  • Posts: 40
ok...I have a testing version.  There is still a lot of work I need to do, but it would help if some of the other users tried it with different thermostats.  I especially need to see if my set point command works with celsius (my thermostat is all on F). 

I left the generic sensor reporting the current temp in C, and I convert it on the UI side to F unless there is a configuration parameter for the module.  (So that I didn't break anything that was already using the generic sensor)

My thermostat reports any changes automatically when associated with node 1, but I need to see what other thermostats do.   

So Gene:  should I send a pull request (probably later this week) with an early beta so that some of the other users can tell me what messages they are getting from their thermostats?   


July 02, 2014, 11:22:50 AM
Reply #6

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Hi mike,

make your pull request whenever you feel to. Then I'll make a testing release with it.
I'm pushing r388 to github soon (mostly a UI update).

Cheers,
g.

July 03, 2014, 09:55:07 PM
Reply #7

pmowry911

  • *
  • Information
  • Newbie
  • Posts: 21
miket,

  I can put my thermostat in celsius mode for a few days to test.  My daughter is about to go to college so she needs to learn the conversion anyway ;)  If you not ready to submit your code to a test build, could I get a copy of your source to play with?

Thanks,

-Patrick

July 04, 2014, 07:08:39 AM
Reply #8

miket

  • **
  • Information
  • Jr. Member
  • Posts: 40
Awesome-  I just sent the pull request to Gene.  Once he has a release for testing, we can start figure out what works or doesn't work with your thermostat, and I can make some modifications. 


July 04, 2014, 04:17:23 PM
Reply #9

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Hi Mike,

merged your modification into the master repo.
Also bundled r392 for testing which includes your modifications.

https://sourceforge.net/projects/homegenie/files/testing/

Cheers,
g.

July 04, 2014, 10:22:09 PM
Reply #10

miket

  • **
  • Information
  • Jr. Member
  • Posts: 40
Awesome!  Thanks Gene!

ok...if anyone is testing this, if homegenie is receiving messages from your thermostat, they will be announced as thermostat.[parameter] on the evens page of the control panel.

If your thermostat has association as an option, associate the thermostat with node 1 (this works for listening to messages from a honeywell thermostat)

Even if you don't see any messages, try setting your thermostat temp and see if it registers.  (If you are on celsius, try setting plausible C and F temps and see what happens)   

Try manually changing the temp from the thermostat and see if the thermostat updates.   


July 05, 2014, 06:22:09 PM
Reply #11

pmowry911

  • *
  • Information
  • Newbie
  • Posts: 21
Let me know if logs/test reports should be posted someplace else.  If I change the fan mode from auto to on and back I see the state update in the gui but temperatures are not close.  The interface shows 28F with a set point of -2.06 when the thermostat has 25c and 44c respectively

Changing the thermostat back to F I see 238F with a set point of 144.67 when the thermostat shows 77 and 80.

Using the dial to set the temperature works, but for Celsius mode I have to stay in the bottom quarter of the dial since the % correlates directly to the degree setting.

My thermostat is a RCS TZ45A

Manufacturer Specific = 0010:0001:0002
Supported Classes
40, 42, 43, 44, 45, Configuration, Sensor Multi Level, Version, 81, Manufacturer Specific


This is all I see in the log, but if I use another application that uses openzwave I see log entries every time the temperature changes a degree or other event.

pmowry@fw-1:/usr/local/bin/homegenie/log$ fgrep Thermostat homegenie.log
2014-07-05T10:37:14.9565320-05:00       HomeAutomation.ZWave    2       ZWave Node      Thermostat.OperatingState       2
2014-07-05T10:37:15.0051080-05:00       HomeAutomation.ZWave    2       ZWave Node      Thermostat.FanState     1
2014-07-05T10:38:40.4526920-05:00       HomeAutomation.ZWave    2       ZWave Node      Thermostat.OperatingState       0
2014-07-05T10:38:40.5533200-05:00       HomeAutomation.ZWave    2       ZWave Node      Thermostat.FanState     0
2014-07-05T10:43:42.8316450-05:00       HomeAutomation.ZWave    2       ZWave Node      Thermostat.OperatingState       2
2014-07-05T10:43:42.8821430-05:00       HomeAutomation.ZWave    2       ZWave Node      Thermostat.FanState     1
2014-07-05T10:59:56.4211160-05:00       HomeAutomation.ZWave    2       ZWave Node      Thermostat.SetPoint     114.44444444444444
2014-07-05T11:01:27.8116380-05:00       HomeAutomation.ZWave    2       ZWave Node      Thermostat.OperatingState       0
2014-07-05T11:01:27.8620960-05:00       HomeAutomation.ZWave    2       ZWave Node      Thermostat.FanState     0
2014-07-05T11:02:25.9443660-05:00       HomeAutomation.ZWave    2       ZWave Node      Thermostat.SetPoint     114.33333333333334
2014-07-05T11:02:34.0066730-05:00       HomeAutomation.ZWave    2       ZWave Node      Thermostat.SetPoint     114.3888888888889
 <<<<<<<  Changed thermostat to C mode >>>>>>>>>>>

2014-07-05T11:03:12.4253010-05:00       HomeAutomation.ZWave    2       ZWave Node      Thermostat.SetPoint     -2.5555555555555562
2014-07-05T11:03:12.4757130-05:00       HomeAutomation.ZWave    2       ZWave Node      Thermostat.SetPoint     -2.0555555555555554
2014-07-05T11:06:18.6730840-05:00       HomeAutomation.ZWave    2       ZWave Node      Thermostat.FanState     1
2014-07-05T11:06:18.7235750-05:00       HomeAutomation.ZWave    2       ZWave Node      Thermostat.FanMode      1
2014-07-05T11:06:30.7540490-05:00       HomeAutomation.ZWave    2       ZWave Node      Thermostat.FanState     0
2014-07-05T11:06:30.8045610-05:00       HomeAutomation.ZWave    2       ZWave Node      Thermostat.FanMode      0

Thank you so much for working on this.

-Patrick

July 05, 2014, 10:03:41 PM
Reply #12

miket

  • **
  • Information
  • Jr. Member
  • Posts: 40
Awesome!   So it looks like your thermostat is announcing the events!  It looks like I have some issues in my C/F conversions.  =)

Were you able to add the module?   If so, what is the module displaying?   How does that compare to the real temp/setpoint on your thermostat's real display.

Thanks!


July 05, 2014, 10:52:44 PM
Reply #13

miket

  • **
  • Information
  • Jr. Member
  • Posts: 40
Update:   

there was a little bug in my release that turned out to be the way I intended things to work.

If you are on F, then the setpoint is reported back in Celsius

This makes sense, I realize.  Let;s report everything in C and let the UI decide how to display it.

I've also moved the dial so it includes more plausible Celsius values.   

If you want to see things in C, add a parameter to the thermostat module:
Conditions.DisplayCelsius   and set it to TRUE

Otherwise it will default to F.   


For testers:  These are just little UI changes so you can download them and drop them in

{homegenie root}/html/pages/control/widgets/homegenie/generic/




« Last Edit: July 06, 2014, 01:58:59 AM by miket »

July 11, 2014, 01:00:16 AM
Reply #14

RichieC

  • ***
  • Information
  • Full Member
  • Posts: 67
I have a Hosrtmann HRT4-ZW thermostat and i can't get it to work..

Im running Homegenie r395 on a raspberry pi which i beleive includes the themostat code, but i can't even add the thermostat as a z-wave node - it just times out and doesnt find anything at all.

Does anyone have any idea why this is and how i can get this to work?

Richie