-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
P093 Mitsubishi HeatPump #4813
P093 Mitsubishi HeatPump #4813
Conversation
Add Support for SetRemoteTemperature Resolves P093 - Mitsubishi Heat Pump Add Remote Temperature letscontrolit#4711
src/_P093_MitsubishiHP.ino
Outdated
@@ -8,12 +8,14 @@ | |||
/** Changelog: | |||
* 2023-05-04 tonhuisman: Add support for PLUGIN_GET_CONFIG_VALUE to enable fetching all available values (as included in the json) | |||
* 2023-05-04 tonhuisman: Start Changelog | |||
* 2023-09-21 jfmennedy: Add support for "SetRemoteTemperature" Issue#4711 |
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.
This changelog is supposed to be from the top from new to old... 😉 I see why this one can be confusing, but the Start message should have been the giveaway 🤔
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.
modified ;-)
} | ||
} | ||
else { | ||
packet[6] |= 0x00; |
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.
Is this intended?
A logic OR with 0 doesn't change anything.
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.
No it´s not intended, will be fixed...
@@ -362,6 +382,26 @@ void P093_data_struct::applySettings() { | |||
packet[21] = checkSum(packet, 21); | |||
|
|||
sendPacket(packet, PACKET_LEN); | |||
|
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 need Help here...
When i put line 382 to 384
packet[21] = checkSum(packet, 21);
sendPacket(packet, PACKET_LEN);
under line 404 remote temperature works, but not the other commands (line 347 to 380).. if these lines are like this the other commands work, but not remote temperature...
What am I missing???
Sorry I am not a programmer, i try just to help myself out on an issue i opened long time ago...
Thx for your help...
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 assume you are moving those lines from 382-384 to below where the remoteTemperature
value is put into the packet buffer?
This could mean that, besides the other commands, also the remoteTemperature is put into the packet buffer, causing the other commands to be overwritten/changed by that data.
Some generic improvements can be made to this plugin, like initializing float values with a float 0 constant: 0.0f
, and compare these values using a special float comparator, I'll mark those lines in the .h file, below (and can also be applied to the other 2 float values).
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.
Yes that´s right.. I also tried with another buffer called packet2, which is just handled after the if (_writeStatus.isDirty(RemoteTemperature)) section.. but same behaviour, i can set the hp on /off etc, but not the remote temp. I can just set remote temperature when it is buffer called packet behind if (_writeStatus.isDirty(RemoteTemperature))...
I also tried to set the buffer in each if(_writeStatus.isDirty(...)) and just execute sendPacket(packet, PACKET_LEN); in the end of this block.. but than only remote remote is handled no other command...
@@ -170,6 +172,7 @@ struct P093_data_struct : public PluginTaskData_base { | |||
vane(0), | |||
wideVane(0), | |||
roomTemperature(0), | |||
remoteTemperature(0), |
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.
This could be initialized with a float zero value: 0.0f
(can also be applied to the other 2 float values temperature
and roomTemperature
)
@@ -182,6 +185,7 @@ struct P093_data_struct : public PluginTaskData_base { | |||
wideVane != rhs.wideVane || | |||
iSee != rhs.iSee || | |||
roomTemperature != rhs.roomTemperature || | |||
remoteTemperature != rhs.remoteTemperature || |
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.
Here you can use a specific, more accurate, float compare function:
!essentiallyEqual(remoteTemperature, rhs.remoteTemperature)
(can also be applied to the other 2 float values temperature
and roomTemperature
)
static const uint8_t Fan = 0x08; | ||
static const uint8_t Vane = 0x10; | ||
static const uint8_t WideVane = 0x20; | ||
static const uint8_t RemoteTemperature = 0x07; |
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.
@jfmennedy these flags are being used as a bitmap, not as a numeric value. If you change this to 0x30
the temperature, power and mode commands should start to work as intended again 😅
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 try this now.. saw this comment too late before my last commit and 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.
That´s it :-) It is working :-) Thank you sooooo much :-)
} | ||
else { | ||
packet[6] = 0x00; | ||
packet[8] |= 0x80; //MHK1 send 80, even though it could be 00, since ControlByte is 00 |
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.
The original code has a simple assignment operator here, not an OR-assign, though effectively it doesn't make a difference, best would be to use just =
.
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.
ok, i wondered why in the whole code the or assignment was used... thats why i choose this on also for the modification..
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.
In this specific case it should be an assignment, the other places should keep |=
as multiple settings can be sent in a single packet, and some set a different bit in that offset.
- Fix float comparator, - Still trying t get SetRemoteTemperature working...
} | ||
|
||
if (_writeStatus.isDirty(RemoteTemperature)) { | ||
packet[5] |= 0x07; |
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.
An improvement might be to re-initialize the packet buffer by inserting memset(packet + 6, 0, 15);
before the (corrected) assignment here: packet[5] = 0x07;
as using command mode 0x01 (probably) isn't compatible with command mode 0x07, required for setting the remoteTemperature value. Multiple values can be sent in a single command, it seems, as most values go into different positions.
} | ||
|
||
if (_writeStatus.isDirty(Vane)) { | ||
packet[12] = _wantedSettings.vane; | ||
packet[6] |= 0x10; | ||
packet[21] = checkSum(packet, 21); |
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.
No need to calculate the checksum that often, once, just before sending the packet, is just fine.
Are you trying to achieve this again: #4809 (comment) ? 😃 |
Only thing left is updating the documentation, there's a commands include file available for this plugin here: How to compile the documentation locally is explained in the development guide I've linked before. When running that converter just ignore any messages about the image converter tool (on Windows), or the p096_page or p123_page labels, that's a known issue (those pages are in another PR that's not merged yet) The P036.rst error I'll take care of. |
docs/source/Plugin/P093.rst
Outdated
... | ||
|
||
|added| | ||
Set Remote Temperature (greater than 0.0 external Temperature Sensor is used. equal 0.0 internal Temperature Sensor is used.) |
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.
Had to read this multiple times before it hit me what you tried to tell here.
Maybe the column width in this Git diff view isn't helping...
Anyway, maybe this is easier to grasp:
Set Remote Temperature. (value > 0: Use external temperature sensor, value = 0: Use internal temperature sensor)
" | ||
``MitsubishiHP,remotetemperature,<value>`` | ||
"," | ||
Value equal ``0.0`` uses internal Temperature Sensor and greater than ``0.0`` external Temperature Sensor . |
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.
Maybe use same wording here? (I like the use of backticks for the numbers by the way)
@@ -6,6 +6,7 @@ | |||
| ``[<taskname>#roomTemperature]`` | |||
"," | |||
| Value as received from the connected device, includes 1 decimal. | |||
| When Remote Temperature is used, received value is rounded by 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.
"Rounded to the nearest 0.5 C"
This one will not be included in the next upcoming build (probably today or tomorrow). |
Ok, Thanks for your support on this :-) |
Add Support for SetRemoteTemperature
Resolves P093 - Mitsubishi Heat Pump Add Remote Temperature
Fixes: #4711