CT101 Thermostat OperatingState/Status Query

I posted over in the old forum, but figured most people weren’t active over there anymore since it’s being locked… so moving over here.

Is there anyway to get the Thermostat Operating State, Mode works fine, but I’d like to see when the thermostat is calling for heat. I see the widget has a place for Status to be reported, but it’s never changed for heat mode, the only time i see it change is for cooling mode for fan controls. Looking at the HomeGenie API, it looks like there should be a Thermostat.OperatingStateGet, which should have a response even of Thermostat.OperatingState. I don’t see the OperatingState listed in the Parameters of the module and trying to poll directly from a C# program doesn’t provide any data either.

I’m really just trying to see if I can poll the thermostat to see when it’s calling for heat. I’m going to be setting up multiple thermostats to automate running them ever so often during the winter while i have my woodburning stove going, to mitigate any issues with pipes freezing.

Any help would be appreciated.

A side note, I did pay for the HomeGenie Plus app on Android to see how that was looking and operating. It seems to have an issue maintaining connection to my server while the old app operates perfectly fine. I’m not sure if it’s due to the fact I’m running an old version of HomeGenie, v1.0-beta.493, or not… but any help would be appreciated there as well.

Hi, @psyctto.

Welcome you aboard new forum!

Just to clarify: are you talking about z-wave thermostat or something else?

Yes, it’s a zwave thermostat. Its the same as the 2gig or iris ct101.

Here’s the thermostat on zwave alliances page.

Well, things are a little bit complicated with requesting ZWave device properties, because they operate asynchronously. So there are two options: rewrite MIG library so it will wait for a response from the device or write a program that listens for modules’ parameters change events.
Here is an example program (in C#): it prints out a message if the module with address 7 in domain HomeAutomation.ZWave reports it’s Mode state.

When.ModuleParameterChanged((module, parameter) => {
  if (module.Instance.Domain == "HomeAutomation.ZWave" && module.Instance.Address == "7")
    // Check if the module has just reported Thermostat.Mode value
    if (parameter.Is("Thermostat.Mode"))
      Program.Notify("Test Program", module.Instance.Name + "<br>" + parameter.Value + " " + parameter.Name);
  return true;
// the program will be running in the background waiting for events

You can easily trigger reporting Mode state by calling API, ex. http://hgaddress/api/HomeAutomation.ZWave/7/Thermostat.ModeGet/

Thanks for the reply.
Getting the information from the thermostat, or more correctly, getting the information from Homegenie’s utilities isn’t the part I’m having an issue with… that’s working fine through my C# scripts. The thing I’m having an issue with is getting the OperatingState parameter, as it doesn’t seem like Homegenie is actually getting that back from the thermostat. It appears that the CT101 has this parameter available, per the zwave alliance documentation, and the Homegenie API documentation seems to say it should also be getting it from the thermostat device. But I’m having no luck getting a response for that parameter in my C#.
Here’s a simple pull of the data. Everything works fine, i can get Temperature, Setpoint, Humidity, Mode… but OperatingState doesn’t return anything. I dump to a file for debugging purposes, just fast and easy.

//Read and display yogaRoomThermostat values
var yogaRoomThermostat = Modules.WithName("Yoga Room Thermostat").Get();
var yogaRoomTemp = Math.Round(yogaRoomThermostat.Parameter("Sensor.Temperature").DecimalValue*1.8+32,2);
var yogaRoomSetpoint = Math.Round(yogaRoomThermostat.Parameter("Thermostat.SetPoint.Heating").DecimalValue*1.8+32,2);
var yogaRoomHum = Math.Round(yogaRoomThermostat.Parameter("Sensor.Humidity").DecimalValue,2);
var yogaRoomMode = yogaRoomThermostat.Parameter("Thermostat.Mode").Value;
var yogaRoomOpState = yogaRoomThermostat.Parameter("Thermostat.OperatingState").Value;
//Program.Notify("Yoga Room", yogaRoomTemp+"F "+yogaRoomSetpoint+"F "+yogaRoomHum+"% "+yogaRoomStatus+"...");
	using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"/var/house/yogaRoomThermostat", true))
		file.WriteLine(DateTime.Now.ToString("yyyyMMdd HH:mm:ss")+","+yogaRoomTemp+","+yogaRoomSetpoint+","+yogaRoomHum+","+yogaRoomMode+","+yogaRoomOpState);
  	Program.Notify("yogaRoomThermostat", "File in use. Will try again in 20s.");

documentation here seems to suggest that Thermostat.OperatingState should work.

Ok. First let’s try to localize the problem: does your thermostat report OperatingState?

Option 1. You call API method at http://hgaddress/api/HomeAutomation.ZWave/7/Thermostat.OperatingStateGet/ where 7 - is node Id of your thermostat. At the same time you should observe a popup in HG UI, like this (unfortunately my thermostat doesn’t support OperatingState command class, so the example is for Mode):

If this happens and you see a popup - it’s good, your thermostat successfully receives OperatingStateGet command and reports with OperatingStateReport command which is successfully parsed by HomeGenie.
In this case, you may find that your program works and logs an Operating State into a file.

Option 2. You make API call as earlier, but for now, you go to your HG installation folder, open logs folder and look through Debug.log. You should find some strings with CommandClass=ThermostatOperatingState. Please, attach a log fragment starting with this event + 5 seconds.
Here is an example with my request:

2017-09-25 20:22:09.9467|DEBUG|ZWaveLib.Utility|ZWaveMessage (Direction=Outbound, Header=SOF, NodeId=7, Type=Request, Function=SendData, CommandClass=ThermostatOperatingState, CallbackId=84, CallbackStatus=NotSet)

Also, I think you should update to the latest version r.526 (do not forget to make a backup of your installation).

Please, let me know the result of these experiments.

I know I’m a bit late in responding… been a bit busy, so I’m just getting back to working this out. The upgrade to r.526 didn’t exactly go great, several things weren’t happy which i believe were causing HomeGenie to crash almost daily, causing me to do a hard reset on my ZStick and start over. Not a huge deal, just time consuming. Hopefully that fixes the crashing issues and it’s not something with r.526.
So, a few things I’ve found about the CT101 thermostat… it doesn’t seem to respond with anything other than temperature reading to the “module.Command(“SensorMultiLevel.Get”).Execute();” call in the ZWave Thermostat Poll program, there are also no Configuration Variables to set the CT101 to push it’s own reading out. I know it’s not the desired method, but i modified the Thermostat Poll program to include
It’s not great, but it works repeatedly…

Another thing I was having issues with was setpoints, i can’t set them from HomeGenie. A bit of logging and playing with direct calls shows that with my display in HomeGenie and the CT101 both set to °F, I can’t set either setpoint. If I manually send out a heating setpoint of 75 (being the °F setting I want), the thermostat takes the setting and all is happy… so it looks like HomeGenie is taking the °F setting, converting it to °C and sending that as the setpoint, which the thermostat isn’t happy with. The odd part is the thermostat, even when set in °F, returns it’s setpoints and temperature sensor readings in °C.

Anything I can do to modify how the setpoints are sent out to the thermostat from HomeGenie? I didn’t see anything at first glance, but I’m also not sure what level that is handled… I have to assume at a lower level than the main UI.

Thanks for the help with this, I really appreciate it.

Hi, @psyctto!

No problem, I’m also busy almost all evenings now and usually don’t have time for side projects.
You did a good job modifying Thermostat Poll program. It was madу just for these cases when the device doesn’t report its state and we have to directly ask it to do a report.

About your problem with Fahrenheit and Celcius. Scale handling is not a strong side of HG and related libraries. Right now when you are sending SetPoint.Set command from interface ZWaveLib uses the scale that was used during the last SetPoint.Report command. So, for example, your device reported SetPoint in F, then when you set the new SetPoint value in UI it’s value is being converted into C and then ZWaveLib sends this C value as F which is very low temperature and the device doesn’t accept it.

Here is a screenshot from Thermostat widget’s code:

As you can see the value is always converted to Celcius, and this causes your problem.
The easiest and fastest way to fix it is to remove that conversion from widget’s code.

Hey Bounz,
Thanks for the info, I had also found that in the widget and commented it out the weekend before. Things work fine from the Widget, but the phone app still sends commands in C, not F. Having no insight into how the phone app sends those commands or interfaces with the HomeGenie server (Android BTW, using the Plus app since the basic/free app has no interface for thermostat control built in.) My “fix”, hokey I know, below works when you have multiple thermostats, just because the time delays allow for it… one thermostat is rough, you end up having times when the value set gets overwritten to quickly and no change occurs.
So I added the below to the zwave polling program.

    //CT101 requires SetPoint in F, not C, phone app only sends command in C. Grab SetPoint in memory prior to getting SetPoint update from CT101 to compare and send in F if needed.
    double newSetpoint = 0;
    var tsatHandle = Modules.WithName(module.Instance.Name).Get();
    var memorySetpoint = Math.Round(tsatHandle.Parameter("Thermostat.SetPoint.Heating").DecimalValue,2);  //Get value in memory
    if(memorySetpoint<38){memorySetpoint=Math.Round(memorySetpoint*1.8+32,0);}  //Check for F value in memory, greater than 38C isn't a real thermostat value, if not convert to F
    //CT101 doesn't seem to support SensorMultiLevel.Get, individual polling works
    Pause(Program.Option("PollInterval").DecimalValue);  //Pause needs to be prior to grabbing new value to allow homegenie time to process
    var tstatSetpoint = Math.Round(tsatHandle.Parameter("Thermostat.SetPoint.Heating").DecimalValue*1.8+32,2);  //Get new value in memory, from thermostat
    if(memorySetpoint>(tstatSetpoint*1.01) || memorySetpoint<(tstatSetpoint*0.99))  //Check for temperature change, +/-10% seemed fine
    {newSetpoint=memorySetpoint; module.Command("Thermostat.SetPointSet/Heating/"+memorySetpoint).Execute();}  //If value changed, send out new set point
    {newSetpoint=0;} //For debug logger, to tell where the IF routed

If you can think of a better solution, I’m all for it, since the above code is really a band-aid… probably more based on my lack of knowledge of HomeGenie’s innerworkings. If there’s a way to change the command coming from the cellphone app from C to F, that’d be fantastic, but I didn’t see any options jumping out and I’m not exactly sure at what level the phone app is communicating with HomeGenie.

Thanks again for all the help, I appreciate it.

Hi, @psyctto.

You did a great job making a workaround solution related to temperature unit conversion. :+1:

HomeGenie Plus Android application is closed-source and maintained only by Gene, so it’s impossible to make fixes to it, you can only write a letter or a comment in Play Store.

I think the best solution would be to fix ZWaveLib and Z-Wave MIG interface so when you change the temperature in UI it’s passed to the server with measurement units and those units are used during the request to a device. But this will not work with the mobile app, furthermore you will need to take care of a backward compatibility.