diff --git a/.clang-format b/.clang-format
index ee49bb82..2228af0b 100644
--- a/.clang-format
+++ b/.clang-format
@@ -2,7 +2,7 @@ Language: Cpp
BasedOnStyle: LLVM
UseTab: Never
IndentWidth: 4
-ColumnLimit: 140
+ColumnLimit: 160
TabWidth: 4
#BreakBeforeBraces: Custom
BraceWrapping:
diff --git a/.gitignore b/.gitignore
index 07428130..c88e89fd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,5 +6,5 @@
platformio.ini
lib/readme.txt
.travis.yml
-stackdmp.txt
-*.jar
\ No newline at end of file
+;stackdmp.txt
+;*.jar
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 12c35617..ce93a42e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [1.7.0] 2019-05-11
+
+### Added
+
+- EMS+ core support (thanks too @gl3nni3 for doing the first research)
+- MQTT 'restart' topic to reboot ESP (thanks @balk77)
+- Support for multiple thermostat heating circuits like the HC1/HC2 on a RC35, also via MQTT (thanks @lobocobra)
+- `boiler flowtemp` command to set the flow temperature [(issue 59)](https://github.com/proddy/EMS-ESP/issues/59)
+- added a test harness to try out response to various telegrams (test command)
+- `tx_delay` setting for circuits where we needed to slow down Tx transmission
+- new boiler: Nefit proline hrc 24 cw4 thermostat and Nefit Enviline heatpump
+- new boiler: Buderus Logamax plus
+- new thermostat: Buderus RC300 and RC310 thermostats, read-only [(issue 37)](https://github.com/proddy/EMS-ESP/issues/37)
+- new thermostat: Junkers FR10, read-only [(issue 98)](https://github.com/proddy/EMS-ESP/issues/98)
+- new devices: Buderus Web Gateway KM200, Buderus Solar Module SM100
+
+### Changed
+
+- `types` renamed to `devices` to also show all detected devices
+- renamed `silent_mode` to `listen_mode`
+- increased Tx queue to 100
+
## [1.6.0] 2019-03-24
### Added
diff --git a/LICENSE b/LICENSE
index 98cee45b..0a041280 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,680 +1,3 @@
-<<<<<<< HEAD
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- Copyright (C)
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-.
-
-=======
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
@@ -840,4 +163,3 @@ whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
->>>>>>> d3a07d22b59af38c2308d6a14bfd043dec282dc3
diff --git a/doc/Domoticz/readme.txt b/doc/Domoticz/readme.txt
index cc8965ab..0f39859b 100644
--- a/doc/Domoticz/readme.txt
+++ b/doc/Domoticz/readme.txt
@@ -1,10 +1,10 @@
-to install the plugin:
-- copy the directory 'nefit' to the domoticz/plugins directory
-- make sure that 'Accept new Hardware Devices' is enabeled in settings/sysem
-- create new hardware with type 'Nefit EMS-ESP with Proddy firmware'
-- set MQTT server and port
-
-The plugin crrently creates 3 devices:
-- a room temperature meter
-- a system pressure meter
+to install the plugin:
+- copy the directory 'nefit' to the domoticz/plugins directory
+- make sure that 'Accept new Hardware Devices' is enabeled in settings/sysem
+- create new hardware with type 'Nefit EMS-ESP with Proddy firmware'
+- set MQTT server and port
+
+The plugin crrently creates 3 devices:
+- a room temperature meter
+- a system pressure meter
- a thermostat setpoint control
\ No newline at end of file
diff --git a/doc/home_assistant/climate.yaml b/doc/home_assistant/climate.yaml
index 18799bc1..b344c66f 100644
--- a/doc/home_assistant/climate.yaml
+++ b/doc/home_assistant/climate.yaml
@@ -1,9 +1,9 @@
- platform: mqtt
name: Thermostat
modes:
- - low
- - manual
- - auto
+ - "auto"
+ - "manual"
+ - "off"
mode_state_topic: "home/ems-esp/thermostat_data"
current_temperature_topic: "home/ems-esp/thermostat_data"
@@ -20,6 +20,9 @@
- platform: mqtt
name: boiler
+ modes:
+ - "on"
+ - "off"
min_temp: 40
max_temp: 60
temp_step: 1
@@ -28,3 +31,6 @@
temperature_command_topic: "home/ems-esp/boiler_cmd_wwtemp"
current_temperature_template: "{{ value_json.wWCurTmp }}"
temperature_state_template: "{{ value_json.wWSelTemp }}"
+ mode_state_template: "{{ value_json.wWActivated }}"
+ mode_state_topic: "home/ems-esp/boiler_data"
+ mode_command_topic: "home/ems-esp/wwactivated"
diff --git a/lib/myESP/MyESP.cpp b/lib/MyESP/MyESP.cpp
similarity index 93%
rename from lib/myESP/MyESP.cpp
rename to lib/MyESP/MyESP.cpp
index 0072d382..109fb6e1 100644
--- a/lib/myESP/MyESP.cpp
+++ b/lib/MyESP/MyESP.cpp
@@ -155,8 +155,6 @@ void MyESP::_wifiCallback(justwifi_messages_t code, char * parameter) {
// finally if we don't want Serial anymore, turn it off
if (!_use_serial) {
myDebug_P(PSTR("Disabling serial port"));
- Serial.flush();
- Serial.end();
SerialAndTelnet.setSerial(NULL);
} else {
myDebug_P(PSTR("Using serial port output"));
@@ -231,6 +229,22 @@ void MyESP::_mqttOnMessage(char * topic, char * payload, size_t len) {
topic = topic_magnitude + 1;
}
+ // check for standard messages
+ // Restart the device
+ if (strcmp(topic, MQTT_TOPIC_RESTART) == 0) {
+ myDebug_P(PSTR("[MQTT] Received restart command"), message);
+ myESP.resetESP();
+ return;
+ }
+
+ // handle response from a start message
+ // for example with HA it sends the system time from the server
+ if (strcmp(topic, MQTT_TOPIC_START) == 0) {
+ myDebug_P(PSTR("[MQTT] Received boottime: %s"), message);
+ myESP.setBoottime(message);
+ return;
+ }
+
// Send message event to custom service
(_mqtt_callback)(MQTT_MESSAGE_EVENT, topic, message);
}
@@ -269,6 +283,13 @@ void MyESP::_mqttOnConnect() {
// say we're alive to the Last Will topic
mqttClient.publish(_mqttTopic(_mqtt_will_topic), 1, true, _mqtt_will_online_payload);
+ // subscribe to general subs
+ mqttSubscribe(MQTT_TOPIC_RESTART);
+
+ // subscribe to a start message and send the first publish
+ myESP.mqttSubscribe(MQTT_TOPIC_START);
+ myESP.mqttPublish(MQTT_TOPIC_START, MQTT_TOPIC_START_PAYLOAD);
+
// call custom function to handle mqtt receives
(_mqtt_callback)(MQTT_CONNECT_EVENT, NULL, NULL);
}
@@ -308,10 +329,9 @@ void MyESP::_mqtt_setup() {
//mqttClient.onPublish([this](uint16_t packetId) { myDebug_P(PSTR("[MQTT] Publish ACK for PID %d"), packetId); });
- mqttClient.onMessage(
- [this](char * topic, char * payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) {
- _mqttOnMessage(topic, payload, len);
- });
+ mqttClient.onMessage([this](char * topic, char * payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) {
+ _mqttOnMessage(topic, payload, len);
+ });
}
// WiFI setup
@@ -428,8 +448,23 @@ void MyESP::setTelnet(command_t * cmds, uint8_t count, telnetcommand_callback_f
void MyESP::_telnetConnected() {
myDebug_P(PSTR("[TELNET] Telnet connection established"));
_consoleShowHelp(); // Show the initial message
+
+ // show crash dump if just restarted after a fatal crash
+#ifdef CRASH
+ uint32_t crash_time;
+ EEPROMr.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_CRASH_TIME, crash_time);
+ if ((crash_time != 0) && (crash_time != 0xFFFFFFFF)) {
+ crashDump();
+ // clear crash data
+ crash_time = 0xFFFFFFFF;
+ EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_CRASH_TIME, crash_time);
+ EEPROMr.commit();
+ }
+#endif
+
+ // call callback
if (_telnet_callback) {
- (_telnet_callback)(TELNET_EVENT_CONNECT); // call callback
+ (_telnet_callback)(TELNET_EVENT_CONNECT);
}
}
@@ -467,7 +502,7 @@ void MyESP::_consoleShowHelp() {
myDebug_P(PSTR("*"));
myDebug_P(PSTR("* Commands:"));
- myDebug_P(PSTR("* ?=help, CTRL-D=quit telnet"));
+ myDebug_P(PSTR("* ?=help, CTRL-D/quit=exit telnet session"));
myDebug_P(PSTR("* set, system, reboot"));
#ifdef CRASH
myDebug_P(PSTR("* crash "));
@@ -679,10 +714,26 @@ bool MyESP::_changeSetting(uint8_t wc, const char * setting, const char * value)
return ok;
}
+// force the serial on/off
+void MyESP::setUseSerial(bool toggle) {
+ //(void)fs_saveConfig(); // save the setting for next reboot
+
+ if (toggle) {
+ SerialAndTelnet.setSerial(&Serial);
+ _use_serial = true;
+ } else {
+ SerialAndTelnet.setSerial(NULL);
+ _use_serial = false;
+ }
+}
+
void MyESP::_telnetCommand(char * commandLine) {
char * str = commandLine;
bool state = false;
+ if (strlen(commandLine) == 0)
+ return;
+
// count the number of arguments
unsigned wc = 0;
while (*str) {
@@ -732,6 +783,14 @@ void MyESP::_telnetCommand(char * commandLine) {
return;
}
+ // show system stats
+ if ((strcmp(ptrToCommandName, "quit") == 0) && (wc == 1)) {
+ myDebug_P(PSTR("[TELNET] exiting telnet session"));
+ SerialAndTelnet.disconnectClient();
+ return;
+ }
+
+
// crash command
#ifdef CRASH
if ((strcmp(ptrToCommandName, "crash") == 0) && (wc >= 2)) {
@@ -820,12 +879,16 @@ void MyESP::showSystemStats() {
if (_boottime != NULL) {
myDebug_P(PSTR(" [APP] Boot time: %s"), _boottime);
}
+
+ // uptime
uint32_t t = _getUptime(); // seconds
- uint32_t h = (uint32_t)t / (uint32_t)3600L;
- uint32_t rem = (uint32_t)t % (uint32_t)3600L;
- uint32_t m = rem / 60;
- uint32_t s = rem % 60;
- myDebug_P(PSTR(" [APP] Uptime: %d seconds (%02d:%02d:%02d)"), t, h, m, s);
+ uint32_t d = t / 86400L;
+ uint32_t h = (t / 3600L) % 60;
+ uint32_t rem = t % 3600L;
+ uint8_t m = rem / 60;
+ uint8_t s = rem % 60;
+ myDebug_P(PSTR(" [APP] Uptime: %d days, %d hours, %d minutes, %d seconds"), d, h, m, s);
+
myDebug_P(PSTR(" [APP] System Load: %d%%"), getSystemLoadAverage());
if (isAPmode()) {
@@ -873,8 +936,7 @@ void MyESP::showSystemStats() {
myDebug_P(PSTR(" [FLASH] Flash chip ID: 0x%06X"), ESP.getFlashChipId());
#endif
myDebug_P(PSTR(" [FLASH] Flash speed: %u Hz"), ESP.getFlashChipSpeed());
- myDebug_P(PSTR(" [FLASH] Flash mode: %s"),
- mode == FM_QIO ? "QIO" : mode == FM_QOUT ? "QOUT" : mode == FM_DIO ? "DIO" : mode == FM_DOUT ? "DOUT" : "UNKNOWN");
+ myDebug_P(PSTR(" [FLASH] Flash mode: %s"), mode == FM_QIO ? "QIO" : mode == FM_QOUT ? "QOUT" : mode == FM_DIO ? "DIO" : mode == FM_DOUT ? "DOUT" : "UNKNOWN");
#if defined(ESP8266)
myDebug_P(PSTR(" [FLASH] Flash size (CHIP): %d"), ESP.getFlashChipRealSize());
#endif
@@ -884,9 +946,6 @@ void MyESP::showSystemStats() {
myDebug_P(PSTR(" [MEM] Max OTA size: %d"), (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000);
myDebug_P(PSTR(" [MEM] OTA Reserved: %d"), 4 * SPI_FLASH_SEC_SIZE);
myDebug_P(PSTR(" [MEM] Free Heap: %d"), ESP.getFreeHeap());
-#if defined(ESP8266)
- myDebug_P(PSTR(" [MEM] Stack: %d"), ESP.getFreeContStack());
-#endif
myDebug_P(PSTR(""));
}
@@ -899,12 +958,16 @@ void MyESP::_telnetHandle() {
while (SerialAndTelnet.available()) {
char c = SerialAndTelnet.read();
+ if (c == 0)
+ return;
+
SerialAndTelnet.serialPrint(c); // echo to Serial (if connected)
switch (c) {
case '\r': // likely have full command in buffer now, commands are terminated by CR and/or LF
case '\n':
_command[charsRead] = '\0'; // null terminate our command char array
+
if (charsRead > 0) {
charsRead = 0; // is static, so have to reset
_suspendOutput = false;
@@ -948,7 +1011,7 @@ void MyESP::_telnetHandle() {
}
}
-// ensure we have a connection to MQTT broker
+// make sure we have a connection to MQTT broker
void MyESP::_mqttConnect() {
if (!_mqtt_host)
return; // MQTT not enabled
@@ -1155,7 +1218,7 @@ bool MyESP::_fs_loadConfig() {
// Deserialize the JSON document
DeserializationError error = deserializeJson(doc, configFile);
if (error) {
- Serial.println(F("[FS] Failed to read file"));
+ myDebug_P(PSTR("[FS] Failed to read config file. Error %s"), error.c_str());
return false;
}
@@ -1360,15 +1423,15 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack
void MyESP::crashTest(uint8_t t) {
if (t == 1) {
- myDebug("[CRASH] Attempting to divide by zero ...");
+ myDebug_P(PSTR("[CRASH] Attempting to divide by zero ..."));
int result, zero;
zero = 0;
result = 1 / zero;
- myDebug("Result = %d", result);
+ myDebug_P(PSTR("Result = %d"), result);
}
if (t == 2) {
- myDebug("[CRASH] Attempting to read through a pointer to no object ...");
+ myDebug_P(PSTR("[CRASH] Attempting to read through a pointer to no object ..."));
int * nullPointer;
nullPointer = NULL;
// null pointer dereference - read
@@ -1377,7 +1440,7 @@ void MyESP::crashTest(uint8_t t) {
}
if (t == 3) {
- Serial.printf("[CRASH] Crashing with hardware WDT (%ld ms) ...\n", millis());
+ myDebug_P(PSTR("[CRASH] Crashing with hardware WDT (%ld ms) ...\n"), millis());
ESP.wdtDisable();
while (true) {
// stay in an infinite loop doing nothing
@@ -1390,7 +1453,7 @@ void MyESP::crashTest(uint8_t t) {
}
if (t == 4) {
- Serial.printf("[CRASH] Crashing with software WDT (%ld ms) ...\n", millis());
+ myDebug_P(PSTR("[CRASH] Crashing with software WDT (%ld ms) ...\n"), millis());
while (true) {
// stay in an infinite loop doing nothing
// this way other process can not be executed
@@ -1444,7 +1507,7 @@ void MyESP::crashDump() {
uint32_t stack_trace;
- myDebug(">>>stack>>>");
+ myDebug_P(PSTR(">>>stack>>>"));
for (int16_t i = 0; i < stack_len; i += 0x10) {
SerialAndTelnet.printf("%08x: ", stack_start + i);
@@ -1455,7 +1518,7 @@ void MyESP::crashDump() {
}
SerialAndTelnet.println();
}
- myDebug("<<
#include
@@ -32,7 +32,6 @@ void custom_crash_callback(struct rst_info *, uint32_t, uint32_t);
#define ets_vsnprintf vsnprintf // added for ESP32
#define OTA_PORT 8266
#else
-//#include
#include
#define OTA_PORT 3232
#endif
@@ -42,16 +41,18 @@ void custom_crash_callback(struct rst_info *, uint32_t, uint32_t);
#define LOADAVG_INTERVAL 30000 // Interval between calculating load average (in ms)
// WIFI
-#define WIFI_CONNECT_TIMEOUT 10000 // Connecting timeout for WIFI in ms
-#define WIFI_RECONNECT_INTERVAL 60000 // If could not connect to WIFI, retry after this time in ms
+#define WIFI_CONNECT_TIMEOUT 10000 // Connecting timeout for WIFI in ms
+#define WIFI_RECONNECT_INTERVAL 600000 // If could not connect to WIFI, retry after this time in ms. 10 minutes
// MQTT
#define MQTT_PORT 1883 // MQTT port
#define MQTT_RECONNECT_DELAY_MIN 2000 // Try to reconnect in 3 seconds upon disconnection
#define MQTT_RECONNECT_DELAY_STEP 3000 // Increase the reconnect delay in 3 seconds after each failed attempt
#define MQTT_RECONNECT_DELAY_MAX 120000 // Set reconnect time to 2 minutes at most
-#define MQTT_MAX_SIZE 600 // max length of MQTT message
#define MQTT_MAX_TOPIC_SIZE 50 // max length of MQTT message
+#define MQTT_TOPIC_START "start"
+#define MQTT_TOPIC_START_PAYLOAD "start"
+#define MQTT_TOPIC_RESTART "restart"
// Internal MQTT events
#define MQTT_CONNECT_EVENT 0
@@ -75,10 +76,18 @@ void custom_crash_callback(struct rst_info *, uint32_t, uint32_t);
#define COLOR_CYAN "\x1B[0;36m"
#define COLOR_WHITE "\x1B[0;37m"
#define COLOR_BOLD_ON "\x1B[1m"
-#define COLOR_BOLD_OFF "\x1B[22m" // fix by Scott Arlott to support Linux
+#define COLOR_BOLD_OFF "\x1B[22m"
+#define COLOR_BRIGHT_BLACK "\x1B[0;90m"
+#define COLOR_BRIGHT_RED "\x1B[0;91m"
+#define COLOR_BRIGHT_GREEN "\x1B[0;92m"
+#define COLOR_BRIGHT_YELLOW "\x1B[0;99m"
+#define COLOR_BRIGHT_BLUE "\x1B[0;94m"
+#define COLOR_BRIGHT_MAGENTA "\x1B[0;95m"
+#define COLOR_BRIGHT_CYAN "\x1B[0;96m"
+#define COLOR_BRIGHT_WHITE "\x1B[0;97m"
// SPIFFS
-#define SPIFFS_MAXSIZE 600 // https://arduinojson.org/v6/assistant/
+#define SPIFFS_MAXSIZE 800 // https://arduinojson.org/v6/assistant/
// CRASH
/**
@@ -171,6 +180,7 @@ class MyESP {
void myDebug_P(PGM_P format_P, ...);
void setTelnet(command_t * cmds, uint8_t count, telnetcommand_callback_f callback_cmd, telnet_callback_f callback);
bool getUseSerial();
+ void setUseSerial(bool toggle);
// FS
void setSettings(fs_callback_f callback, fs_settings_callback_f fs_settings_callback);
diff --git a/lib/TelnetSpy/TelnetSpy.cpp b/lib/TelnetSpy/TelnetSpy.cpp
index ea1762fa..6acbf9c4 100644
--- a/lib/TelnetSpy/TelnetSpy.cpp
+++ b/lib/TelnetSpy/TelnetSpy.cpp
@@ -346,6 +346,7 @@ void TelnetSpy::begin(unsigned long baud, SerialConfig config, SerialMode mode,
if (usedSer) {
usedSer->begin(baud, config, mode, tx_pin);
}
+
started = true;
}
@@ -435,7 +436,6 @@ TelnetSpy::operator bool() const {
void TelnetSpy::setDebugOutput(bool en) {
debugOutput = en;
- // TODO: figure out how to disable system printing for the ESP32
if (debugOutput) {
actualObject = this;
@@ -446,7 +446,6 @@ void TelnetSpy::setDebugOutput(bool en) {
} else {
if (actualObject == this) {
-
#ifdef ESP8266
system_set_os_print(false);
os_install_putc1((void *)TelnetSpy_ignore_putc); // Ignore system printing
diff --git a/platformio.ini-dev b/platformio.ini-dev
new file mode 100644
index 00000000..1861cc13
--- /dev/null
+++ b/platformio.ini-dev
@@ -0,0 +1,50 @@
+;
+; PlatformIO Project Configuration File for EMS-ESP
+; Uses PlatformIO 4.0
+;
+
+[platformio]
+env_default = debug
+
+[common]
+; hard code if you prefer. Recommendation is to set from within the app when in Serial or AP mode
+; wifi_settings = '-DWIFI_SSID="XXXX"' '-DWIFI_PASSWORD="XXXX"'
+wifi_settings =
+
+[env]
+platform = espressif8266
+; platform = https://github.com/platformio/platform-espressif8266.git
+board = d1_mini
+; board = nodemcuv2
+; board = d1_mini_pro
+framework = arduino
+lib_deps =
+ CRC32
+ CircularBuffer
+ JustWifi
+ AsyncMqttClient
+ ArduinoJson
+ OneWire
+ EEPROM_rotate
+lib_ignore =
+;lib_extra_dirs = D:\dev\lib
+upload_speed = 921600
+monitor_speed = 115200
+; Set the ESP8266 clock frequency to 160MHz
+;board_f_cpu = 160000000L
+upload_protocol = espota
+upload_port = ems-esp.local
+
+[env:debug]
+build_flags = -g -Wall -Wextra -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -DCRASH -DTESTS ${common.wifi_settings}
+
+[env:clean]
+extra_scripts = pre:scripts/clean_fw.py
+
+[env:release]
+build_flags = -g -w
+extra_scripts = pre:scripts/rename_fw.py
+
+[env:checkcode]
+build_flags = -g -Wall -Wextra -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -DCRASH -DTESTS
+extra_scripts = scripts/checkcode.py
diff --git a/platformio.ini-example b/platformio.ini-example
index 0a597bab..00f68f0a 100644
--- a/platformio.ini-example
+++ b/platformio.ini-example
@@ -8,11 +8,11 @@ flash_mode = dout
build_flags = -g -w
; for debug use these...
-; build_flags = -g -Wall -Wextra -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -DCRASH
+; build_flags = -g -Wall -Wextra -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -DCRASH -DTESTS
wifi_settings =
; hard code if you prefer. Recommendation is to set from within the app when in Serial or AP mode
-;wifi_settings = '-DWIFI_SSID="XXXX"' '-DWIFI_PASSWORD="XXXX"'
+; wifi_settings = '-DWIFI_SSID="XXXX"' '-DWIFI_PASSWORD="XXXX"'
lib_deps =
CRC32
@@ -35,6 +35,4 @@ monitor_speed = 115200
; for OTA comment out these sections
;upload_protocol = espota
;upload_port = ems-esp.local
-;upload_port =
-
-
+;upload_port =
diff --git a/scripts/EspStackTraceDecoder.jar b/scripts/EspStackTraceDecoder.jar
new file mode 100644
index 00000000..bc530183
Binary files /dev/null and b/scripts/EspStackTraceDecoder.jar differ
diff --git a/scripts/checkcode.py b/scripts/checkcode.py
new file mode 100644
index 00000000..53da6305
--- /dev/null
+++ b/scripts/checkcode.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+from subprocess import call
+import os
+Import("env")
+
+def code_check(source, target, env):
+ print("\n** Starting cppcheck...")
+ call(["cppcheck", os.getcwd()+"/.", "--force", "--enable=all"])
+ print("\n** Finished cppcheck...\n")
+ print("\n** Starting cpplint...")
+ call(["cpplint", "--extensions=ino,cpp,h", "--filter=-legal/copyright,-build/include,-whitespace",
+ "--linelength=120", "--recursive", "src", "lib/myESP"])
+ print("\n** Finished cpplint...")
+
+#my_flags = env.ParseFlags(env['BUILD_FLAGS'])
+#defines = {k: v for (k, v) in my_flags.get("CPPDEFINES")}
+# print defines
+# print env.Dump()
+
+# built in targets: (buildprog, size, upload, program, buildfs, uploadfs, uploadfsota)
+env.AddPreAction("buildprog", code_check)
+# env.AddPostAction(.....)
+
+# see http://docs.platformio.org/en/latest/projectconf/advanced_scripting.html#before-pre-and-after-post-actions
+# env.Replace(PROGNAME="firmware_%s" % defines.get("VERSION"))
+# env.Replace(PROGNAME="firmware_%s" % env['BOARD'])
diff --git a/scripts/clean_fw.py b/scripts/clean_fw.py
new file mode 100644
index 00000000..140f23ee
--- /dev/null
+++ b/scripts/clean_fw.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+from subprocess import call
+import os
+Import("env")
+
+def clean(source, target, env):
+ print("\n** Starting clean...")
+ call(["pio", "run", "-t", "erase"])
+ call(["esptool.py", "-p COM6", "write_flash 0x00000", os.getcwd()+"../firmware/*.bin"])
+ print("\n** Finished clean.")
+
+# built in targets: (buildprog, size, upload, program, buildfs, uploadfs, uploadfsota)
+env.AddPreAction("buildprog", clean)
+
diff --git a/scripts/debug.py b/scripts/debug.py
new file mode 100644
index 00000000..eb10e24a
--- /dev/null
+++ b/scripts/debug.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+from subprocess import call
+import os
+
+# example stackdmp.txt would contain text like below copied & pasted from a 'crash dump' command:
+
+# >>>stack>>>
+# 3fffff20: 3fff32f0 00000003 3fff3028 402101b2
+# 3fffff30: 3fffdad0 3fff3280 0000000d 402148aa
+# 3fffff40: 3fffdad0 3fff3280 3fff326c 3fff32f0
+# 3fffff50: 0000000d 3fff326c 3fff3028 402103bd
+# 3fffff60: 0000000d 3fff34cc 40211de4 3fff34cc
+# 3fffff70: 3fff3028 3fff14c4 3fff301c 3fff34cc
+# 3fffff80: 3fffdad0 3fff14c4 3fff3028 40210493
+# 3fffff90: 3fffdad0 00000000 3fff14c4 4020a738
+# 3fffffa0: 3fffdad0 00000000 3fff349c 40211e90
+# 3fffffb0: feefeffe feefeffe 3ffe8558 40100b01
+# <<[0-9]*)\\):$")
+COUNTER_REGEX = re.compile('^epc1=(?P0x[0-9a-f]+) epc2=(?P0x[0-9a-f]+) epc3=(?P0x[0-9a-f]+) '
+ 'excvaddr=(?P0x[0-9a-f]+) depc=(?P0x[0-9a-f]+)$')
+CTX_REGEX = re.compile("^ctx: (?P.+)$")
+POINTER_REGEX = re.compile('^sp: (?P[0-9a-f]+) end: (?P[0-9a-f]+) offset: (?P[0-9a-f]+)$')
+STACK_BEGIN = '>>>stack>>>'
+STACK_END = '<<[0-9a-f]+):\W+(?P[0-9a-f]+) (?P[0-9a-f]+) (?P[0-9a-f]+) (?P[0-9a-f]+)(\W.*)?$')
+
+StackLine = namedtuple("StackLine", ["offset", "content"])
+
+
+class ExceptionDataParser(object):
+ def __init__(self):
+ self.exception = None
+
+ self.epc1 = None
+ self.epc2 = None
+ self.epc3 = None
+ self.excvaddr = None
+ self.depc = None
+
+ self.ctx = None
+
+ self.sp = None
+ self.end = None
+ self.offset = None
+
+ self.stack = []
+
+ def _parse_exception(self, line):
+ match = EXCEPTION_REGEX.match(line)
+ if match is not None:
+ self.exception = int(match.group('exc'))
+ return self._parse_counters
+ return self._parse_exception
+
+ def _parse_counters(self, line):
+ match = COUNTER_REGEX.match(line)
+ if match is not None:
+ self.epc1 = match.group("epc1")
+ self.epc2 = match.group("epc2")
+ self.epc3 = match.group("epc3")
+ self.excvaddr = match.group("excvaddr")
+ self.depc = match.group("depc")
+ return self._parse_ctx
+ return self._parse_counters
+
+ def _parse_ctx(self, line):
+ match = CTX_REGEX.match(line)
+ if match is not None:
+ self.ctx = match.group("ctx")
+ return self._parse_pointers
+ return self._parse_ctx
+
+ def _parse_pointers(self, line):
+ match = POINTER_REGEX.match(line)
+ if match is not None:
+ self.sp = match.group("sp")
+ self.end = match.group("end")
+ self.offset = match.group("offset")
+ return self._parse_stack_begin
+ return self._parse_pointers
+
+ def _parse_stack_begin(self, line):
+ if line == STACK_BEGIN:
+ return self._parse_stack_line
+ return self._parse_stack_begin
+
+ def _parse_stack_line(self, line):
+ if line != STACK_END:
+ match = STACK_REGEX.match(line)
+ if match is not None:
+ self.stack.append(StackLine(offset=match.group("off"),
+ content=(match.group("c1"), match.group("c2"), match.group("c3"),
+ match.group("c4"))))
+ return self._parse_stack_line
+ return None
+
+ def parse_file(self, file, stack_only=False):
+ func = self._parse_exception
+ if stack_only:
+ func = self._parse_stack_begin
+
+ for line in file:
+ func = func(line.strip())
+ if func is None:
+ break
+
+ if func is not None:
+ print("ERROR: Parser not complete!")
+ sys.exit(1)
+
+
+class AddressResolver(object):
+ def __init__(self, tool_path, elf_path):
+ self._tool = tool_path
+ self._elf = elf_path
+ self._address_map = {}
+
+ def _lookup(self, addresses):
+ cmd = [self._tool, "-aipfC", "-e", self._elf] + [addr for addr in addresses if addr is not None]
+
+ if sys.version_info[0] < 3:
+ output = subprocess.check_output(cmd)
+ else:
+ output = subprocess.check_output(cmd, encoding="utf-8")
+
+ line_regex = re.compile("^(?P[0-9a-fx]+): (?P.+)$")
+
+ last = None
+ for line in output.splitlines():
+ line = line.strip()
+ match = line_regex.match(line)
+
+ if match is None:
+ if last is not None and line.startswith('(inlined by)'):
+ line = line [12:].strip()
+ self._address_map[last] += ("\n \-> inlined by: " + line)
+ continue
+
+ if match.group("result") == '?? ??:0':
+ continue
+
+ self._address_map[match.group("addr")] = match.group("result")
+ last = match.group("addr")
+
+ def fill(self, parser):
+ addresses = [parser.epc1, parser.epc2, parser.epc3, parser.excvaddr, parser.sp, parser.end, parser.offset]
+ for line in parser.stack:
+ addresses.extend(line.content)
+
+ self._lookup(addresses)
+
+ def _sanitize_addr(self, addr):
+ if addr.startswith("0x"):
+ addr = addr[2:]
+
+ fill = "0" * (8 - len(addr))
+ return "0x" + fill + addr
+
+ def resolve_addr(self, addr):
+ out = self._sanitize_addr(addr)
+
+ if out in self._address_map:
+ out += ": " + self._address_map[out]
+
+ return out
+
+ def resolve_stack_addr(self, addr, full=True):
+ addr = self._sanitize_addr(addr)
+ if addr in self._address_map:
+ return addr + ": " + self._address_map[addr]
+
+ if full:
+ return "[DATA (0x" + addr + ")]"
+
+ return None
+
+
+def print_addr(name, value, resolver):
+ print("{}:{} {}".format(name, " " * (8 - len(name)), resolver.resolve_addr(value)))
+
+
+def print_stack_full(lines, resolver):
+ print("stack:")
+ for line in lines:
+ print(line.offset + ":")
+ for content in line.content:
+ print(" " + resolver.resolve_stack_addr(content))
+
+
+def print_stack(lines, resolver):
+ print("stack:")
+ for line in lines:
+ for content in line.content:
+ out = resolver.resolve_stack_addr(content, full=False)
+ if out is None:
+ continue
+ print(out)
+
+
+def print_result(parser, resolver, full=True, stack_only=False):
+ if not stack_only:
+ print('Exception: {} ({})'.format(parser.exception, EXCEPTIONS[parser.exception]))
+
+ print("")
+ print_addr("epc1", parser.epc1, resolver)
+ print_addr("epc2", parser.epc2, resolver)
+ print_addr("epc3", parser.epc3, resolver)
+ print_addr("excvaddr", parser.excvaddr, resolver)
+ print_addr("depc", parser.depc, resolver)
+
+ print("")
+ print("ctx: " + parser.ctx)
+
+ print("")
+ print_addr("sp", parser.sp, resolver)
+ print_addr("end", parser.end, resolver)
+ print_addr("offset", parser.offset, resolver)
+
+ print("")
+ if full:
+ print_stack_full(parser.stack, resolver)
+ else:
+ print_stack(parser.stack, resolver)
+
+
+def parse_args():
+ parser = argparse.ArgumentParser(description="decode ESP Stacktraces.")
+
+ parser.add_argument("-p", "--platform", help="The platform to decode from", choices=PLATFORMS.keys(),
+ default="ESP8266")
+ parser.add_argument("-t", "--tool", help="Path to the xtensa toolchain",
+ default="~/.platformio/packages/toolchain-xtensa/")
+ parser.add_argument("-e", "--elf", help="path to elf file", required=True)
+ parser.add_argument("-f", "--full", help="Print full stack dump", action="store_true")
+ parser.add_argument("-s", "--stack_only", help="Decode only a stractrace", action="store_true")
+ parser.add_argument("file", help="The file to read the exception data from ('-' for STDIN)", default="-")
+
+ return parser.parse_args()
+
+
+if __name__ == "__main__":
+ args = parse_args()
+
+ if args.file == "-":
+ file = sys.stdin
+ else:
+ if not os.path.exists(args.file):
+ print("ERROR: file " + args.file + " not found")
+ sys.exit(1)
+ file = open(args.file, "r")
+
+ addr2line = os.path.join(os.path.abspath(os.path.expanduser(args.tool)),
+ "bin/xtensa-" + PLATFORMS[args.platform] + "-elf-addr2line.exe")
+ if not os.path.exists(addr2line):
+ print("ERROR: addr2line not found (" + addr2line + ")")
+
+ elf_file = os.path.abspath(os.path.expanduser(args.elf))
+ if not os.path.exists(elf_file):
+ print("ERROR: elf file not found (" + elf_file + ")")
+
+ parser = ExceptionDataParser()
+ resolver = AddressResolver(addr2line, elf_file)
+
+ parser.parse_file(file, args.stack_only)
+ resolver.fill(parser)
+
+ print_result(parser, resolver, args.full, args.stack_only)
diff --git a/scripts/rename_fw.py b/scripts/rename_fw.py
new file mode 100644
index 00000000..7b4d4229
--- /dev/null
+++ b/scripts/rename_fw.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+from subprocess import call
+import os
+Import("env")
+
+# see http://docs.platformio.org/en/latest/projectconf/advanced_scripting.html#before-pre-and-after-post-actions
+# env.Replace(PROGNAME="firmware_%s" % defines.get("VERSION"))
+env.Replace(PROGNAME="firmware_%s" % env['BOARD'])
diff --git a/scripts/stackdmp.txt b/scripts/stackdmp.txt
new file mode 100644
index 00000000..afd25142
--- /dev/null
+++ b/scripts/stackdmp.txt
@@ -0,0 +1,11 @@
+>>>stack>>>
+3fffff30: 00000020 3fff4dcc 0000000d 40216e4e
+3fffff40: 00000020 3fff4dcc 3fff4db8 3fff4e3c
+3fffff50: 0000000d 3fff4db8 3fff4b64 4021280d
+3fffff60: 0000000d 3fff5094 3ffe8560 3fff5038
+3fffff70: 3fff4b64 3fff316c 3fff4b54 3fff5038
+3fffff80: 3fffdad0 3fff316c 3fff4b64 402128df
+3fffff90: 3fffdad0 00000000 3fff316c 4020bc20
+3fffffa0: 3fffdad0 00000000 3fff5008 402143d4
+3fffffb0: feefeffe feefeffe 3ffe8560 40100b01
+<<0 if the ESP is overheating or there are timing issues. Recommend a value of 1.
#define EMSESP_DELAY 1 // initially set to 0 for no delay
+#define DEFAULT_HEATINGCIRCUIT 1 // default to HC1 for thermostats that support multiple heating circuits like the RC35
+
// timers, all values are in seconds
#define DEFAULT_PUBLISHWAIT 120 // every 2 minutes publish MQTT values, including Dallas sensors
Ticker publishValuesTimer;
Ticker publishSensorValuesTimer;
-#define SYSTEMCHECK_TIME 20 // every 20 seconds check if Boiler is online
+#define SYSTEMCHECK_TIME 10 // every 10 seconds check if EMS can be reached
Ticker systemCheckTimer;
#define REGULARUPDATES_TIME 60 // every minute a call is made to fetch data from EMS devices manually
@@ -53,6 +55,11 @@ Ticker scanThermostat;
#define SCANTHERMOSTAT_TIME 1
uint8_t scanThermostat_count = 0;
+// ems bus scan
+Ticker scanDevices;
+#define SCANDEVICES_TIME 350 // ms
+uint8_t scanDevices_count;
+
Ticker showerColdShotStopTimer;
// if using the shower timer, change these settings
@@ -63,26 +70,27 @@ Ticker showerColdShotStopTimer;
#define SHOWER_MAX_DURATION 420000 // in ms. 7 minutes, before trigger a shot of cold water
typedef struct {
- unsigned long timestamp; // for internal timings, via millis()
- uint8_t dallas_sensors; // count of dallas sensors
+ uint32_t timestamp; // for internal timings, via millis()
+ uint8_t dallas_sensors; // count of dallas sensors
// custom params
- bool shower_timer; // true if we want to report back on shower times
- bool shower_alert; // true if we want the alert of cold water
- bool led; // LED on/off
- bool silent_mode; // stop automatic Tx on/off
- uint16_t publish_wait; // frequency of MQTT publish in seconds
- uint8_t led_gpio;
- uint8_t dallas_gpio;
- uint8_t dallas_parasite;
+ bool shower_timer; // true if we want to report back on shower times
+ bool shower_alert; // true if we want the alert of cold water
+ bool led; // LED on/off
+ bool listen_mode; // stop automatic Tx on/off
+ uint16_t publish_wait; // frequency of MQTT publish in seconds
+ uint8_t led_gpio; // pin for LED
+ uint8_t dallas_gpio; // pin for attaching external dallas temperature sensors
+ bool dallas_parasite; // on/off is using parasite
+ uint8_t heating_circuit; // number of heating circuit, 1 or 2
} _EMSESP_Status;
typedef struct {
- bool showerOn;
- unsigned long timerStart; // ms
- unsigned long timerPause; // ms
- unsigned long duration; // ms
- bool doingColdShot; // true if we've just sent a jolt of cold water
+ bool showerOn;
+ uint32_t timerStart; // ms
+ uint32_t timerPause; // ms
+ uint32_t duration; // ms
+ bool doingColdShot; // true if we've just sent a jolt of cold water
} _EMSESP_Shower;
command_t PROGMEM project_cmds[] = {
@@ -91,30 +99,35 @@ command_t PROGMEM project_cmds[] = {
{true, "led_gpio ", "set the LED pin. Default is the onboard LED (D1=5)"},
{true, "dallas_gpio ", "set the pin for external Dallas temperature sensors (D5=14)"},
{true, "dallas_parasite ", "set to on if powering Dallas via parasite"},
- {true, "thermostat_type ", "set the thermostat type id (e.g. 10 for 0x10)"},
- {true, "boiler_type ", "set the boiler type id (e.g. 8 for 0x08)"},
- {true, "silent_mode ", "when on all automatic Tx is disabled"},
+ {true, "thermostat_type ", "set the thermostat type id (e.g. 10 for 0x10)"},
+ {true, "boiler_type ", "set the boiler type id (e.g. 8 for 0x08)"},
+ {true, "listen_mode ", "when on all automatic Tx is disabled"},
{true, "shower_timer ", "notify via MQTT all shower durations"},
{true, "shower_alert ", "send a warning of cold water after shower time is exceeded"},
{true, "publish_wait ", "set frequency for publishing to MQTT"},
+ {true, "heating_circuit <1 | 2>", "set the thermostat HC to work with if using multiple heating circuits"},
+ {true, "tx_delay ", "turn on if Tx not working on newer boilers"},
{false, "info", "show data captured on the EMS bus"},
{false, "log ", "set logging mode to none, basic, thermostat only, raw or verbose"},
{false, "publish", "publish all values to MQTT"},
{false, "refresh", "fetch values from the EMS devices"},
- {false, "types", "list supported EMS telegram type IDs"},
+ {false, "devices", "list all supported and detected EMS devices and types IDs"},
{false, "queue", "show current Tx queue"},
- {false, "autodetect", "detect EMS devices and attempt to automatically set boiler and thermostat types"},
+ {false, "autodetect [deep]", "detect EMS devices and attempt to automatically set boiler and thermostat types"},
{false, "shower ", "toggle either timer or alert on/off"},
{false, "send XX ...", "send raw telegram data as hex to EMS bus"},
{false, "thermostat read ", "send read request to the thermostat"},
{false, "thermostat temp ", "set current thermostat temperature"},
{false, "thermostat mode ", "set mode (0=low/night, 1=manual/day, 2=auto)"},
- {false, "thermostat scan ", "do a read on all type IDs"},
+ {false, "thermostat scan ", "probe thermostat on all type id responses"},
{false, "boiler read ", "send read request to boiler"},
{false, "boiler wwtemp ", "set boiler warm water temperature"},
{false, "boiler tapwater ", "set boiler warm tap water on/off"},
- {false, "boiler comfort ", "set boiler warm water comfort setting"}};
+ {false, "boiler flowtemp ", "set boiler flow temperature"},
+ {false, "boiler comfort ", "set boiler warm water comfort setting"}
+
+};
// store for overall system status
_EMSESP_Status EMSESP_Status;
@@ -131,23 +144,19 @@ void myDebugLog(const char * s) {
char * _float_to_char(char * a, float f, uint8_t precision = 2) {
long p[] = {0, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000};
- char * ret = a;
- // check for 0x8000 (sensor missing)
- if (f == EMS_VALUE_SHORT_NOTSET) {
- strlcpy(ret, "?", sizeof(ret));
- } else {
- long whole = (long)f;
- itoa(whole, a, 10);
- while (*a != '\0')
- a++;
- *a++ = '.';
- long decimal = abs((long)((f - whole) * p[precision]));
- itoa(decimal, a, 10);
- }
+ char * ret = a;
+ long whole = (long)f;
+ itoa(whole, a, 10);
+ while (*a != '\0')
+ a++;
+ *a++ = '.';
+ long decimal = abs((long)((f - whole) * p[precision]));
+ itoa(decimal, a, 10);
+
return ret;
}
-// convert bool to text
+// convert bool to text. bools are stored as bytes
char * _bool_to_char(char * s, uint8_t value) {
if (value == EMS_VALUE_INT_ON) {
strlcpy(s, "on", sizeof(s));
@@ -159,39 +168,42 @@ char * _bool_to_char(char * s, uint8_t value) {
return s;
}
-// convert short (two bytes) to text value
+// convert short (two bytes) to text string
+// decimals: 0 = no division, 1=divide value by 10, 10=divide value by 100
// negative values are assumed stored as 1-compliment (https://medium.com/@LeeJulija/how-integers-are-stored-in-memory-using-twos-complement-5ba04d61a56c)
char * _short_to_char(char * s, int16_t value, uint8_t decimals = 1) {
- // remove errors on invalid values
+ // remove errors or invalid values
if (abs(value) >= EMS_VALUE_SHORT_NOTSET) {
- strlcpy(s, "?", sizeof(s));
+ strlcpy(s, "?", 10);
return (s);
}
+ // just print
if (decimals == 0) {
- itoa(value, s, 10);
+ ltoa(value, s, 10);
return (s);
}
- // floating point
- char s2[5] = {0};
+ // do floating point
+ char s2[10] = {0};
// check for negative values
if (value < 0) {
- strlcpy(s, "-", 2);
+ strlcpy(s, "-", 10);
value = abs(value);
}
- strlcpy(s, itoa(value / (decimals * 10), s2, 10), 5);
- strlcat(s, ".", sizeof(s));
- strlcat(s, itoa(value % (decimals * 10), s2, 10), 5);
+
+ strlcpy(s, ltoa(value / (decimals * 10), s2, 10), 10);
+ strlcat(s, ".", 10);
+ strlcat(s, ltoa(value % (decimals * 10), s2, 10), 10);
return s;
}
// takes a short value (2 bytes), converts to a fraction
-// most values stored a s short are either *10 or *100
+// decimals: 0 = no division, 1=divide value by 10, 10=divide value by 100
void _renderShortValue(const char * prefix, const char * postfix, int16_t value, uint8_t decimals = 1) {
- char buffer[200] = {0};
- char s[20] = {0};
+ static char buffer[200] = {0};
+ static char s[20] = {0};
strlcpy(buffer, " ", sizeof(buffer));
strlcat(buffer, prefix, sizeof(buffer));
strlcat(buffer, ": ", sizeof(buffer));
@@ -213,7 +225,7 @@ char * _int_to_char(char * s, uint8_t value, uint8_t div = 1) {
return (s);
}
- char s2[5] = {0};
+ static char s2[5] = {0};
switch (div) {
case 1:
@@ -242,8 +254,8 @@ char * _int_to_char(char * s, uint8_t value, uint8_t div = 1) {
// takes an int value (1 byte), converts to a fraction
void _renderIntValue(const char * prefix, const char * postfix, uint8_t value, uint8_t div = 1) {
- char buffer[200] = {0};
- char s[20] = {0};
+ static char buffer[200] = {0};
+ static char s[20] = {0};
strlcpy(buffer, " ", sizeof(buffer));
strlcat(buffer, prefix, sizeof(buffer));
strlcat(buffer, ": ", sizeof(buffer));
@@ -260,7 +272,7 @@ void _renderIntValue(const char * prefix, const char * postfix, uint8_t value, u
// takes a long value at prints it to debug log
void _renderLongValue(const char * prefix, const char * postfix, uint32_t value) {
- char buffer[200] = {0};
+ static char buffer[200] = {0};
strlcpy(buffer, " ", sizeof(buffer));
strlcat(buffer, prefix, sizeof(buffer));
strlcat(buffer, ": ", sizeof(buffer));
@@ -282,8 +294,8 @@ void _renderLongValue(const char * prefix, const char * postfix, uint32_t value)
// takes a bool value at prints it to debug log
void _renderBoolValue(const char * prefix, uint8_t value) {
- char buffer[200] = {0};
- char s[20] = {0};
+ static char buffer[200] = {0};
+ static char s[20] = {0};
strlcpy(buffer, " ", sizeof(buffer));
strlcat(buffer, prefix, sizeof(buffer));
strlcat(buffer, ": ", sizeof(buffer));
@@ -297,51 +309,61 @@ void _renderBoolValue(const char * prefix, uint8_t value) {
void showInfo() {
// General stats from EMS bus
- char buffer_type[128] = {0};
+ static char buffer_type[128] = {0};
- myDebug("%sEMS-ESP system stats:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF);
+ myDebug_P(PSTR("%sEMS-ESP system stats:%s"), COLOR_BOLD_ON, COLOR_BOLD_OFF);
_EMS_SYS_LOGGING sysLog = ems_getLogging();
if (sysLog == EMS_SYS_LOGGING_BASIC) {
- myDebug(" System logging set to Basic");
+ myDebug_P(PSTR(" System logging set to Basic"));
} else if (sysLog == EMS_SYS_LOGGING_VERBOSE) {
- myDebug(" System logging set to Verbose");
+ myDebug_P(PSTR(" System logging set to Verbose"));
} else if (sysLog == EMS_SYS_LOGGING_THERMOSTAT) {
- myDebug(" System logging set to Thermostat only");
+ myDebug_P(PSTR(" System logging set to Thermostat only"));
} else {
- myDebug(" System logging set to None");
+ myDebug_P(PSTR(" System logging set to None"));
+ }
+
+ myDebug_P(PSTR(" LED is %s, Listen mode is %s"), EMSESP_Status.led ? "on" : "off", EMSESP_Status.listen_mode ? "on" : "off");
+ if (EMSESP_Status.dallas_sensors > 0) {
+ myDebug_P(PSTR(" %d external temperature sensor%s found"), EMSESP_Status.dallas_sensors, (EMSESP_Status.dallas_sensors == 1) ? "" : "s");
}
- myDebug(" LED is %s, Silent mode is %s", EMSESP_Status.led ? "on" : "off", EMSESP_Status.silent_mode ? "on" : "off");
- myDebug(" %d external temperature sensor%s connected", EMSESP_Status.dallas_sensors, (EMSESP_Status.dallas_sensors > 1) ? "s" : "");
+ myDebug_P(PSTR(" Thermostat is %s, Boiler is %s, Shower Timer is %s, Shower Alert is %s"),
+ (ems_getThermostatEnabled() ? "enabled" : "disabled"),
+ (ems_getBoilerEnabled() ? "enabled" : "disabled"),
+ ((EMSESP_Status.shower_timer) ? "enabled" : "disabled"),
+ ((EMSESP_Status.shower_alert) ? "enabled" : "disabled"));
- myDebug(" Thermostat is %s, Boiler is %s, Shower Timer is %s, Shower Alert is %s",
- (ems_getThermostatEnabled() ? "enabled" : "disabled"),
- (ems_getBoilerEnabled() ? "enabled" : "disabled"),
- ((EMSESP_Status.shower_timer) ? "enabled" : "disabled"),
- ((EMSESP_Status.shower_alert) ? "enabled" : "disabled"));
+ myDebug_P(PSTR("\n%sEMS Bus stats:%s"), COLOR_BOLD_ON, COLOR_BOLD_OFF);
- myDebug("\n%sEMS Bus stats:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF);
- myDebug(" Bus Connected=%s, Tx is %s, # Rx telegrams=%d, # Tx telegrams=%d, # Crc Errors=%d",
- (ems_getBusConnected() ? "yes" : "no"),
- (ems_getTxCapable() ? "active" : "not active"),
- EMS_Sys_Status.emsRxPgks,
- EMS_Sys_Status.emsTxPkgs,
- EMS_Sys_Status.emxCrcErr);
+ if (ems_getBusConnected()) {
+ myDebug_P(PSTR(" Bus is connected"));
- myDebug("");
- myDebug("%sBoiler stats:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF);
+ myDebug_P(PSTR(" Rx: Poll=%d ms, # Rx telegrams read=%d, # CRC errors=%d"), ems_getPollFrequency(), EMS_Sys_Status.emsRxPgks, EMS_Sys_Status.emxCrcErr);
+
+ if (ems_getTxCapable()) {
+ myDebug_P(PSTR(" Tx: available, Tx delay is %s, # Tx telegrams sent=%d"), (ems_getTxDelay() ? "on" : "off"), EMS_Sys_Status.emsTxPkgs);
+ } else {
+ myDebug_P(PSTR(" Tx: no signal"));
+ }
+ } else {
+ myDebug_P(PSTR(" No connection can be made to the EMS bus"));
+ }
+
+ myDebug_P(PSTR(""));
+ myDebug_P(PSTR("%sBoiler stats:%s"), COLOR_BOLD_ON, COLOR_BOLD_OFF);
// version details
- myDebug(" Boiler type: %s", ems_getBoilerDescription(buffer_type));
+ myDebug_P(PSTR(" Boiler: %s"), ems_getBoilerDescription(buffer_type));
// active stats
if (ems_getBusConnected()) {
if (EMS_Boiler.tapwaterActive != EMS_VALUE_INT_NOTSET) {
- myDebug(" Hot tap water: %s", EMS_Boiler.tapwaterActive ? "running" : "off");
+ myDebug_P(PSTR(" Hot tap water: %s"), EMS_Boiler.tapwaterActive ? "running" : "off");
}
if (EMS_Boiler.heatingActive != EMS_VALUE_INT_NOTSET) {
- myDebug(" Central heating: %s", EMS_Boiler.heatingActive ? "active" : "off");
+ myDebug_P(PSTR(" Central heating: %s"), EMS_Boiler.heatingActive ? "active" : "off");
}
}
@@ -349,11 +371,11 @@ void showInfo() {
_renderBoolValue("Warm Water activated", EMS_Boiler.wWActivated);
_renderBoolValue("Warm Water circulation pump available", EMS_Boiler.wWCircPump);
if (EMS_Boiler.wWComfort == EMS_VALUE_UBAParameterWW_wwComfort_Hot) {
- myDebug(" Warm Water comfort setting: Hot");
+ myDebug_P(PSTR(" Warm Water comfort setting: Hot"));
} else if (EMS_Boiler.wWComfort == EMS_VALUE_UBAParameterWW_wwComfort_Eco) {
- myDebug(" Warm Water comfort setting: Eco");
+ myDebug_P(PSTR(" Warm Water comfort setting: Eco"));
} else if (EMS_Boiler.wWComfort == EMS_VALUE_UBAParameterWW_wwComfort_Intelligent) {
- myDebug(" Warm Water comfort setting: Intelligent");
+ myDebug_P(PSTR(" Warm Water comfort setting: Intelligent"));
}
_renderIntValue("Warm Water selected temperature", "C", EMS_Boiler.wWSelTemp);
@@ -364,10 +386,10 @@ void showInfo() {
_renderIntValue("Warm Water current tap water flow", "l/min", EMS_Boiler.wWCurFlow, 10);
_renderLongValue("Warm Water # starts", "times", EMS_Boiler.wWStarts);
if (EMS_Boiler.wWWorkM != EMS_VALUE_LONG_NOTSET) {
- myDebug(" Warm Water active time: %d days %d hours %d minutes",
- EMS_Boiler.wWWorkM / 1440,
- (EMS_Boiler.wWWorkM % 1440) / 60,
- EMS_Boiler.wWWorkM % 60);
+ myDebug_P(PSTR(" Warm Water active time: %d days %d hours %d minutes"),
+ EMS_Boiler.wWWorkM / 1440,
+ (EMS_Boiler.wWWorkM % 1440) / 60,
+ EMS_Boiler.wWWorkM % 60);
}
_renderBoolValue("Warm Water 3-way valve", EMS_Boiler.wWHeat);
@@ -385,9 +407,9 @@ void showInfo() {
_renderShortValue("Flame current", "uA", EMS_Boiler.flameCurr);
_renderIntValue("System pressure", "bar", EMS_Boiler.sysPress, 10);
if (EMS_Boiler.serviceCode == EMS_VALUE_SHORT_NOTSET) {
- myDebug(" System service code: %s", EMS_Boiler.serviceCodeChar);
+ myDebug_P(PSTR(" System service code: %s"), EMS_Boiler.serviceCodeChar);
} else {
- myDebug(" System service code: %s (%d)", EMS_Boiler.serviceCodeChar, EMS_Boiler.serviceCode);
+ myDebug_P(PSTR(" System service code: %s (%d)"), EMS_Boiler.serviceCodeChar, EMS_Boiler.serviceCode);
}
// UBAParametersMessage
@@ -396,105 +418,126 @@ void showInfo() {
_renderIntValue("Boiler circuit pump modulation min power", "%", EMS_Boiler.pump_mod_min);
// UBAMonitorSlow
- if (EMS_Boiler.extTemp != EMS_VALUE_SHORT_NOTSET) {
+ if (EMS_Boiler.extTemp != (int16_t)EMS_VALUE_SHORT_NOTSET) {
_renderShortValue("Outside temperature", "C", EMS_Boiler.extTemp);
}
_renderShortValue("Boiler temperature", "C", EMS_Boiler.boilTemp);
_renderIntValue("Pump modulation", "%", EMS_Boiler.pumpMod);
_renderLongValue("Burner # starts", "times", EMS_Boiler.burnStarts);
if (EMS_Boiler.burnWorkMin != EMS_VALUE_LONG_NOTSET) {
- myDebug(" Total burner operating time: %d days %d hours %d minutes",
- EMS_Boiler.burnWorkMin / 1440,
- (EMS_Boiler.burnWorkMin % 1440) / 60,
- EMS_Boiler.burnWorkMin % 60);
+ myDebug_P(PSTR(" Total burner operating time: %d days %d hours %d minutes"),
+ EMS_Boiler.burnWorkMin / 1440,
+ (EMS_Boiler.burnWorkMin % 1440) / 60,
+ EMS_Boiler.burnWorkMin % 60);
}
if (EMS_Boiler.heatWorkMin != EMS_VALUE_LONG_NOTSET) {
- myDebug(" Total heat operating time: %d days %d hours %d minutes",
- EMS_Boiler.heatWorkMin / 1440,
- (EMS_Boiler.heatWorkMin % 1440) / 60,
- EMS_Boiler.heatWorkMin % 60);
+ myDebug_P(PSTR(" Total heat operating time: %d days %d hours %d minutes"),
+ EMS_Boiler.heatWorkMin / 1440,
+ (EMS_Boiler.heatWorkMin % 1440) / 60,
+ EMS_Boiler.heatWorkMin % 60);
}
if (EMS_Boiler.UBAuptime != EMS_VALUE_LONG_NOTSET) {
- myDebug(" Total UBA working time: %d days %d hours %d minutes",
- EMS_Boiler.UBAuptime / 1440,
- (EMS_Boiler.UBAuptime % 1440) / 60,
- EMS_Boiler.UBAuptime % 60);
+ myDebug_P(PSTR(" Total UBA working time: %d days %d hours %d minutes"),
+ EMS_Boiler.UBAuptime / 1440,
+ (EMS_Boiler.UBAuptime % 1440) / 60,
+ EMS_Boiler.UBAuptime % 60);
}
- // For SM10 Solar Module
- if (EMS_Other.SM10) {
- myDebug(""); // newline
- myDebug("%sSolar Module stats:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF);
- _renderShortValue(" Collector temperature", "C", EMS_Other.SM10collectorTemp);
- _renderShortValue(" Bottom temperature", "C", EMS_Other.SM10bottomTemp);
- _renderIntValue(" Pump modulation", "%", EMS_Other.SM10pumpModulation);
- _renderBoolValue(" Pump active", EMS_Other.SM10pump);
+ // For SM10/SM100 Solar Module
+ if (EMS_Other.SM) {
+ myDebug_P(PSTR("")); // newline
+ myDebug_P(PSTR("%sSolar Module stats:%s"), COLOR_BOLD_ON, COLOR_BOLD_OFF);
+ _renderShortValue(" Collector temperature", "C", EMS_Other.SMcollectorTemp);
+ _renderShortValue(" Bottom temperature", "C", EMS_Other.SMbottomTemp);
+ _renderIntValue(" Pump modulation", "%", EMS_Other.SMpumpModulation);
+ _renderBoolValue(" Pump active", EMS_Other.SMpump);
+ _renderShortValue(" Energy Last Hour", "Wh", EMS_Other.SMEnergyLastHour, 1); // *10
+ _renderShortValue(" Energy Today", "Wh", EMS_Other.SMEnergyToday, 0);
+ _renderShortValue(" Energy Total", "kWH", EMS_Other.SMEnergyTotal, 1); // *10
}
// Thermostat stats
if (ems_getThermostatEnabled()) {
- myDebug(""); // newline
- myDebug("%sThermostat stats:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF);
- myDebug(" Thermostat type: %s", ems_getThermostatDescription(buffer_type));
+ myDebug_P(PSTR("")); // newline
+ myDebug_P(PSTR("%sThermostat stats:%s"), COLOR_BOLD_ON, COLOR_BOLD_OFF);
+ myDebug_P(PSTR(" Thermostat: %s"), ems_getThermostatDescription(buffer_type));
if ((ems_getThermostatModel() == EMS_MODEL_EASY) || (ems_getThermostatModel() == EMS_MODEL_BOSCHEASY)) {
- // for easy temps are * 100
- // also we don't have the time or mode
- _renderShortValue("Set room temperature", "C", EMS_Thermostat.setpoint_roomTemp, 10);
- _renderShortValue("Current room temperature", "C", EMS_Thermostat.curr_roomTemp, 10);
+ // for easy temps are * 100, also we don't have the time or mode
+ _renderShortValue("Set room temperature", "C", EMS_Thermostat.setpoint_roomTemp, 10); // *100
+ _renderShortValue("Current room temperature", "C", EMS_Thermostat.curr_roomTemp, 10); // *100
+ } else if (ems_getThermostatModel() == EMS_MODEL_FR10) {
+ // Junkers are *10
+ _renderIntValue("Set room temperature", "C", EMS_Thermostat.setpoint_roomTemp, 10); // *10
+ _renderIntValue("Current room temperature", "C", EMS_Thermostat.curr_roomTemp, 10); // *10
} else {
// because we store in 2 bytes short, when converting to a single byte we'll loose the negative value if its unset
- if ((EMS_Thermostat.setpoint_roomTemp <= 0) || (EMS_Thermostat.curr_roomTemp <= 0)) {
+ if (EMS_Thermostat.setpoint_roomTemp <= 0) {
EMS_Thermostat.setpoint_roomTemp = EMS_VALUE_INT_NOTSET;
- EMS_Thermostat.curr_roomTemp = EMS_VALUE_INT_NOTSET;
}
+
+ if (EMS_Thermostat.curr_roomTemp <= 0) {
+ EMS_Thermostat.curr_roomTemp = EMS_VALUE_INT_NOTSET;
+ }
+
_renderIntValue("Setpoint room temperature", "C", EMS_Thermostat.setpoint_roomTemp, 2); // convert to a single byte * 2
_renderIntValue("Current room temperature", "C", EMS_Thermostat.curr_roomTemp, 10); // is *10
- myDebug(" Thermostat time is %02d:%02d:%02d %d/%d/%d",
- EMS_Thermostat.hour,
- EMS_Thermostat.minute,
- EMS_Thermostat.second,
- EMS_Thermostat.day,
- EMS_Thermostat.month,
- EMS_Thermostat.year + 2000);
+ if ((EMS_Thermostat.holidaytemp > 0) && (EMSESP_Status.heating_circuit == 2)) { // only if we are on a RC35 we show more info
+ _renderIntValue("Day temperature", "C", EMS_Thermostat.daytemp, 2); // convert to a single byte * 2
+ _renderIntValue("Night temperature", "C", EMS_Thermostat.nighttemp, 2); // convert to a single byte * 2
+ _renderIntValue("Vacation temperature", "C", EMS_Thermostat.holidaytemp, 2); // convert to a single byte * 2
+ }
+
+ myDebug_P(PSTR(" Thermostat time is %02d:%02d:%02d %d/%d/%d"),
+ EMS_Thermostat.hour,
+ EMS_Thermostat.minute,
+ EMS_Thermostat.second,
+ EMS_Thermostat.day,
+ EMS_Thermostat.month,
+ EMS_Thermostat.year + 2000);
if (EMS_Thermostat.mode == 0) {
- myDebug(" Mode is set to low");
+ myDebug_P(PSTR(" Mode is set to low"));
} else if (EMS_Thermostat.mode == 1) {
- myDebug(" Mode is set to manual");
+ myDebug_P(PSTR(" Mode is set to manual"));
} else if (EMS_Thermostat.mode == 2) {
- myDebug(" Mode is set to auto");
+ myDebug_P(PSTR(" Mode is set to auto"));
} else {
- myDebug(" Mode is set to ?");
+ myDebug_P(PSTR(" Mode is set to ?"));
}
}
-
- myDebug(""); // newline
}
// Dallas
if (EMSESP_Status.dallas_sensors != 0) {
- myDebug(""); // newline
+ myDebug_P(PSTR("")); // newline
char buffer[128] = {0};
char valuestr[8] = {0}; // for formatting temp
- myDebug("%sExternal temperature sensors:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF);
+ myDebug_P(PSTR("%sExternal temperature sensors:%s"), COLOR_BOLD_ON, COLOR_BOLD_OFF);
for (uint8_t i = 0; i < EMSESP_Status.dallas_sensors; i++) {
- myDebug(" Sensor #%d %s: %s C", i + 1, ds18.getDeviceString(buffer, i), _float_to_char(valuestr, ds18.getValue(i)));
+ myDebug_P(PSTR(" Sensor #%d %s: %s C"), i + 1, ds18.getDeviceString(buffer, i), _float_to_char(valuestr, ds18.getValue(i)));
}
}
// show the Shower Info
if (EMSESP_Status.shower_timer) {
- myDebug(""); // newline
- myDebug("%sShower stats:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF);
- myDebug(" Shower is %s", (EMSESP_Shower.showerOn ? "running" : "off"));
+ myDebug_P(PSTR("")); // newline
+ myDebug_P(PSTR("%sShower stats:%s"), COLOR_BOLD_ON, COLOR_BOLD_OFF);
+ myDebug_P(PSTR(" Shower is %s"), (EMSESP_Shower.showerOn ? "running" : "off"));
}
+
+ myDebug_P(PSTR("")); // newline
}
// send all dallas sensor values as a JSON package to MQTT
void publishSensorValues() {
- StaticJsonDocument doc;
- JsonObject sensors = doc.to();
+ // don't send if MQTT is connected
+ if (!myESP.isMQTTConnected()) {
+ return;
+ }
+
+ StaticJsonDocument<200> doc;
+ JsonObject sensors = doc.to();
bool hasdata = false;
char label[8] = {0};
@@ -511,7 +554,7 @@ void publishSensorValues() {
}
if (hasdata) {
- char data[MQTT_MAX_SIZE] = {0};
+ char data[200] = {0};
serializeJson(doc, data, sizeof(data));
myESP.mqttPublish(TOPIC_EXTERNAL_SENSORS, data);
}
@@ -520,7 +563,13 @@ void publishSensorValues() {
// send values via MQTT
// a json object is created for the boiler and one for the thermostat
// CRC check is done to see if there are changes in the values since the last send to avoid too much wifi traffic
+// a check is done against the previous values and if there are changes only then they are published. Unless force=true
void publishValues(bool force) {
+ // don't send if MQTT is connected
+ if (!myESP.isMQTTConnected()) {
+ return;
+ }
+
char s[20] = {0}; // for formatting strings
StaticJsonDocument doc;
char data[MQTT_MAX_SIZE] = {0};
@@ -534,11 +583,6 @@ void publishValues(bool force) {
JsonObject rootBoiler = doc.to();
- rootBoiler["wWSelTemp"] = _int_to_char(s, EMS_Boiler.wWSelTemp);
- rootBoiler["selFlowTemp"] = _int_to_char(s, EMS_Boiler.selFlowTemp);
- rootBoiler["outdoorTemp"] = _short_to_char(s, EMS_Boiler.extTemp);
- rootBoiler["wWActivated"] = _bool_to_char(s, EMS_Boiler.wWActivated);
-
if (EMS_Boiler.wWComfort == EMS_VALUE_UBAParameterWW_wwComfort_Hot) {
rootBoiler["wWComfort"] = "Hot";
} else if (EMS_Boiler.wWComfort == EMS_VALUE_UBAParameterWW_wwComfort_Eco) {
@@ -547,21 +591,53 @@ void publishValues(bool force) {
rootBoiler["wWComfort"] = "Intelligent";
}
- rootBoiler["wWCurTmp"] = _short_to_char(s, EMS_Boiler.wWCurTmp);
- rootBoiler["wWCurFlow"] = _int_to_char(s, EMS_Boiler.wWCurFlow, 10);
- rootBoiler["wWHeat"] = _bool_to_char(s, EMS_Boiler.wWHeat);
- rootBoiler["curFlowTemp"] = _short_to_char(s, EMS_Boiler.curFlowTemp);
- rootBoiler["retTemp"] = _short_to_char(s, EMS_Boiler.retTemp);
- rootBoiler["burnGas"] = _bool_to_char(s, EMS_Boiler.burnGas);
- rootBoiler["heatPmp"] = _bool_to_char(s, EMS_Boiler.heatPmp);
- rootBoiler["fanWork"] = _bool_to_char(s, EMS_Boiler.fanWork);
- rootBoiler["ignWork"] = _bool_to_char(s, EMS_Boiler.ignWork);
- rootBoiler["wWCirc"] = _bool_to_char(s, EMS_Boiler.wWCirc);
- rootBoiler["selBurnPow"] = _int_to_char(s, EMS_Boiler.selBurnPow);
- rootBoiler["curBurnPow"] = _int_to_char(s, EMS_Boiler.curBurnPow);
- rootBoiler["sysPress"] = _int_to_char(s, EMS_Boiler.sysPress, 10);
- rootBoiler["boilTemp"] = _short_to_char(s, EMS_Boiler.boilTemp);
- rootBoiler["pumpMod"] = _int_to_char(s, EMS_Boiler.pumpMod);
+ if (EMS_Boiler.wWSelTemp != EMS_VALUE_INT_NOTSET)
+ rootBoiler["wWSelTemp"] = EMS_Boiler.wWSelTemp;
+ if (EMS_Boiler.selFlowTemp != EMS_VALUE_INT_NOTSET)
+ rootBoiler["selFlowTemp"] = EMS_Boiler.selFlowTemp;
+ if (EMS_Boiler.selBurnPow != EMS_VALUE_INT_NOTSET)
+ rootBoiler["selBurnPow"] = EMS_Boiler.selBurnPow;
+ if (EMS_Boiler.curBurnPow != EMS_VALUE_INT_NOTSET)
+ rootBoiler["curBurnPow"] = EMS_Boiler.curBurnPow;
+ if (EMS_Boiler.pumpMod != EMS_VALUE_INT_NOTSET)
+ rootBoiler["pumpMod"] = EMS_Boiler.pumpMod;
+
+ if (abs(EMS_Boiler.extTemp) < EMS_VALUE_SHORT_NOTSET)
+ rootBoiler["outdoorTemp"] = (double)EMS_Boiler.extTemp / 10;
+ if (abs(EMS_Boiler.wWCurTmp) < EMS_VALUE_SHORT_NOTSET)
+ rootBoiler["wWCurTmp"] = (double)EMS_Boiler.wWCurTmp / 10;
+ if (abs(EMS_Boiler.wWCurFlow) != EMS_VALUE_INT_NOTSET)
+ rootBoiler["wWCurFlow"] = (double)EMS_Boiler.wWCurFlow / 10;
+ if (abs(EMS_Boiler.curFlowTemp) < EMS_VALUE_SHORT_NOTSET)
+ rootBoiler["curFlowTemp"] = (double)EMS_Boiler.curFlowTemp / 10;
+ if (abs(EMS_Boiler.retTemp) < EMS_VALUE_SHORT_NOTSET)
+ rootBoiler["retTemp"] = (double)EMS_Boiler.retTemp / 10;
+ if (abs(EMS_Boiler.sysPress) != EMS_VALUE_INT_NOTSET)
+ rootBoiler["sysPress"] = (double)EMS_Boiler.sysPress / 10;
+ if (abs(EMS_Boiler.boilTemp) < EMS_VALUE_SHORT_NOTSET)
+ rootBoiler["boilTemp"] = (double)EMS_Boiler.boilTemp / 10;
+
+ if (EMS_Boiler.wWActivated != EMS_VALUE_INT_NOTSET)
+ rootBoiler["wWActivated"] = _bool_to_char(s, EMS_Boiler.wWActivated);
+
+ if (EMS_Boiler.burnGas != EMS_VALUE_INT_NOTSET)
+ rootBoiler["burnGas"] = _bool_to_char(s, EMS_Boiler.burnGas);
+
+ if (EMS_Boiler.heatPmp != EMS_VALUE_INT_NOTSET)
+ rootBoiler["heatPmp"] = _bool_to_char(s, EMS_Boiler.heatPmp);
+
+ if (EMS_Boiler.fanWork != EMS_VALUE_INT_NOTSET)
+ rootBoiler["fanWork"] = _bool_to_char(s, EMS_Boiler.fanWork);
+
+ if (EMS_Boiler.ignWork != EMS_VALUE_INT_NOTSET)
+ rootBoiler["ignWork"] = _bool_to_char(s, EMS_Boiler.ignWork);
+
+ if (EMS_Boiler.wWCirc != EMS_VALUE_INT_NOTSET)
+ rootBoiler["wWCirc"] = _bool_to_char(s, EMS_Boiler.wWCirc);
+
+ if (EMS_Boiler.wWHeat != EMS_VALUE_INT_NOTSET)
+ rootBoiler["wWHeat"] = _bool_to_char(s, EMS_Boiler.wWHeat);
+
rootBoiler["ServiceCode"] = EMS_Boiler.serviceCodeChar;
rootBoiler["ServiceCodeNumber"] = EMS_Boiler.serviceCode;
@@ -593,19 +669,46 @@ void publishValues(bool force) {
// handle the thermostat values separately
if (ems_getThermostatEnabled()) {
// only send thermostat values if we actually have them
- if ((EMS_Thermostat.curr_roomTemp <= 0) || (EMS_Thermostat.setpoint_roomTemp <= 0))
+ if ((EMS_Thermostat.curr_roomTemp <= 0) && (EMS_Thermostat.setpoint_roomTemp <= 0))
return;
// build new json object
doc.clear();
JsonObject rootThermostat = doc.to();
+ rootThermostat[THERMOSTAT_HC] = _int_to_char(s, EMSESP_Status.heating_circuit);
+
+ // different logic depending on thermostat types
if ((ems_getThermostatModel() == EMS_MODEL_EASY) || (ems_getThermostatModel() == EMS_MODEL_BOSCHEASY)) {
- rootThermostat[THERMOSTAT_SELTEMP] = _short_to_char(s, EMS_Thermostat.setpoint_roomTemp, 10);
- rootThermostat[THERMOSTAT_CURRTEMP] = _short_to_char(s, EMS_Thermostat.curr_roomTemp, 10);
+ if (abs(EMS_Thermostat.setpoint_roomTemp) < EMS_VALUE_SHORT_NOTSET)
+ rootThermostat[THERMOSTAT_SELTEMP] = (double)EMS_Thermostat.setpoint_roomTemp / 10;
+ if (abs(EMS_Thermostat.curr_roomTemp) < EMS_VALUE_SHORT_NOTSET)
+ rootThermostat[THERMOSTAT_CURRTEMP] = (double)EMS_Thermostat.curr_roomTemp / 10;
+
+ } else if (ems_getThermostatModel() == EMS_MODEL_FR10) {
+ if (abs(EMS_Thermostat.setpoint_roomTemp) < EMS_VALUE_SHORT_NOTSET)
+ rootThermostat[THERMOSTAT_SELTEMP] = (double)EMS_Thermostat.setpoint_roomTemp / 10;
+ if (abs(EMS_Thermostat.curr_roomTemp) < EMS_VALUE_SHORT_NOTSET)
+ rootThermostat[THERMOSTAT_CURRTEMP] = (double)EMS_Thermostat.curr_roomTemp / 10;
+
} else {
- rootThermostat[THERMOSTAT_SELTEMP] = _int_to_char(s, EMS_Thermostat.setpoint_roomTemp, 2);
- rootThermostat[THERMOSTAT_CURRTEMP] = _int_to_char(s, EMS_Thermostat.curr_roomTemp, 10);
+ if (EMS_Thermostat.setpoint_roomTemp != EMS_VALUE_INT_NOTSET)
+ rootThermostat[THERMOSTAT_SELTEMP] = (double)EMS_Thermostat.setpoint_roomTemp / 2;
+ if (EMS_Thermostat.curr_roomTemp != EMS_VALUE_INT_NOTSET)
+ rootThermostat[THERMOSTAT_CURRTEMP] = (double)EMS_Thermostat.curr_roomTemp / 10;
+
+ if (EMS_Thermostat.daytemp != EMS_VALUE_INT_NOTSET)
+ rootThermostat[THERMOSTAT_DAYTEMP] = (double)EMS_Thermostat.daytemp / 2;
+ if (EMS_Thermostat.nighttemp != EMS_VALUE_INT_NOTSET)
+ rootThermostat[THERMOSTAT_NIGHTTEMP] = (double)EMS_Thermostat.nighttemp / 2;
+ if (EMS_Thermostat.holidaytemp != EMS_VALUE_INT_NOTSET)
+ rootThermostat[THERMOSTAT_HOLIDAYTEMP] = (double)EMS_Thermostat.holidaytemp / 2;
+
+ if (EMS_Thermostat.heatingtype != EMS_VALUE_INT_NOTSET)
+ rootThermostat[THERMOSTAT_HEATINGTYPE] = EMS_Thermostat.heatingtype;
+
+ if (EMS_Thermostat.circuitcalctemp != EMS_VALUE_INT_NOTSET)
+ rootThermostat[THERMOSTAT_CIRCUITCALCTEMP] = EMS_Thermostat.circuitcalctemp;
}
// RC20 has different mode settings
@@ -646,16 +749,33 @@ void publishValues(bool force) {
}
// handle the other values separately
- // For SM10 Solar Module
- if (EMS_Other.SM10) {
+ // For SM10 and SM100 Solar Modules
+ if (EMS_Other.SM) {
// build new json object
doc.clear();
- JsonObject rootSM10 = doc.to();
+ JsonObject rootSM = doc.to();
+
+ if (abs(EMS_Other.SMcollectorTemp) < EMS_VALUE_SHORT_NOTSET)
+ rootSM[SM_COLLECTORTEMP] = (double)EMS_Other.SMcollectorTemp / 10;
- rootSM10[SM10_COLLECTORTEMP] = _short_to_char(s, EMS_Other.SM10collectorTemp);
- rootSM10[SM10_BOTTOMTEMP] = _short_to_char(s, EMS_Other.SM10bottomTemp);
- rootSM10[SM10_PUMPMODULATION] = _int_to_char(s, EMS_Other.SM10pumpModulation);
- rootSM10[SM10_PUMP] = _bool_to_char(s, EMS_Other.SM10pump);
+ if (abs(EMS_Other.SMbottomTemp) < EMS_VALUE_SHORT_NOTSET)
+ rootSM[SM_BOTTOMTEMP] = (double)EMS_Other.SMbottomTemp / 10;
+
+ if (EMS_Other.SMpumpModulation != EMS_VALUE_INT_NOTSET)
+ rootSM[SM_PUMPMODULATION] = EMS_Other.SMpumpModulation;
+
+ if (EMS_Other.SMpump != EMS_VALUE_INT_NOTSET) {
+ rootSM[SM_PUMP] = _bool_to_char(s, EMS_Other.SMpump);
+ }
+
+ if (abs(EMS_Other.SMEnergyLastHour) < EMS_VALUE_SHORT_NOTSET)
+ rootSM[SM_ENERGYLASTHOUR] = (double)EMS_Other.SMEnergyLastHour / 10;
+
+ if (abs(EMS_Other.SMEnergyToday) < EMS_VALUE_SHORT_NOTSET)
+ rootSM[SM_ENERGYTODAY] = EMS_Other.SMEnergyToday;
+
+ if (abs(EMS_Other.SMEnergyTotal) < EMS_VALUE_SHORT_NOTSET)
+ rootSM[SM_ENERGYTOTAL] = (double)EMS_Other.SMEnergyTotal / 10;
data[0] = '\0'; // reset data for next package
serializeJson(doc, data, sizeof(data));
@@ -668,10 +788,10 @@ void publishValues(bool force) {
fchecksum = crc.finalize();
if ((previousOtherPublishCRC != fchecksum) || force) {
previousOtherPublishCRC = fchecksum;
- myDebugLog("Publishing SM10 data via MQTT");
+ myDebugLog("Publishing SM data via MQTT");
// send values via MQTT
- myESP.mqttPublish(TOPIC_SM10_DATA, data);
+ myESP.mqttPublish(TOPIC_SM_DATA, data);
}
}
}
@@ -679,14 +799,14 @@ void publishValues(bool force) {
// sets the shower timer on/off
void set_showerTimer() {
if (ems_getLogging() != EMS_SYS_LOGGING_NONE) {
- myDebug("Shower timer has been set to %s", EMSESP_Status.shower_timer ? "enabled" : "disabled");
+ myDebug_P(PSTR("Shower timer has been set to %s"), EMSESP_Status.shower_timer ? "enabled" : "disabled");
}
}
// sets the shower alert on/off
void set_showerAlert() {
if (ems_getLogging() != EMS_SYS_LOGGING_NONE) {
- myDebug("Shower alert has been set to %s", EMSESP_Status.shower_alert ? "enabled" : "disabled");
+ myDebug_P(PSTR("Shower alert has been set to %s"), EMSESP_Status.shower_alert ? "enabled" : "disabled");
}
}
@@ -734,7 +854,7 @@ void do_publishSensorValues() {
void do_publishValues() {
// don't publish if we're not connected to the EMS bus
if ((ems_getBusConnected()) && (!myESP.getUseSerial()) && myESP.isMQTTConnected()) {
- publishValues(false);
+ publishValues(true); // force publish
}
}
@@ -754,8 +874,8 @@ void do_ledcheck() {
// Thermostat scan
void do_scanThermostat() {
if ((ems_getBusConnected()) && (!myESP.getUseSerial())) {
- myDebug("> Scanning thermostat message type #0x%02X...", scanThermostat_count);
- ems_doReadCommand(scanThermostat_count, EMS_Thermostat.type_id);
+ myDebug_P(PSTR("> Scanning thermostat message type #0x%02X..."), scanThermostat_count);
+ ems_doReadCommand(scanThermostat_count, EMS_Thermostat.device_id);
scanThermostat_count++;
}
}
@@ -763,7 +883,7 @@ void do_scanThermostat() {
// do a system health check every now and then to see if we all connections
void do_systemCheck() {
if ((!ems_getBusConnected()) && (!myESP.getUseSerial())) {
- myDebug("Error! Unable to read from EMS bus. Retrying in %d seconds...", SYSTEMCHECK_TIME);
+ myDebug_P(PSTR("Error! Unable to read the EMS bus."));
}
}
@@ -771,13 +891,51 @@ void do_systemCheck() {
// only if we have a EMS connection
void do_regularUpdates() {
if ((ems_getBusConnected()) && (!myESP.getUseSerial())) {
- myDebugLog("Calling scheduled data refresh from EMS devices...");
+ myDebugLog("Requesting scheduled EMS device data");
ems_getThermostatValues();
ems_getBoilerValues();
ems_getOtherValues();
}
}
+// stop devices scan and restart all other timers
+void stopDeviceScan() {
+ publishValuesTimer.attach(EMSESP_Status.publish_wait, do_publishValues); // post MQTT EMS values
+ publishSensorValuesTimer.attach(EMSESP_Status.publish_wait, do_publishSensorValues); // post MQTT sensor values
+ regularUpdatesTimer.attach(REGULARUPDATES_TIME, do_regularUpdates); // regular reads from the EMS
+ systemCheckTimer.attach(SYSTEMCHECK_TIME, do_systemCheck); // check if Boiler is online
+ scanThermostat_count = 0;
+ scanThermostat.detach();
+}
+
+// EMS device scan
+void do_scanDevices() {
+ if (scanDevices_count == 0) {
+ // we're at the finish line
+ myDebug_P(PSTR("Finished the deep EMS device scan."));
+ stopDeviceScan();
+ ems_printDevices();
+ ems_setLogging(EMS_SYS_LOGGING_NONE);
+ return;
+ }
+
+ if ((ems_getBusConnected()) && (!myESP.getUseSerial())) {
+ ems_doReadCommand(EMS_TYPE_Version, scanDevices_count++); // ask for version
+ }
+}
+
+// initiate a force scan by sending a version command to all type ids
+void startDeviceScan() {
+ publishValuesTimer.detach();
+ systemCheckTimer.detach();
+ regularUpdatesTimer.detach();
+ publishSensorValuesTimer.detach();
+ scanDevices_count = 1; // starts at 1
+ ems_setLogging(EMS_SYS_LOGGING_NONE);
+ myDebug_P(PSTR("Starting a deep EMS device scan. This can take up to 2 minutes. Please wait..."));
+ scanThermostat.attach_ms(SCANDEVICES_TIME, do_scanDevices);
+}
+
// initiate a force scan by sending type read requests from 0 to FF to the thermostat
// used to analyze responses for debugging
void startThermostatScan(uint8_t start) {
@@ -786,7 +944,7 @@ void startThermostatScan(uint8_t start) {
systemCheckTimer.detach();
regularUpdatesTimer.detach();
scanThermostat_count = start;
- myDebug("Starting a deep message scan on thermostat");
+ myDebug_P(PSTR("Starting a deep message scan on thermostat"));
scanThermostat.attach(SCANTHERMOSTAT_TIME, do_scanThermostat);
}
@@ -811,11 +969,21 @@ void _showerColdShotStart() {
}
}
+// run tests to validate handling of telegrams by injecting fake telegrams
+void runUnitTest(uint8_t test_num) {
+ ems_setLogging(EMS_SYS_LOGGING_VERBOSE);
+ publishValuesTimer.detach();
+ systemCheckTimer.detach();
+ regularUpdatesTimer.detach();
+ EMSESP_Status.listen_mode = true; // temporary go into listen mode to disable Tx
+ ems_testTelegram(test_num);
+}
+
// callback for loading/saving settings to the file system (SPIFFS)
bool FSCallback(MYESP_FSACTION action, const JsonObject json) {
- bool recreate_config = true;
-
if (action == MYESP_FSACTION_LOAD) {
+ bool recreate_config = true;
+
// led
EMSESP_Status.led = json["led"];
@@ -830,23 +998,21 @@ bool FSCallback(MYESP_FSACTION action, const JsonObject json) {
}
// dallas_parasite
- if (!(EMSESP_Status.dallas_parasite = json["dallas_parasite"])) {
- EMSESP_Status.dallas_parasite = EMSESP_DALLAS_PARASITE; // default value
- }
+ EMSESP_Status.dallas_parasite = json["dallas_parasite"];
// thermostat_type
- if (!(EMS_Thermostat.type_id = json["thermostat_type"])) {
- EMS_Thermostat.type_id = EMSESP_THERMOSTAT_TYPE; // set default
+ if (!(EMS_Thermostat.device_id = json["thermostat_type"])) {
+ EMS_Thermostat.device_id = EMSESP_THERMOSTAT_TYPE; // set default
}
// boiler_type
- if (!(EMS_Boiler.type_id = json["boiler_type"])) {
- EMS_Boiler.type_id = EMSESP_BOILER_TYPE; // set default
+ if (!(EMS_Boiler.device_id = json["boiler_type"])) {
+ EMS_Boiler.device_id = EMSESP_BOILER_TYPE; // set default
}
- // silent mode
- EMSESP_Status.silent_mode = json["silent_mode"];
- ems_setTxDisabled(EMSESP_Status.silent_mode);
+ // listen mode
+ EMSESP_Status.listen_mode = json["listen_mode"];
+ ems_setTxDisabled(EMSESP_Status.listen_mode);
// shower_timer
EMSESP_Status.shower_timer = json["shower_timer"];
@@ -854,25 +1020,36 @@ bool FSCallback(MYESP_FSACTION action, const JsonObject json) {
// shower_alert
EMSESP_Status.shower_alert = json["shower_alert"];
+ // tx delay
+ ems_setTxDelay(json["tx_delay"]);
+
// publish_wait
if (!(EMSESP_Status.publish_wait = json["publish_wait"])) {
EMSESP_Status.publish_wait = DEFAULT_PUBLISHWAIT; // default value
}
+ // heating_circuit
+ if (!(EMSESP_Status.heating_circuit = json["heating_circuit"])) {
+ EMSESP_Status.heating_circuit = DEFAULT_HEATINGCIRCUIT; // default value
+ }
+ ems_setThermostatHC(EMSESP_Status.heating_circuit);
+
return recreate_config; // return false if some settings are missing and we need to rebuild the file
}
if (action == MYESP_FSACTION_SAVE) {
+ json["thermostat_type"] = EMS_Thermostat.device_id;
+ json["boiler_type"] = EMS_Boiler.device_id;
json["led"] = EMSESP_Status.led;
json["led_gpio"] = EMSESP_Status.led_gpio;
json["dallas_gpio"] = EMSESP_Status.dallas_gpio;
json["dallas_parasite"] = EMSESP_Status.dallas_parasite;
- json["thermostat_type"] = EMS_Thermostat.type_id;
- json["boiler_type"] = EMS_Boiler.type_id;
- json["silent_mode"] = EMSESP_Status.silent_mode;
+ json["listen_mode"] = EMSESP_Status.listen_mode;
json["shower_timer"] = EMSESP_Status.shower_timer;
json["shower_alert"] = EMSESP_Status.shower_alert;
json["publish_wait"] = EMSESP_Status.publish_wait;
+ json["heating_circuit"] = EMSESP_Status.heating_circuit;
+ json["tx_delay"] = ems_getTxDelay();
return true;
}
@@ -898,24 +1075,24 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c
// let's make sure LED is really off - For onboard high=off
digitalWrite(EMSESP_Status.led_gpio, (EMSESP_Status.led_gpio == LED_BUILTIN) ? HIGH : LOW);
} else {
- myDebug("Error. Usage: set led ");
+ myDebug_P(PSTR("Error. Usage: set led "));
}
}
// test mode
- if ((strcmp(setting, "silent_mode") == 0) && (wc == 2)) {
+ if ((strcmp(setting, "listen_mode") == 0) && (wc == 2)) {
if (strcmp(value, "on") == 0) {
- EMSESP_Status.silent_mode = true;
+ EMSESP_Status.listen_mode = true;
ok = true;
- myDebug("* in Silent mode. All Tx is disabled.");
+ myDebug_P(PSTR("* in listen mode. All Tx is disabled."));
ems_setTxDisabled(true);
} else if (strcmp(value, "off") == 0) {
- EMSESP_Status.silent_mode = false;
+ EMSESP_Status.listen_mode = false;
ok = true;
ems_setTxDisabled(false);
- myDebug("* out of Silent mode. Tx is enabled.");
+ myDebug_P(PSTR("* out of listen mode. Tx is enabled."));
} else {
- myDebug("Error. Usage: set silent_mode ");
+ myDebug_P(PSTR("Error. Usage: set listen_mode "));
}
}
@@ -943,20 +1120,20 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c
EMSESP_Status.dallas_parasite = false;
ok = true;
} else {
- myDebug("Error. Usage: set dallas_parasite ");
+ myDebug_P(PSTR("Error. Usage: set dallas_parasite "));
}
}
// thermostat_type
if (strcmp(setting, "thermostat_type") == 0) {
- EMS_Thermostat.type_id = ((wc == 2) ? (uint8_t)strtol(value, 0, 16) : EMS_ID_NONE);
- ok = true;
+ EMS_Thermostat.device_id = ((wc == 2) ? (uint8_t)strtol(value, 0, 16) : EMS_ID_NONE);
+ ok = true;
}
// boiler_type
if (strcmp(setting, "boiler_type") == 0) {
- EMS_Boiler.type_id = ((wc == 2) ? (uint8_t)strtol(value, 0, 16) : EMS_ID_NONE);
- ok = true;
+ EMS_Boiler.device_id = ((wc == 2) ? (uint8_t)strtol(value, 0, 16) : EMS_ID_NONE);
+ ok = true;
}
// shower timer
@@ -968,7 +1145,7 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c
EMSESP_Status.shower_timer = false;
ok = true;
} else {
- myDebug("Error. Usage: set shower_timer ");
+ myDebug_P(PSTR("Error. Usage: set shower_timer "));
}
}
@@ -981,7 +1158,7 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c
EMSESP_Status.shower_alert = false;
ok = true;
} else {
- myDebug("Error. Usage: set shower_alert ");
+ myDebug_P(PSTR("Error. Usage: set shower_alert "));
}
}
@@ -990,32 +1167,58 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c
EMSESP_Status.publish_wait = atoi(value);
ok = true;
}
+
+ // heating_circuit
+ if ((strcmp(setting, "heating_circuit") == 0) && (wc == 2)) {
+ uint8_t hc = atoi(value);
+ if ((hc >= 1) && (hc <= 2)) {
+ EMSESP_Status.heating_circuit = hc;
+ ems_setThermostatHC(hc);
+ ok = true;
+ } else {
+ myDebug_P(PSTR("Error. Usage: set heating_circuit <1 | 2>"));
+ }
+ }
+
+ // tx delay
+ if ((strcmp(setting, "tx_delay") == 0) && (wc == 2)) {
+ if (strcmp(value, "on") == 0) {
+ ems_setTxDelay(true);
+ ok = true;
+ } else if (strcmp(value, "off") == 0) {
+ ems_setTxDelay(false);
+ ok = true;
+ } else {
+ myDebug_P(PSTR("Error. Usage: set tx_delay "));
+ }
+ }
}
if (action == MYESP_FSACTION_LIST) {
- myDebug(" led=%s", EMSESP_Status.led ? "on" : "off");
- myDebug(" led_gpio=%d", EMSESP_Status.led_gpio);
- myDebug(" dallas_gpio=%d", EMSESP_Status.dallas_gpio);
- myDebug(" dallas_parasite=%s", EMSESP_Status.dallas_parasite ? "on" : "off");
-
- if (EMS_Thermostat.type_id == EMS_ID_NONE) {
- myDebug(" thermostat_type=");
+ myDebug_P(PSTR(" led=%s"), EMSESP_Status.led ? "on" : "off");
+ myDebug_P(PSTR(" led_gpio=%d"), EMSESP_Status.led_gpio);
+ myDebug_P(PSTR(" dallas_gpio=%d"), EMSESP_Status.dallas_gpio);
+ myDebug_P(PSTR(" dallas_parasite=%s"), EMSESP_Status.dallas_parasite ? "on" : "off");
+ if (EMS_Thermostat.device_id == EMS_ID_NONE) {
+ myDebug_P(PSTR(" thermostat_type="));
} else {
- myDebug(" thermostat_type=%02X", EMS_Thermostat.type_id);
+ myDebug_P(PSTR(" thermostat_type=%02X"), EMS_Thermostat.device_id);
}
- if (EMS_Boiler.type_id == EMS_ID_NONE) {
- myDebug(" boiler_type=");
+ myDebug_P(PSTR(" heating_circuit=%d"), EMSESP_Status.heating_circuit);
+ if (EMS_Boiler.device_id == EMS_ID_NONE) {
+ myDebug_P(PSTR(" boiler_type="));
} else {
- myDebug(" boiler_type=%02X", EMS_Boiler.type_id);
+ myDebug_P(PSTR(" boiler_type=%02X"), EMS_Boiler.device_id);
}
- myDebug(" silent_mode=%s", EMSESP_Status.silent_mode ? "on" : "off");
- myDebug(" shower_timer=%s", EMSESP_Status.shower_timer ? "on" : "off");
- myDebug(" shower_alert=%s", EMSESP_Status.shower_alert ? "on" : "off");
- myDebug(" publish_wait=%d", EMSESP_Status.publish_wait);
+ myDebug_P(PSTR(" listen_mode=%s"), EMSESP_Status.listen_mode ? "on" : "off");
+ myDebug_P(PSTR(" shower_timer=%s"), EMSESP_Status.shower_timer ? "on" : "off");
+ myDebug_P(PSTR(" shower_alert=%s"), EMSESP_Status.shower_alert ? "on" : "off");
+ myDebug_P(PSTR(" publish_wait=%d"), EMSESP_Status.publish_wait);
+ myDebug_P(PSTR(" tx_delay=%s"), ems_getTxDelay() ? "on" : "off");
}
return ok;
@@ -1049,13 +1252,13 @@ void TelnetCommandCallback(uint8_t wc, const char * commandLine) {
}
if (strcmp(first_cmd, "refresh") == 0) {
- myDebug("Fetching data from EMS devices...");
+ myDebug_P(PSTR("Fetching data from EMS devices..."));
do_regularUpdates();
ok = true;
}
- if (strcmp(first_cmd, "types") == 0) {
- ems_printAllTypes();
+ if (strcmp(first_cmd, "devices") == 0) {
+ ems_printAllDevices();
ok = true;
}
@@ -1065,8 +1268,16 @@ void TelnetCommandCallback(uint8_t wc, const char * commandLine) {
}
if (strcmp(first_cmd, "autodetect") == 0) {
- ems_scanDevices();
- ok = true;
+ if (wc == 2) {
+ char * second_cmd = _readWord();
+ if (strcmp(second_cmd, "deep") == 0) {
+ startDeviceScan();
+ ok = true;
+ }
+ } else {
+ ems_scanDevices();
+ ok = true;
+ }
}
if (strcmp(first_cmd, "startup") == 0) {
@@ -1119,7 +1330,7 @@ void TelnetCommandCallback(uint8_t wc, const char * commandLine) {
ems_setThermostatMode(_readIntNumber());
ok = true;
} else if (strcmp(second_cmd, "read") == 0) {
- ems_doReadCommand(_readHexNumber(), EMS_Thermostat.type_id);
+ ems_doReadCommand(_readHexNumber(), EMS_Thermostat.device_id);
ok = true;
} else if (strcmp(second_cmd, "scan") == 0) {
startThermostatScan(_readIntNumber());
@@ -1146,7 +1357,7 @@ void TelnetCommandCallback(uint8_t wc, const char * commandLine) {
ok = true;
}
} else if (strcmp(second_cmd, "read") == 0) {
- ems_doReadCommand(_readHexNumber(), EMS_Boiler.type_id);
+ ems_doReadCommand(_readHexNumber(), EMS_Boiler.device_id);
ok = true;
} else if (strcmp(second_cmd, "tapwater") == 0) {
char * third_cmd = _readWord();
@@ -1157,6 +1368,9 @@ void TelnetCommandCallback(uint8_t wc, const char * commandLine) {
ems_setWarmTapWaterActivated(false);
ok = true;
}
+ } else if (strcmp(second_cmd, "flowtemp") == 0) {
+ ems_setFlowTemp(_readIntNumber());
+ ok = true;
}
}
@@ -1166,9 +1380,15 @@ void TelnetCommandCallback(uint8_t wc, const char * commandLine) {
ok = true;
}
+ // test commands
+ if ((strcmp(first_cmd, "test") == 0) && (wc == 2)) {
+ runUnitTest(_readIntNumber());
+ ok = true;
+ }
+
// check for invalid command
if (!ok) {
- myDebug("Unknown command. Use ? for help.");
+ myDebug_P(PSTR("Unknown command. Use ? for help."));
}
}
@@ -1196,10 +1416,10 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
myESP.mqttSubscribe(TOPIC_SHOWER_TIMER);
myESP.mqttSubscribe(TOPIC_SHOWER_ALERT);
myESP.mqttSubscribe(TOPIC_SHOWER_COLDSHOT);
-
- // subscribe to a start message and send the first publish
- myESP.mqttSubscribe(MQTT_TOPIC_START);
- myESP.mqttPublish(MQTT_TOPIC_START, MQTT_TOPIC_START_PAYLOAD);
+ myESP.mqttSubscribe(TOPIC_THERMOSTAT_CMD_HC);
+ myESP.mqttSubscribe(TOPIC_THERMOSTAT_CMD_DAYTEMP);
+ myESP.mqttSubscribe(TOPIC_THERMOSTAT_CMD_NIGHTTEMP);
+ myESP.mqttSubscribe(TOPIC_THERMOSTAT_CMD_HOLIDAYTEMP);
// publish the status of the Shower parameters
myESP.mqttPublish(TOPIC_SHOWER_TIMER, EMSESP_Status.shower_timer ? "1" : "0");
@@ -1208,39 +1428,67 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
// handle incoming MQTT publish events
if (type == MQTT_MESSAGE_EVENT) {
- // handle response from a start message
- // for example with HA it sends the system time from the server
- if (strcmp(topic, MQTT_TOPIC_START) == 0) {
- myDebug("Received boottime: %s", message);
- myESP.setBoottime(message);
- }
-
// thermostat temp changes
if (strcmp(topic, TOPIC_THERMOSTAT_CMD_TEMP) == 0) {
float f = strtof((char *)message, 0);
char s[10] = {0};
- myDebug("MQTT topic: thermostat temperature value %s", _float_to_char(s, f));
+ myDebug_P(PSTR("MQTT topic: thermostat temperature value %s"), _float_to_char(s, f));
ems_setThermostatTemp(f);
- publishValues(true); // publish back immediately
+ publishValues(true); // publish back immediately, can't remember why I do this?!
}
// thermostat mode changes
if (strcmp(topic, TOPIC_THERMOSTAT_CMD_MODE) == 0) {
- myDebug("MQTT topic: thermostat mode value %s", message);
+ myDebug_P(PSTR("MQTT topic: thermostat mode value %s"), message);
if (strcmp((char *)message, "auto") == 0) {
ems_setThermostatMode(2);
- } else if (strcmp((char *)message, "day") == 0) {
+ } else if (strcmp((char *)message, "day") == 0 || strcmp((char *)message, "manual") == 0) {
ems_setThermostatMode(1);
- } else if (strcmp((char *)message, "night") == 0) {
+ } else if (strcmp((char *)message, "night") == 0 || strcmp((char *)message, "off") == 0) {
ems_setThermostatMode(0);
}
}
+ // thermostat heating circuit change
+ if (strcmp(topic, TOPIC_THERMOSTAT_CMD_HC) == 0) {
+ myDebug_P(PSTR("MQTT topic: thermostat heating circuit value %s"), message);
+ uint8_t hc = atoi((char *)message);
+ if ((hc >= 1) && (hc <= 2)) {
+ EMSESP_Status.heating_circuit = hc;
+ ems_setThermostatHC(hc);
+ // TODO: save setting to SPIFFS??
+ }
+ }
+
+ // set night temp value
+ if (strcmp(topic, TOPIC_THERMOSTAT_CMD_NIGHTTEMP) == 0) {
+ float f = strtof((char *)message, 0);
+ char s[10] = {0};
+ myDebug_P(PSTR("MQTT topic: new thermostat night temperature value %s"), _float_to_char(s, f));
+ ems_setThermostatTemp(f, 1);
+ }
+
+ // set daytemp value
+ if (strcmp(topic, TOPIC_THERMOSTAT_CMD_DAYTEMP) == 0) {
+ float f = strtof((char *)message, 0);
+ char s[10] = {0};
+ myDebug_P(PSTR("MQTT topic: new thermostat day temperature value %s"), _float_to_char(s, f));
+ ems_setThermostatTemp(f, 2);
+ }
+
+ // set holiday value
+ if (strcmp(topic, TOPIC_THERMOSTAT_CMD_HOLIDAYTEMP) == 0) {
+ float f = strtof((char *)message, 0);
+ char s[10] = {0};
+ myDebug_P(PSTR("MQTT topic: new thermostat holiday temperature value %s"), _float_to_char(s, f));
+ ems_setThermostatTemp(f, 3);
+ }
+
// wwActivated
if (strcmp(topic, TOPIC_BOILER_WWACTIVATED) == 0) {
- if (message[0] == '1') {
+ if (message[0] == '1' || strcmp(message, "on") == 0) {
ems_setWarmWaterActivated(true);
- } else if (message[0] == '0') {
+ } else if (message[0] == '0' || strcmp(message, "off") == 0) {
ems_setWarmWaterActivated(false);
}
}
@@ -1248,14 +1496,14 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
// boiler wwtemp changes
if (strcmp(topic, TOPIC_BOILER_CMD_WWTEMP) == 0) {
uint8_t t = atoi((char *)message);
- myDebug("MQTT topic: boiler warm water temperature value %d", t);
+ myDebug_P(PSTR("MQTT topic: boiler warm water temperature value %d"), t);
ems_setWarmWaterTemp(t);
- publishValues(true); // publish back immediately
+ publishValues(true); // publish back immediately, can't remember why I do this?!
}
// boiler ww comfort setting
if (strcmp(topic, TOPIC_BOILER_CMD_COMFORT) == 0) {
- myDebug("MQTT topic: boiler warm water comfort value is %s", message);
+ myDebug_P(PSTR("MQTT topic: boiler warm water comfort value is %s"), message);
if (strcmp((char *)message, "hot") == 0) {
ems_setWarmWaterModeComfort(1);
} else if (strcmp((char *)message, "comfort") == 0) {
@@ -1263,7 +1511,6 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
} else if (strcmp((char *)message, "intelligent") == 0) {
ems_setWarmWaterModeComfort(3);
}
- // publishValues(true); // publish back immediately
}
// shower timer
@@ -1299,12 +1546,12 @@ void WIFICallback() {
// This is done after we have a WiFi signal to avoid any resource conflicts
if (myESP.getUseSerial()) {
- myDebug("Warning! EMS bus disabled when in Serial mode. Use 'set serial off' to start EMS.");
+ myDebug_P(PSTR("Warning! EMS bus disabled when in Serial mode. Use 'set serial off' to start EMS."));
} else {
emsuart_init();
- myDebug("[UART] Opened Rx/Tx connection");
- if (!EMSESP_Status.silent_mode) {
- // go and find the boiler and thermostat types, if not in silent mode
+ myDebug_P(PSTR("[UART] Opened Rx/Tx connection"));
+ if (!EMSESP_Status.listen_mode) {
+ // go and find the boiler and thermostat types, if not in listen mode
ems_discoverModels();
}
}
@@ -1314,17 +1561,16 @@ void WIFICallback() {
// Most of these will be overwritten after the SPIFFS config file is loaded
void initEMSESP() {
// general settings
- EMSESP_Status.shower_timer = false;
- EMSESP_Status.shower_alert = false;
- EMSESP_Status.led = true; // LED is on by default
- EMSESP_Status.silent_mode = false;
- EMSESP_Status.publish_wait = DEFAULT_PUBLISHWAIT;
-
- EMSESP_Status.timestamp = millis();
- EMSESP_Status.dallas_sensors = 0;
-
- EMSESP_Status.led_gpio = EMSESP_LED_GPIO;
- EMSESP_Status.dallas_gpio = EMSESP_DALLAS_GPIO;
+ EMSESP_Status.shower_timer = false;
+ EMSESP_Status.shower_alert = false;
+ EMSESP_Status.led = true; // LED is on by default
+ EMSESP_Status.listen_mode = false;
+ EMSESP_Status.publish_wait = DEFAULT_PUBLISHWAIT;
+ EMSESP_Status.timestamp = millis();
+ EMSESP_Status.dallas_sensors = 0;
+ EMSESP_Status.led_gpio = EMSESP_LED_GPIO;
+ EMSESP_Status.dallas_gpio = EMSESP_DALLAS_GPIO;
+ EMSESP_Status.heating_circuit = 1; // default heating circuit to HC1
// shower settings
EMSESP_Shower.timerStart = 0;
@@ -1383,7 +1629,7 @@ void showerCheck() {
strlcat(s, itoa((uint8_t)((EMSESP_Shower.duration / 1000) % 60), buffer, 10), sizeof(s));
strlcat(s, " seconds", sizeof(s));
if (ems_getLogging() != EMS_SYS_LOGGING_NONE) {
- myDebug("[Shower] finished with duration %s", s);
+ myDebug_P(PSTR("[Shower] finished with duration %s"), s);
}
myESP.mqttPublish(TOPIC_SHOWERTIME, s); // publish to MQTT
}
@@ -1420,17 +1666,8 @@ void setup() {
#endif
// MQTT host, username and password taken from the SPIFFS settings
- myESP.setMQTT(NULL,
- NULL,
- NULL,
- MQTT_BASE,
- MQTT_KEEPALIVE,
- MQTT_QOS,
- MQTT_RETAIN,
- MQTT_WILL_TOPIC,
- MQTT_WILL_ONLINE_PAYLOAD,
- MQTT_WILL_OFFLINE_PAYLOAD,
- MQTTCallback);
+ myESP.setMQTT(
+ NULL, NULL, NULL, MQTT_BASE, MQTT_KEEPALIVE, MQTT_QOS, MQTT_RETAIN, MQTT_WILL_TOPIC, MQTT_WILL_ONLINE_PAYLOAD, MQTT_WILL_OFFLINE_PAYLOAD, MQTTCallback);
// OTA callback which is called when OTA is starting and stopping
myESP.setOTA(OTACallback_pre, OTACallback_post);
@@ -1441,10 +1678,10 @@ void setup() {
// start up all the services
myESP.begin(APP_HOSTNAME, APP_NAME, APP_VERSION);
- // at this point we have the settings from our internall SPIFFS config file
+ // at this point we have all the settings from our internall SPIFFS config file
// enable regular checks if not in test mode
- if (!EMSESP_Status.silent_mode) {
+ if (!EMSESP_Status.listen_mode) {
publishValuesTimer.attach(EMSESP_Status.publish_wait, do_publishValues); // post MQTT EMS values
publishSensorValuesTimer.attach(EMSESP_Status.publish_wait, do_publishSensorValues); // post MQTT sensor values
regularUpdatesTimer.attach(REGULARUPDATES_TIME, do_regularUpdates); // regular reads from the EMS
@@ -1471,14 +1708,14 @@ void loop() {
myESP.loop();
// check Dallas sensors, every 2 seconds
- // these values are published to MQTT seperately via the timer publishSensorValuesTimer
+ // these values are published to MQTT separately via the timer publishSensorValuesTimer
if (EMSESP_Status.dallas_sensors != 0) {
ds18.loop();
}
// publish the values to MQTT, only if the values have changed
// although we don't want to publish when doing a deep scan of the thermostat
- if (ems_getEmsRefreshed() && (scanThermostat_count == 0) && (!EMSESP_Status.silent_mode)) {
+ if (ems_getEmsRefreshed() && (scanThermostat_count == 0) && (!EMSESP_Status.listen_mode)) {
publishValues(false);
ems_setEmsRefreshed(false); // reset
}
diff --git a/src/ems.cpp b/src/ems.cpp
index 2e640915..a5ed6c2d 100644
--- a/src/ems.cpp
+++ b/src/ems.cpp
@@ -14,62 +14,90 @@
#include
#include // std::list
+#ifdef TESTS
+#include "test_data.h"
+uint8_t _TEST_DATA_max = ArraySize(TEST_DATA);
+#endif
+
// myESP for logging to telnet and serial
#define myDebug(...) myESP.myDebug(__VA_ARGS__)
+#define myDebug_P(...) myESP.myDebug_P(__VA_ARGS__)
_EMS_Sys_Status EMS_Sys_Status; // EMS Status
CircularBuffer<_EMS_TxTelegram, EMS_TX_TELEGRAM_QUEUE_MAX> EMS_TxQueue; // FIFO queue for Tx send buffer
+// for storing all detected EMS devices
+std::list<_Generic_Type> Devices;
+
+// macros used in the _process* functions
+#define _toByte(i) (EMS_RxTelegram->data[i])
+#define _toShort(i) ((EMS_RxTelegram->data[i] << 8) + EMS_RxTelegram->data[i + 1])
+#define _toLong(i) ((EMS_RxTelegram->data[i] << 16) + (EMS_RxTelegram->data[i + 1] << 8) + (EMS_RxTelegram->data[i + 2]))
+#define _bitRead(i, bit) (((EMS_RxTelegram->data[i]) >> (bit)) & 0x01)
+
//
// process callbacks per type
//
-// macros used in the _process* functions
-#define _toByte(i) (data[i])
-#define _toShort(i) ((data[i] << 8) + data[i + 1])
-#define _toLong(i) ((data[i] << 16) + (data[i + 1] << 8) + (data[i + 2]))
-#define _bitRead(i, bit) (((data[i]) >> (bit)) & 0x01)
-
// generic
-void _process_Version(uint8_t src, uint8_t * data, uint8_t length);
-
-// Boiler and Buderus devices
-void _process_UBAMonitorFast(uint8_t src, uint8_t * data, uint8_t length);
-void _process_UBAMonitorSlow(uint8_t src, uint8_t * data, uint8_t length);
-void _process_UBAMonitorWWMessage(uint8_t src, uint8_t * data, uint8_t length);
-void _process_UBAParameterWW(uint8_t src, uint8_t * data, uint8_t length);
-void _process_UBATotalUptimeMessage(uint8_t src, uint8_t * data, uint8_t length);
-void _process_UBAParametersMessage(uint8_t src, uint8_t * data, uint8_t length);
-void _process_SetPoints(uint8_t src, uint8_t * data, uint8_t length);
-void _process_SM10Monitor(uint8_t src, uint8_t * data, uint8_t length);
+void _process_Version(_EMS_RxTelegram * EMS_RxTelegram);
+
+// EMS master/Boiler devices
+void _process_UBAMonitorFast(_EMS_RxTelegram * EMS_RxTelegram);
+void _process_UBAMonitorSlow(_EMS_RxTelegram * EMS_RxTelegram);
+void _process_UBAMonitorWWMessage(_EMS_RxTelegram * EMS_RxTelegram);
+void _process_UBAParameterWW(_EMS_RxTelegram * EMS_RxTelegram);
+void _process_UBATotalUptimeMessage(_EMS_RxTelegram * EMS_RxTelegram);
+void _process_UBAParametersMessage(_EMS_RxTelegram * EMS_RxTelegram);
+
+void _process_SetPoints(_EMS_RxTelegram * EMS_RxTelegram);
+
+// SM10
+void _process_SM10Monitor(_EMS_RxTelegram * EMS_RxTelegram);
+
+// SM100
+void _process_SM100Monitor(_EMS_RxTelegram * EMS_RxTelegram);
+void _process_SM100Status(_EMS_RxTelegram * EMS_RxTelegram);
+void _process_SM100Status2(_EMS_RxTelegram * EMS_RxTelegram);
+void _process_SM100Energy(_EMS_RxTelegram * EMS_RxTelegram);
// Common for most thermostats
-void _process_RCTime(uint8_t src, uint8_t * data, uint8_t length);
-void _process_RCOutdoorTempMessage(uint8_t src, uint8_t * data, uint8_t length);
+void _process_RCTime(_EMS_RxTelegram * EMS_RxTelegram);
+void _process_RCOutdoorTempMessage(_EMS_RxTelegram * EMS_RxTelegram);
// RC10
-void _process_RC10Set(uint8_t src, uint8_t * data, uint8_t length);
-void _process_RC10StatusMessage(uint8_t src, uint8_t * data, uint8_t length);
+void _process_RC10Set(_EMS_RxTelegram * EMS_RxTelegram);
+void _process_RC10StatusMessage(_EMS_RxTelegram * EMS_RxTelegram);
// RC20
-void _process_RC20Set(uint8_t src, uint8_t * data, uint8_t length);
-void _process_RC20StatusMessage(uint8_t src, uint8_t * data, uint8_t length);
+void _process_RC20Set(_EMS_RxTelegram * EMS_RxTelegram);
+void _process_RC20StatusMessage(_EMS_RxTelegram * EMS_RxTelegram);
// RC30
-void _process_RC30Set(uint8_t src, uint8_t * data, uint8_t length);
-void _process_RC30StatusMessage(uint8_t src, uint8_t * data, uint8_t length);
+void _process_RC30Set(_EMS_RxTelegram * EMS_RxTelegram);
+void _process_RC30StatusMessage(_EMS_RxTelegram * EMS_RxTelegram);
// RC35
-void _process_RC35Set(uint8_t src, uint8_t * data, uint8_t length);
-void _process_RC35StatusMessage(uint8_t src, uint8_t * data, uint8_t length);
+void _process_RC35Set(_EMS_RxTelegram * EMS_RxTelegram);
+void _process_RC35StatusMessage(_EMS_RxTelegram * EMS_RxTelegram);
-// Easy
-void _process_EasyStatusMessage(uint8_t src, uint8_t * data, uint8_t length);
+// Easy type devices like C100
+void _process_EasyStatusMessage(_EMS_RxTelegram * EMS_RxTelegram);
-/*
+// RC1010, RC300, RC310
+void _process_RCPLUSStatusMessage(_EMS_RxTelegram * EMS_RxTelegram);
+void _process_RCPLUSSetMessage(_EMS_RxTelegram * EMS_RxTelegram);
+void _process_RCPLUSStatusHeating(_EMS_RxTelegram * EMS_RxTelegram);
+void _process_RCPLUSStatusHeating(_EMS_RxTelegram * EMS_RxTelegram);
+void _process_RCPLUSStatusMode(_EMS_RxTelegram * EMS_RxTelegram);
+
+// Junkers FR10
+void _process_FR10StatusMessage(_EMS_RxTelegram * EMS_RxTelegram);
+
+/**
* Recognized EMS types and the functions they call to process the telegrams
- * Format: MODEL ID, TYPE ID, Description, function
+ * Format: MODEL ID, TYPE ID, Description, function, emsplus
*/
const _EMS_Type EMS_Types[] = {
@@ -88,6 +116,10 @@ const _EMS_Type EMS_Types[] = {
// Other devices
{EMS_MODEL_OTHER, EMS_TYPE_SM10Monitor, "SM10Monitor", _process_SM10Monitor},
+ {EMS_MODEL_OTHER, EMS_TYPE_SM100Monitor, "SM100Monitor", _process_SM100Monitor},
+ {EMS_MODEL_OTHER, EMS_TYPE_SM100Status, "SM100Status", _process_SM100Status},
+ {EMS_MODEL_OTHER, EMS_TYPE_SM100Status2, "SM100Status2", _process_SM100Status2},
+ {EMS_MODEL_OTHER, EMS_TYPE_SM100Energy, "SM100Energy", _process_SM100Energy},
// RC10
{EMS_MODEL_RC10, EMS_TYPE_RCTime, "RCTime", _process_RCTime},
@@ -114,19 +146,31 @@ const _EMS_Type EMS_Types[] = {
// RC35
{EMS_MODEL_RC35, EMS_TYPE_RCOutdoorTempMessage, "RCOutdoorTempMessage", _process_RCOutdoorTempMessage},
{EMS_MODEL_RC35, EMS_TYPE_RCTime, "RCTime", _process_RCTime},
- {EMS_MODEL_RC35, EMS_TYPE_RC35Set, "RC35Set", _process_RC35Set},
- {EMS_MODEL_RC35, EMS_TYPE_RC35StatusMessage, "RC35StatusMessage", _process_RC35StatusMessage},
+ {EMS_MODEL_RC35, EMS_TYPE_RC35Set_HC1, "RC35Set_HC1", _process_RC35Set},
+ {EMS_MODEL_RC35, EMS_TYPE_RC35StatusMessage_HC1, "RC35StatusMessage_HC1", _process_RC35StatusMessage},
+ {EMS_MODEL_RC35, EMS_TYPE_RC35Set_HC2, "RC35Set_HC2", _process_RC35Set},
+ {EMS_MODEL_RC35, EMS_TYPE_RC35StatusMessage_HC2, "RC35StatusMessage_HC2", _process_RC35StatusMessage},
// ES73
{EMS_MODEL_ES73, EMS_TYPE_RCOutdoorTempMessage, "RCOutdoorTempMessage", _process_RCOutdoorTempMessage},
{EMS_MODEL_ES73, EMS_TYPE_RCTime, "RCTime", _process_RCTime},
- {EMS_MODEL_ES73, EMS_TYPE_RC35Set, "RC35Set", _process_RC35Set},
- {EMS_MODEL_ES73, EMS_TYPE_RC35StatusMessage, "RC35StatusMessage", _process_RC35StatusMessage},
+ {EMS_MODEL_ES73, EMS_TYPE_RC35Set_HC1, "RC35Set", _process_RC35Set},
+ {EMS_MODEL_ES73, EMS_TYPE_RC35StatusMessage_HC1, "RC35StatusMessage", _process_RC35StatusMessage},
// Easy
{EMS_MODEL_EASY, EMS_TYPE_EasyStatusMessage, "EasyStatusMessage", _process_EasyStatusMessage},
{EMS_MODEL_BOSCHEASY, EMS_TYPE_EasyStatusMessage, "EasyStatusMessage", _process_EasyStatusMessage},
+ // Nefit 1010, RC300, RC310 (EMS Plus)
+ {EMS_MODEL_ALL, EMS_TYPE_RCPLUSStatusMessage, "RCPLUSStatusMessage", _process_RCPLUSStatusMessage},
+ {EMS_MODEL_ALL, EMS_TYPE_RCPLUSSet, "RCPLUSSetMessage", _process_RCPLUSSetMessage},
+ {EMS_MODEL_ALL, EMS_TYPE_RCPLUSStatusHeating, "RCPLUSStatusHeating", _process_RCPLUSStatusHeating},
+ {EMS_MODEL_ALL, EMS_TYPE_RCPLUSStatusMode, "RCPLUSStatusMode", _process_RCPLUSStatusMode},
+
+ // Junkers FR10
+ {EMS_MODEL_ALL, EMS_TYPE_FR10StatusMessage, "FR10StatusMessage", _process_FR10StatusMessage}
+
+
};
// calculate sizes of arrays at compile
@@ -141,25 +185,23 @@ _EMS_Thermostat EMS_Thermostat; // for thermostat
_EMS_Other EMS_Other; // for other known EMS devices
// CRC lookup table with poly 12 for faster checking
-const uint8_t ems_crc_table[] = {0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E, 0x20, 0x22,
- 0x24, 0x26, 0x28, 0x2A, 0x2C, 0x2E, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3A, 0x3C, 0x3E, 0x40, 0x42, 0x44, 0x46,
- 0x48, 0x4A, 0x4C, 0x4E, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5A, 0x5C, 0x5E, 0x60, 0x62, 0x64, 0x66, 0x68, 0x6A,
- 0x6C, 0x6E, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7A, 0x7C, 0x7E, 0x80, 0x82, 0x84, 0x86, 0x88, 0x8A, 0x8C, 0x8E,
- 0x90, 0x92, 0x94, 0x96, 0x98, 0x9A, 0x9C, 0x9E, 0xA0, 0xA2, 0xA4, 0xA6, 0xA8, 0xAA, 0xAC, 0xAE, 0xB0, 0xB2,
- 0xB4, 0xB6, 0xB8, 0xBA, 0xBC, 0xBE, 0xC0, 0xC2, 0xC4, 0xC6, 0xC8, 0xCA, 0xCC, 0xCE, 0xD0, 0xD2, 0xD4, 0xD6,
- 0xD8, 0xDA, 0xDC, 0xDE, 0xE0, 0xE2, 0xE4, 0xE6, 0xE8, 0xEA, 0xEC, 0xEE, 0xF0, 0xF2, 0xF4, 0xF6, 0xF8, 0xFA,
- 0xFC, 0xFE, 0x19, 0x1B, 0x1D, 0x1F, 0x11, 0x13, 0x15, 0x17, 0x09, 0x0B, 0x0D, 0x0F, 0x01, 0x03, 0x05, 0x07,
- 0x39, 0x3B, 0x3D, 0x3F, 0x31, 0x33, 0x35, 0x37, 0x29, 0x2B, 0x2D, 0x2F, 0x21, 0x23, 0x25, 0x27, 0x59, 0x5B,
- 0x5D, 0x5F, 0x51, 0x53, 0x55, 0x57, 0x49, 0x4B, 0x4D, 0x4F, 0x41, 0x43, 0x45, 0x47, 0x79, 0x7B, 0x7D, 0x7F,
- 0x71, 0x73, 0x75, 0x77, 0x69, 0x6B, 0x6D, 0x6F, 0x61, 0x63, 0x65, 0x67, 0x99, 0x9B, 0x9D, 0x9F, 0x91, 0x93,
- 0x95, 0x97, 0x89, 0x8B, 0x8D, 0x8F, 0x81, 0x83, 0x85, 0x87, 0xB9, 0xBB, 0xBD, 0xBF, 0xB1, 0xB3, 0xB5, 0xB7,
- 0xA9, 0xAB, 0xAD, 0xAF, 0xA1, 0xA3, 0xA5, 0xA7, 0xD9, 0xDB, 0xDD, 0xDF, 0xD1, 0xD3, 0xD5, 0xD7, 0xC9, 0xCB,
- 0xCD, 0xCF, 0xC1, 0xC3, 0xC5, 0xC7, 0xF9, 0xFB, 0xFD, 0xFF, 0xF1, 0xF3, 0xF5, 0xF7, 0xE9, 0xEB, 0xED, 0xEF,
- 0xE1, 0xE3, 0xE5, 0xE7};
-
-const uint8_t TX_WRITE_TIMEOUT_COUNT = 2; // 3 retries before timeout
-const unsigned long EMS_BUS_TIMEOUT = 15000; // timeout in ms before recognizing the ems bus is offline (15 seconds)
-const unsigned long EMS_POLL_TIMEOUT = 5000; // timeout in ms before recognizing the ems bus is offline (5 seconds)
+const uint8_t ems_crc_table[] = {0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E, 0x20, 0x22, 0x24, 0x26,
+ 0x28, 0x2A, 0x2C, 0x2E, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3A, 0x3C, 0x3E, 0x40, 0x42, 0x44, 0x46, 0x48, 0x4A, 0x4C, 0x4E,
+ 0x50, 0x52, 0x54, 0x56, 0x58, 0x5A, 0x5C, 0x5E, 0x60, 0x62, 0x64, 0x66, 0x68, 0x6A, 0x6C, 0x6E, 0x70, 0x72, 0x74, 0x76,
+ 0x78, 0x7A, 0x7C, 0x7E, 0x80, 0x82, 0x84, 0x86, 0x88, 0x8A, 0x8C, 0x8E, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9A, 0x9C, 0x9E,
+ 0xA0, 0xA2, 0xA4, 0xA6, 0xA8, 0xAA, 0xAC, 0xAE, 0xB0, 0xB2, 0xB4, 0xB6, 0xB8, 0xBA, 0xBC, 0xBE, 0xC0, 0xC2, 0xC4, 0xC6,
+ 0xC8, 0xCA, 0xCC, 0xCE, 0xD0, 0xD2, 0xD4, 0xD6, 0xD8, 0xDA, 0xDC, 0xDE, 0xE0, 0xE2, 0xE4, 0xE6, 0xE8, 0xEA, 0xEC, 0xEE,
+ 0xF0, 0xF2, 0xF4, 0xF6, 0xF8, 0xFA, 0xFC, 0xFE, 0x19, 0x1B, 0x1D, 0x1F, 0x11, 0x13, 0x15, 0x17, 0x09, 0x0B, 0x0D, 0x0F,
+ 0x01, 0x03, 0x05, 0x07, 0x39, 0x3B, 0x3D, 0x3F, 0x31, 0x33, 0x35, 0x37, 0x29, 0x2B, 0x2D, 0x2F, 0x21, 0x23, 0x25, 0x27,
+ 0x59, 0x5B, 0x5D, 0x5F, 0x51, 0x53, 0x55, 0x57, 0x49, 0x4B, 0x4D, 0x4F, 0x41, 0x43, 0x45, 0x47, 0x79, 0x7B, 0x7D, 0x7F,
+ 0x71, 0x73, 0x75, 0x77, 0x69, 0x6B, 0x6D, 0x6F, 0x61, 0x63, 0x65, 0x67, 0x99, 0x9B, 0x9D, 0x9F, 0x91, 0x93, 0x95, 0x97,
+ 0x89, 0x8B, 0x8D, 0x8F, 0x81, 0x83, 0x85, 0x87, 0xB9, 0xBB, 0xBD, 0xBF, 0xB1, 0xB3, 0xB5, 0xB7, 0xA9, 0xAB, 0xAD, 0xAF,
+ 0xA1, 0xA3, 0xA5, 0xA7, 0xD9, 0xDB, 0xDD, 0xDF, 0xD1, 0xD3, 0xD5, 0xD7, 0xC9, 0xCB, 0xCD, 0xCF, 0xC1, 0xC3, 0xC5, 0xC7,
+ 0xF9, 0xFB, 0xFD, 0xFF, 0xF1, 0xF3, 0xF5, 0xF7, 0xE9, 0xEB, 0xED, 0xEF, 0xE1, 0xE3, 0xE5, 0xE7};
+
+const uint8_t TX_WRITE_TIMEOUT_COUNT = 2; // 3 retries before timeout
+const uint32_t EMS_BUS_TIMEOUT = 15000; // timeout in ms before recognizing the ems bus is offline (15 seconds)
+const uint32_t EMS_POLL_TIMEOUT = 5000; // timeout in ms before recognizing the ems bus is offline (5 seconds)
// init stats and counters and buffers
// uses -255 or 255 for values that haven't been set yet (EMS_VALUE_INT_NOTSET and EMS_VALUE_FLOAT_NOTSET)
@@ -176,8 +218,9 @@ void ems_init() {
EMS_Sys_Status.emsRxTimestamp = 0;
EMS_Sys_Status.emsTxCapable = false;
EMS_Sys_Status.emsTxDisabled = false;
- EMS_Sys_Status.emsPollTimestamp = 0;
+ EMS_Sys_Status.emsPollFrequency = 0;
EMS_Sys_Status.txRetryCount = 0;
+ EMS_Sys_Status.emsTxDelay = false;
// thermostat
EMS_Thermostat.setpoint_roomTemp = EMS_VALUE_SHORT_NOTSET;
@@ -190,10 +233,15 @@ void ems_init() {
EMS_Thermostat.year = 0;
EMS_Thermostat.mode = 255; // dummy value
EMS_Thermostat.day_mode = 255; // dummy value
+ EMS_Thermostat.device_id = EMS_ID_NONE;
+ EMS_Thermostat.write_supported = false;
+ EMS_Thermostat.hc = 1; // default heating circuit is 1
+ EMS_Thermostat.daytemp = EMS_VALUE_INT_NOTSET; // 0x47 byte
+ EMS_Thermostat.nighttemp = EMS_VALUE_INT_NOTSET; // 0x47 byte
+ EMS_Thermostat.holidaytemp = EMS_VALUE_INT_NOTSET; // 0x47 byte
+ EMS_Thermostat.heatingtype = EMS_VALUE_INT_NOTSET; // 0x47 byte floor heating = 3
+ EMS_Thermostat.circuitcalctemp = EMS_VALUE_INT_NOTSET; // 0x48 byte 14
- EMS_Thermostat.type_id = EMS_ID_NONE;
- EMS_Thermostat.read_supported = false;
- EMS_Thermostat.write_supported = false;
// UBAParameterWW
EMS_Boiler.wWActivated = EMS_VALUE_INT_NOTSET; // Warm Water activated
@@ -228,7 +276,7 @@ void ems_init() {
EMS_Boiler.heatWorkMin = EMS_VALUE_LONG_NOTSET; // Total heat operating time
// UBAMonitorWWMessage
- EMS_Boiler.wWCurTmp = EMS_VALUE_SHORT_NOTSET; // Warm Water current temperature:
+ EMS_Boiler.wWCurTmp = EMS_VALUE_SHORT_NOTSET; // Warm Water current temperature
EMS_Boiler.wWStarts = EMS_VALUE_LONG_NOTSET; // Warm Water # starts
EMS_Boiler.wWWorkM = EMS_VALUE_LONG_NOTSET; // Warm Water # minutes
EMS_Boiler.wWOneTime = EMS_VALUE_INT_NOTSET; // Warm Water one time function on/off
@@ -243,26 +291,29 @@ void ems_init() {
EMS_Boiler.pump_mod_min = EMS_VALUE_INT_NOTSET; // Boiler circuit pump modulation min. power
// Other EMS devices values
- EMS_Other.SM10collectorTemp = EMS_VALUE_SHORT_NOTSET; // collector temp from SM10
- EMS_Other.SM10bottomTemp = EMS_VALUE_SHORT_NOTSET; // bottom temp from SM10
- EMS_Other.SM10pumpModulation = EMS_VALUE_INT_NOTSET; // modulation solar pump SM10
- EMS_Other.SM10pump = EMS_VALUE_INT_NOTSET; // pump active
+ EMS_Other.SMcollectorTemp = EMS_VALUE_SHORT_NOTSET; // collector temp from SM10/SM100
+ EMS_Other.SMbottomTemp = EMS_VALUE_SHORT_NOTSET; // bottom temp from SM10/SM100
+ EMS_Other.SMpumpModulation = EMS_VALUE_INT_NOTSET; // modulation solar pump SM10/SM100
+ EMS_Other.SMpump = EMS_VALUE_INT_NOTSET; // pump active
+ EMS_Other.SMEnergyLastHour = EMS_VALUE_SHORT_NOTSET;
+ EMS_Other.SMEnergyToday = EMS_VALUE_SHORT_NOTSET;
+ EMS_Other.SMEnergyTotal = EMS_VALUE_SHORT_NOTSET;
// calculated values
EMS_Boiler.tapwaterActive = EMS_VALUE_INT_NOTSET; // Hot tap water is on/off
EMS_Boiler.heatingActive = EMS_VALUE_INT_NOTSET; // Central heating is on/off
// set boiler type
- EMS_Boiler.product_id = 0;
+ EMS_Boiler.product_id = EMS_ID_NONE;
strlcpy(EMS_Boiler.version, "?", sizeof(EMS_Boiler.version));
// set thermostat model
EMS_Thermostat.model_id = EMS_MODEL_NONE;
- EMS_Thermostat.product_id = 0;
+ EMS_Thermostat.product_id = EMS_ID_NONE;
strlcpy(EMS_Thermostat.version, "?", sizeof(EMS_Thermostat.version));
// set other types
- EMS_Other.SM10 = false;
+ EMS_Other.SM = false;
// default logging is none
ems_setLogging(EMS_SYS_LOGGING_DEFAULT);
@@ -271,13 +322,22 @@ void ems_init() {
// Getters and Setters for parameters
void ems_setPoll(bool b) {
EMS_Sys_Status.emsPollEnabled = b;
- myDebug("EMS Bus Poll is set to %s", EMS_Sys_Status.emsPollEnabled ? "enabled" : "disabled");
+ myDebug_P(PSTR("EMS Bus Poll is set to %s"), EMS_Sys_Status.emsPollEnabled ? "enabled" : "disabled");
}
bool ems_getPoll() {
return EMS_Sys_Status.emsPollEnabled;
}
+void ems_setTxDelay(bool b) {
+ EMS_Sys_Status.emsTxDelay = b;
+ myDebug_P(PSTR("EMS Tx delay is %s"), EMS_Sys_Status.emsTxDelay ? "enabled" : "disabled");
+}
+
+bool ems_getTxDelay() {
+ return EMS_Sys_Status.emsTxDelay;
+}
+
bool ems_getEmsRefreshed() {
return EMS_Sys_Status.emsRefreshed;
}
@@ -286,12 +346,16 @@ void ems_setEmsRefreshed(bool b) {
EMS_Sys_Status.emsRefreshed = b;
}
+void ems_setThermostatHC(uint8_t hc) {
+ EMS_Thermostat.hc = hc;
+}
+
bool ems_getBoilerEnabled() {
- return (EMS_Boiler.type_id != EMS_ID_NONE);
+ return (EMS_Boiler.device_id != EMS_ID_NONE);
}
bool ems_getThermostatEnabled() {
- return (EMS_Thermostat.type_id != EMS_ID_NONE);
+ return (EMS_Thermostat.device_id != EMS_ID_NONE);
}
uint8_t ems_getThermostatModel() {
@@ -302,8 +366,12 @@ void ems_setTxDisabled(bool b) {
EMS_Sys_Status.emsTxDisabled = b;
}
+uint32_t ems_getPollFrequency() {
+ return EMS_Sys_Status.emsPollFrequency;
+}
+
bool ems_getTxCapable() {
- if ((millis() - EMS_Sys_Status.emsPollTimestamp) > EMS_POLL_TIMEOUT) {
+ if ((EMS_Sys_Status.emsPollFrequency == 0) || (EMS_Sys_Status.emsPollFrequency > EMS_POLL_TIMEOUT)) {
EMS_Sys_Status.emsTxCapable = false;
}
return EMS_Sys_Status.emsTxCapable;
@@ -324,23 +392,22 @@ void ems_setLogging(_EMS_SYS_LOGGING loglevel) {
if (loglevel <= EMS_SYS_LOGGING_VERBOSE) {
EMS_Sys_Status.emsLogging = loglevel;
if (loglevel == EMS_SYS_LOGGING_NONE) {
- myDebug("System Logging set to None");
+ myDebug_P(PSTR("System Logging set to None"));
} else if (loglevel == EMS_SYS_LOGGING_BASIC) {
- myDebug("System Logging set to Basic");
+ myDebug_P(PSTR("System Logging set to Basic"));
} else if (loglevel == EMS_SYS_LOGGING_VERBOSE) {
- myDebug("System Logging set to Verbose");
+ myDebug_P(PSTR("System Logging set to Verbose"));
} else if (loglevel == EMS_SYS_LOGGING_THERMOSTAT) {
- myDebug("System Logging set to Thermostat only");
+ myDebug_P(PSTR("System Logging set to Thermostat only"));
} else if (loglevel == EMS_SYS_LOGGING_RAW) {
- myDebug("System Logging set to Raw mode");
+ myDebug_P(PSTR("System Logging set to Raw mode"));
}
}
}
/**
* Calculate CRC checksum using lookup table for speed
- * len is length of data in bytes (including the CRC byte at end)
- * So its the complete telegram with the header
+ * len is length of all the data in bytes (including the header & CRC byte at end)
*/
uint8_t _crcCalculator(uint8_t * data, uint8_t len) {
uint8_t crc = 0;
@@ -405,16 +472,13 @@ int _ems_findType(uint8_t type) {
/**
* debug print a telegram to telnet/serial including the CRC
- * len is length in bytes including the CRC
*/
-void _debugPrintTelegram(const char * prefix, _EMS_RxTelegram * EMS_RxTelegram, const char * color) {
- if (EMS_Sys_Status.emsLogging <= EMS_SYS_LOGGING_BASIC)
- return;
-
+void _debugPrintTelegram(const char * prefix, _EMS_RxTelegram * EMS_RxTelegram, const char * color, bool raw = false) {
char output_str[200] = {0};
char buffer[16] = {0};
- uint8_t len = EMS_RxTelegram->length;
uint8_t * data = EMS_RxTelegram->telegram;
+ uint8_t data_len = EMS_RxTelegram->data_length; // length of data block
+ uint8_t length = EMS_RxTelegram->length; // includes CRC
strlcpy(output_str, "(", sizeof(output_str));
strlcat(output_str, COLOR_CYAN, sizeof(output_str));
@@ -430,21 +494,28 @@ void _debugPrintTelegram(const char * prefix, _EMS_RxTelegram * EMS_RxTelegram,
strlcat(output_str, color, sizeof(output_str));
strlcat(output_str, prefix, sizeof(output_str));
- strlcat(output_str, " telegram: ", sizeof(output_str));
- for (int i = 0; i < len - 1; i++) {
+ if (!raw) {
+ strlcat(output_str, " telegram: ", sizeof(output_str));
+ }
+
+ for (int i = 0; i < (length - 1); i++) {
strlcat(output_str, _hextoa(data[i], buffer), sizeof(output_str));
strlcat(output_str, " ", sizeof(output_str)); // add space
}
- strlcat(output_str, "(CRC=", sizeof(output_str));
- strlcat(output_str, _hextoa(data[len - 1], buffer), sizeof(output_str));
- strlcat(output_str, ")", sizeof(output_str));
-
- // print number of data bytes only if its a valid telegram
- if (len > 5) {
- strlcat(output_str, ", #data=", sizeof(output_str));
- strlcat(output_str, itoa(len - 5, buffer, 10), sizeof(output_str));
+ if (raw) {
+ strlcat(output_str, _hextoa(data[length - 1], buffer), sizeof(output_str));
+ } else {
+ strlcat(output_str, "(CRC=", sizeof(output_str));
+ strlcat(output_str, _hextoa(data[length - 1], buffer), sizeof(output_str));
+ strlcat(output_str, ")", sizeof(output_str));
+
+ // print number of data bytes only if its a valid telegram
+ if (data_len) {
+ strlcat(output_str, " #data=", sizeof(output_str));
+ strlcat(output_str, itoa(data_len, buffer, 10), sizeof(output_str));
+ }
}
strlcat(output_str, COLOR_RESET, sizeof(output_str));
@@ -472,17 +543,18 @@ void _ems_sendTelegram() {
return;
}
-
// if we're in raw mode just fire and forget
+ // e.g. send 0B 88 02 00 20
if (EMS_TxTelegram.action == EMS_TX_TELEGRAM_RAW) {
+ _EMS_RxTelegram EMS_RxTelegram; // create new Rx object
+
EMS_TxTelegram.data[EMS_TxTelegram.length - 1] = _crcCalculator(EMS_TxTelegram.data, EMS_TxTelegram.length); // add the CRC
- _EMS_RxTelegram EMS_RxTelegram;
- EMS_RxTelegram.length = EMS_TxTelegram.length;
- EMS_RxTelegram.telegram = EMS_TxTelegram.data;
- EMS_RxTelegram.timestamp = millis(); // now
- _debugPrintTelegram("Sending raw", &EMS_RxTelegram, COLOR_CYAN); // always show
- emsuart_tx_buffer(EMS_TxTelegram.data, EMS_TxTelegram.length); // send the telegram to the UART Tx
- EMS_TxQueue.shift(); // remove from queue
+ EMS_RxTelegram.length = EMS_TxTelegram.length; // full length of telegram
+ EMS_RxTelegram.telegram = EMS_TxTelegram.data;
+ EMS_RxTelegram.timestamp = millis(); // now
+ _debugPrintTelegram("Sending raw: ", &EMS_RxTelegram, COLOR_CYAN, true); // always show
+ emsuart_tx_buffer(EMS_TxTelegram.data, EMS_TxTelegram.length); // send the telegram to the UART Tx
+ EMS_TxQueue.shift(); // remove from queue
return;
}
@@ -521,7 +593,7 @@ void _ems_sendTelegram() {
}
_EMS_RxTelegram EMS_RxTelegram;
- EMS_RxTelegram.length = EMS_TxTelegram.length;
+ EMS_RxTelegram.length = EMS_TxTelegram.length; // complete length of telegram
EMS_RxTelegram.telegram = EMS_TxTelegram.data;
EMS_RxTelegram.timestamp = millis(); // now
_debugPrintTelegram(s, &EMS_RxTelegram, COLOR_CYAN);
@@ -577,10 +649,9 @@ void _createValidate() {
EMS_TxQueue.unshift(new_EMS_TxTelegram); // add back to queue making it first to be picked up next (FIFO)
}
-
-/*
+/**
* Entry point triggered by an interrupt in emsuart.cpp
- * length is only data bytes, excluding the BRK
+ * length is size of all the telegram bytes including the CRC, excluding the BRK at the end
* Read commands are asynchronous as they're handled by the interrupt
* When a telegram is processed we forcefully erase it from the stack to prevent overflow
*/
@@ -588,21 +659,23 @@ void ems_parseTelegram(uint8_t * telegram, uint8_t length) {
if ((length != 0) && (telegram[0] != 0x00)) {
_ems_readTelegram(telegram, length);
}
- // now clear the Rx buffer just be safe and prevent duplicates
- for (uint8_t i = 0; i < EMS_MAXBUFFERSIZE; telegram[i++] = 0x00)
- ;
+
+ // clear the Rx buffer just be safe and prevent duplicates
+ memset(telegram, 0, EMS_MAXBUFFERSIZE);
}
/**
* the main logic that parses the telegram message
* When we receive a Poll Request we need to send any Tx packages quickly within a 200ms window
+ * length is total number of bytes of the telegram including the CRC byte at the end (if it exists)
*/
void _ems_readTelegram(uint8_t * telegram, uint8_t length) {
// create the Rx package
static _EMS_RxTelegram EMS_RxTelegram;
- EMS_RxTelegram.length = length;
- EMS_RxTelegram.telegram = telegram;
- EMS_RxTelegram.timestamp = millis();
+ static uint32_t _last_emsPollFrequency = 0;
+ EMS_RxTelegram.telegram = telegram;
+ EMS_RxTelegram.timestamp = millis();
+ EMS_RxTelegram.length = length;
// check if we just received a single byte
// it could well be a Poll request from the boiler for us, which will have a value of 0x8B (0x0B | 0x80)
@@ -610,10 +683,12 @@ void _ems_readTelegram(uint8_t * telegram, uint8_t length) {
if (length == 1) {
uint8_t value = telegram[0]; // 1st byte of data package
+ EMS_Sys_Status.emsPollFrequency = (EMS_RxTelegram.timestamp - _last_emsPollFrequency);
+ _last_emsPollFrequency = EMS_RxTelegram.timestamp;
+
// check first for a Poll for us
if (value == (EMS_ID_ME | 0x80)) {
- EMS_Sys_Status.emsPollTimestamp = EMS_RxTelegram.timestamp; // store when we received a last poll
- EMS_Sys_Status.emsTxCapable = true;
+ EMS_Sys_Status.emsTxCapable = true;
// do we have something to send thats waiting in the Tx queue?
// if so send it if the Queue is not in a wait state
@@ -635,7 +710,7 @@ void _ems_readTelegram(uint8_t * telegram, uint8_t length) {
} else if (value == EMS_TX_ERROR) {
// last write failed (04), delete it from queue and dont bother to retry
if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_VERBOSE) {
- myDebug("** Write command failed from host");
+ myDebug_P(PSTR("** Write command failed from host"));
}
emsaurt_tx_poll(); // send a poll to free the EMS bus
_removeTxQueue(); // remove from queue
@@ -652,13 +727,50 @@ void _ems_readTelegram(uint8_t * telegram, uint8_t length) {
return;
}
+ // fill in the rest of the telegram
+ EMS_RxTelegram.src = telegram[0] & 0x7F; // removing 8th bit as we deal with both reads and writes here
+ EMS_RxTelegram.dest = telegram[1] & 0x7F; // remove 8th bit (don't care if read or write)
+ EMS_RxTelegram.offset = telegram[3]; // offset is always 4th byte
+
+ // determing if its normal ems or ems plus
+ if (telegram[2] >= 0xF0) {
+ // its EMS plus / EMS 2.0
+ EMS_RxTelegram.emsplus = true;
+
+ if (telegram[2] == 0xFF) {
+ EMS_RxTelegram.type = (telegram[4] << 8) + telegram[5]; // is a long in bytes 5 & 6
+ EMS_RxTelegram.data = telegram + 6;
+
+ if (length <= 7) {
+ EMS_RxTelegram.data_length = 0; // special broadcast on ems+ have no data values
+ } else {
+ EMS_RxTelegram.data_length = length - 7; // remove 6 byte header plus CRC
+ }
+ } else {
+ // its F9 or F7
+ uint8_t shift = (telegram[4] != 0xFF); // true (1) if byte 4 is not 0xFF, then telegram is 1 byte longer
+ EMS_RxTelegram.type = (telegram[5 + shift] << 8) + telegram[6 + shift];
+ EMS_RxTelegram.data = telegram + 6 + shift; // there is a special byte after the typeID which we ignore for now
+ if (length <= (9 + shift)) {
+ EMS_RxTelegram.data_length = 0; // special broadcast on ems+ have no data values
+ } else {
+ EMS_RxTelegram.data_length = length - (9 + shift);
+ }
+ }
+ } else {
+ // Normal EMS 1.0
+ EMS_RxTelegram.emsplus = false;
+ EMS_RxTelegram.type = telegram[2]; // 3rd byte
+ EMS_RxTelegram.data = telegram + 4;
+ EMS_RxTelegram.data_length = length - 5; // remove 4 bytes header plus CRC
+ }
+
// Assume at this point we have something that vaguely resembles a telegram in the format [src] [dest] [type] [offset] [data] [crc]
- // validate the CRC, if its bad ignore it
- uint8_t crc = _crcCalculator(telegram, length);
- if (telegram[length - 1] != crc) {
+ // validate the CRC, if it's bad ignore it
+ if (telegram[length - 1] != _crcCalculator(telegram, length)) {
EMS_Sys_Status.emxCrcErr++;
if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_VERBOSE) {
- _debugPrintTelegram("Corrupt telegram:", &EMS_RxTelegram, COLOR_RED);
+ _debugPrintTelegram("Corrupt telegram: ", &EMS_RxTelegram, COLOR_RED, true);
}
return;
}
@@ -666,13 +778,7 @@ void _ems_readTelegram(uint8_t * telegram, uint8_t length) {
// if we are in raw logging mode then just print out the telegram as it is
// but still continue to process it
if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_RAW) {
- char raw[300] = {0};
- char buffer[16] = {0};
- for (int i = 0; i < length; i++) {
- strlcat(raw, _hextoa(telegram[i], buffer), sizeof(raw));
- strlcat(raw, " ", sizeof(raw)); // add space
- }
- myDebug(raw);
+ _debugPrintTelegram("", &EMS_RxTelegram, COLOR_WHITE, true);
}
// here we know its a valid incoming telegram of at least 6 bytes
@@ -685,88 +791,118 @@ void _ems_readTelegram(uint8_t * telegram, uint8_t length) {
}
/**
- * print detailed telegram
- * and then call its callback if there is one defined
+ * print the telegram
*/
-void _ems_processTelegram(_EMS_RxTelegram * EMS_RxTelegram) {
- // header
- uint8_t * telegram = EMS_RxTelegram->telegram;
- uint8_t src = telegram[0] & 0x7F;
- uint8_t dest = telegram[1] & 0x7F; // remove 8th bit to handle both reads and writes
- uint8_t type = telegram[2];
- uint8_t offset = telegram[3];
- uint8_t * data = telegram + 4; // data block starts at position 5
-
- // print detailed telegram data
- if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_THERMOSTAT) {
- char output_str[200] = {0};
- char buffer[16] = {0};
- char color_s[20] = {0};
-
- // source
- if (src == EMS_Boiler.type_id) {
- strlcpy(output_str, "Boiler", sizeof(output_str));
- } else if (src == EMS_Thermostat.type_id) {
- strlcpy(output_str, "Thermostat", sizeof(output_str));
- } else if (src == EMS_ID_SM10) {
- strlcpy(output_str, "SM10", sizeof(output_str));
- } else {
- strlcpy(output_str, "0x", sizeof(output_str));
- strlcat(output_str, _hextoa(src, buffer), sizeof(output_str));
- }
+void _printMessage(_EMS_RxTelegram * EMS_RxTelegram) {
+ // header info
+ uint8_t src = EMS_RxTelegram->src;
+ uint8_t dest = EMS_RxTelegram->dest;
+ uint16_t type = EMS_RxTelegram->type;
+
+ char output_str[200] = {0};
+ char buffer[16] = {0};
+ char color_s[20] = {0};
+
+ // source
+ if (src == EMS_Boiler.device_id) {
+ strlcpy(output_str, "Boiler", sizeof(output_str));
+ } else if (src == EMS_Thermostat.device_id) {
+ strlcpy(output_str, "Thermostat", sizeof(output_str));
+ } else if (src == EMS_ID_SM) {
+ strlcpy(output_str, "SM", sizeof(output_str));
+ } else if (src == EMS_ID_GATEWAY) {
+ strlcpy(output_str, "Gateway", sizeof(output_str));
+ } else {
+ strlcpy(output_str, "0x", sizeof(output_str));
+ strlcat(output_str, _hextoa(src, buffer), sizeof(output_str));
+ }
+
+ strlcat(output_str, " -> ", sizeof(output_str));
+
+ // destination
+ if (dest == EMS_ID_ME) {
+ strlcat(output_str, "me", sizeof(output_str));
+ strlcpy(color_s, COLOR_YELLOW, sizeof(color_s));
+ } else if (dest == EMS_ID_NONE) {
+ strlcat(output_str, "all", sizeof(output_str));
+ strlcpy(color_s, COLOR_GREEN, sizeof(color_s));
+ } else if (dest == EMS_Boiler.device_id) {
+ strlcat(output_str, "Boiler", sizeof(output_str));
+ strlcpy(color_s, COLOR_MAGENTA, sizeof(color_s));
+ } else if (dest == EMS_ID_SM) {
+ strlcat(output_str, "SM", sizeof(output_str));
+ strlcpy(color_s, COLOR_MAGENTA, sizeof(color_s));
+ } else if (dest == EMS_ID_GATEWAY) {
+ strlcat(output_str, "Gateway", sizeof(output_str));
+ strlcpy(color_s, COLOR_MAGENTA, sizeof(color_s));
+ } else if (dest == EMS_Thermostat.device_id) {
+ strlcat(output_str, "Thermostat", sizeof(output_str));
+ strlcpy(color_s, COLOR_MAGENTA, sizeof(color_s));
+ } else {
+ strlcat(output_str, "0x", sizeof(output_str));
+ strlcat(output_str, _hextoa(dest, buffer), sizeof(output_str));
+ strlcpy(color_s, COLOR_MAGENTA, sizeof(color_s));
+ }
- strlcat(output_str, " -> ", sizeof(output_str));
-
- // destination
- if (dest == EMS_ID_ME) {
- strlcat(output_str, "me", sizeof(output_str));
- strlcpy(color_s, COLOR_YELLOW, sizeof(color_s));
- } else if (dest == EMS_ID_NONE) {
- strlcat(output_str, "all", sizeof(output_str));
- strlcpy(color_s, COLOR_GREEN, sizeof(color_s));
- } else if (dest == EMS_Boiler.type_id) {
- strlcat(output_str, "Boiler", sizeof(output_str));
- strlcpy(color_s, COLOR_MAGENTA, sizeof(color_s));
- } else if (dest == EMS_ID_SM10) {
- strlcat(output_str, "SM10", sizeof(output_str));
- strlcpy(color_s, COLOR_MAGENTA, sizeof(color_s));
- } else if (dest == EMS_Thermostat.type_id) {
- strlcat(output_str, "Thermostat", sizeof(output_str));
- strlcpy(color_s, COLOR_MAGENTA, sizeof(color_s));
- } else {
- strlcat(output_str, "0x", sizeof(output_str));
- strlcat(output_str, _hextoa(dest, buffer), sizeof(output_str));
- strlcpy(color_s, COLOR_MAGENTA, sizeof(color_s));
- }
+ // type
+ strlcat(output_str, ", type 0x", sizeof(output_str));
- // type
- strlcat(output_str, ", type 0x", sizeof(output_str));
+ if (EMS_RxTelegram->emsplus) {
+ strlcat(output_str, _hextoa(type >> 8, buffer), sizeof(output_str));
+ strlcat(output_str, _hextoa(type & 0xFF, buffer), sizeof(output_str));
+ } else {
strlcat(output_str, _hextoa(type, buffer), sizeof(output_str));
+ }
- if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_THERMOSTAT) {
- // only print ones to/from thermostat if logging is set to thermostat only
- if ((src == EMS_Thermostat.type_id) || (dest == EMS_Thermostat.type_id)) {
- _debugPrintTelegram(output_str, EMS_RxTelegram, color_s);
- }
- } else {
- // always print
+ if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_THERMOSTAT) {
+ // only print ones to/from thermostat if logging is set to thermostat only
+ if ((src == EMS_Thermostat.device_id) || (dest == EMS_Thermostat.device_id)) {
_debugPrintTelegram(output_str, EMS_RxTelegram, color_s);
}
+ } else {
+ // always print
+ _debugPrintTelegram(output_str, EMS_RxTelegram, color_s);
+ }
+}
+
+/**
+ * print detailed telegram
+ * and then call its callback if there is one defined
+ */
+void _ems_processTelegram(_EMS_RxTelegram * EMS_RxTelegram) {
+ // print out the telegram for verbose mode
+ if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_THERMOSTAT) {
+ _printMessage(EMS_RxTelegram);
+ }
+
+ // ignore telegrams that don't have any data
+ if (EMS_RxTelegram->data_length == 0) {
+ return;
}
+ // header
+ uint8_t dest = EMS_RxTelegram->dest;
+ uint16_t type = EMS_RxTelegram->type;
+
// see if we recognize the type first by scanning our known EMS types list
bool typeFound = false;
uint8_t i = 0;
while (i < _EMS_Types_max) {
if (EMS_Types[i].type == type) {
- // is it common type for everyone?
- // is it for us? So the src must match with either the boiler, thermostat or other devices
- if ((EMS_Types[i].model_id == EMS_MODEL_ALL)
- || ((src == EMS_Boiler.type_id) || (src == EMS_Thermostat.type_id) || (src == EMS_ID_SM10))) {
+ // is it a broadcast or something sent to us?
+ // we don't really care where it is from
+ if ((dest == EMS_ID_NONE) || (dest == EMS_ID_ME)) {
typeFound = true;
break;
}
+
+ /*
+ if ((EMS_Types[i].model_id == EMS_MODEL_ALL) || ((src == EMS_Boiler.device_id) || (src == EMS_Thermostat.device_id) || (src == EMS_ID_SM))) {
+ typeFound = true;
+ break;
+ }
+ */
}
i++;
}
@@ -776,16 +912,23 @@ void _ems_processTelegram(_EMS_RxTelegram * EMS_RxTelegram) {
if (typeFound) {
if ((EMS_Types[i].processType_cb) != (void *)NULL) {
// print non-verbose message
- if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_BASIC) {
- myDebug("<--- %s(0x%02X) received", EMS_Types[i].typeString, type);
+ if ((EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_BASIC) || (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_VERBOSE)) {
+ myDebug_P(PSTR("<--- %s(0x%02X)"), EMS_Types[i].typeString, type);
}
- // call callback function to process it
- // as we only handle complete telegrams (not partial) check that the offset is 0
- if (offset == 0) {
- (void)EMS_Types[i].processType_cb(src, data, EMS_RxTelegram->length - 5);
+ // call callback function to process the telegram, only if there is data
+ if (EMS_RxTelegram->emsplus) {
+ // if EMS+ always proces it
+ (void)EMS_Types[i].processType_cb(EMS_RxTelegram);
+ } else {
+ // only if the offset is 0 as we want to handle full telegrams and not partial
+ if (EMS_RxTelegram->offset == EMS_ID_NONE) {
+ (void)EMS_Types[i].processType_cb(EMS_RxTelegram);
+ }
}
}
}
+
+ EMS_Sys_Status.emsTxStatus = EMS_TX_STATUS_IDLE;
}
/**
@@ -806,11 +949,8 @@ void _removeTxQueue() {
void _processType(_EMS_RxTelegram * EMS_RxTelegram) {
uint8_t * telegram = EMS_RxTelegram->telegram;
- // header
- uint8_t src = telegram[0] & 0x7F; // removing 8th bit as we deal with both reads and writes here
-
// if its an echo of ourselves from the master UBA, ignore
- if (src == EMS_ID_ME) {
+ if (EMS_RxTelegram->src == EMS_ID_ME) {
// _debugPrintTelegram("echo:", EMS_RxTelegram, COLOR_WHITE);
return;
}
@@ -847,12 +987,10 @@ void _processType(_EMS_RxTelegram * EMS_RxTelegram) {
// if WRITE, should not happen
// if VALIDATE, check the contents
if (EMS_TxTelegram.action == EMS_TX_TELEGRAM_READ) {
- uint8_t type = telegram[2];
- if ((src == EMS_TxTelegram.dest) && (type == EMS_TxTelegram.type)) {
+ if ((EMS_RxTelegram->src == EMS_TxTelegram.dest) && (EMS_RxTelegram->type == EMS_TxTelegram.type)) {
// all checks out, read was successful, remove tx from queue and continue to process telegram
_removeTxQueue();
- EMS_Sys_Status.emsRxPgks++; // increment counter
- // myDebug("** Read from 0x%02X ok", type);
+ EMS_Sys_Status.emsRxPgks++; // increment counter
ems_setEmsRefreshed(EMS_TxTelegram.forceRefresh); // does mqtt need refreshing?
} else {
// read not OK, we didn't get back a telegram we expected
@@ -861,12 +999,12 @@ void _processType(_EMS_RxTelegram * EMS_RxTelegram) {
// if retried too many times, give up and remove it
if (EMS_Sys_Status.txRetryCount >= TX_WRITE_TIMEOUT_COUNT) {
if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_BASIC) {
- myDebug("Read failed. Giving up, removing from queue");
+ myDebug_P(PSTR("Read failed. Giving up, removing from queue"));
}
_removeTxQueue();
} else {
if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_BASIC) {
- myDebug("...Retrying read. Attempt %d/%d...", EMS_Sys_Status.txRetryCount, TX_WRITE_TIMEOUT_COUNT);
+ myDebug_P(PSTR("...Retrying read. Attempt %d/%d..."), EMS_Sys_Status.txRetryCount, TX_WRITE_TIMEOUT_COUNT);
}
}
}
@@ -875,7 +1013,7 @@ void _processType(_EMS_RxTelegram * EMS_RxTelegram) {
if (EMS_TxTelegram.action == EMS_TX_TELEGRAM_WRITE) {
// should not get here, since this is handled earlier receiving a 01 or 04
- myDebug("** Error ! Write - should not be here");
+ myDebug_P(PSTR("** Error ! Write - should not be here"));
}
if (EMS_TxTelegram.action == EMS_TX_TELEGRAM_VALIDATE) {
@@ -886,26 +1024,24 @@ void _processType(_EMS_RxTelegram * EMS_RxTelegram) {
// validate was successful, the write changed the value
_removeTxQueue(); // now we can remove the Tx validate command the queue
if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_BASIC) {
- myDebug("Write to 0x%02X was successful", EMS_TxTelegram.dest);
+ myDebug_P(PSTR("Write to 0x%02X was successful"), EMS_TxTelegram.dest);
}
// follow up with the post read command
ems_doReadCommand(EMS_TxTelegram.comparisonPostRead, EMS_TxTelegram.dest, true);
} else {
// write failed
if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_BASIC) {
- myDebug("Last write failed. Compared set value 0x%02X with received value 0x%02X",
- EMS_TxTelegram.comparisonValue,
- dataReceived);
+ myDebug_P(PSTR("Last write failed. Compared set value 0x%02X with received value 0x%02X"), EMS_TxTelegram.comparisonValue, dataReceived);
}
if (++EMS_Sys_Status.txRetryCount > TX_WRITE_TIMEOUT_COUNT) {
if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_BASIC) {
- myDebug("Write failed. Giving up, removing from queue");
+ myDebug_P(PSTR("Write failed. Giving up, removing from queue"));
}
_removeTxQueue();
} else {
// retry, turn the validate back into a write and try again
if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_BASIC) {
- myDebug("...Retrying write. Attempt %d/%d...", EMS_Sys_Status.txRetryCount, TX_WRITE_TIMEOUT_COUNT);
+ myDebug_P(PSTR("...Retrying write. Attempt %d/%d..."), EMS_Sys_Status.txRetryCount, TX_WRITE_TIMEOUT_COUNT);
}
EMS_TxTelegram.action = EMS_TX_TELEGRAM_WRITE;
EMS_TxTelegram.dataValue = EMS_TxTelegram.comparisonValue; // restore old value
@@ -940,7 +1076,7 @@ void _checkActive() {
* UBAParameterWW - type 0x33 - warm water parameters
* received only after requested (not broadcasted)
*/
-void _process_UBAParameterWW(uint8_t src, uint8_t * data, uint8_t length) {
+void _process_UBAParameterWW(_EMS_RxTelegram * EMS_RxTelegram) {
EMS_Boiler.wWActivated = (_toByte(1) == 0xFF); // 0xFF means on
EMS_Boiler.wWSelTemp = _toByte(2);
EMS_Boiler.wWCircPump = (_toByte(6) == 0xFF); // 0xFF means on
@@ -954,15 +1090,15 @@ void _process_UBAParameterWW(uint8_t src, uint8_t * data, uint8_t length) {
* UBATotalUptimeMessage - type 0x14 - total uptime
* received only after requested (not broadcasted)
*/
-void _process_UBATotalUptimeMessage(uint8_t src, uint8_t * data, uint8_t length) {
+void _process_UBATotalUptimeMessage(_EMS_RxTelegram * EMS_RxTelegram) {
EMS_Boiler.UBAuptime = _toLong(0);
EMS_Sys_Status.emsRefreshed = true; // when we receieve this, lets force an MQTT publish
}
-/*
+/**
* UBAParametersMessage - type 0x16
*/
-void _process_UBAParametersMessage(uint8_t src, uint8_t * data, uint8_t length) {
+void _process_UBAParametersMessage(_EMS_RxTelegram * EMS_RxTelegram) {
EMS_Boiler.heating_temp = _toByte(1);
EMS_Boiler.pump_mod_max = _toByte(9);
EMS_Boiler.pump_mod_min = _toByte(10);
@@ -972,7 +1108,7 @@ void _process_UBAParametersMessage(uint8_t src, uint8_t * data, uint8_t length)
* UBAMonitorWWMessage - type 0x34 - warm water monitor. 19 bytes long
* received every 10 seconds
*/
-void _process_UBAMonitorWWMessage(uint8_t src, uint8_t * data, uint8_t length) {
+void _process_UBAMonitorWWMessage(_EMS_RxTelegram * EMS_RxTelegram) {
EMS_Boiler.wWCurTmp = _toShort(1);
EMS_Boiler.wWStarts = _toLong(13);
EMS_Boiler.wWWorkM = _toLong(10);
@@ -984,7 +1120,7 @@ void _process_UBAMonitorWWMessage(uint8_t src, uint8_t * data, uint8_t length) {
* UBAMonitorFast - type 0x18 - central heating monitor part 1 (25 bytes long)
* received every 10 seconds
*/
-void _process_UBAMonitorFast(uint8_t src, uint8_t * data, uint8_t length) {
+void _process_UBAMonitorFast(_EMS_RxTelegram * EMS_RxTelegram) {
EMS_Boiler.selFlowTemp = _toByte(0);
EMS_Boiler.curFlowTemp = _toShort(1);
EMS_Boiler.retTemp = _toShort(13);
@@ -1020,7 +1156,7 @@ void _process_UBAMonitorFast(uint8_t src, uint8_t * data, uint8_t length) {
* UBAMonitorSlow - type 0x19 - central heating monitor part 2 (27 bytes long)
* received every 60 seconds
*/
-void _process_UBAMonitorSlow(uint8_t src, uint8_t * data, uint8_t length) {
+void _process_UBAMonitorSlow(_EMS_RxTelegram * EMS_RxTelegram) {
EMS_Boiler.extTemp = _toShort(0); // 0x8000 if not available
EMS_Boiler.boilTemp = _toShort(2); // 0x8000 if not available
EMS_Boiler.pumpMod = _toByte(9);
@@ -1035,9 +1171,9 @@ void _process_UBAMonitorSlow(uint8_t src, uint8_t * data, uint8_t length) {
* received every 60 seconds
* e.g. 17 0B 91 00 80 1E 00 CB 27 00 00 00 00 05 01 00 CB 00 (CRC=47), #data=14
*/
-void _process_RC10StatusMessage(uint8_t src, uint8_t * data, uint8_t length) {
- EMS_Thermostat.setpoint_roomTemp = _toByte(EMS_TYPE_RC10StatusMessage_setpoint); // is * 2
- EMS_Thermostat.curr_roomTemp = _toByte(EMS_TYPE_RC10StatusMessage_curr); // is * 10
+void _process_RC10StatusMessage(_EMS_RxTelegram * EMS_RxTelegram) {
+ EMS_Thermostat.setpoint_roomTemp = _toByte(EMS_OFFSET_RC10StatusMessage_setpoint); // is * 2
+ EMS_Thermostat.curr_roomTemp = _toByte(EMS_OFFSET_RC10StatusMessage_curr); // is * 10
EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
}
@@ -1047,59 +1183,126 @@ void _process_RC10StatusMessage(uint8_t src, uint8_t * data, uint8_t length) {
* For reading the temp values only
* received every 60 seconds
*/
-void _process_RC20StatusMessage(uint8_t src, uint8_t * data, uint8_t length) {
- EMS_Thermostat.setpoint_roomTemp = _toByte(EMS_TYPE_RC20StatusMessage_setpoint); // is * 2
- EMS_Thermostat.curr_roomTemp = _toShort(EMS_TYPE_RC20StatusMessage_curr); // is * 10
+void _process_RC20StatusMessage(_EMS_RxTelegram * EMS_RxTelegram) {
+ EMS_Thermostat.setpoint_roomTemp = _toByte(EMS_OFFSET_RC20StatusMessage_setpoint); // is * 2
+ EMS_Thermostat.curr_roomTemp = _toShort(EMS_OFFSET_RC20StatusMessage_curr); // is * 10
EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
}
/**
- * type 0x41 - data from the RC30 thermostat (0x10) - 14 bytes long
- * For reading the temp values only
- * received every 60 seconds
- */
-void _process_RC30StatusMessage(uint8_t src, uint8_t * data, uint8_t length) {
- EMS_Thermostat.setpoint_roomTemp = _toByte(EMS_TYPE_RC30StatusMessage_setpoint); // is * 2
- EMS_Thermostat.curr_roomTemp = _toShort(EMS_TYPE_RC30StatusMessage_curr); // note, its 2 bytes here
+ * type 0x41 - data from the RC30 thermostat(0x10) - 14 bytes long
+ * For reading the temp values only * received every 60 seconds
+*/
+void _process_RC30StatusMessage(_EMS_RxTelegram * EMS_RxTelegram) {
+ EMS_Thermostat.setpoint_roomTemp = _toByte(EMS_OFFSET_RC30StatusMessage_setpoint); // is * 2
+ EMS_Thermostat.curr_roomTemp = _toShort(EMS_OFFSET_RC30StatusMessage_curr); // note, its 2 bytes here
EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
}
/**
- * type 0x3E - data from the RC35 thermostat (0x10) - 16 bytes
+ * type 0x3E and 0x48 - data from the RC35 thermostat (0x10) - 16 bytes
* For reading the temp values only
* received every 60 seconds
*/
-void _process_RC35StatusMessage(uint8_t src, uint8_t * data, uint8_t length) {
- EMS_Thermostat.setpoint_roomTemp = _toByte(EMS_TYPE_RC35StatusMessage_setpoint); // is * 2
+void _process_RC35StatusMessage(_EMS_RxTelegram * EMS_RxTelegram) {
+ EMS_Thermostat.setpoint_roomTemp = _toByte(EMS_OFFSET_RC35StatusMessage_setpoint); // is * 2
// check if temp sensor is unavailable
- if ((data[0] == 0x7D) && (data[1] = 0x00)) {
+ if (EMS_RxTelegram->data[3] == 0x7D) {
EMS_Thermostat.curr_roomTemp = EMS_VALUE_SHORT_NOTSET;
} else {
- EMS_Thermostat.curr_roomTemp = _toShort(EMS_TYPE_RC35StatusMessage_curr);
+ EMS_Thermostat.curr_roomTemp = _toShort(EMS_OFFSET_RC35StatusMessage_curr);
}
- EMS_Thermostat.day_mode = bitRead(data[EMS_OFFSET_RC35Get_mode_day], 1); //get day mode flag
- EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
+ EMS_Thermostat.day_mode = _bitRead(EMS_OFFSET_RC35Get_mode_day, 1); // get day mode flag
+
+ EMS_Thermostat.circuitcalctemp = _toByte(EMS_OFFSET_RC35Set_circuitcalctemp); // 0x48 calculated temperature
+
+ EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
}
/**
* type 0x0A - data from the Nefit Easy/TC100 thermostat (0x18) - 31 bytes long
* The Easy has a digital precision of its floats to 2 decimal places, so values must be divided by 100
*/
-void _process_EasyStatusMessage(uint8_t src, uint8_t * data, uint8_t length) {
- EMS_Thermostat.curr_roomTemp = _toShort(EMS_TYPE_EasyStatusMessage_curr); // is *100
- EMS_Thermostat.setpoint_roomTemp = _toShort(EMS_TYPE_EasyStatusMessage_setpoint); // is *100
+void _process_EasyStatusMessage(_EMS_RxTelegram * EMS_RxTelegram) {
+ EMS_Thermostat.curr_roomTemp = _toShort(EMS_OFFSET_EasyStatusMessage_curr); // is *100
+ EMS_Thermostat.setpoint_roomTemp = _toShort(EMS_OFFSET_EasyStatusMessage_setpoint); // is *100
EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
}
+/**
+ * type 0x01A5 - data from the Nefit RC1010 thermostat (0x18) and RC300/310s on 0x10
+ * EMS+ messages may come in with different offsets so handle them here
+ */
+void _process_RCPLUSStatusMessage(_EMS_RxTelegram * EMS_RxTelegram) {
+ if (EMS_RxTelegram->offset == 0) {
+ // the whole telegram
+ // e.g. Thermostat -> all, telegram: 10 00 FF 00 01 A5 00 D7 21 00 00 00 00 30 01 84 01 01 03 01 84 01 F1 00 00 11 01 00 08 63 00
+ // 10 00 FF 00 01 A5 80 00 01 30 28 00 30 28 01 54 03 03 01 01 54 02 A8 00 00 11 01 03 FF FF 00
+ EMS_Thermostat.curr_roomTemp = _toShort(EMS_OFFSET_RCPLUSStatusMessage_curr); // value is * 10
+ EMS_Thermostat.setpoint_roomTemp = _toByte(EMS_OFFSET_RCPLUSStatusMessage_setpoint); // value is * 2
+
+ EMS_Thermostat.day_mode = _bitRead(EMS_OFFSET_RCPLUSGet_mode_day, 1); // get day mode flag
+
+ // room night setpoint is _toByte(2) (value is *2)
+ // boiler set temp is _toByte(4) (value is *2)
+ // day night is byte(8), 0x01 for night, 0x00 for day
+ }
+
+ // actual set point
+ // e.g. Thermostat -> all, telegram: 10 00 FF 07 01 A5 32
+ if (EMS_RxTelegram->offset == 7) {
+ // to add...
+ }
+
+ // next set point
+ // e.g. Thermostat -> all, telegram: 18 00 FF 06 01 A5 22
+ if (EMS_RxTelegram->offset == 6) {
+ // to add...
+ }
+}
+
+/**
+ * type 0x01B9 - heating data from the Nefit RC1010 thermostat (0x18) and RC300/310s on 0x10
+ */
+void _process_RCPLUSStatusHeating(_EMS_RxTelegram * EMS_RxTelegram) {
+ // see wiki
+ // operation mode, comfort levels 1,2,3, eco level
+}
+
+/**
+ * type 0x01AF - summer/winter mode from the Nefit RC1010 thermostat (0x18) and RC300/310s on 0x10
+ */
+void _process_RCPLUSStatusMode(_EMS_RxTelegram * EMS_RxTelegram) {
+ // _toByte(0); // 0x00=OFF 0x01=Automatic 0x02=Forced
+}
+
+/**
+ * FR10 Junkers - type x6F01
+ */
+void _process_FR10StatusMessage(_EMS_RxTelegram * EMS_RxTelegram) {
+ if (EMS_RxTelegram->data_length == 6) {
+ // e.g. 90 00 FF 00 00 6F 03 01 00 BE 00 BF
+ EMS_Thermostat.curr_roomTemp = _toByte(EMS_OFFSET_FR10StatusMessage_curr); // value is * 10
+ EMS_Thermostat.setpoint_roomTemp = _toByte(EMS_OFFSET_FR10StatusMessage_setpoint); // value is * 10, which is different from other EMS+ devices
+ }
+}
+
+/**
+ * to complete....
+ */
+void _process_RCPLUSSetMessage(_EMS_RxTelegram * EMS_RxTelegram) {
+ // to complete
+}
+
/**
* type 0xB0 - for reading the mode from the RC10 thermostat (0x17)
* received only after requested
*/
-void _process_RC10Set(uint8_t src, uint8_t * data, uint8_t length) {
+void _process_RC10Set(_EMS_RxTelegram * EMS_RxTelegram) {
// mode not implemented yet
}
@@ -1107,7 +1310,7 @@ void _process_RC10Set(uint8_t src, uint8_t * data, uint8_t length) {
* type 0xA8 - for reading the mode from the RC20 thermostat (0x17)
* received only after requested
*/
-void _process_RC20Set(uint8_t src, uint8_t * data, uint8_t length) {
+void _process_RC20Set(_EMS_RxTelegram * EMS_RxTelegram) {
EMS_Thermostat.mode = _toByte(EMS_OFFSET_RC20Set_mode);
}
@@ -1115,59 +1318,144 @@ void _process_RC20Set(uint8_t src, uint8_t * data, uint8_t length) {
* type 0xA7 - for reading the mode from the RC30 thermostat (0x10)
* received only after requested
*/
-void _process_RC30Set(uint8_t src, uint8_t * data, uint8_t length) {
+void _process_RC30Set(_EMS_RxTelegram * EMS_RxTelegram) {
EMS_Thermostat.mode = _toByte(EMS_OFFSET_RC30Set_mode);
}
/**
- * type 0x3D - for reading the mode from the RC35 thermostat (0x10)
- * Working Mode Heating Circuit 1 (HC1)
+ * type 0x3D and 0x47 - for reading the mode from the RC35 thermostat (0x10)
+ * Working Mode Heating Circuit 1 & 2 (HC1, HC2)
* received only after requested
*/
-void _process_RC35Set(uint8_t src, uint8_t * data, uint8_t length) {
+void _process_RC35Set(_EMS_RxTelegram * EMS_RxTelegram) {
EMS_Thermostat.mode = _toByte(EMS_OFFSET_RC35Set_mode);
+
+ EMS_Thermostat.daytemp = _toByte(EMS_OFFSET_RC35Set_temp_day); // is * 2
+ EMS_Thermostat.nighttemp = _toByte(EMS_OFFSET_RC35Set_temp_night); // is * 2
+ EMS_Thermostat.holidaytemp = _toByte(EMS_OFFSET_RC35Set_temp_holiday); // is * 2
+ EMS_Thermostat.heatingtype = _toByte(EMS_OFFSET_RC35Set_heatingtype); // byte 0 bit floor heating = 3 0x47
+
+ EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
}
/**
* type 0xA3 - for external temp settings from the the RC* thermostats
*/
-void _process_RCOutdoorTempMessage(uint8_t src, uint8_t * data, uint8_t length) {
+void _process_RCOutdoorTempMessage(_EMS_RxTelegram * EMS_RxTelegram) {
// add support here if you're reading external sensors
}
/*
* SM10Monitor - type 0x97
*/
-void _process_SM10Monitor(uint8_t src, uint8_t * data, uint8_t length) {
- EMS_Other.SM10collectorTemp = _toShort(2); // collector temp from SM10, is *10
- EMS_Other.SM10bottomTemp = _toShort(5); // bottom temp from SM10, is *10
- EMS_Other.SM10pumpModulation = _toByte(4); // modulation solar pump
- EMS_Other.SM10pump = _bitRead(7, 1); // active if bit 1 is set
+void _process_SM10Monitor(_EMS_RxTelegram * EMS_RxTelegram) {
+ EMS_Other.SMcollectorTemp = _toShort(2); // collector temp from SM10, is *10
+ EMS_Other.SMbottomTemp = _toShort(5); // bottom temp from SM10, is *10
+ EMS_Other.SMpumpModulation = _toByte(4); // modulation solar pump
+ EMS_Other.SMpump = _bitRead(7, 1); // active if bit 1 is set
+ EMS_Other.SM = true;
+ EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
+}
+
+/*
+ * SM100Monitor - type 0x0262 EMS+
+ * e.g, 30 00 FF 00 02 62 01 AC
+ * 30 00 FF 18 02 62 80 00
+ * 30 00 FF 00 02 62 01 A1 - for bottom temps
+ */
+void _process_SM100Monitor(_EMS_RxTelegram * EMS_RxTelegram) {
+ // only process the complete telegram, not partial
+ if (EMS_RxTelegram->offset != 0) {
+ return;
+ }
+
+ EMS_Other.SMcollectorTemp = _toShort(0); // collector temp from SM100, is *10
+
+ if (EMS_RxTelegram->data_length > 2) {
+ EMS_Other.SMbottomTemp = _toShort(2); // bottom temp from SM100, is *10
+ }
+
+ EMS_Other.SM = true;
+ EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
+}
+
+/*
+ * SM100Status - type 0x0264 EMS+ for pump modulation
+ * e.g. 30 00 FF 09 02 64 64 = 100%
+ * 30 00 FF 09 02 64 1E = 30%
+ */
+void _process_SM100Status(_EMS_RxTelegram * EMS_RxTelegram) {
+ // check for complete telegram
+ if (EMS_RxTelegram->offset == 0) {
+ EMS_Other.SMpumpModulation = _toByte(9); // modulation solar pump
+ } else if (EMS_RxTelegram->offset == 0x09) {
+ // or short telegram with a single byte with offset 09
+ EMS_Other.SMpumpModulation = _toByte(0); // modulation solar pump
+ }
+
+ EMS_Other.SM = true;
+ EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
+}
+
+/*
+ * SM100Status2 - type 0x026A EMS+ for pump on/off at offset 0x0A
+ */
+void _process_SM100Status2(_EMS_RxTelegram * EMS_RxTelegram) {
+ // check for complete telegram
+ if (EMS_RxTelegram->offset == 0) {
+ EMS_Other.SMpump = _bitRead(10, 2); // 03=off 04=on at offset 10 which is byte 10
+ } else if (EMS_RxTelegram->offset == 0x0A) {
+ // or short telegram with a single byte with offset 0A
+ EMS_Other.SMpump = _bitRead(0, 2); // 03=off 04=on
+ }
+
+ EMS_Other.SM = true;
+ EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
+}
+
+/*
+ * SM100Energy - type 0x028E EMS+ for energy readings
+ */
+void _process_SM100Energy(_EMS_RxTelegram * EMS_RxTelegram) {
+ // e.g. 30 00 FF 00 02 8E 00 00 00 00 00 00 06 C5 00 00 76 35
+
+ EMS_Other.SMEnergyLastHour = _toShort(2); // last hour / 10 in Wh
+ EMS_Other.SMEnergyToday = _toShort(6); // todays in Wh
+ EMS_Other.SMEnergyTotal = _toShort(10); // total / 10 in kWh
+
+ EMS_Other.SM = true;
EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
}
/**
* UBASetPoint 0x1A
*/
-void _process_SetPoints(uint8_t src, uint8_t * data, uint8_t length) {
- /*
+void _process_SetPoints(_EMS_RxTelegram * EMS_RxTelegram) {
if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_VERBOSE) {
- if (length != 0) {
- uint8_t setpoint = data[0];
- uint8_t hk_power = data[1];
- uint8_t ww_power = data[2];
- myDebug(" SetPoint=%d, hk_power=%d, ww_power=%d", setpoint, hk_power, ww_power);
+ if (EMS_RxTelegram->data_length != 0) {
+ uint8_t setpoint = EMS_RxTelegram->data[0]; // flow temp
+ //uint8_t ww_power = data[2]; // power in %
+
+ /* use this logic if the value is *2
+ char s[5];
+ char s2[5];
+ strlcpy(s, itoa(setpoint >> 1, s2, 10), 5);
+ strlcat(s, ".", sizeof(s));
+ strlcat(s, ((setpoint & 0x01) ? "5" : "0"), 5);
+ myDebug_P(PSTR(" Boiler flow temp %s C, Warm Water power %d %"), s, ww_power);
+ */
+
+ myDebug_P(PSTR(" Boiler flow temperature is %d C"), setpoint);
}
}
- */
}
/**
* process_RCTime - type 0x06 - date and time from a thermostat - 14 bytes long
* common for all thermostats
*/
-void _process_RCTime(uint8_t src, uint8_t * data, uint8_t length) {
+void _process_RCTime(_EMS_RxTelegram * EMS_RxTelegram) {
if ((EMS_Thermostat.model_id == EMS_MODEL_EASY) || (EMS_Thermostat.model_id == EMS_MODEL_BOSCHEASY)) {
return; // not supported
}
@@ -1180,13 +1468,36 @@ void _process_RCTime(uint8_t src, uint8_t * data, uint8_t length) {
EMS_Thermostat.year = _toByte(0);
}
+/*
+ * add an EMS device to our list of detected devices
+ */
+void _addDevice(uint8_t product_id, uint8_t device_id, char * version, const char * model_string) {
+ _Generic_Type device;
+
+ // if its a duplicate don't add
+ bool found = false;
+ for (std::list<_Generic_Type>::iterator it = Devices.begin(); it != Devices.end(); it++) {
+ if (((it)->product_id == product_id) && ((it)->device_id == device_id)) {
+ found = true;
+ }
+ }
+
+ if (!found) {
+ device.product_id = product_id;
+ device.device_id = device_id;
+ strlcpy(device.version, version, sizeof(device.version));
+ strlcpy(device.model_string, model_string, sizeof(device.model_string));
+ Devices.push_back(device);
+ }
+}
+
/**
* type 0x02 - get the firmware version and type of an EMS device
* look up known devices via the product id and setup if not already set
*/
-void _process_Version(uint8_t src, uint8_t * data, uint8_t length) {
+void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
// ignore short messages that we can't interpret
- if (length < 3) {
+ if (EMS_RxTelegram->data_length < 3) {
return;
}
@@ -1207,22 +1518,25 @@ void _process_Version(uint8_t src, uint8_t * data, uint8_t length) {
if (typeFound) {
// its a boiler
- myDebug("Boiler found. Model %s with TypeID 0x%02X, ProductID %d, Version %s",
- Boiler_Types[i].model_string,
- Boiler_Types[i].type_id,
- product_id,
- version);
+ myDebug_P(PSTR("Boiler found. Model %s (DeviceID:0x%02X ProductID:%d Version:%s)"),
+ Boiler_Types[i].model_string,
+ Boiler_Types[i].device_id,
+ product_id,
+ version);
+
+ // add to list
+ _addDevice(product_id, Boiler_Types[i].device_id, version, Boiler_Types[i].model_string);
- // if its a boiler set it
+ // if its a boiler set it, unless it already has been set by checking for a productID
// it will take the first one found in the list
- if ((EMS_Boiler.type_id == EMS_ID_NONE) || (EMS_Boiler.type_id == Boiler_Types[i].type_id)) {
- myDebug("* Setting Boiler type to Model %s, TypeID 0x%02X, ProductID %d, Version %s",
- Boiler_Types[i].model_string,
- Boiler_Types[i].type_id,
- product_id,
- version);
-
- EMS_Boiler.type_id = Boiler_Types[i].type_id;
+ if (((EMS_Boiler.device_id == EMS_ID_NONE) || (EMS_Boiler.device_id == Boiler_Types[i].device_id)) && EMS_Boiler.product_id == EMS_ID_NONE) {
+ myDebug_P(PSTR("* Setting Boiler to model %s (DeviceID:0x%02X ProductID:%d Version:%s)"),
+ Boiler_Types[i].model_string,
+ Boiler_Types[i].device_id,
+ product_id,
+ version);
+
+ EMS_Boiler.device_id = Boiler_Types[i].device_id;
EMS_Boiler.product_id = Boiler_Types[i].product_id;
strlcpy(EMS_Boiler.version, version, sizeof(EMS_Boiler.version));
@@ -1246,25 +1560,28 @@ void _process_Version(uint8_t src, uint8_t * data, uint8_t length) {
if (typeFound) {
// its a known thermostat
if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_BASIC) {
- myDebug("Thermostat found. Model %s with TypeID 0x%02X, ProductID %d, Version %s",
- Thermostat_Types[i].model_string,
- Thermostat_Types[i].type_id,
- product_id,
- version);
+ myDebug_P(PSTR("Thermostat found. Model %s (DeviceID:0x%02X ProductID:%d Version:%s)"),
+ Thermostat_Types[i].model_string,
+ Thermostat_Types[i].device_id,
+ product_id,
+ version);
}
+ // add to list
+ _addDevice(product_id, Boiler_Types[i].device_id, version, Thermostat_Types[i].model_string);
+
// if we don't have a thermostat set, use this one
- if ((EMS_Thermostat.type_id == EMS_ID_NONE) || (EMS_Thermostat.model_id == EMS_MODEL_NONE)
- || (EMS_Thermostat.type_id == Thermostat_Types[i].type_id)) {
- myDebug("* Setting Thermostat type to Model %s, TypeID 0x%02X, ProductID %d, Version %s",
- Thermostat_Types[i].model_string,
- Thermostat_Types[i].type_id,
- product_id,
- version);
+ if (((EMS_Thermostat.device_id == EMS_ID_NONE) || (EMS_Thermostat.model_id == EMS_MODEL_NONE)
+ || (EMS_Thermostat.device_id == Thermostat_Types[i].device_id))
+ && EMS_Thermostat.product_id == EMS_ID_NONE) {
+ myDebug_P(PSTR("* Setting Thermostat model to %s (DeviceID:0x%02X ProductID:%d Version:%s)"),
+ Thermostat_Types[i].model_string,
+ Thermostat_Types[i].device_id,
+ product_id,
+ version);
EMS_Thermostat.model_id = Thermostat_Types[i].model_id;
- EMS_Thermostat.type_id = Thermostat_Types[i].type_id;
- EMS_Thermostat.read_supported = Thermostat_Types[i].read_supported;
+ EMS_Thermostat.device_id = Thermostat_Types[i].device_id;
EMS_Thermostat.write_supported = Thermostat_Types[i].write_supported;
EMS_Thermostat.product_id = product_id;
strlcpy(EMS_Thermostat.version, version, sizeof(EMS_Thermostat.version));
@@ -1288,16 +1605,19 @@ void _process_Version(uint8_t src, uint8_t * data, uint8_t length) {
}
if (typeFound) {
- myDebug("Device found. Model %s with TypeID 0x%02X, ProductID %d, Version %s",
- Other_Types[i].model_string,
- Other_Types[i].type_id,
- product_id,
- version);
+ myDebug_P(PSTR("Device found. Model %s with DeviceID 0x%02X, ProductID %d, Version %s"),
+ Other_Types[i].model_string,
+ Other_Types[i].device_id,
+ product_id,
+ version);
+
+ // add to list
+ _addDevice(product_id, Other_Types[i].device_id, version, Other_Types[i].model_string);
// see if this is a Solar Module SM10
- if (Other_Types[i].type_id == EMS_ID_SM10) {
- EMS_Other.SM10 = true; // we have detected a SM10
- myDebug("SM10 Solar Module support enabled.");
+ if (Other_Types[i].device_id == EMS_ID_SM) {
+ EMS_Other.SM = true; // we have detected a SM10
+ myDebug_P(PSTR("SM10 Solar Module support enabled."));
}
// fetch other values
@@ -1305,7 +1625,10 @@ void _process_Version(uint8_t src, uint8_t * data, uint8_t length) {
return;
} else {
- myDebug("Unrecognized device found. TypeID 0x%02X, ProductID %d, Version %s", src, product_id, version);
+ myDebug_P(PSTR("Unrecognized device found. DeviceID 0x%02X, ProductID %d, Version %s"), EMS_RxTelegram->src, product_id, version);
+
+ // add to list
+ _addDevice(product_id, EMS_RxTelegram->src, version, "unknown?");
}
}
@@ -1313,59 +1636,22 @@ void _process_Version(uint8_t src, uint8_t * data, uint8_t length) {
* Figure out the boiler and thermostat types
*/
void ems_discoverModels() {
+ myDebug_P(PSTR("Starting auto discover of EMS devices..."));
+
// boiler
- ems_doReadCommand(EMS_TYPE_Version, EMS_Boiler.type_id); // get version details of boiler
+ ems_doReadCommand(EMS_TYPE_Version, EMS_Boiler.device_id); // get version details of boiler
// solar module
- ems_doReadCommand(EMS_TYPE_Version, EMS_ID_SM10); // check if there is Solar Module available
+ ems_doReadCommand(EMS_TYPE_Version, EMS_ID_SM); // check if there is Solar Module available
// thermostat
// if it hasn't been set, auto discover it
- if (EMS_Thermostat.type_id == EMS_ID_NONE) {
+ if (EMS_Thermostat.device_id == EMS_ID_NONE) {
ems_scanDevices(); // auto-discover it
} else {
// set the model as hardcoded (see my_devices.h) and fetch the version and product id
- ems_doReadCommand(EMS_TYPE_Version, EMS_Thermostat.type_id);
- }
-}
-
-/*
- * Given a thermostat model ID go and fetch its characteristics
- */
-void _ems_setThermostatModel(uint8_t thermostat_modelid) {
- bool found = false;
- uint8_t i = 0;
- const _Thermostat_Type * thermostat_type;
- while (i < _Thermostat_Types_max) {
- thermostat_type = &Thermostat_Types[i];
- if (thermostat_type->model_id == thermostat_modelid) {
- found = true; // we have a matching product id
- break;
- }
- i++;
+ ems_doReadCommand(EMS_TYPE_Version, EMS_Thermostat.device_id);
}
-
- if (!found) {
- if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_BASIC) {
- myDebug("Unknown thermostat model specified. Trying a scan...");
- }
- ems_scanDevices(); // auto-discover it
- return;
- }
-
- // set the thermostat
- if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_BASIC) {
- myDebug("Setting Thermostat. Model %s with TypeID 0x%02X, ProductID %d",
- thermostat_type->model_string,
- thermostat_type->type_id,
- thermostat_type->product_id);
- }
-
- // set its capabilities
- EMS_Thermostat.model_id = thermostat_type->model_id;
- EMS_Thermostat.type_id = thermostat_type->type_id;
- EMS_Thermostat.read_supported = thermostat_type->read_supported;
- EMS_Thermostat.write_supported = thermostat_type->write_supported;
}
/**
@@ -1376,11 +1662,11 @@ void ems_printTxQueue() {
char sType[20] = {0};
if (EMS_TxQueue.size() == 0) {
- myDebug("Tx queue is empty.");
+ myDebug_P(PSTR("Tx queue is empty"));
return;
}
- myDebug("Tx queue (%d/%d)", EMS_TxQueue.size(), EMS_TxQueue.capacity);
+ myDebug_P(PSTR("Tx queue (%d/%d)"), EMS_TxQueue.size(), EMS_TxQueue.capacity);
for (byte i = 0; i < EMS_TxQueue.size(); i++) {
EMS_TxTelegram = EMS_TxQueue[i]; // retrieves the i-th element from the buffer without removing it
@@ -1396,8 +1682,8 @@ void ems_printTxQueue() {
strlcpy(sType, "?", sizeof(sType));
}
- char addedTime[15] = {0};
- unsigned long upt = EMS_TxTelegram.timestamp;
+ char addedTime[15] = {0};
+ uint32_t upt = EMS_TxTelegram.timestamp;
snprintf(addedTime,
sizeof(addedTime),
"(%02d:%02d:%02d)",
@@ -1405,19 +1691,19 @@ void ems_printTxQueue() {
(uint8_t)((upt / (1000 * 60)) % 60),
(uint8_t)((upt / 1000) % 60));
- myDebug(" [%d] action=%s dest=0x%02x type=0x%02x offset=%d length=%d dataValue=%d "
- "comparisonValue=%d type_validate=0x%02x comparisonPostRead=0x%02x @ %s",
- i + 1,
- sType,
- EMS_TxTelegram.dest & 0x7F,
- EMS_TxTelegram.type,
- EMS_TxTelegram.offset,
- EMS_TxTelegram.length,
- EMS_TxTelegram.dataValue,
- EMS_TxTelegram.comparisonValue,
- EMS_TxTelegram.type_validate,
- EMS_TxTelegram.comparisonPostRead,
- addedTime);
+ myDebug_P(PSTR(" [%d] action=%s dest=0x%02x type=0x%02x offset=%d length=%d dataValue=%d "
+ "comparisonValue=%d type_validate=0x%02x comparisonPostRead=0x%02x @ %s"),
+ i + 1,
+ sType,
+ EMS_TxTelegram.dest & 0x7F,
+ EMS_TxTelegram.type,
+ EMS_TxTelegram.offset,
+ EMS_TxTelegram.length,
+ EMS_TxTelegram.dataValue,
+ EMS_TxTelegram.comparisonValue,
+ EMS_TxTelegram.type_validate,
+ EMS_TxTelegram.comparisonPostRead,
+ addedTime);
}
}
@@ -1429,13 +1715,9 @@ void ems_getThermostatValues() {
return;
}
- if (!EMS_Thermostat.read_supported) {
- myDebug("Read operations not yet supported for this model thermostat");
- return;
- }
-
uint8_t model_id = EMS_Thermostat.model_id;
- uint8_t type = EMS_Thermostat.type_id;
+ uint8_t type = EMS_Thermostat.device_id;
+ uint8_t hc = EMS_Thermostat.hc;
if (model_id == EMS_MODEL_RC20) {
ems_doReadCommand(EMS_TYPE_RC20StatusMessage, type); // to get the setpoint temp
@@ -1444,8 +1726,13 @@ void ems_getThermostatValues() {
ems_doReadCommand(EMS_TYPE_RC30StatusMessage, type); // to get the setpoint temp
ems_doReadCommand(EMS_TYPE_RC30Set, type); // to get the mode
} else if ((model_id == EMS_MODEL_RC35) || (model_id == EMS_MODEL_ES73)) {
- ems_doReadCommand(EMS_TYPE_RC35StatusMessage, type); // to get the setpoint temp
- ems_doReadCommand(EMS_TYPE_RC35Set, type); // to get the mode
+ if (hc == 1) {
+ ems_doReadCommand(EMS_TYPE_RC35StatusMessage_HC1, type); // to get the setpoint temp
+ ems_doReadCommand(EMS_TYPE_RC35Set_HC1, type); // to get the mode
+ } else if (hc == 2) {
+ ems_doReadCommand(EMS_TYPE_RC35StatusMessage_HC2, type); // to get the setpoint temp
+ ems_doReadCommand(EMS_TYPE_RC35Set_HC2, type); // to get the mode
+ }
} else if ((model_id == EMS_MODEL_EASY) || (model_id == EMS_MODEL_BOSCHEASY)) {
ems_doReadCommand(EMS_TYPE_EasyStatusMessage, type);
}
@@ -1457,19 +1744,19 @@ void ems_getThermostatValues() {
* Generic function to return various settings from the thermostat
*/
void ems_getBoilerValues() {
- ems_doReadCommand(EMS_TYPE_UBAMonitorFast, EMS_Boiler.type_id); // get boiler stats, instead of waiting 10secs for the broadcast
- ems_doReadCommand(EMS_TYPE_UBAMonitorSlow, EMS_Boiler.type_id); // get more boiler stats, instead of waiting 60secs for the broadcast
- ems_doReadCommand(EMS_TYPE_UBAParameterWW, EMS_Boiler.type_id); // get Warm Water values
- ems_doReadCommand(EMS_TYPE_UBAParametersMessage, EMS_Boiler.type_id); // get MC10 boiler values
- ems_doReadCommand(EMS_TYPE_UBATotalUptimeMessage, EMS_Boiler.type_id); // get uptime from boiler
+ ems_doReadCommand(EMS_TYPE_UBAMonitorFast, EMS_Boiler.device_id); // get boiler stats, instead of waiting 10secs for the broadcast
+ ems_doReadCommand(EMS_TYPE_UBAMonitorSlow, EMS_Boiler.device_id); // get more boiler stats, instead of waiting 60secs for the broadcast
+ ems_doReadCommand(EMS_TYPE_UBAParameterWW, EMS_Boiler.device_id); // get Warm Water values
+ ems_doReadCommand(EMS_TYPE_UBAParametersMessage, EMS_Boiler.device_id); // get MC10 boiler values
+ ems_doReadCommand(EMS_TYPE_UBATotalUptimeMessage, EMS_Boiler.device_id); // get uptime from boiler
}
/*
* Get other values from EMS devices
*/
void ems_getOtherValues() {
- if (EMS_Other.SM10) {
- ems_doReadCommand(EMS_TYPE_SM10Monitor, EMS_ID_SM10); // fetch all from SM10Monitor, e.g. 0B B0 97 00 16
+ if (EMS_Other.SM) {
+ ems_doReadCommand(EMS_TYPE_SM10Monitor, EMS_ID_SM); // fetch all from SM10Monitor, e.g. 0B B0 97 00 16
}
}
@@ -1497,12 +1784,16 @@ char * ems_getThermostatDescription(char * buffer) {
if (found) {
strlcpy(buffer, Thermostat_Types[i].model_string, size);
} else {
- strlcpy(buffer, "TypeID: 0x", size);
- strlcat(buffer, _hextoa(EMS_Thermostat.type_id, tmp), size);
+ strlcpy(buffer, "DeviceID: 0x", size);
+ strlcat(buffer, _hextoa(EMS_Thermostat.device_id, tmp), size);
}
strlcat(buffer, " (ProductID:", size);
- strlcat(buffer, itoa(EMS_Thermostat.product_id, tmp, 10), size);
+ if (EMS_Thermostat.product_id == EMS_ID_NONE) {
+ strlcat(buffer, "?", size);
+ } else {
+ strlcat(buffer, itoa(EMS_Thermostat.product_id, tmp, 10), size);
+ }
strlcat(buffer, " Version:", size);
strlcat(buffer, EMS_Thermostat.version, size);
strlcat(buffer, ")", size);
@@ -1534,12 +1825,16 @@ char * ems_getBoilerDescription(char * buffer) {
if (found) {
strlcpy(buffer, Boiler_Types[i].model_string, size);
} else {
- strlcpy(buffer, "TypeID: 0x", size);
- strlcat(buffer, _hextoa(EMS_Boiler.type_id, tmp), size);
+ strlcpy(buffer, "DeviceID: 0x", size);
+ strlcat(buffer, _hextoa(EMS_Boiler.device_id, tmp), size);
}
strlcat(buffer, " (ProductID:", size);
- strlcat(buffer, itoa(EMS_Boiler.product_id, tmp, 10), size);
+ if (EMS_Boiler.product_id == EMS_ID_NONE) {
+ strlcat(buffer, "?", size);
+ } else {
+ strlcat(buffer, itoa(EMS_Boiler.product_id, tmp, 10), size);
+ }
strlcat(buffer, " Version:", size);
strlcat(buffer, EMS_Boiler.version, size);
strlcat(buffer, ")", size);
@@ -1548,27 +1843,27 @@ char * ems_getBoilerDescription(char * buffer) {
return buffer;
}
-/*
+/**
* Find the versions of our connected devices
*/
void ems_scanDevices() {
- myDebug("Started scan of EMS bus for known devices");
+ myDebug_P(PSTR("Started scan on EMS bus for known devices"));
std::list Device_Ids; // create a new list
// copy over boilers
for (_Boiler_Type bt : Boiler_Types) {
- Device_Ids.push_back(bt.type_id);
+ Device_Ids.push_back(bt.device_id);
}
// copy over thermostats
for (_Thermostat_Type tt : Thermostat_Types) {
- Device_Ids.push_back(tt.type_id);
+ Device_Ids.push_back(tt.device_id);
}
// copy over others
for (_Other_Type ot : Other_Types) {
- Device_Ids.push_back(ot.type_id);
+ Device_Ids.push_back(ot.device_id);
}
// remove duplicates and reserved IDs (like our own device)
@@ -1577,42 +1872,79 @@ void ems_scanDevices() {
Device_Ids.remove(EMS_MODEL_NONE);
// send the read command with Version command
- for (uint8_t type_id : Device_Ids) {
- ems_doReadCommand(EMS_TYPE_Version, type_id);
+ for (uint8_t device_id : Device_Ids) {
+ ems_doReadCommand(EMS_TYPE_Version, device_id);
}
}
/**
* Print out all handled types
*/
-void ems_printAllTypes() {
+void ems_printAllDevices() {
uint8_t i;
- myDebug("\nThese %d boiler type devices are in the library:", _Boiler_Types_max);
+ myDebug_P(PSTR("\nThese %d devices are supported as boiler units:"), _Boiler_Types_max);
for (i = 0; i < _Boiler_Types_max; i++) {
- myDebug(" %s, type ID:0x%02X ProductID:%d", Boiler_Types[i].model_string, Boiler_Types[i].type_id, Boiler_Types[i].product_id);
+ myDebug_P(PSTR(" %s%s%s (DeviceID:0x%02X ProductID:%d)"),
+ COLOR_BOLD_ON,
+ Boiler_Types[i].model_string,
+ COLOR_BOLD_OFF,
+ Boiler_Types[i].device_id,
+ Boiler_Types[i].product_id);
}
- myDebug("\nThese %d EMS devices are in the library:", _Other_Types_max);
+ myDebug_P(PSTR("\nThese %d devices are supported as other known EMS devices:"), _Other_Types_max);
for (i = 0; i < _Other_Types_max; i++) {
- myDebug(" %s, type ID:0x%02X ProductID:%d", Other_Types[i].model_string, Other_Types[i].type_id, Other_Types[i].product_id);
+ myDebug_P(PSTR(" %s%s%s (DeviceID:0x%02X ProductID:%d)"),
+ COLOR_BOLD_ON,
+ Other_Types[i].model_string,
+ COLOR_BOLD_OFF,
+ Other_Types[i].device_id,
+ Other_Types[i].product_id);
}
- myDebug("\nThese telegram type IDs are recognized for the selected boiler:");
+ myDebug_P(PSTR("\nThe following telegram type IDs are supported:"));
for (i = 0; i < _EMS_Types_max; i++) {
if ((EMS_Types[i].model_id == EMS_MODEL_ALL) || (EMS_Types[i].model_id == EMS_MODEL_UBA)) {
- myDebug(" type %02X (%s)", EMS_Types[i].type, EMS_Types[i].typeString);
+ myDebug_P(PSTR(" type %02X (%s)"), EMS_Types[i].type, EMS_Types[i].typeString);
}
}
- myDebug("\nThese %d thermostats models are supported:", _Thermostat_Types_max);
+ myDebug_P(PSTR("\nThese %d thermostat devices are supported:"), _Thermostat_Types_max);
for (i = 0; i < _Thermostat_Types_max; i++) {
- myDebug(" %s, type ID:0x%02X ProductID:%d Read/Write support:%c%c",
- Thermostat_Types[i].model_string,
- Thermostat_Types[i].type_id,
- Thermostat_Types[i].product_id,
- (Thermostat_Types[i].read_supported) ? 'r' : ' ',
- (Thermostat_Types[i].write_supported) ? 'w' : ' ');
+ myDebug_P(PSTR(" %s%s%s (DeviceID:0x%02X ProductID:%d) can write:%c"),
+ COLOR_BOLD_ON,
+ Thermostat_Types[i].model_string,
+ COLOR_BOLD_OFF,
+ Thermostat_Types[i].device_id,
+ Thermostat_Types[i].product_id,
+ (Thermostat_Types[i].write_supported) ? 'y' : 'n');
+ }
+
+ // print out known devices
+ ems_printDevices();
+
+ myDebug_P(PSTR("")); // newline
+}
+
+/**
+ * print out contents of the device list that was captured
+ */
+void ems_printDevices() {
+ if (Devices.size() != 0) {
+ myDebug_P(PSTR("\nThese %d EMS devices were detected:"), Devices.size());
+ for (std::list<_Generic_Type>::iterator it = Devices.begin(); it != Devices.end(); it++) {
+ myDebug_P(PSTR(" %s%s%s (DeviceID:0x%02X ProductID:%d Version:%s)"),
+ COLOR_BOLD_ON,
+ (it)->model_string,
+ COLOR_BOLD_OFF,
+ (it)->device_id,
+ (it)->product_id,
+ (it)->version);
+ }
+
+ myDebug_P(PSTR("\nNote: if any devices are marked as 'unknown?' please report this as a GitHub issue so the EMS devices list can be "
+ "updated.\n"));
}
}
@@ -1620,7 +1952,7 @@ void ems_printAllTypes() {
* Send a command to UART Tx to Read from another device
* Read commands when sent must respond by the destination (target) immediately (or within 10ms)
*/
-void ems_doReadCommand(uint8_t type, uint8_t dest, bool forceRefresh) {
+void ems_doReadCommand(uint16_t type, uint8_t dest, bool forceRefresh) {
// if not a valid type of boiler is not accessible then quits
if ((type == EMS_ID_NONE) || (dest == EMS_ID_NONE)) {
return;
@@ -1628,7 +1960,7 @@ void ems_doReadCommand(uint8_t type, uint8_t dest, bool forceRefresh) {
// if we're preventing all outbound traffic, quit
if (EMS_Sys_Status.emsTxDisabled) {
- myDebug("in Silent Mode. All Tx is disabled.");
+ myDebug_P(PSTR("in Listen Mode. All Tx is disabled."));
return;
}
@@ -1641,9 +1973,9 @@ void ems_doReadCommand(uint8_t type, uint8_t dest, bool forceRefresh) {
if ((ems_getLogging() == EMS_SYS_LOGGING_BASIC) || (ems_getLogging() == EMS_SYS_LOGGING_VERBOSE)) {
if (i == -1) {
- myDebug("Requesting type (0x%02X) from dest 0x%02X", type, dest);
+ myDebug_P(PSTR("Requesting type (0x%02X) from dest 0x%02X"), type, dest);
} else {
- myDebug("Requesting type %s(0x%02X) from dest 0x%02X", EMS_Types[i].typeString, type, dest);
+ myDebug_P(PSTR("Requesting type %s(0x%02X) from dest 0x%02X"), EMS_Types[i].typeString, type, dest);
}
}
EMS_TxTelegram.action = EMS_TX_TELEGRAM_READ; // read command
@@ -1714,14 +2046,15 @@ void ems_sendRawTelegram(char * telegram) {
/**
* Set the temperature of the thermostat
+ * temptype 0 = normal, 1=night temp, 2=day temp, 3=holiday temp
*/
-void ems_setThermostatTemp(float temperature) {
+void ems_setThermostatTemp(float temperature, uint8_t temptype) {
if (!ems_getThermostatEnabled()) {
return;
}
if (!EMS_Thermostat.write_supported) {
- myDebug("Write not supported for this model Thermostat");
+ myDebug_P(PSTR("Write not supported for this model Thermostat"));
return;
}
@@ -1730,12 +2063,13 @@ void ems_setThermostatTemp(float temperature) {
EMS_Sys_Status.txRetryCount = 0; // reset retry counter
uint8_t model_id = EMS_Thermostat.model_id;
- uint8_t type = EMS_Thermostat.type_id;
+ uint8_t type = EMS_Thermostat.device_id;
+ uint8_t hc = EMS_Thermostat.hc; // heating circuit
EMS_TxTelegram.action = EMS_TX_TELEGRAM_WRITE;
EMS_TxTelegram.dest = type;
- myDebug("Setting new thermostat temperature");
+ myDebug_P(PSTR("Setting new thermostat temperature"));
// when doing a comparison to validate the new temperature we call a different type
@@ -1752,14 +2086,35 @@ void ems_setThermostatTemp(float temperature) {
EMS_TxTelegram.offset = EMS_OFFSET_RC30Set_temp;
EMS_TxTelegram.comparisonPostRead = EMS_TYPE_RC30StatusMessage;
} else if ((model_id == EMS_MODEL_RC35) || (model_id == EMS_MODEL_ES73)) {
- EMS_TxTelegram.type = EMS_TYPE_RC35Set;
- if (EMS_Thermostat.day_mode == 0) {
+ switch (temptype) {
+ case 1: // change the night temp
EMS_TxTelegram.offset = EMS_OFFSET_RC35Set_temp_night;
- } else if (EMS_Thermostat.day_mode == 1) {
+ break;
+ case 2: // change the day temp
EMS_TxTelegram.offset = EMS_OFFSET_RC35Set_temp_day;
+ break;
+ case 3: // change the holiday temp
+ EMS_TxTelegram.offset = 3; //holiday on RC35
+ break;
+ default:
+ case 0: // automatic selection, if no type is defined, we use the standard code
+ if (EMS_Thermostat.day_mode == 0) {
+ EMS_TxTelegram.offset = EMS_OFFSET_RC35Set_temp_night;
+ } else if (EMS_Thermostat.day_mode == 1) {
+ EMS_TxTelegram.offset = EMS_OFFSET_RC35Set_temp_day;
+ }
+ break;
}
- EMS_TxTelegram.comparisonPostRead = EMS_TYPE_RC35StatusMessage;
+ if (hc == 1) {
+ // heating circuit 1
+ EMS_TxTelegram.type = EMS_TYPE_RC35Set_HC1;
+ EMS_TxTelegram.comparisonPostRead = EMS_TYPE_RC35StatusMessage_HC1;
+ } else {
+ // heating circuit 2
+ EMS_TxTelegram.type = EMS_TYPE_RC35Set_HC2;
+ EMS_TxTelegram.comparisonPostRead = EMS_TYPE_RC35StatusMessage_HC2;
+ }
}
EMS_TxTelegram.length = EMS_MIN_TELEGRAM_LENGTH;
@@ -1768,7 +2123,7 @@ void ems_setThermostatTemp(float temperature) {
EMS_TxTelegram.comparisonOffset = EMS_TxTelegram.offset;
EMS_TxTelegram.comparisonValue = EMS_TxTelegram.dataValue;
- EMS_TxTelegram.forceRefresh = false; // send to MQTT is done automatically in EMS_TYPE_RC30StatusMessage
+ EMS_TxTelegram.forceRefresh = false; // send to MQTT is done automatically in EMS_TYPE_RC*StatusMessage
EMS_TxQueue.push(EMS_TxTelegram);
}
@@ -1782,14 +2137,15 @@ void ems_setThermostatMode(uint8_t mode) {
}
if (!EMS_Thermostat.write_supported) {
- myDebug("Write not supported for this model Thermostat");
+ myDebug_P(PSTR("Write not supported for this model Thermostat"));
return;
}
uint8_t model_id = EMS_Thermostat.model_id;
- uint8_t type = EMS_Thermostat.type_id;
+ uint8_t type = EMS_Thermostat.device_id;
+ uint8_t hc = EMS_Thermostat.hc;
- myDebug("Setting thermostat mode to %d", mode);
+ myDebug_P(PSTR("Setting thermostat mode to %d"), mode);
_EMS_TxTelegram EMS_TxTelegram = EMS_TX_TELEGRAM_NEW; // create new Tx
EMS_TxTelegram.timestamp = millis(); // set timestamp
@@ -1808,7 +2164,7 @@ void ems_setThermostatMode(uint8_t mode) {
EMS_TxTelegram.type = EMS_TYPE_RC30Set;
EMS_TxTelegram.offset = EMS_OFFSET_RC30Set_mode;
} else if ((model_id == EMS_MODEL_RC35) || (model_id == EMS_MODEL_ES73)) {
- EMS_TxTelegram.type = EMS_TYPE_RC35Set;
+ EMS_TxTelegram.type = (hc == 2) ? EMS_TYPE_RC35Set_HC2 : EMS_TYPE_RC35Set_HC1;
EMS_TxTelegram.offset = EMS_OFFSET_RC35Set_mode;
}
@@ -1830,14 +2186,14 @@ void ems_setWarmWaterTemp(uint8_t temperature) {
return;
}
- myDebug("Setting boiler warm water temperature to %d C", temperature);
+ myDebug_P(PSTR("Setting boiler warm water temperature to %d C"), temperature);
_EMS_TxTelegram EMS_TxTelegram = EMS_TX_TELEGRAM_NEW; // create new Tx
EMS_TxTelegram.timestamp = millis(); // set timestamp
EMS_Sys_Status.txRetryCount = 0; // reset retry counter
EMS_TxTelegram.action = EMS_TX_TELEGRAM_WRITE;
- EMS_TxTelegram.dest = EMS_Boiler.type_id;
+ EMS_TxTelegram.dest = EMS_Boiler.device_id;
EMS_TxTelegram.type = EMS_TYPE_UBAParameterWW;
EMS_TxTelegram.offset = EMS_OFFSET_UBAParameterWW_wwtemp;
EMS_TxTelegram.length = EMS_MIN_TELEGRAM_LENGTH;
@@ -1852,6 +2208,32 @@ void ems_setWarmWaterTemp(uint8_t temperature) {
EMS_TxQueue.push(EMS_TxTelegram);
}
+/**
+ * Set the boiler flow temp
+ */
+void ems_setFlowTemp(uint8_t temperature) {
+ myDebug_P(PSTR("Setting boiler flow temperature to %d C"), temperature);
+
+ _EMS_TxTelegram EMS_TxTelegram = EMS_TX_TELEGRAM_NEW; // create new Tx
+ EMS_TxTelegram.timestamp = millis(); // set timestamp
+ EMS_Sys_Status.txRetryCount = 0; // reset retry counter
+
+ EMS_TxTelegram.action = EMS_TX_TELEGRAM_WRITE;
+ EMS_TxTelegram.dest = EMS_Boiler.device_id;
+ EMS_TxTelegram.type = EMS_TYPE_UBASetPoints;
+ EMS_TxTelegram.offset = EMS_OFFSET_UBASetPoints_flowtemp;
+ EMS_TxTelegram.length = EMS_MIN_TELEGRAM_LENGTH;
+ EMS_TxTelegram.dataValue = temperature; // value to compare against. must be a single int
+
+ EMS_TxTelegram.type_validate = EMS_TYPE_UBASetPoints; // validate
+ EMS_TxTelegram.comparisonOffset = EMS_OFFSET_UBASetPoints_flowtemp;
+ EMS_TxTelegram.comparisonValue = temperature;
+ EMS_TxTelegram.comparisonPostRead = EMS_TYPE_UBASetPoints;
+ EMS_TxTelegram.forceRefresh = false;
+
+ EMS_TxQueue.push(EMS_TxTelegram);
+}
+
/**
* Set the warm water mode to comfort to Eco/Comfort
* 1 = Hot, 2 = Eco, 3 = Intelligent
@@ -1862,20 +2244,20 @@ void ems_setWarmWaterModeComfort(uint8_t comfort) {
EMS_Sys_Status.txRetryCount = 0; // reset retry counter
if (comfort == 1) {
- myDebug("Setting boiler warm water comfort mode to Hot");
+ myDebug_P(PSTR("Setting boiler warm water comfort mode to Hot"));
EMS_TxTelegram.dataValue = EMS_VALUE_UBAParameterWW_wwComfort_Hot;
} else if (comfort == 2) {
- myDebug("Setting boiler warm water comfort mode to Eco");
+ myDebug_P(PSTR("Setting boiler warm water comfort mode to Eco"));
EMS_TxTelegram.dataValue = EMS_VALUE_UBAParameterWW_wwComfort_Eco;
} else if (comfort == 3) {
- myDebug("Setting boiler warm water comfort mode to Intelligent");
+ myDebug_P(PSTR("Setting boiler warm water comfort mode to Intelligent"));
EMS_TxTelegram.dataValue = EMS_VALUE_UBAParameterWW_wwComfort_Intelligent;
} else {
return; // invalid comfort value
}
EMS_TxTelegram.action = EMS_TX_TELEGRAM_WRITE;
- EMS_TxTelegram.dest = EMS_Boiler.type_id;
+ EMS_TxTelegram.dest = EMS_Boiler.device_id;
EMS_TxTelegram.type = EMS_TYPE_UBAParameterWW;
EMS_TxTelegram.offset = EMS_OFFSET_UBAParameterWW_wwComfort;
EMS_TxTelegram.length = EMS_MIN_TELEGRAM_LENGTH;
@@ -1889,14 +2271,14 @@ void ems_setWarmWaterModeComfort(uint8_t comfort) {
* true = on, false = off
*/
void ems_setWarmWaterActivated(bool activated) {
- myDebug("Setting boiler warm water %s", activated ? "on" : "off");
+ myDebug_P(PSTR("Setting boiler warm water %s"), activated ? "on" : "off");
_EMS_TxTelegram EMS_TxTelegram = EMS_TX_TELEGRAM_NEW; // create new Tx
EMS_TxTelegram.timestamp = millis(); // set timestamp
EMS_Sys_Status.txRetryCount = 0; // reset retry counter
EMS_TxTelegram.action = EMS_TX_TELEGRAM_WRITE;
- EMS_TxTelegram.dest = EMS_Boiler.type_id;
+ EMS_TxTelegram.dest = EMS_Boiler.device_id;
EMS_TxTelegram.type = EMS_TYPE_UBAParameterWW;
EMS_TxTelegram.offset = EMS_OFFSET_UBAParameterWW_wwactivated;
EMS_TxTelegram.length = EMS_MIN_TELEGRAM_LENGTH;
@@ -1912,7 +2294,7 @@ void ems_setWarmWaterActivated(bool activated) {
* Using the type 0x1D to put the boiler into Test mode. This may be shown on the boiler with a flashing 'T'
*/
void ems_setWarmTapWaterActivated(bool activated) {
- myDebug("Setting boiler warm tap water %s", activated ? "on" : "off");
+ myDebug_P(PSTR("Setting boiler warm tap water %s"), activated ? "on" : "off");
_EMS_TxTelegram EMS_TxTelegram = EMS_TX_TELEGRAM_NEW; // create new Tx
EMS_TxTelegram.timestamp = millis(); // set timestamp
@@ -1924,7 +2306,7 @@ void ems_setWarmTapWaterActivated(bool activated) {
}
EMS_TxTelegram.action = EMS_TX_TELEGRAM_WRITE;
- EMS_TxTelegram.dest = EMS_Boiler.type_id;
+ EMS_TxTelegram.dest = EMS_Boiler.device_id;
EMS_TxTelegram.type = EMS_TYPE_UBAFunctionTest;
EMS_TxTelegram.offset = 0;
EMS_TxTelegram.length = 22; // 17 bytes of data including header and CRC
@@ -1955,25 +2337,75 @@ void ems_setWarmTapWaterActivated(bool activated) {
EMS_TxQueue.push(EMS_TxTelegram); // add to queue
}
-/*
+/**
* Start up sequence for UBA Master, hopefully to initialize a handshake
* Still experimental
*/
void ems_startupTelegrams() {
if ((EMS_Sys_Status.emsTxDisabled) || (!EMS_Sys_Status.emsBusConnected)) {
- myDebug("Unable to send startup sequence when in silent mode or bus is disabled");
+ myDebug_P(PSTR("Unable to send startup sequence when in listen mode or the bus is disabled"));
}
- myDebug("Sending startup sequence...");
+ myDebug_P(PSTR("Sending startup sequence..."));
char s[20] = {0};
- // (00:07:27.512) Telegram echo: telegram: 0B 08 1D 00 00 (CRC=84), #data=1
// Write type 0x1D to get out of function test mode
- snprintf(s, sizeof(s), "%02X %02X 1D 00 00", EMS_ID_ME, EMS_Boiler.type_id);
+ snprintf(s, sizeof(s), "%02X %02X 1D 00 00", EMS_ID_ME, EMS_Boiler.device_id);
ems_sendRawTelegram(s);
- // (00:07:35.555) Telegram echo: telegram: 0B 88 01 00 1B (CRC=8B), #data=1
// Read type 0x01
- snprintf(s, sizeof(s), "%02X %02X 01 00 1B", EMS_ID_ME, EMS_Boiler.type_id | 0x80);
+ snprintf(s, sizeof(s), "%02X %02X 01 00 1B", EMS_ID_ME, EMS_Boiler.device_id | 0x80);
ems_sendRawTelegram(s);
}
+
+/**
+ * Test parsing of telgrams by injecting fake telegrams and simulating the response
+ */
+void ems_testTelegram(uint8_t test_num) {
+#ifdef TESTS
+ if ((test_num == 0) || (test_num > _TEST_DATA_max)) {
+ myDebug_P(PSTR("Invalid test. Pick between 1 and %d"), _TEST_DATA_max);
+ return;
+ }
+
+ // stop all Tx
+ if (!EMS_TxQueue.isEmpty()) {
+ EMS_TxQueue.clear();
+ EMS_Sys_Status.emsTxStatus = EMS_TX_STATUS_IDLE;
+ }
+
+ static uint8_t * telegram = (uint8_t *)malloc(EMS_MAX_TELEGRAM_LENGTH); // warning, memory is not free'd so use only for debugging
+
+ char telegram_string[200];
+ strlcpy(telegram_string, TEST_DATA[test_num - 1], sizeof(telegram_string));
+
+ uint8_t length = 0;
+ char * p;
+ char value[10] = {0};
+
+ // get first value, which should be the src
+ if ((p = strtok(telegram_string, " ,"))) {
+ strlcpy(value, p, sizeof(value));
+ telegram[0] = (uint8_t)strtol(value, 0, 16);
+ }
+
+ // and interate until end
+ while (p != 0) {
+ if ((p = strtok(NULL, " ,"))) {
+ strlcpy(value, p, sizeof(value));
+ uint8_t val = (uint8_t)strtol(value, 0, 16);
+ telegram[++length] = val;
+ }
+ }
+
+ length++; // this is the total amount of bytes
+ telegram[length] = _crcCalculator(telegram, length + 1); // add the CRC
+
+ myDebug_P(PSTR("[TEST %d] Injecting telegram %s"), test_num, TEST_DATA[test_num - 1]);
+
+ // go an parse it
+ _ems_readTelegram(telegram, length + 1); // include CRC in length
+#else
+ myDebug_P(PSTR("Firmware not compiled with test data set"));
+#endif
+}
diff --git a/src/ems.h b/src/ems.h
index e1e97f33..eb721632 100644
--- a/src/ems.h
+++ b/src/ems.h
@@ -13,10 +13,12 @@
#include
// EMS IDs
-#define EMS_ID_NONE 0x00 // Fixed - used as a dest in broadcast messages and empty type IDs
-#define EMS_ID_ME 0x0B // Fixed - our device, hardcoded as the "Service Key"
+#define EMS_ID_NONE 0x00 // Fixed - used as a dest in broadcast messages and empty device IDs
+#define EMS_PLUS_ID_NONE 0x01 // Fixed - used as a dest in broadcast messages and empty device IDs
+#define EMS_ID_ME 0x0B // Fixed - our device, hardcoded as the "Service Key"
#define EMS_ID_DEFAULT_BOILER 0x08
-#define EMS_ID_SM10 0x30 // Solar Module SM10
+#define EMS_ID_SM 0x30 // Solar Module SM10 and SM100
+#define EMS_ID_GATEWAY 0x48 // KM200 Web Gateway
#define EMS_MIN_TELEGRAM_LENGTH 6 // minimal length for a validation telegram, including CRC
@@ -27,11 +29,9 @@
#define EMS_VALUE_INT_ON 1 // boolean true
#define EMS_VALUE_INT_OFF 0 // boolean false
#define EMS_VALUE_INT_NOTSET 0xFF // for 8-bit ints
-#define EMS_VALUE_SHORT_NOTSET 0x8000 // for 2-byte shorts
+#define EMS_VALUE_SHORT_NOTSET 0x8000 // for 2-byte signed shorts
#define EMS_VALUE_LONG_NOTSET 0xFFFFFF // for 3-byte longs
-#define EMS_THERMOSTAT_READ_YES true
-#define EMS_THERMOSTAT_READ_NO false
#define EMS_THERMOSTAT_WRITE_YES true
#define EMS_THERMOSTAT_WRITE_NO false
@@ -39,12 +39,12 @@
#define EMS_BOILER_BURNPOWER_TAPWATER 100
#define EMS_BOILER_SELFLOWTEMP_HEATING 70
-//define maximum settable tapwater temperature, not every installation supports 90 degrees
+// define maximum settable tapwater temperature
#define EMS_BOILER_TAPWATER_TEMPERATURE_MAX 60
-#define EMS_TX_TELEGRAM_QUEUE_MAX 50 // max size of Tx FIFO queue
+#define EMS_TX_TELEGRAM_QUEUE_MAX 100 // max size of Tx FIFO queue
-//#define EMS_SYS_LOGGING_DEFAULT EMS_SYS_LOGGING_VERBOSE
+// #define EMS_SYS_LOGGING_DEFAULT EMS_SYS_LOGGING_VERBOSE
#define EMS_SYS_LOGGING_DEFAULT EMS_SYS_LOGGING_NONE
/* EMS UART transfer status */
@@ -89,38 +89,45 @@ typedef struct {
_EMS_SYS_LOGGING emsLogging; // logging
bool emsRefreshed; // fresh data, needs to be pushed out to MQTT
bool emsBusConnected; // is there an active bus
- unsigned long emsRxTimestamp; // timestamp of last EMS message received
- unsigned long emsPollTimestamp; // timestamp of last EMS poll sent to us
+ uint32_t emsRxTimestamp; // timestamp of last EMS message received
+ uint32_t emsPollFrequency; // time between EMS polls
bool emsTxCapable; // able to send via Tx
bool emsTxDisabled; // true to prevent all Tx
uint8_t txRetryCount; // # times the last Tx was re-sent
+ bool emsTxDelay; // if true, slows down the Tx transmit
} _EMS_Sys_Status;
// The Tx send package
typedef struct {
_EMS_TX_TELEGRAM_ACTION action; // read, write, validate, init
uint8_t dest;
- uint8_t type;
+ uint16_t type;
uint8_t offset;
- uint8_t length;
+ uint8_t length; // full length of complete telegram
uint8_t dataValue; // value to validate against
- uint8_t type_validate; // type to call after a successful Write command
+ uint16_t type_validate; // type to call after a successful Write command
uint8_t comparisonValue; // value to compare against during a validate
uint8_t comparisonOffset; // offset of where the byte is we want to compare too later
- uint8_t comparisonPostRead; // after a successful write call this to read
+ uint16_t comparisonPostRead; // after a successful write call this to read from this type ID
bool forceRefresh; // should we send to MQTT after a successful Tx?
- unsigned long timestamp; // when created
+ uint32_t timestamp; // when created
uint8_t data[EMS_MAX_TELEGRAM_LENGTH];
} _EMS_TxTelegram;
// The Rx receive package
typedef struct {
- uint32_t timestamp; // timestamp from millis()
- uint8_t * telegram; // the full data package
- uint8_t length; // length in bytes
+ uint32_t timestamp; // timestamp from millis()
+ uint8_t * telegram; // the full data package
+ uint8_t data_length; // length in bytes of the data
+ uint8_t length; // full length of the complete telegram
+ uint8_t src; // source ID
+ uint8_t dest; // destination ID
+ uint16_t type; // type ID as a double byte to support EMS+
+ uint8_t offset; // offset
+ uint8_t * data; // pointer to where telegram data starts
+ bool emsplus; // true if ems+/ems 2.0
} _EMS_RxTelegram;
-
// default empty Tx
const _EMS_TxTelegram EMS_TX_TELEGRAM_NEW = {
EMS_TX_TELEGRAM_INIT, // action
@@ -141,27 +148,33 @@ const _EMS_TxTelegram EMS_TX_TELEGRAM_NEW = {
typedef struct {
uint8_t model_id;
uint8_t product_id;
- uint8_t type_id;
+ uint8_t device_id;
char model_string[50];
} _Boiler_Type;
typedef struct {
uint8_t model_id;
uint8_t product_id;
- uint8_t type_id;
+ uint8_t device_id;
char model_string[50];
} _Other_Type;
-// Definition for thermostat type
+// Definition for thermostat devices
typedef struct {
uint8_t model_id;
uint8_t product_id;
- uint8_t type_id;
+ uint8_t device_id;
char model_string[50];
- bool read_supported;
bool write_supported;
} _Thermostat_Type;
+typedef struct {
+ uint8_t product_id;
+ uint8_t device_id;
+ char version[10];
+ char model_string[50];
+} _Generic_Type;
+
/*
* Telegram package defintions
*/
@@ -218,29 +231,33 @@ typedef struct { // UBAParameterWW
// settings
char version[10];
- uint8_t type_id; // this is typically always 0x08
+ uint8_t device_id; // this is typically always 0x08
uint8_t product_id;
} _EMS_Boiler;
/*
* Telegram package defintions for Other EMS devices
*/
+
+// SM Solar Module - SM10Monitor/SM100Monitor
typedef struct {
- // SM10 Solar Module - SM10Monitor
- bool SM10; // set true if there is a SM10 available
- int16_t SM10collectorTemp; // collector temp from SM10
- int16_t SM10bottomTemp; // bottom temp from SM10
- uint8_t SM10pumpModulation; // modulation solar pump
- uint8_t SM10pump; // pump active
+ bool SM; // set true if there is a SM available
+ int16_t SMcollectorTemp; // collector temp
+ int16_t SMbottomTemp; // bottom temp
+ uint8_t SMpumpModulation; // modulation solar pump
+ uint8_t SMpump; // pump active
+ int16_t SMEnergyLastHour;
+ int16_t SMEnergyToday;
+ int16_t SMEnergyTotal;
} _EMS_Other;
// Thermostat data
typedef struct {
- uint8_t type_id; // the type ID of the thermostat
- uint8_t model_id; // which Thermostat type
+ uint8_t device_id; // the device ID of the thermostat
+ uint8_t model_id; // thermostat model
uint8_t product_id;
- bool read_supported;
bool write_supported;
+ uint8_t hc; // heating circuit 1 or 2
char version[10];
int16_t setpoint_roomTemp; // current set temp
int16_t curr_roomTemp; // current room temp
@@ -252,15 +269,20 @@ typedef struct {
uint8_t day;
uint8_t month;
uint8_t year;
+ uint8_t daytemp;
+ uint8_t nighttemp;
+ uint8_t holidaytemp;
+ uint8_t heatingtype;
+ uint8_t circuitcalctemp;
} _EMS_Thermostat;
// call back function signature for processing telegram types
-typedef void (*EMS_processType_cb)(uint8_t src, uint8_t * data, uint8_t length);
+typedef void (*EMS_processType_cb)(_EMS_RxTelegram * EMS_RxTelegram);
// Definition for each EMS type, including the relative callback function
typedef struct {
uint8_t model_id;
- uint8_t type;
+ uint16_t type; // long to support EMS+ types
const char typeString[50];
EMS_processType_cb processType_cb;
} _EMS_Type;
@@ -268,15 +290,18 @@ typedef struct {
// function definitions
extern void ems_parseTelegram(uint8_t * telegram, uint8_t len);
void ems_init();
-void ems_doReadCommand(uint8_t type, uint8_t dest, bool forceRefresh = false);
+void ems_doReadCommand(uint16_t type, uint8_t dest, bool forceRefresh = false);
void ems_sendRawTelegram(char * telegram);
-void ems_setThermostatTemp(float temp);
+void ems_setThermostatTemp(float temperature, uint8_t temptype = 0);
void ems_setThermostatMode(uint8_t mode);
+void ems_setThermostatHC(uint8_t hc);
void ems_setWarmWaterTemp(uint8_t temperature);
+void ems_setFlowTemp(uint8_t temperature);
void ems_setWarmWaterActivated(bool activated);
void ems_setWarmTapWaterActivated(bool activated);
void ems_setPoll(bool b);
+void ems_setTxDelay(bool b);
void ems_setLogging(_EMS_SYS_LOGGING loglevel);
void ems_setEmsRefreshed(bool b);
void ems_setWarmWaterModeComfort(uint8_t comfort);
@@ -291,18 +316,23 @@ bool ems_getPoll();
bool ems_getTxEnabled();
bool ems_getThermostatEnabled();
bool ems_getBoilerEnabled();
+bool ems_getTxDelay();
bool ems_getBusConnected();
_EMS_SYS_LOGGING ems_getLogging();
bool ems_getEmsRefreshed();
uint8_t ems_getThermostatModel();
void ems_discoverModels();
bool ems_getTxCapable();
+uint32_t ems_getPollFrequency();
void ems_scanDevices();
-void ems_printAllTypes();
+void ems_printAllDevices();
+void ems_printDevices();
char * ems_getThermostatDescription(char * buffer);
void ems_printTxQueue();
char * ems_getBoilerDescription(char * buffer);
+void ems_testTelegram(uint8_t test_num);
+void ems_startupTelegrams();
void ems_startupTelegrams();
@@ -313,7 +343,6 @@ void _debugPrintPackage(const char * prefix, _EMS_RxTelegram * EMS_RxTelegram
void _ems_clearTxData();
int _ems_findBoilerModel(uint8_t model_id);
bool _ems_setModel(uint8_t model_id);
-void _ems_setThermostatModel(uint8_t thermostat_modelid);
void _removeTxQueue();
void _ems_readTelegram(uint8_t * telegram, uint8_t length);
diff --git a/src/ems_devices.h b/src/ems_devices.h
index e959895a..0030a7d8 100644
--- a/src/ems_devices.h
+++ b/src/ems_devices.h
@@ -12,7 +12,6 @@
#include "ems.h"
-
/*
* Common
*/
@@ -39,8 +38,14 @@
#define EMS_VALUE_UBAParameterWW_wwComfort_Eco 0xD8 // the value for eco
#define EMS_VALUE_UBAParameterWW_wwComfort_Intelligent 0xEC // the value for intelligent
+#define EMS_OFFSET_UBASetPoints_flowtemp 0 // flow temp
+
// Other
-#define EMS_TYPE_SM10Monitor 0x97 // SM10Monitor
+#define EMS_TYPE_SM10Monitor 0x97 // SM10Monitor
+#define EMS_TYPE_SM100Monitor 0x0262 // SM100Monitor
+#define EMS_TYPE_SM100Status 0x0264 // SM100Status
+#define EMS_TYPE_SM100Status2 0x026A // SM100Status2
+#define EMS_TYPE_SM100Energy 0x028E // SM100Energy
/*
* Thermostats...
@@ -51,42 +56,62 @@
#define EMS_TYPE_RCOutdoorTempMessage 0xA3 // is an automatic thermostat broadcast, outdoor external temp
// RC10 specific
-#define EMS_TYPE_RC10StatusMessage 0xB1 // is an automatic thermostat broadcast giving us temps
-#define EMS_TYPE_RC10Set 0xB0 // for setting values like temp and mode
-#define EMS_OFFSET_RC10Set_temp 4 // position of thermostat setpoint temperature
-#define EMS_TYPE_RC10StatusMessage_setpoint 1 // setpoint temp
-#define EMS_TYPE_RC10StatusMessage_curr 3 // current temp
+#define EMS_TYPE_RC10StatusMessage 0xB1 // is an automatic thermostat broadcast giving us temps
+#define EMS_TYPE_RC10Set 0xB0 // for setting values like temp and mode
+#define EMS_OFFSET_RC10Set_temp 4 // position of thermostat setpoint temperature
+#define EMS_OFFSET_RC10StatusMessage_setpoint 1 // setpoint temp
+#define EMS_OFFSET_RC10StatusMessage_curr 3 // current temp
// RC20 specific
-#define EMS_TYPE_RC20StatusMessage 0x91 // is an automatic thermostat broadcast giving us temps
-#define EMS_TYPE_RC20Set 0xA8 // for setting values like temp and mode
-#define EMS_OFFSET_RC20Set_mode 23 // position of thermostat mode
-#define EMS_OFFSET_RC20Set_temp 28 // position of thermostat setpoint temperature
-#define EMS_TYPE_RC20StatusMessage_setpoint 1 // setpoint temp
-#define EMS_TYPE_RC20StatusMessage_curr 2 // current temp
+#define EMS_TYPE_RC20StatusMessage 0x91 // is an automatic thermostat broadcast giving us temps
+#define EMS_TYPE_RC20Set 0xA8 // for setting values like temp and mode
+#define EMS_OFFSET_RC20Set_mode 23 // position of thermostat mode
+#define EMS_OFFSET_RC20Set_temp 28 // position of thermostat setpoint temperature
+#define EMS_OFFSET_RC20StatusMessage_setpoint 1 // setpoint temp
+#define EMS_OFFSET_RC20StatusMessage_curr 2 // current temp
// RC30 specific
-#define EMS_TYPE_RC30StatusMessage 0x41 // is an automatic thermostat broadcast giving us temps
-#define EMS_TYPE_RC30Set 0xA7 // for setting values like temp and mode
-#define EMS_OFFSET_RC30Set_mode 23 // position of thermostat mode
-#define EMS_OFFSET_RC30Set_temp 28 // position of thermostat setpoint temperature
-#define EMS_TYPE_RC30StatusMessage_setpoint 1 // setpoint temp
-#define EMS_TYPE_RC30StatusMessage_curr 2 // current temp
+#define EMS_TYPE_RC30StatusMessage 0x41 // is an automatic thermostat broadcast giving us temps
+#define EMS_TYPE_RC30Set 0xA7 // for setting values like temp and mode
+#define EMS_OFFSET_RC30Set_mode 23 // position of thermostat mode
+#define EMS_OFFSET_RC30Set_temp 28 // position of thermostat setpoint temperature
+#define EMS_OFFSET_RC30StatusMessage_setpoint 1 // setpoint temp
+#define EMS_OFFSET_RC30StatusMessage_curr 2 // current temp
// RC35 specific
-#define EMS_TYPE_RC35StatusMessage 0x3E // is an automatic thermostat broadcast giving us temps
-#define EMS_TYPE_RC35StatusMessage_setpoint 2 // desired temp
-#define EMS_TYPE_RC35StatusMessage_curr 3 // current temp
-#define EMS_TYPE_RC35Set 0x3D // for setting values like temp and mode (Working mode HC1)
-#define EMS_OFFSET_RC35Set_mode 7 // position of thermostat mode
-#define EMS_OFFSET_RC35Set_temp_day 2 // position of thermostat setpoint temperature for day time
-#define EMS_OFFSET_RC35Set_temp_night 1 // position of thermostat setpoint temperature for night time
-#define EMS_OFFSET_RC35Get_mode_day 1 // position of thermostat day mode
+#define EMS_TYPE_RC35StatusMessage_HC1 0x3E // is an automatic thermostat broadcast giving us temps on HC1
+#define EMS_TYPE_RC35StatusMessage_HC2 0x48 // is an automatic thermostat broadcast giving us temps on HC2
+#define EMS_TYPE_RC35Set_HC1 0x3D // for setting values like temp and mode (Working mode HC1)
+#define EMS_TYPE_RC35Set_HC2 0x47 // for setting values like temp and mode (Working mode HC2)
+#define EMS_OFFSET_RC35StatusMessage_setpoint 2 // desired temp
+#define EMS_OFFSET_RC35StatusMessage_curr 3 // current temp
+#define EMS_OFFSET_RC35Set_mode 7 // position of thermostat mode
+#define EMS_OFFSET_RC35Set_temp_day 2 // position of thermostat setpoint temperature for day time
+#define EMS_OFFSET_RC35Set_temp_night 1 // position of thermostat setpoint temperature for night time
+#define EMS_OFFSET_RC35Get_mode_day 1 // position of thermostat day mode
+#define EMS_OFFSET_RC35Set_temp_holiday 3 // temp during holiday 0x47
+#define EMS_OFFSET_RC35Set_heatingtype 0 // floor heating = 3 0x47
+#define EMS_OFFSET_RC35Set_circuitcalctemp 14 // calculated circuit temperature 0x48
// Easy specific
-#define EMS_TYPE_EasyStatusMessage 0x0A // reading values on an Easy Thermostat
-#define EMS_TYPE_EasyStatusMessage_setpoint 10 // setpoint temp
-#define EMS_TYPE_EasyStatusMessage_curr 8 // current temp
+#define EMS_TYPE_EasyStatusMessage 0x0A // reading values on an Easy Thermostat
+#define EMS_OFFSET_EasyStatusMessage_setpoint 10 // setpoint temp
+#define EMS_OFFSET_EasyStatusMessage_curr 8 // current temp
+
+// RC1010, RC310 and RC300 specific (EMS Plus)
+#define EMS_TYPE_RCPLUSStatusMessage 0x01A5 // is an automatic thermostat broadcast giving us temps
+#define EMS_TYPE_RCPLUSStatusHeating 0x01B9 // heating mode
+#define EMS_TYPE_RCPLUSStatusMode 0x1AF // summer/winter mode
+#define EMS_TYPE_RCPLUSSet 0x03 // setpoint temp message
+#define EMS_OFFSET_RCPLUSStatusMessage_setpoint 3 // setpoint temp
+#define EMS_OFFSET_RCPLUSStatusMessage_curr 0 // current temp
+#define EMS_OFFSET_RCPLUSGet_mode_day 8 // day/night mode
+
+// Junkers FR10 (EMS Plus)
+#define EMS_TYPE_FR10StatusMessage 0x6F // is an automatic thermostat broadcast giving us temps
+#define EMS_OFFSET_FR10StatusMessage_setpoint 3 // setpoint temp
+#define EMS_OFFSET_FR10StatusMessage_curr 5 // current temp
+
// Known EMS types
typedef enum {
@@ -99,7 +124,7 @@ typedef enum {
// generic ID for all the other weird devices
EMS_MODEL_OTHER,
- // and finaly the thermostats
+ // and finally the thermostats
EMS_MODEL_ES73,
EMS_MODEL_RC10,
EMS_MODEL_RC20,
@@ -110,7 +135,11 @@ typedef enum {
EMS_MODEL_BOSCHEASY,
EMS_MODEL_RC310,
EMS_MODEL_CW100,
- EMS_MODEL_OT
+ EMS_MODEL_1010,
+ EMS_MODEL_OT,
+ EMS_MODEL_FR10,
+ EMS_MODEL_FR100,
+ EMS_MODEL_FR110
} _EMS_MODEL_ID;
@@ -120,10 +149,13 @@ const _Boiler_Type Boiler_Types[] = {
{EMS_MODEL_UBA, 72, 0x08, "MC10 Module"},
{EMS_MODEL_UBA, 123, 0x08, "Buderus GB172/Nefit Trendline"},
- {EMS_MODEL_UBA, 115, 0x08, "Nefit Topline Compact"},
+ {EMS_MODEL_UBA, 115, 0x08, "Nefit Topline Compact/Buderus GB162"},
{EMS_MODEL_UBA, 203, 0x08, "Buderus Logamax U122"},
+ {EMS_MODEL_UBA, 208, 0x08, "Buderus Logamax plus/GB192"},
{EMS_MODEL_UBA, 64, 0x08, "Sieger BK15 Boiler/Nefit Smartline"},
- {EMS_MODEL_UBA, 95, 0x08, "Bosch Condens 2500"}
+ {EMS_MODEL_UBA, 95, 0x08, "Bosch Condens 2500/Junkers Heatronics3"},
+ {EMS_MODEL_UBA, 122, 0x08, "Nefit Proline"},
+ {EMS_MODEL_UBA, 172, 0x08, "Nefit Enviline"}
};
@@ -132,12 +164,17 @@ const _Other_Type Other_Types[] = {
{EMS_MODEL_OTHER, 251, 0x21, "MM10 Mixer Module"}, // warning, fake product id!
{EMS_MODEL_OTHER, 250, 0x11, "WM10 Switch Module"}, // warning, fake product id!
- {EMS_MODEL_OTHER, 68, 0x09, "RFM20 Receiver"},
+ {EMS_MODEL_OTHER, 160, 0x20, "MM100 Mixing Module"},
+ {EMS_MODEL_OTHER, 160, 0x21, "MM100 Mixing Module"},
+ {EMS_MODEL_OTHER, 68, 0x09, "BC10/RFM20 Receiver"},
{EMS_MODEL_OTHER, 190, 0x09, "BC10 Base Controller"},
{EMS_MODEL_OTHER, 114, 0x09, "BC10 Base Controller"},
{EMS_MODEL_OTHER, 125, 0x09, "BC25 Base Controller"},
{EMS_MODEL_OTHER, 205, 0x02, "Nefit Moduline Easy Connect"},
- {EMS_MODEL_OTHER, 73, EMS_ID_SM10, "SM10 Solar Module"}
+ {EMS_MODEL_OTHER, 73, EMS_ID_SM, "SM10 Solar Module"},
+ {EMS_MODEL_OTHER, 163, EMS_ID_SM, "SM100 Solar Module"},
+ {EMS_MODEL_OTHER, 171, 0x02, "EMS-OT OpenTherm converter"},
+ {EMS_MODEL_OTHER, 189, EMS_ID_GATEWAY, "Web Gateway KM200"}
};
@@ -146,17 +183,27 @@ const _Other_Type Other_Types[] = {
*/
const _Thermostat_Type Thermostat_Types[] = {
- {EMS_MODEL_ES73, 76, 0x10, "Sieger ES73", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
- {EMS_MODEL_RC10, 79, 0x17, "RC10/Nefit Moduline 100", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
- {EMS_MODEL_RC20, 77, 0x17, "RC20/Nefit Moduline 300", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
- {EMS_MODEL_RC20F, 93, 0x18, "RC20F", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
- {EMS_MODEL_RC30, 78, 0x10, "RC30/Nefit Moduline 400", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
- {EMS_MODEL_RC35, 86, 0x10, "RC35", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
- {EMS_MODEL_EASY, 202, 0x18, "TC100/Nefit Easy", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_NO},
- {EMS_MODEL_BOSCHEASY, 206, 0x02, "Bosch Easy", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_NO},
- {EMS_MODEL_RC310, 158, 0x10, "RC310", EMS_THERMOSTAT_READ_NO, EMS_THERMOSTAT_WRITE_NO},
- {EMS_MODEL_CW100, 255, 0x18, "Bosch CW100", EMS_THERMOSTAT_READ_NO, EMS_THERMOSTAT_WRITE_NO},
- {EMS_MODEL_OT, 171, 0x02, "EMS-OT OpenTherm converter", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
- {EMS_MODEL_RC10, 165, 0x02, "RC10/Nefit Moduline 1010", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES}
+ // Easy devices - not currently supporting write operations
+ {EMS_MODEL_EASY, 202, 0x18, "TC100/Nefit Easy", EMS_THERMOSTAT_WRITE_NO},
+ {EMS_MODEL_BOSCHEASY, 206, 0x02, "Bosch Easy", EMS_THERMOSTAT_WRITE_NO},
+ {EMS_MODEL_CW100, 157, 0x18, "CW100", EMS_THERMOSTAT_WRITE_NO},
+
+ // Buderus/Nefit
+ {EMS_MODEL_RC10, 79, 0x17, "RC10/Nefit Moduline 100", EMS_THERMOSTAT_WRITE_YES},
+ {EMS_MODEL_RC20, 77, 0x17, "RC20/Nefit Moduline 300", EMS_THERMOSTAT_WRITE_YES},
+ {EMS_MODEL_RC20F, 93, 0x18, "RC20F", EMS_THERMOSTAT_WRITE_YES},
+ {EMS_MODEL_RC30, 78, 0x10, "RC30/Nefit Moduline 400", EMS_THERMOSTAT_WRITE_YES},
+ {EMS_MODEL_RC35, 86, 0x10, "RC35", EMS_THERMOSTAT_WRITE_YES},
+ {EMS_MODEL_RC310, 158, 0x10, "RC3x0/Nefit Moduline 1010H", EMS_THERMOSTAT_WRITE_NO},
+ {EMS_MODEL_1010, 165, 0x18, "Nefit Moduline 1010", EMS_THERMOSTAT_WRITE_NO},
+
+ // Sieger
+ {EMS_MODEL_ES73, 76, 0x10, "Sieger ES73", EMS_THERMOSTAT_WRITE_YES},
+
+ // Junkers
+ {EMS_MODEL_FR10, 111, 0x18, "Junkers FR10", EMS_THERMOSTAT_WRITE_NO},
+ {EMS_MODEL_FR100, 105, 0x18, "Junkers FR100", EMS_THERMOSTAT_WRITE_NO},
+ {EMS_MODEL_FR110, 108, 0x18, "Junkers FR110", EMS_THERMOSTAT_WRITE_NO}
+
};
diff --git a/src/emsuart.cpp b/src/emsuart.cpp
index 65b479b0..8895a4cc 100644
--- a/src/emsuart.cpp
+++ b/src/emsuart.cpp
@@ -72,7 +72,7 @@ static void emsuart_rx_intr_handler(void * para) {
*/
static void ICACHE_FLASH_ATTR emsuart_recvTask(os_event_t * events) {
_EMSRxBuf * pCurrent = pEMSRxBuf;
- ems_parseTelegram((uint8_t *)pCurrent->buffer, (pCurrent->writePtr) - 1); // transmit EMS buffer, excluding the BRK
+ ems_parseTelegram((uint8_t *)pCurrent->buffer, (pCurrent->writePtr) - 1); // transmit EMS buffer, excluding the BRK
pEMSRxBuf = paEMSRxBuf[++emsRxBufIdx % EMS_MAXBUFFERS]; // next free EMS Receive buffer
}
@@ -109,8 +109,9 @@ void ICACHE_FLASH_ATTR emsuart_init() {
// UCTOE = RX TimeOut enable (default is 1)
// UCTOT = RX TimeOut Threshold (7bit) = want this when no more data after 2 characters. (default is 2)
// UCFFT = RX FIFO Full Threshold (7 bit) = want this to be 31 for 32 bytes of buffer. (default was 127).
+ // see https://www.espressif.com/sites/default/files/documentation/esp8266-technical_reference_en.pdf
USC1(EMSUART_UART) = 0; // reset config first
- USC1(EMSUART_UART) = (31 << UCFFT) | (0x02 << UCTOT) | (1 << UCTOE); // enable interupts
+ USC1(EMSUART_UART) = (EMS_MAX_TELEGRAM_LENGTH << UCFFT) | (0x02 << UCTOT) | (1 << UCTOE); // enable interupts
// set interrupts for triggers
USIC(EMSUART_UART) = 0xffff; // clear all interupts
@@ -177,8 +178,14 @@ void ICACHE_FLASH_ATTR emsuart_tx_brk() {
void ICACHE_FLASH_ATTR emsuart_tx_buffer(uint8_t * buf, uint8_t len) {
for (uint8_t i = 0; i < len; i++) {
USF(EMSUART_UART) = buf[i];
+
+ // check if we need to force a delay to slow down Tx
+ // https://github.com/proddy/EMS-ESP/issues/23#
+ if (EMS_Sys_Status.emsTxDelay) {
+ delayMicroseconds(EMS_TX_BRK_WAIT);
+ }
}
- emsuart_tx_brk();
+ emsuart_tx_brk(); // send
}
/*
@@ -186,5 +193,5 @@ void ICACHE_FLASH_ATTR emsuart_tx_buffer(uint8_t * buf, uint8_t len) {
*/
void ICACHE_FLASH_ATTR emsaurt_tx_poll() {
USF(EMSUART_UART) = EMS_ID_ME;
- emsuart_tx_brk();
+ emsuart_tx_brk(); // send
}
diff --git a/src/my_config.h b/src/my_config.h
index 8f55c891..b2713a2a 100644
--- a/src/my_config.h
+++ b/src/my_config.h
@@ -14,22 +14,31 @@
#define MQTT_BASE "home" // all MQTT topics are prefix with this string, in the format //
// MQTT general settings
-#define MQTT_TOPIC_START "start"
-#define MQTT_TOPIC_START_PAYLOAD "start"
#define MQTT_WILL_TOPIC "status" // for last will & testament topic name
#define MQTT_WILL_ONLINE_PAYLOAD "online" // for last will & testament payload
#define MQTT_WILL_OFFLINE_PAYLOAD "offline" // for last will & testament payload
#define MQTT_RETAIN false
#define MQTT_KEEPALIVE 120 // 2 minutes
#define MQTT_QOS 1
+#define MQTT_MAX_SIZE 700 // max size of a JSON object. See https://arduinojson.org/v6/assistant/
// MQTT for thermostat
-#define TOPIC_THERMOSTAT_DATA "thermostat_data" // for sending thermostat values to MQTT
-#define TOPIC_THERMOSTAT_CMD_TEMP "thermostat_cmd_temp" // for received thermostat temp changes via MQTT
-#define TOPIC_THERMOSTAT_CMD_MODE "thermostat_cmd_mode" // for received thermostat mode changes via MQTT
-#define THERMOSTAT_CURRTEMP "thermostat_currtemp" // current temperature
-#define THERMOSTAT_SELTEMP "thermostat_seltemp" // selected temperature
-#define THERMOSTAT_MODE "thermostat_mode" // mode
+#define TOPIC_THERMOSTAT_DATA "thermostat_data" // for sending thermostat values to MQTT
+#define TOPIC_THERMOSTAT_CMD_TEMP "thermostat_cmd_temp" // for received thermostat temp changes via MQTT
+#define TOPIC_THERMOSTAT_CMD_MODE "thermostat_cmd_mode" // for received thermostat mode changes via MQTT
+#define TOPIC_THERMOSTAT_CMD_HC "thermostat_cmd_hc" // for received thermostat hc number changes via MQTT
+#define TOPIC_THERMOSTAT_CMD_DAYTEMP "thermostat_daytemp" // RC35 specific
+#define TOPIC_THERMOSTAT_CMD_NIGHTTEMP "thermostat_nighttemp" // RC35 specific
+#define TOPIC_THERMOSTAT_CMD_HOLIDAYTEMP "thermostat_holidayttemp" // RC35 specific
+#define THERMOSTAT_CURRTEMP "thermostat_currtemp" // current temperature
+#define THERMOSTAT_SELTEMP "thermostat_seltemp" // selected temperature
+#define THERMOSTAT_HC "thermostat_hc" // which heating circuit number
+#define THERMOSTAT_MODE "thermostat_mode" // mode
+#define THERMOSTAT_DAYTEMP "thermostat_daytemp" // RC35 specific
+#define THERMOSTAT_NIGHTTEMP "thermostat_nighttemp" // RC35 specific
+#define THERMOSTAT_HOLIDAYTEMP "thermostat_holidayttemp" // RC35 specific
+#define THERMOSTAT_HEATINGTYPE "thermostat_heatingtype" // RC35 specific (3=floorheating)
+#define THERMOSTAT_CIRCUITCALCTEMP "thermostat_circuitcalctemp" // RC35 specific
// MQTT for boiler
#define TOPIC_BOILER_DATA "boiler_data" // for sending boiler values to MQTT
@@ -39,12 +48,15 @@
#define TOPIC_BOILER_CMD_WWTEMP "boiler_cmd_wwtemp" // for received boiler wwtemp changes via MQTT
#define TOPIC_BOILER_CMD_COMFORT "boiler_cmd_comfort" // for received boiler ww comfort setting via MQTT
-// MQTT for SM10 Solar Module
-#define TOPIC_SM10_DATA "sm10_data" // topic name
-#define SM10_COLLECTORTEMP "temp" // collector temp
-#define SM10_BOTTOMTEMP "bottomtemp" // bottom temp
-#define SM10_PUMPMODULATION "pumpmodulation" // pump modulation
-#define SM10_PUMP "pump" // pump active
+// MQTT for SM10/SM100 Solar Module
+#define TOPIC_SM_DATA "sm_data" // topic name
+#define SM_COLLECTORTEMP "collectortemp" // collector temp
+#define SM_BOTTOMTEMP "bottomtemp" // bottom temp
+#define SM_PUMPMODULATION "pumpmodulation" // pump modulation
+#define SM_PUMP "pump" // pump active
+#define SM_ENERGYLASTHOUR "energylasthour" // energy last hour
+#define SM_ENERGYTODAY "energytoday" // energy today
+#define SM_ENERGYTOTAL "energytotal" // energy total
// shower time
#define TOPIC_SHOWERTIME "showertime" // for sending shower time results
diff --git a/src/test_data.h b/src/test_data.h
new file mode 100644
index 00000000..40b2b365
--- /dev/null
+++ b/src/test_data.h
@@ -0,0 +1,53 @@
+
+#ifdef TESTS
+
+static const char * TEST_DATA[] = {
+
+ "08 00 34 00 3E 02 1D 80 00 31 00 00 01 00 01 0B AE 02", // test 1 - EMS
+ "10 00 FF 00 01 A5 80 00 01 30 28 00 30 28 01 54 03 03 01 01 54 02 A8 00 00 11 01 03 FF FF 00", // test 2 - RC310 ems+
+ "10 00 FF 19 01 A5 06 04 00 00 00 00 FF 64 37 00 3C 01 FF 01", // test 3 - RC310 ems+
+ "30 00 FF 00 02 62 00 A1 01 3F 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00", // test 4 - SM100
+ "10 00 FF 00 01 A5 00 D7 21 00 00 00 00 30 01 84 01 01 03 01 84 01 F1 00 00 11 01 00 08 63 00", // test 5 - Moduline 1010
+ "18 00 FF 00 01 A5 00 DD 21 23 00 00 23 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00", // test 6 - RC300
+ "90 00 FF 00 00 6F 01 01 00 46 00 B9", // test 7 - FR10
+ "30 00 FF 00 02 62 01 FB 01 9E 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 2B", // test 8 - SM100
+ "30 00 FF 00 02 64 00 00 00 04 00 00 FF 00 00 1E 0C 20 64 00 00 00 00 E9", // test 9 - SM100
+ "30 09 FF 00 00 01", // test 10 - EMS+
+ "30 0B 97 00", // test 11 - SM100
+ "30 00 FF 00 02 62 01 CA", // test 12 - SM100
+ "30 00 FF 00 02 8E 00 00 00 00 00 00 05 19 00 00 75 D3", // test 13 - SM100
+ "30 00 FF 00 02 63 80 00 80 00 00 00 80 00 80 00 80 00 00", // test 14 - SM100
+ "30 00 FF 00 02 64 00 00 00 04 00 00 FF 00 00 1E 0B 09 64 00 00 00 00", // test 15 - SM100
+ "30 00 FF 00 02 62 01 CA 01 93 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00", // test 16 - SM100
+ "30 00 FF 00 02 6A 03 03 03 00 03 03 03 03 03 00 03 03", // test 17 - SM100
+ "30 00 FF 00 02 6A 03 03 03 00 03 03 03 03 03 00 04 03", // test 18 - SM100
+ "30 00 FF 00 02 64 00 00 00 04 00 00 FF 00 00 1E 09 08 64 00 00 00 00", // test 19 - SM100
+ "10 00 FF 07 01 A5 32", // test 20 - RC EMS+
+ "38 10 FF 00 03 2B 00 D1 08 2A 01", // test 21 - heatpump
+ "38 10 FF 00 03 7B 08 24 00 4B", // test 22 - heatpump
+ "08 00 FF 31 03 94 00 00 00 00 00 00 00", // test 23 - heatpump
+ "08 00 FF 00 03 95 00 6D C5 0E 00 05 BA 7C 00 68 0A 92 00 00 00 00 00 00 00 00 00 00 00 CD", // test 24 - heatpump
+ "08 00 FF 48 03 95 00 00 01 47 00 00 00 00 00 00 00 00", // test 25 - heatpump
+ "08 00 FF 00 03 A2 10 01 02 02 00", // test 26 - heatpump
+ "08 00 FF 00 03 A3 00 0B 00 00 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 00 08 00 00 00 0A", // test 27 - heatpump
+ "30 00 FF 0A 02 6A 04", // test 28 - SM100 pump on
+ "30 00 FF 0A 02 6A 03", // test 29 - SM100 pump off
+ "48 90 02 00 01", // test 30 - version test
+ "10 48 02 00 9E", // test 31 - version test
+ "30 00 FF 00 02 8E 00 00 0C F3 00 00 06 02 00 00 76 33", // test 32 - SM100 energy
+ "30 00 FF 00 02 8E 00 00 07 9E 00 00 06 C5 00 00 76 35", // test 33 - SM100 energy
+ "30 00 FF 00 02 8E 00 00 00 00 00 00 06 C5 00 00 76 35", // test 34 - SM100 energy
+ "10 48 F9 00 FF 01 6C 08 4F 00 00 00 02 00 00 00 02 00 03 00 03 00 03 00 02", // test 35 - F9
+ "48 90 F9 00 11 FF 01 6D 08", // test 36 - F9
+ "10 48 F9 00 FF 01 6D 08", // test 37 - F9
+ "10 00 F7 00 FF 01 B9 35 19", // test 38 - F7
+ "30 00 FF 00 02 62 00 E7 01 AE 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00", // test 39 - SM100
+ "30 00 FF 00 02 62 00 E4", // test 40 - SM100
+ "10 48 F7 00 FF 01 A5 DF FF F7 7F 1F", // test 41 - gateway
+ "30 00 FF 09 02 64 1E", // test 42 - SM100
+ "08 00 18 00 05 03 30 00 00 00 00 04 40 80 00 02 17 80 00 00 00 FF 30 48 00 CB 00 00 00", // test 43 - sys pressure
+ "90 00 FF 00 00 6F 03 01 00 BE 00 BF" // test 44 - FR10
+
+};
+
+#endif
diff --git a/src/version.h b/src/version.h
index d4e4d839..fc8dc599 100644
--- a/src/version.h
+++ b/src/version.h
@@ -6,5 +6,5 @@
#pragma once
#define APP_NAME "EMS-ESP"
-#define APP_VERSION "1.6.0"
+#define APP_VERSION "1.7.0"
#define APP_HOSTNAME "ems-esp"