StrykerSKS / SmartThingsPublic

32 stars 11 forks source link

Celsius Handling #5

Closed snakedog116 closed 8 years ago

snakedog116 commented 8 years ago

If you look at the code, or the Readme file you'll notice that making Celsius work is in the development plan but is not currently working.

For anyone using Celsius on your Ecobee Thermostat I just want to let you know of what that'll do to your thermostat. It's still usable, but you need to understand how it works:

  1. Your Thermostat will show you the readings in Celsius, but the sensors will be in Fahrenheit.
  2. If you change the temperature it'll send the commands in Fahrenheit. So, if you change the temperature with the up arrow it'll do the following:
    1. Let's pretend that the display reads 21 degrees (that's in Celsius) and we are working with 'heat' mode only.
    2. You press the up arrow
    3. It'll tell your Ecobee to go to 22 decrees but commands are in Fahrenheit, so it's telling your Ecobee to go to 22 Fahrenheit. Typically the Ecobee has a minimum set temp and so it'll go to that (for me it's 15 degrees Celsius.) So although you wanted it to be 22 Celsius, it's now set to 15.
    4. So basically, don't use the arrows
  3. If you use the 'home', 'away' routines, or any other smartapps that set the temperature of your ecobee, make sure to set the temperatures you type in are in Fahrenheit otherwise it'll do the same thing as in issue 2.
  4. The dials on the bottom of the screen (where you can set cool, or heat with a linear dial:
    1. It read out in Celsius, but again sets the temp in Fahrenheit.
    2. So if you want to change the temperature, use these dials, but you need to convert whatever you are setting it to. (move the dial to 72 if you want the house to be heated to 22 Celsius)
    3. When you set the temperature using those dials, they will then stay in Fahrenheit until you press the 'refresh' icon.

If you remember to convert properly, the devices and SmartApps should work just fine with the code as is, until someone updates it to handle Celsius properly.

StrykerSKS commented 8 years ago

Reopening this one. Since Celsius is a critical feature for many, let's use this one to track it as an actual issue.

I'll make this the next priority for the code and will try to get this resolved this week.

ncsufire commented 8 years ago

Can this be done in a formula in the code? T(°C) = (T(°F) - 32) / 1.8 or T(°F) = T(°C) × 1.8 + 32?

snakedog116 commented 8 years ago

Sounds good. Thanks StrykerSKS.

Also I forgot to mention the temperature forecast is in Fahrenheit too.

Any idea if the weather forecast (not the temp tile, but the sunny vs overcast tile) not working would have anything to do with Celsius not being set up? My app doesn't tell me that the weather is cloudy. It just keeps saying that it is updating forever. Is this related or should I open a separate ticket for that?

StrykerSKS commented 8 years ago

Yes. In fact I have helper functions already defined (and There are some built in conversion functions). I just need to go through and find all the places that it needs to be converted back and forth.

The Ecobee only uses F so have to go back and forth.

// Sean

Sent from my iPhone

On Jan 4, 2016, at 8:33 PM, ncsufire notifications@github.com wrote:

Can this be done in a formula in the code? T(°C) = (T(°F) - 32) / 1.8 or T(°F) = T(°C) × 9/5 + 32?

— Reply to this email directly or view it on GitHub https://github.com/StrykerSKS/SmartThingsPublic/issues/5#issuecomment-168875059 .

snakedog116 commented 8 years ago

From Ecobee's API, slight modification of the formula:

The temperature values are all provided in units of 0.1 of a Fahrenheit (℉). For example, our actualTemperature of 711 is actually 71.1℉. It is up to the caller of the API to convert to Celsius (℃). You can use the following formula:

(F - 320) * 5 / 90 = ℃ https://www.ecobee.com/home/developer/api/examples/ex2.shtml

StrykerSKS commented 8 years ago

Okay, anyone feeling adventurous and wanting to test Celsius support, I have a ready for test version on the StrykerSKS-enhanced-ecobeedevice branch. After I get some sleep and hopefully some time to test tomorrow night then I'll move it over to the release branch, but in the meantime it is available now for testing.

snakedog116 commented 8 years ago

Thanks StrykerSKS!

I've updated my apps to use your test code. Here are my findings:

Outstanding Issues

  1. temperature tile: The temperature reading on the thermostat itself is off... It was actually working fine off the previous code. But now it's reading -6 degrees! I sure hope my house isn't below freezing! Ha. I think the calculations are applied twice. FIXED I pressed the 'refresh' icon on the bottom and that seems to have reset something and now the temp reading works fine
  2. heatingSetpoint and coolingSetpoint Tiles: The initial current temp readings for the cool and heat setpoints is not reading correctly (it's also in the negatives and used to work). Note, when I changed the temp using the sliders these read out in celsius (this used to be in Fahrenheit when you adjusted the sliders). FIXED INTERMITTENTLY - still buggy I pressed the 'refresh' icon on the bottom and that seems to have reset something and now the temp reading works fine. But as I play with it a bit, there are some times that it pops back down to negative numbers. The refresh button fixes the issue.
  3. The up and down arrows within the device seem to set the temp randomly. My temp started at 18. Initially the up arrow set it to 24, I reset it and then tried the down arrow and it went to 19. I reset it and tried the down arrow again and it went to 24 (I think that's my max). - I think this could be the same issue as issue 4 below?
  4. Routines: I've tried using different routines to set the thermostat and it isn't working right:
    • 1 goes to 18.5
    • 10 goes to 18.5
    • 15 goes to 33.5
    • 20 goes to 33.5
    • Then I tried 10 again and now I got 33.5. So I'm really not sure how this is working. Then I tried it again and got 18.5 and then the next time 33.5. Seems very odd.

You seem to have fixed:

  1. The sensors are now reading the temps correctly.
  2. The thermostat seems to be reading correctly (After my initial refresh)
  3. heatSliderControl and coolSliderControl When I set the temperature using the 'heat' and 'cool' sliders it sets the temp correctly
  4. The Outside Temp is working
  5. heatingSetpoint and coolingSetpoint tiles: When I adjust the sliders it used to read out in Fahrenheit. now it's in Celsius.

It would be nice to also see:

  1. The heat and cool sliders currently slide between 0-100? Celsius ranges between 15 and 30 maximum.
  2. Celsius temps can be shown with 1 decimal.
StrykerSKS commented 8 years ago

Thank you for the very detailed feedback! Let me try to address each point. Can you also provide the following details:

(2.) heatingSetpoint and coolingSetpoint Tiles: The initial current temp readings for the cool and heat setpoints is not reading correctly (it's also in the negatives and used to work). Note, when I changed the temp using the sliders these read out in celsius (this used to be in Fahrenheit when you adjusted the sliders). FIXED INTERMITTENTLY - still buggy I pressed the 'refresh' icon on the bottom and that seems to have reset something and now the temp reading works fine. But as I play with it a bit, there are some times that it pops back down to negative numbers. The refresh button fixes the issue.

The initial value will not change until a refresh is done in most cases. This is because it doesn't see that the values have changed.

As far as the reading switching to negative, I've very baffled by this. This shouldn't even be possible if you are using the latest code as there are checks for boundary numbers:

 if ( getTemperatureScale() == "F" ) {
        if (heatingSetpoint > 79) {
            heatingSetpoint = 79
        } else if (heatingSetpoint < 45) {
            heatingSetpoint = 45
        }
    } else {
        if (heatingSetpoint > 26) {
            heatingSetpoint = 26
        } else if (heatingSetpoint < 7) {
            heatingSetpoint = 7
        }    
    }

As you can see, the lowest value allowed in Celsius mode is 7 for heat. (There is an equivalent set of code for cool handling. (Although, since the Ecobee already has limit controls in place, perhaps I should just delete these and let Ecobee enforce the limits on the backend.)

I suspect that perhaps the Thermostat device-type was not updated.

(3.) The up and down arrows within the device seem to set the temp randomly. My temp started at 18. Initially the up arrow set it to 24, I reset it and then tried the down arrow and it went to 19. I reset it and tried the down arrow again and it went to 24 (I think that's my max). - I think this could be the same issue as issue 4 below?

This was a good catch, turns out that I was missing Celsius limit checks, so it was using F ones instead, which was screwing up the numbers! I've removed the limit checks and will simply let Ecobee use the limits already set in the unit instead.

(4.) Routines: I've tried using different routines to set the thermostat and it isn't working right:

I think the fixes from the above items have also fixed this problem as well. So far my tests on this are all working as expected.

It would be nice to also see:

  1. The heat and cool sliders currently slide between 0-100? Celsius ranges between 15 and 30 maximum.
  2. Celsius temps can be shown with 1 decimal.
  3. Okay, looks like the slider can take a parameter that specifies the range. I may have to use a range that encompasses both C and F values as there isn't a lot of flexibility in the Tiles, but let me see if I can make it work. (Will have to come back to this one.)
  4. Will also have to look at this one. There is rounding used in many places in the current SmartApp and device type. Will have to change this in several places.

The updates for the bug fixes (not the nice to have yet) have been synced up to the beta branch so you should be able to retest this now. Hopefully I caught most of everything.

// Sean

snakedog116 commented 8 years ago

I'm using the thermostat in 'heat' mode. Yes, the thermostat is Celsius My thermostat is set to be between 15 and 24 It's not in cooling so I'm not sure what the cooling setpoint is. Do you need me to find out? Yes, I updated both devices, and the smartapp. I've attached some of the debug messages. (these screen shots are from the code you had last night except for the last one, which is this morning with the new code)

I haven't done much with your updated code this morning yet. I'll test it out this weekend.

img_4675 - copy

img_4676 - copy

img_4677 - copy

img_4678 - copy

img_4679 - copy

img_4680 - copy

img_4681 - copy

img_4682 - copy

img_4683 - copy

img_4684 - copy

img_4685 - copy

This one is from this morning

img_4686 - copy

snakedog116 commented 8 years ago

Ok, so I've tested the device a bit more in Celsius.

Below are my findings (Note, I'm in Canada, and don't have an AC unit. So I only tested this in 'heat' mode, and only the 'heat' side of things. So I can't speak to whether the 'cool' slider works, or if it's setting the 'cool' set points properly.

Further details for 3.

Seems like there is an issue with the up arrow but only if you use the down arrow first? Does that make any sense with the code?

9890ea57-2de6-439a-bcf0-eb06ae3b86eb 11:22:58 PM MST: debug Generate Status Event = Right Now: Idle 9890ea57-2de6-439a-bcf0-eb06ae3b86eb 11:22:58 PM MST: debug HVAC Mode = heat 9890ea57-2de6-439a-bcf0-eb06ae3b86eb 11:22:58 PM MST: debug Cooling set point = 33 9890ea57-2de6-439a-bcf0-eb06ae3b86eb 11:22:58 PM MST: debug Heating set point = 16 9890ea57-2de6-439a-bcf0-eb06ae3b86eb 11:22:58 PM MST: debug Temperature = 20 9890ea57-2de6-439a-bcf0-eb06ae3b86eb 11:22:58 PM MST: debug Generate Status Event for Mode = heat 9890ea57-2de6-439a-bcf0-eb06ae3b86eb 11:22:58 PM MST: debug alterSetpoint in mode heat succeed change setpoint to= 16 9890ea57-2de6-439a-bcf0-eb06ae3b86eb 11:22:56 PM MST: debug Entered whatHoldType() with nextTransition settings.holdType == Temporary 9890ea57-2de6-439a-bcf0-eb06ae3b86eb 11:22:56 PM MST: debug alterSetpoint >> in mode heat trying to change heatingSetpoint to 16 coolingSetpoint to 33 with holdType : nextTransition 9890ea57-2de6-439a-bcf0-eb06ae3b86eb 11:22:56 PM MST: debug Entered whatHoldType() with nextTransition settings.holdType == Temporary 9890ea57-2de6-439a-bcf0-eb06ae3b86eb 11:22:56 PM MST: debug alterSetpoint - temp.value is 16 9890ea57-2de6-439a-bcf0-eb06ae3b86eb 11:22:53 PM MST: info In mode heat lowerSetpoint() to 16 9890ea57-2de6-439a-bcf0-eb06ae3b86eb 11:22:53 PM MST: debug lowerSetpoint() mode = heat, heatingSetpoint: 17, coolingSetpoint:33, thermostatSetpoint:17 9890ea57-2de6-439a-bcf0-eb06ae3b86eb 11:22:53 PM MST: debug Heat: lowerSetpoint being called 9890ea57-2de6-439a-bcf0-eb06ae3b86eb 11:22:53 PM MST: debug setTemperature(): change the heat temp 9890ea57-2de6-439a-bcf0-eb06ae3b86eb 11:22:53 PM MST: debug deltaTemp = -19 9890ea57-2de6-439a-bcf0-eb06ae3b86eb 11:22:53 PM MST: debug setTemperature() called with setpoint 1. Current temperature: 20. Heat Setpoint: 17. Cool Setpoint: 33. Thermo Setpoint: 17

snakedog116 commented 8 years ago

Just wanted to say thank you for adding a range of 17-85 for the heating slider. Much better than 0-100

Okay, looks like the slider can take a parameter that specifies the range. I may have to use a range that encompasses both C and F values as there isn't a lot of flexibility in the Tiles, but let me see if I can make it work. (Will have to come back to this one.)

StrykerSKS commented 8 years ago

On the slider, I had a good chat with one of the SmartThings engineers (at CES) and he acknowledged the need to have dynamic tiles (like they do for the dynamic config pages) but also said it was pretty low on the priority list. So, for now the best we can do is have a range that covers both C and F on the same slider.

Otherwise, I think I've ironed out the rest of the Celsius items, so @snakedog116 (and other Celsius users) could test the latest version to confirm, then we can close this one out.

snakedog116 commented 8 years ago
  1. Adjusting Temp up and down arrows The arrows are now all working in Celsius, sending the changes in Celsius. Great. However, the up arrow sometimes doesn't increase the temperature. Below are more details. I think the issue is that if you press on the down arrow first, then the up arrow stops working and instead lowers the temp setting every time you press on it.

Did you fix my issue 3 above? I can test it again to see if the newest code changes anything?

StrykerSKS commented 8 years ago

Yes, I think I fixed it. There is a bug (feature?) in the ST side that causes it to act differently for passing the setpoint to the function when it is set to Celsius. I've put in a workaround. I still need to open a bug report with ST, but for now the code should work for the arrows. (I tested a lot of combinations.)

I find the arrows a bit hard to hit sometimes, but that is another issue I want to take up with ST as the UI needs some work from a usability (IMO).

snakedog116 commented 8 years ago

Yup, seems to be working for me, I'll mark the other comment with a complete.