Skip to content

Commit

Permalink
Boiler specific settings
Browse files Browse the repository at this point in the history
- Added boiler specific settings to customaize iRT boiler
- correct typecast for external temp.
- changed default settings for WiFi to irt-esp
- added settings to calculate the gas-meter-reading based on the power of the bruner
- dallas sensors and shower device now also have config based on the mqtt-base
- added iRT "product-ID" 255 which will read boiler specific settings from flash
- changed boiler wWHeat to ww3wayValve
- added iRT commands to boiler test
  • Loading branch information
harrymayr committed Dec 16, 2022
1 parent 85b2de4 commit 40c996e
Show file tree
Hide file tree
Showing 24 changed files with 378 additions and 74 deletions.
6 changes: 3 additions & 3 deletions factory_settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ build_flags =
; WiFi settings
-D FACTORY_WIFI_SSID=\"\"
-D FACTORY_WIFI_PASSWORD=\"\"
-D FACTORY_WIFI_HOSTNAME=\"ems-esp\"
-D FACTORY_WIFI_HOSTNAME=\"irt-esp\"

; Access point settings
-D FACTORY_AP_PROVISION_MODE=AP_MODE_DISCONNECTED
-D FACTORY_AP_SSID=\"ems-esp\" ; 1-64 characters
-D FACTORY_AP_SSID=\"irt-esp\" ; 1-64 characters
-D FACTORY_AP_PASSWORD=\"ems-esp-neo\" ; 8-64 characters
-D FACTORY_AP_LOCAL_IP=\"192.168.4.1\"
-D FACTORY_AP_GATEWAY_IP=\"192.168.4.1\"
Expand Down Expand Up @@ -36,7 +36,7 @@ build_flags =
-D FACTORY_MQTT_PORT=1883
-D FACTORY_MQTT_USERNAME=\"\"
-D FACTORY_MQTT_PASSWORD=\"\"
-D FACTORY_MQTT_CLIENT_ID=\"ems-esp\"
-D FACTORY_MQTT_CLIENT_ID=\"irt\"
-D FACTORY_MQTT_KEEP_ALIVE=60
-D FACTORY_MQTT_CLEAN_SESSION=true
-D FACTORY_MQTT_MAX_TOPIC_LENGTH=128
Expand Down
22 changes: 16 additions & 6 deletions interface/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 78 additions & 2 deletions interface/src/project/EMSESPSettingsController.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import { ValidatorForm, TextValidator, SelectValidator } from 'react-material-ui-form-validator';

import { Checkbox, Typography, Box, Link } from '@material-ui/core';
import { Checkbox, TextField, Typography, Box, Link } from '@material-ui/core';
import SaveIcon from '@material-ui/icons/Save';
import MenuItem from '@material-ui/core/MenuItem';

Expand Down Expand Up @@ -301,7 +301,83 @@ function EMSESPSettingsControllerForm(props: EMSESPSettingsControllerFormProps)
<MenuItem value={4}>"ON""/"OFF""</MenuItem>
</SelectValidator>
<br></br>
<FormActions>
<Typography variant="h6" color="primary" >
Boiler-Settings
</Typography>
<SelectValidator name="usr_brand"
label="Boiler brand"
value={data.usr_brand}
fullWidth
variant="outlined"
onChange={handleValueChange('usr_brand')}
margin="normal">
<MenuItem value={0}>0 - not set/other</MenuItem>
<MenuItem value={1}>1 - Bosch</MenuItem>
<MenuItem value={2}>2 - Junkers</MenuItem>
<MenuItem value={3}>3 - Buderus</MenuItem>
<MenuItem value={4}>4 - Nefit</MenuItem>
<MenuItem value={5}>5 - Sieger</MenuItem>
<MenuItem value={11}>11 - Worcester</MenuItem>
</SelectValidator>
<TextField
name="usr_type"
label="Type of boiler (optional)"
fullWidth
variant="outlined"
value={data.usr_type}
onChange={handleValueChange('usr_type')}
margin="normal"
/>
<TextValidator
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:65535']}
errorMessages={['Min boiler power(Wh) is required', "Must be a number", "Must be 0 or higher", "Max value is 65000 (65kWh)"]}
name="min_boiler_wh"
label="Min boiler power (Wh, 0=not set)"
fullWidth
variant="outlined"
value={data.min_boiler_wh}
type="number"
onChange={handleValueChange('min_boiler_wh')}
margin="normal"
/>
<TextValidator
validators={['required', 'isNumber', 'minNumber:0', 'maxNumber:65535']}
errorMessages={['Max boiler power(Wh) is required', "Must be a number", "Must be 0 or higher", "Max value is 65000 (65kWh)"]}
name="max_boiler_wh"
label="Max boiler power (Wh, 0=not set)"
fullWidth
variant="outlined"
value={data.max_boiler_wh}
type="number"
onChange={handleValueChange('max_boiler_wh')}
margin="normal"
/>
<TextValidator
validators={['isNumber', 'minNumber:0', 'maxNumber:99999']}
errorMessages={["Must be a number", "Must be 0 or higher", "Max value is 99999 (99999 m³)"]}
name="gas_meter_reading"
label="Gas meter reading (m³, 0=not set)"
fullWidth
variant="outlined"
value={data.gas_meter_reading}
type="number"
onChange={handleValueChange('gas_meter_reading')}
margin="normal"
/>
<TextValidator
validators={['isNumber', 'minNumber:0', 'maxNumber:12000']}
errorMessages={["Must be a number", "Must be 0 or higher", "Max value is 12000"]}
name="conv_factor"
label="Conversion factor m³<-> Wh"
fullWidth
variant="outlined"
value={data.conv_factor}
type="number"
onChange={handleValueChange('conv_factor')}
margin="normal"
/>
<br></br>
<FormActions>
<FormButton startIcon={<SaveIcon />} variant="contained" color="primary" type="submit">
Save
</FormButton>
Expand Down
6 changes: 6 additions & 0 deletions interface/src/project/EMSESPtypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export interface EMSESPSettings {
api_enabled: boolean;
bool_format: number;
analog_enabled: boolean;
usr_brand: number;
usr_type: string;
min_boiler_wh: number;
max_boiler_wh: number;
gas_meter_reading: number;
conv_factor: number;
trace_raw: boolean;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/framework/APSettingsService.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#endif

#ifndef FACTORY_AP_SSID
#define FACTORY_AP_SSID "ems-esp"
#define FACTORY_AP_SSID "irt-esp"
#endif

#ifndef FACTORY_AP_PASSWORD
Expand Down
2 changes: 1 addition & 1 deletion lib/framework/MqttSettingsService.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#endif

#ifndef FACTORY_MQTT_BASE
#define FACTORY_MQTT_BASE "ems-esp"
#define FACTORY_MQTT_BASE "irt"
#endif

#ifndef FACTORY_MQTT_PORT
Expand Down
16 changes: 11 additions & 5 deletions lib_standalone/ESP8266React.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ class DummySettings {
uint8_t mqtt_format = 3; // 1=single, 2=nested, 3=ha, 4=custom
uint8_t mqtt_qos = 0;
bool mqtt_retain = false;
String base = "ems-esp";
String base ="irt-esp";
bool enabled = true; // MQTT
String hostname = "ems-esp";
String jwtSecret = "ems-esp";
String ssid = "ems-esp";
String password = "ems-esp";
String hostname = "irt-esp";
String jwtSecret = "irt-esp";
String ssid = "irt-esp";
String password = "irt-esp";
String localIP = "";
String gatewayIP = "";
String subnetMask = "";
Expand All @@ -47,6 +47,12 @@ class DummySettings {
uint16_t publish_time_other = 10;
uint16_t publish_time_sensor = 10;
uint8_t bool_format = 1; // on off
uint8_t usr_brand = 3; // BUDERUS
String usr_type = "";
uint16_t min_boiler_wh = 6600;
uint16_t max_boiler_wh = 24300;
uint32_t gas_meter_reading = 0;
uint16_t conv_factor = 10300;

static void read(DummySettings & settings, JsonObject & root){};
static void read(DummySettings & settings){};
Expand Down
35 changes: 35 additions & 0 deletions src/WebSettingsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ void WebSettings::read(WebSettings & settings, JsonObject & root) {
root["api_enabled"] = settings.api_enabled;
root["bool_format"] = settings.bool_format;
root["analog_enabled"] = settings.analog_enabled;
root["usr_brand"] = settings.usr_brand;
root["usr_type"] = settings.usr_type;
root["min_boiler_wh"] = settings.min_boiler_wh;
root["max_boiler_wh"] = settings.max_boiler_wh;
root["gas_meter_reading"] = settings.gas_meter_reading;
root["conv_factor"] = settings.conv_factor;
}

StateUpdateResult WebSettings::update(JsonObject & root, WebSettings & settings) {
Expand Down Expand Up @@ -129,6 +135,35 @@ StateUpdateResult WebSettings::update(JsonObject & root, WebSettings & settings)
if (crc_before != crc_after) {
add_flags(ChangeFlags::LED);
}
// iRT
snprintf_P(&crc_before[0],
crc_before.capacity() + 1,
PSTR("%d%s%d%d"),
settings.usr_brand,
settings.usr_type.c_str(),
settings.min_boiler_wh,
settings.max_boiler_wh,
settings.gas_meter_reading,
settings.conv_factor);
settings.usr_brand = root["usr_brand"] | EMSESP_DEFAULT_usr_brand;
settings.usr_type = root["usr_type"] | EMSESP_DEFAULT_usr_type;
settings.min_boiler_wh = root["min_boiler_wh"] | EMSESP_DEFAULT_MIN_BOILER_WH;
settings.max_boiler_wh = root["max_boiler_wh"] | EMSESP_DEFAULT_MAX_BOILER_WH;
settings.gas_meter_reading = root["gas_meter_reading"] | 0;
settings.conv_factor = root["conv_factor"] | EMSESP_DEFAULT_CONV_FACTOR;

snprintf_P(&crc_after[0],
crc_after.capacity() + 1,
PSTR("%d%s%d%d"),
settings.usr_brand,
settings.usr_type.c_str(),
settings.min_boiler_wh,
settings.max_boiler_wh,
settings.gas_meter_reading,
settings.conv_factor);
if (crc_before != crc_after) {
add_flags(ChangeFlags::OTHER);
}

// these both need reboots to be applied
settings.ems_bus_id = root["ems_bus_id"] | EMSESP_DEFAULT_EMS_BUS_ID;
Expand Down
11 changes: 11 additions & 0 deletions src/WebSettingsService.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
#define EMSESP_DEFAULT_API_ENABLED false // turn off, because its insecure
#define EMSESP_DEFAULT_BOOL_FORMAT 1 // on/off
#define EMSESP_DEFAULT_ANALOG_ENABLED false
#define EMSESP_DEFAULT_usr_brand EMSdevice::Brand::BUDERUS
#define EMSESP_DEFAULT_usr_type "UBA4000"
#define EMSESP_DEFAULT_MIN_BOILER_WH 0 // not set
#define EMSESP_DEFAULT_MAX_BOILER_WH 0 // not set
#define EMSESP_DEFAULT_CONV_FACTOR 10300

// Default GPIO PIN definitions
#if defined(ESP8266)
Expand Down Expand Up @@ -89,6 +94,12 @@ class WebSettings {
bool api_enabled;
uint8_t bool_format;
bool analog_enabled;
uint8_t usr_brand;
String usr_type;
uint16_t min_boiler_wh;
uint16_t max_boiler_wh;
uint32_t gas_meter_reading;
uint16_t conv_factor;

static void read(WebSettings & settings, JsonObject & root);
static StateUpdateResult update(JsonObject & root, WebSettings & settings);
Expand Down
9 changes: 9 additions & 0 deletions src/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,19 @@ void Command::add(const uint8_t device_type, const uint8_t device_id, const __Fl
void Command::add_with_json(const uint8_t device_type, const __FlashStringHelper * cmd, cmdfunction_json_p cb) {
// if the command already exists for that device type don't add it
if (find_command(device_type, uuid::read_flash_string(cmd).c_str()) != nullptr) {
#if defined(EMSESP_TEST)
LOG_DEBUG(F("Command %s found"), uuid::read_flash_string(cmd).c_str());
#endif
return;
}

#if defined(EMSESP_TEST)
LOG_DEBUG(F("Command %s add"), uuid::read_flash_string(cmd).c_str());
#endif
cmdfunctions_.emplace_back(device_type, cmd, nullptr, cb); // add command
#if defined(EMSESP_TEST)
LOG_DEBUG(F("Command %s added"), uuid::read_flash_string(cmd).c_str());
#endif
}

// see if a command exists for that device type
Expand Down
15 changes: 13 additions & 2 deletions src/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void EMSESPShell::stopped() {
void EMSESPShell::display_banner() {
println();
printfln(F("┌──────────────────────────────────────────┐"));
printfln(F("│ %sEMS-ESP version %-10s%s "), COLOR_BOLD_ON, EMSESP_APP_VERSION, COLOR_BOLD_OFF);
printfln(F("│ %sEMS/iRT-ESP version %-10s%s │"), COLOR_BOLD_ON, EMSESP_APP_VERSION, COLOR_BOLD_OFF);
printfln(F("│ %s%shttps://github.com/emsesp/EMS-ESP%s │"), COLOR_BRIGHT_GREEN, COLOR_UNDERLINE, COLOR_RESET);
printfln(F("│ │"));
printfln(F("│ type %shelp%s to show available commands │"), COLOR_UNDERLINE, COLOR_RESET);
Expand Down Expand Up @@ -114,7 +114,7 @@ void EMSESPShell::add_console_commands() {
CommandFlags::USER,
flash_string_vector{F_(show)},
[](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) {
shell.printfln(F("%s%sEMS-ESP version %s%s"), COLOR_BRIGHT_GREEN, COLOR_BOLD_ON, EMSESP_APP_VERSION, COLOR_RESET);
shell.printfln(F("%s%sEMS/iRT-ESP version %s%s"), COLOR_BRIGHT_GREEN, COLOR_BOLD_ON, EMSESP_APP_VERSION, COLOR_RESET);
shell.println();
EMSESP::show_device_values(shell);
EMSESP::show_sensor_values(shell);
Expand Down Expand Up @@ -243,6 +243,17 @@ void EMSESPShell::add_console_commands() {
shell.printfln(F_(master_thermostat_fmt),
settings.master_thermostat == 0 ? uuid::read_flash_string(F_(auto)).c_str()
: Helpers::hextoa(buffer, settings.master_thermostat));
for (const auto & emsdevice : EMSESP::emsdevices) {
if (emsdevice->device_type()==EMSdevice::DeviceType::BOILER) {
shell.printfln(F_(usr_brand_fmt),settings.usr_brand,
emsdevice->to_string_short().c_str());
shell.printfln(F_(usr_type_fmt),settings.usr_type);
shell.printfln(F_(min_boiler_wh_fmt),settings.min_boiler_wh);
shell.printfln(F_(max_boiler_wh_fmt),settings.max_boiler_wh);
shell.printfln(F_(gas_meter_reading_fmt),settings.gas_meter_reading);
shell.printfln(F_(conv_factor_fmt),settings.conv_factor);
}
}
});
});

Expand Down
27 changes: 13 additions & 14 deletions src/dallassensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,30 +361,29 @@ void DallasSensor::publish_values(const bool force) {
//StaticJsonDocument<EMSESP_MAX_JSON_SIZE_MEDIUM> config;
config["dev_cla"] = FJSON("temperature");

char stat_t[128];
snprintf_P(stat_t, sizeof(stat_t), PSTR("%s/dallassensor_data"), Mqtt::base().c_str());
config["stat_t"] = stat_t;
char temp[128];
snprintf_P(temp, sizeof(temp), PSTR("%s/dallassensor_data"), Mqtt::base().c_str());
config["stat_t"] = temp;

config["unit_of_meas"] = FJSON("°C");

char str[50];
snprintf_P(str, sizeof(str), PSTR("{{value_json.sensor%d.temp}}"), sensor_no);
config["val_tpl"] = str;
snprintf_P(temp, sizeof(temp), PSTR("{{value_json.sensor%d.temp}}"), sensor_no);
config["val_tpl"] = temp;

// name as sensor number not the long unique ID
snprintf_P(str, sizeof(str), PSTR("Dallas Sensor %d"), sensor_no);
config["name"] = str;
snprintf_P(temp, sizeof(temp), PSTR("Dallas Sensor %d"), sensor_no);
config["name"] = temp;

snprintf_P(str, sizeof(str), PSTR("dallas_%s"), sensor.to_string().c_str());
config["uniq_id"] = str;
snprintf_P(temp, sizeof(temp), PSTR("dallas_%s"), sensor.to_string().c_str());
config["uniq_id"] = temp;

JsonObject dev = config.createNestedObject("dev");
JsonArray ids = dev.createNestedArray("ids");
ids.add("ems-esp");
snprintf_P(temp, sizeof(temp), PSTR("%s"), Mqtt::base().c_str());
ids.add(temp);

std::string topic(100, '\0');
snprintf_P(&topic[0], 100, PSTR("homeassistant/sensor/ems-esp/dallas_%s/config"), sensor.to_string().c_str());
Mqtt::publish_ha(topic, config.as<JsonObject>());
snprintf_P(temp, sizeof(temp), PSTR("homeassistant/sensor/%s/dallas_%s/config"), Mqtt::base().c_str(), sensor.to_string().c_str());
Mqtt::publish_ha(temp, config.as<JsonObject>());

registered_ha_[sensor_no - 1] = true;
}
Expand Down
1 change: 1 addition & 0 deletions src/device_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
{211, DeviceType::BOILER, F("EasyControl Adapter"), DeviceFlags::EMS_DEVICE_FLAG_NONE},
{234, DeviceType::BOILER, F("Logamax Plus GB122"), DeviceFlags::EMS_DEVICE_FLAG_NONE},
{206, DeviceType::BOILER, F("Ecomline Excellent"), DeviceFlags::EMS_DEVICE_FLAG_NONE},
{255, DeviceType::BOILER, F("UBA 4000/4001"), DeviceFlags::EMS_DEVICE_FLAG_NONE},

// Controllers - 0x09 / 0x10 / 0x50
{ 68, DeviceType::CONTROLLER, F("BC10/RFM20"), DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x09
Expand Down
Loading

0 comments on commit 40c996e

Please sign in to comment.