Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thermostat requires empty elements to be self-closing tags #66

Closed
sbrown4 opened this issue Dec 13, 2018 · 10 comments
Closed

Thermostat requires empty elements to be self-closing tags #66

sbrown4 opened this issue Dec 13, 2018 · 10 comments

Comments

@sbrown4
Copy link
Contributor

sbrown4 commented Dec 13, 2018

--- Wrong assumption see next comment ---

It appears that if an api req is issued just before the window to the remote server opens, the t-stat will fetch the stale config from the remote server and not from the cache.

[2018-12-13 02:43:05.77413] [5933] [debug] GET "/api/1/hold" (a7ac7ca1)
[2018-12-13 02:43:05.77560] [5933] [debug] Routing to a callback
[2018-12-13 02:43:11.75903] [5933] [debug] 200 OK (5.984766s, 0.167/s)
[2018-12-13 02:44:19.91746] [5933] [debug] GET "/systems.xml" (17a64170)
[2018-12-13 02:44:19.91899] [5933] [debug] Routing to a callback
[2018-12-13 02:44:19.92249] [5933] [debug] 200 OK (0.004897s, 204.207/s)
------ The check above shows that the change has been made to systems.xml -----
[2018-12-13 02:45:02.93130] [5933] [debug] systems-3418W001316-status cached or passthru disabled
[2018-12-13 02:45:02.93249] [5933] [debug] /systems/3418W001316/status
[2018-12-13 02:45:02.96270] [5933] [debug] Saving status
[2018-12-13 02:45:03.05404] [5933] [debug] POST "/systems/3418W001316/status" (9affeeb3)
[2018-12-13 02:45:03.05570] [5933] [debug] Routing to a callback
[2018-12-13 02:45:03.05827] [5933] [debug] ********** There are changes. ****************
[2018-12-13 02:45:03.06569] [5933] [debug] 200 OK (0.011543s, 86.633/s)
[2018-12-13 02:45:03.40758] [5933] [debug] No cache for systems-3418W001316-config. Make Carrier request
REQUEST:
GET /systems/3418W001316/config HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: www.api.eng.bryant.com


------- and here it gets overwritten by a stale copy on Bryant's server
@sbrown4
Copy link
Contributor Author

sbrown4 commented Dec 13, 2018

Wrong diagnosis

After some more instrumentation, the t-stat doesn’t seem to parse elements without content properly. The construction is ok. But isn’t. The t-stat prefers the self-closing version.
The response to a get config using the latter gets ignored and sets off.

@sbrown4
Copy link
Contributor Author

sbrown4 commented Dec 13, 2018

My prior comment didn't have the tags escaped and doesn't make much sense with them missing.

The failure scenario is:

  1. Set a permanent hold using the t-stat's menus
    The next post system from the t-stat will have <otmr/> in zone 1
  2. Get /api/1/activity/away?clsp=50
  3. The next get config will get xml that has been recycled through XMLin & XMLout. converting the <otmr/> to <otmr></otmr>
  4. My t-stat ignores the xml returned by the get config, sets <cfgpgm> and maybe other stuff to 'off''. I have to go into the service menu to re-enable program mode.
    I'll look at the XML::Simple doc and see if there is a way around this.

@sbrown4
Copy link
Contributor Author

sbrown4 commented Dec 13, 2018

XML::Simple doesn't seem to be able to convert empty tags to self-closing tags. In fact, it dioes the opposite.

XML::LibXML has an option $XML::LibXML::setTagCompression = 1; that represents empty elements with begin/end elements. It defaults to representing them as self-closing.

This is a bug in the XML parser in the t-stat. I don't have much hope that Carrier/Bryant are likely to fix it.

@sbrown4 sbrown4 changed the title Thermostat fetches stale config from Bryant/Carrier server Thermostat requires empty elements to be self-closing tags Dec 14, 2018
@sbrown4
Copy link
Contributor Author

sbrown4 commented Dec 18, 2018

I used XML::LibXML to "cleanse" the local systems.xml response to get config. The problem is gone. Though not a solution, I'm convinced that the problem is the t-stat is only happy with empty elements as self-closing tags.

Changing libraries seems like a lot of work. Anybody have a better idea?

@sbrown4
Copy link
Contributor Author

sbrown4 commented Dec 18, 2018

There's got to be a regex expression to convert to . The thermostat is really unhappy with the former.

I've worked on this for hours and all I have is a headache. This was pretty easy with SNOBOL back in the day.

@nebulous
Copy link
Owner

The thermostat is way too picky(in non-standard ways) with xml parsing. I've been toying with the idea of only modifying the text of xml responses from the Carrier servers rather than doing correct parsing and regeneration. In throwaway test branches I've been able to convince myself that the stat actually cares about key order as well. Facepalm.

@nebulous
Copy link
Owner

I used XML::LibXML to "cleanse" the local systems.xml response to get config. The problem is gone. Though not a solution, I'm convinced that the problem is the t-stat is only happy with empty elements as self-closing tags.

Changing libraries seems like a lot of work. Anybody have a better idea?

If it truly is the case that empty tags should always be self-closing, that's doable with an extension to XML::Simple::Minded. Possibly even with a regex on the text output, but hopefully can be done more elegantly than that.

@sbrown4
Copy link
Contributor Author

sbrown4 commented Dec 18, 2018 via email

@nebulous
Copy link
Owner

nebulous commented Dec 20, 2018

very naive patch applied which converts cases of <tag></tag> to <tag/> Hopefully that solves your problem and doesn't blow up anything else 😄

@sbrown4
Copy link
Contributor Author

sbrown4 commented Dec 20, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants