-
Notifications
You must be signed in to change notification settings - Fork 838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added 'sensorTemperature' and 'iFeel' to IRac (common) #1928
Added 'sensorTemperature' and 'iFeel' to IRac (common) #1928
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have minor reservations due to the code size increment compared to how useful this might be.
However that is something that can be resolved in other ways if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for all the comments. Looks pretty good except for my comments.
src/IRac.cpp
Outdated
ac->setSensorTemp(static_cast<uint8_t>(sensorTemp + 0.5)); | ||
} else { | ||
ac->setSensorTemp(degrees); //< Set to the desired temp | ||
// until we cab disable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: s/cab/can/
src/IRac.cpp
Outdated
const bool turbo, const int16_t sleep) { | ||
ac->begin(); | ||
ac->setPower(on); | ||
ac->setMode(ac->convertMode(mode)); | ||
ac->setTemp(degrees); | ||
ac->setTemp(static_cast<uint8_t>(degrees + 0.5)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you increasing the desired temp here by 0.5 degrees?
src/IRac.cpp
Outdated
if (sensorTemp != kNoTempValue) { | ||
ac->setSensorTemp(static_cast<uint8_t>(sensorTemp + 0.5)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See later comments about this. Not commenting here due to proximity to the other comment.
src/IRac.cpp
Outdated
if (sensorTemp != kNoTempValue) { | ||
ac->setSensorTemp(static_cast<uint8_t>(sensorTemp + 0.5)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you (seemingly always) setting the sensor temp half a degree higher than the requested sensorTemp
value? This makes little sense to me.
Also, it seems like a lot of duplicate code (for every time you do it) in each method.
This goes for almost all occurances of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, if it is to make the sensor temp be higher than the desired temp so the A/C operates, that's potentially a failure.
i.e. The A/C units might not decide to operate within +/-2 deg or something. Also, you may be assuming "Cool" mode. i.e. If the unit is in "Heat" mode, you'd want the opposite in that approach.
In principle, these methods/procedures/etc should deliver the results they have been instructed to do, not change the behavior unless needed. That allows decissions, changes, and operational logic to be done at a higher (and maybe more common) level.
But this is all a guess for why you're adding half a degree ... shrug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tl;dr;
Will update to std::round()
. Please check if this would be OK with your direction, or if it should be std::trunc() || static_cast<uint8_t>()
instead?
BTW. I'd highly recommend to consider enabling -Wconversion
or at least -Wfloat-conversion
in UT compiler options someday, so that these narrowing conversions are always explicit.
I'm not doing this now, as it will/does yield a ton of warnings...
Verbose
Why are you (seemingly always) setting the sensor temp half a degree higher than the requested
sensorTemp
value?
I'm merely converting float->uint8_t
(with rounding). That is:
0.1 -> 0
0.5 -> 1
0.9 -> 1
1.4 -> 1
etc.
Given that it wasn't immediately apparent, signals to me that it reads poorly, I now see I should have used std::round()
or even std::nearbyint()
(see here for how they differ) for it, esp. since my naive method doesn't handle negative numbers too intuitively (i.e. -1.3
would become a 0
).
if it is to make the sensor temp be higher than the desired temp so the A/C operates
No, not really. I only wanted to capture the gist of the interface (which operates on float
).
The A/C units might not decide to operate within +/-2 deg or something.
This thinking is the reasoning behind a more "natural" rounding of values.
While it is indeed the current implementation of degrees
(for all int-based AC temp. protocols I've seen across the lib), to truncate the decimal part... I fear that a higher-precision temp sensor (operating with, say 2 digit precision) may encounter the following:
mode: COOL
degrees: 21 [°C]
sensorTemperature: 21.99 [°C]
So, if I left it as-is, it would be int(21) == 21 == int(21.99)
and would likely cause the device to sit idle (while it should start cooling, give or take its temp hysteresis configuration), which is why I broke convention of truncating (this wasn't an explicit one, though... so I'm not sure how deliberate that was).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it seems like a lot of duplicate code (for every time you do it) in each method.
std::round
would (kind-of) take care of it (fun fact... it will be more characters to write than the +0.5
:) but much more proper ).
I'd argue though the static _cast<>()
should stay there and while this is repeated in multiple places... is not boilerplate (I'm of the opinion a narrowing cast should always be very explicit, so that it signals the "I know what I'm doing" to future maintainers :) ).
Creating a custom "i8round()
" function (following boost's iround
[ref]) to get rid of the static_cast
and implement overflow checking... is also possible, but I think it would be an overkill for this (there's no overflow check today for degrees
, so probably is a YAGNI item).
src/IRac.cpp
Outdated
if (sensorTemp != kNoTempValue) { | ||
ac->setSensorTemp(static_cast<uint8_t>(sensorTemp + 0.5)); | ||
} else { | ||
ac->setSensorTemp(degrees); // Set the sensor temp to the desired temp. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change comment to:
// Set the sensor temp to the desired (normal) temp.
or make it clearer/more obvious.
This confused me for a bit as I read the comment, and not the code. I thought you were doing:
ac->setSensorTemp(sensorTemp);
here instead of degrees
based on the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will update as suggested.
- Disclamer: I copied this as-is from what used to be line
2242
. To be honest, I don't know exactly why it was being done (seems counterintuitive: always setsdesired == actual
so I'd assume the A/C may decide to do nothing in this case).
I have left it however, as it was there in the original code. If you know if this can be removed, I'd happily delete this.
On the flip side, I have even debated if not to apply this pattern globally, e.g.:
stdAc::state_t IRac::cleanState(const stdAc::state_t state) {
stdAc::state_t result = state;
// (...)
if (state.sensorTemp == kNoTempValue) result.sensorTemp = state.degrees; //< HERE
return result;
But finally decided against it as too risky.
src/IRac.cpp
Outdated
@@ -537,7 +551,7 @@ void IRac::argoWrem3_ACCommand(IRArgoAC_WREM3 *ac, const bool on, | |||
void IRac::argoWrem3_iFeelReport(IRArgoAC_WREM3 *ac, const float sensorTemp) { | |||
ac->begin(); | |||
ac->setMessageType(argoIrMessageType_t::IFEEL_TEMP_REPORT); | |||
ac->setSensorTemp(sensorTemp); | |||
ac->setSensorTemp(static_cast<uint8_t>(sensorTemp + 0.5)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the +0.5?
No worries. I appreciate all the comments... just may not be able to digest them fast enough :) By the way, the discussion on Not sure if this is a problem (I know some A/C protocols offset the value by a few units, but not sure if any proto. - e.g. for heat pumps - allows the target/ambient temperature to be negative). Not making this change proactively though, as:
|
Incl. impl. for Argo A/C Signed-off-by: Mateusz Bronk <[email protected]>
Signed-off-by: Mateusz Bronk <[email protected]>
0abf6cc
to
3b28c4b
Compare
Hi @crankyoldgit, |
_v2.8.5 (20230305)_ **[Bug Fixes]** - Missing argument in use of midea function (#1959 #1958) - IRMQTTServer: Improve HA MQTT climate handling. (#1911) - SEND_SANYO_AC88: Fix poor cut-n-paste error (#1905 #1897) **[Features]** - IRMQTTServer: SHT-3x Temperature Sensor Support (#1951) - IRMQTTServer: HA multi output discovery (#1947) - IRMQTTServer: extended with new A/C common fields (#1940) - IRMQTTServer: Sync the on state to power from mode for HA (#1946) - Experimental basic support for Carrier 84-bit protocol. (#1945 #1943) - Add support the WowWee 11-Bit RoboRaptor-X protocol. (#1939 #1938) - Added 'sensorTemperature' and 'iFeel' to IRac (common) (#1928) - Added extra 'mid' option for Fan & SwingV to IRac (#1929) - Added "commandType" to IRAc (#1921) - Added support for Argo WREM-3 A/C remote protocol [part1] (#1920) - Added Dutch (nl-NL) translation (#1907) - ARGO: Improve code & add support for decoding 32bit sensor msgs. (#1906 #1859) - Added support for Gorenje cooker hood IR protocol (#1888 #1887) **[Misc]** - Update `XMP` status to Stable (#1944) - upgrade to a later version of `googletest` (#1936) - MITSUBISHI128: Added model to supported protocol (#1924) - Added Dutch (nl-NL) README (#1908) - Added GMock to UT Makefile (#1902) - Update HA example config for HA 2022.6+ (#1901 #1900)
_v2.8.5 (20230508)_ **[Bug Fixes]** - Fix a bug where we never detached the timer interrupt on ESP32s. (#1984 #1983) - Missing argument in use of midea function (#1959 #1958) - IRMQTTServer: Improve HA MQTT climate handling. (#1911) - SEND_SANYO_AC88: Fix poor cut-n-paste error (#1905 #1897) **[Features]** - Add support for a 40bit variant of the standard Panasonic protocol (#1977 @1976) - Initial support for York AC protocol (#1889) - IRMQTTServer: SHT-3x Temperature Sensor Support (#1951) - IRMQTTServer: HA multi output discovery (#1947) - IRMQTTServer: extended with new A/C common fields (#1940) - IRMQTTServer: Sync the on state to power from mode for HA (#1946) - Experimental basic support for Carrier 84-bit protocol. (#1945 #1943) - Add support the WowWee 11-Bit RoboRaptor-X protocol. (#1939 #1938) - Added 'sensorTemperature' and 'iFeel' to IRac (common) (#1928) - Added extra 'mid' option for Fan & SwingV to IRac (#1929) - Added "commandType" to IRAc (#1921) - Added support for Argo WREM-3 A/C remote protocol [part1] (#1920) - Added Dutch (nl-NL) translation (#1907) - ARGO: Improve code & add support for decoding 32bit sensor msgs. (#1906 #1859) - Added support for Gorenje cooker hood IR protocol (#1888 #1887) **[Misc]** - Add Electrolux YKR-H/531E as a supported device (#1981 #1980) - Update `XMP` status to Stable (#1944) - upgrade to a later version of `googletest` (#1936) - MITSUBISHI128: Added model to supported protocol (#1924) - Added Dutch (nl-NL) README (#1908) - Added GMock to UT Makefile (#1902) - Update HA example config for HA 2022.6+ (#1901 #1900) - Add a `d1_mini_noMDNS` build option to `IRMQTTServer`. (#1985)
## _v2.8.5 (20230508)_ **[Bug Fixes]** - Fix a bug where we never detached the timer interrupt on ESP32s. (#1984 #1983) - Missing argument in use of midea function (#1959 #1958) - IRMQTTServer: Improve HA MQTT climate handling. (#1911) - SEND_SANYO_AC88: Fix poor cut-n-paste error (#1905 #1897) **[Features]** - Add support for a 40bit variant of the standard Panasonic protocol (#1977 @1976) - Initial support for York AC protocol (#1889) - IRMQTTServer: SHT-3x Temperature Sensor Support (#1951) - IRMQTTServer: HA multi output discovery (#1947) - IRMQTTServer: extended with new A/C common fields (#1940) - IRMQTTServer: Sync the on state to power from mode for HA (#1946) - Experimental basic support for Carrier 84-bit protocol. (#1945 #1943) - Add support the WowWee 11-Bit RoboRaptor-X protocol. (#1939 #1938) - Added 'sensorTemperature' and 'iFeel' to IRac (common) (#1928) - Added extra 'mid' option for Fan & SwingV to IRac (#1929) - Added "commandType" to IRAc (#1921) - Added support for Argo WREM-3 A/C remote protocol [part1] (#1920) - Added Dutch (nl-NL) translation (#1907) - ARGO: Improve code & add support for decoding 32bit sensor msgs. (#1906 #1859) - Added support for Gorenje cooker hood IR protocol (#1888 #1887) **[Misc]** - Add Electrolux YKR-H/531E as a supported device (#1981 #1980) - Update `XMP` status to Stable (#1944) - upgrade to a later version of `googletest` (#1936) - MITSUBISHI128: Added model to supported protocol (#1924) - Added Dutch (nl-NL) README (#1908) - Added GMock to UT Makefile (#1902) - Update HA example config for HA 2022.6+ (#1901 #1900) - Add a `d1_mini_noMDNS` build option to `IRMQTTServer`. (#1985)
Adds support for
sensorTemperature
(a.k.a.roomTemp
,iFeel
, ...) incl. temp. source selection toIRac
.For: #1912
This PR is a standalone part#3 of changes detached from: #1913.
...roomTemp...
existence in other protocols.I'm happy to pull these and submit only the "Argo" part which I can confirm working. On the other hand - if you'd like to get the support lib-wide and I failed at updating sth, I'd welcome co-authoring this change set.
Relevant discusion: