Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
arjenhiemstra committed Feb 14, 2023
2 parents 2fdf636 + 8718a71 commit 271617b
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 3 deletions.
39 changes: 39 additions & 0 deletions software/NRG_itho_wifi/main/IthoSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,45 @@ void sendQuery31D9(bool updateweb)
}
}

void setSettingCE30(uint16_t temporary_temperature, uint16_t fallback_temperature, uint32_t timestamp, bool updateweb)
// Set the outside temperature for WPU devices.
// [00,3E,CE,30,05,08, 63,91,DA,C7, xx,xx, yy,yy, FF]
// from: 00 (broadcast)
// source: 3E
// command: CE30
// type: 5 (update)
// length: 8
// 6391DAC7 => 4 byte unix timestamp: lifetime of temporary_temparture. After timestamp temporary_temp is replaced by fallback_temp.
// xxxx two byte temporary_temp: 0x0539 = 13.37 degrees C.
// yyyy two byte fallback_temp: 0xFC18 = -10 degrees C.
// FF checksum

{
uint8_t command[] = {0x00, 0x3E, 0xCE, 0x30, 0x05, 0x08, 0x63, 0x91, 0x00, 0x00, 0x7F, 0xFF, 0x7F, 0xFF, 0xFF};

command[6] = (timestamp >> 24) & 0xFF;
command[7] = (timestamp >> 16) & 0xFF;
command[8] = (timestamp >> 8) & 0xFF;
command[9] = timestamp & 0xFF;

command[10] = (temporary_temperature >> 8) & 0xFF;
command[11] = temporary_temperature & 0xFF;
command[12] = (fallback_temperature >> 8) & 0xFF;
command[13] = fallback_temperature & 0xFF;

command[sizeof(command) - 1] = checksum(command, sizeof(command) - 1);

if (!i2c_sendBytes(command, sizeof(command), I2C_CMD_SET_CE30))
{
if (updateweb)
{
updateweb = false;
jsonSysmessage("itho_CE30_result", "failed");
}
return;
}
}

int32_t *sendQuery2410(uint8_t index, bool updateweb)
{

Expand Down
1 change: 1 addition & 0 deletions software/NRG_itho_wifi/main/IthoSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ void sendQueryStatusFormat(bool updateweb);
void sendQueryStatus(bool updateweb);
void sendQuery31DA(bool updateweb);
void sendQuery31D9(bool updateweb);
void setSettingCE30(uint16_t temporary_temperature, uint16_t fallback_temperature, uint32_t timestamp, bool updateweb);
int32_t *sendQuery2410(uint8_t index, bool updateweb);
void setSetting2410(uint8_t index, int32_t value, bool updateweb);
// void setSetting2410(bool updateweb);
Expand Down
4 changes: 3 additions & 1 deletion software/NRG_itho_wifi/main/i2c_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ typedef enum
I2C_CMD_QUERY_31D9,
I2C_CMD_QUERY_2410,
I2C_CMD_SET_2410,
I2C_CMD_SET_CE30,
I2C_CMD_FILTER_RESET,
I2C_CMD_TEMP_READ_ITHO,
I2C_CMD_TEMP_READ_SLAVE,
Expand Down Expand Up @@ -70,7 +71,7 @@ class I2CLogger
const char *msg;
} i2c_error_state_msg;

const i2c_cmdref_msg i2c_cmdref_msg_table[16]{
const i2c_cmdref_msg i2c_cmdref_msg_table[17]{
{I2C_CMD_EMPTY_CMDREF, ""},
{I2C_CMD_UNKOWN, "UNKOWN"},
{I2C_CMD_PWM_INIT, "PWM_INIT"},
Expand All @@ -83,6 +84,7 @@ class I2CLogger
{I2C_CMD_QUERY_31D9, "QUERY_31D9"},
{I2C_CMD_QUERY_2410, "QUERY_2410"},
{I2C_CMD_SET_2410, "SET_2410"},
{I2C_CMD_SET_CE30, "SET_CE30"},
{I2C_CMD_FILTER_RESET, "FILTER_RESET"},
{I2C_CMD_TEMP_READ_ITHO, "TEMP_READ_FROM_ITHO"},
{I2C_CMD_TEMP_READ_SLAVE, "TEMP_READ_SLAVE"},
Expand Down
8 changes: 8 additions & 0 deletions software/NRG_itho_wifi/main/task_mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,14 @@ void mqttCallback(const char *topic, const byte *payload, unsigned int length)
clearQueue = true;
}
}
if (!(const char *)root["outside_temp"].isNull())
{
jsonCmd = true;
float outside_temp = root["outside_temp"].as<float>();
float temporary_outside_temp = root["temporary_outside_temp"].as<float>();
uint32_t valid_until = root["valid_until"].as<uint32_t>();
setSettingCE30(static_cast<int16_t>(temporary_outside_temp*100), static_cast<int16_t>(outside_temp*100), valid_until, false);
}
if (!jsonCmd)
{
ithoSetSpeed(s_payload, MQTTAPI);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,24 @@ <h1>Debug page</h1>
value="0"><br>
<span>Sent command:&nbsp;</span><span id="itho2410set"></span><br><span>Result:&nbsp;</span><span
id="itho2410setres"></span><br>
<span style="color:red">Warning!!</span><br><br><button id="ithobutton-31DA"
<span style="color:red">Warning!!</span><br><br>

<button id="ithobutton-31DA"
class="pure-button pure-button-primary">Query 31DA</button><br><span>Result:&nbsp;</span>
<span id="itho31DA"></span><br><br><button id="ithobutton-31D9"
class="pure-button pure-button-primary">Query 31D9</button><br><span>Result:&nbsp;</span><span
id="itho31D9"></span><br><br>

<button id="ithobutton-10D0" class="pure-button pure-button-primary">Filter
reset</button><br><span>Filter
reset function uses virtual remote 0, this remote needs to be paired with your itho for this command
to
work</span>
work</span><br><br>
<button id="buttonCE30" class="pure-button pure-button-primary">Send CE30</button>
Set outside temperature to: <input id="itho_ce30_temp" type="number" min="-20" max="50" size="4" value="15"><br>
Optional temporary temperature: <input id="itho_ce30_temptemp" type="number" min="-20" max="50" size="4" value="0">
Valid until(timestamp) <input id="itho_ce30_timestamp" type="number" min="0" max="2147483647" size="12" value="0"><br>
<span>Result:&nbsp;</span><span id="itho_ce30_result"></span><br>
</fieldset><br><br><br>
</fieldset>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,14 @@ $(document).ready(function () {
value: parseFloat($('#itho_setting_value_set').val())
}));
}
else if ($(this).attr('id') == 'buttonCE30') {
websock.send(JSON.stringify({
ithobutton: 0xCE30,
ithotemp: parseFloat($('#itho_ce30_temp').val()*100.),
ithotemptemp: parseFloat($('#itho_ce30_temptemp').val()*100.),
ithotimestamp: $('#itho_ce30_timestamp').val()
}));
}
else if ($(this).attr('id') == 'ithogetsettings') {
settingIndex = 0;
websock.send(JSON.stringify({
Expand Down
4 changes: 4 additions & 0 deletions software/NRG_itho_wifi/main/websocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ static void wsEvent(struct mg_connection *c, int ev, void *ev_data, void *fn_dat
}
}
}
else if (val == 0xCE30)
{
setSettingCE30(root["ithotemptemp"].as<int16_t>(), root["ithotemp"].as<int16_t>(), root["ithotimestamp"].as<uint32_t>(), true);
}
}
else
{
Expand Down

0 comments on commit 271617b

Please sign in to comment.