Merge branch 'dev11' into dev

This commit is contained in:
MichaelDvP
2023-05-10 18:47:07 +02:00
162 changed files with 9895 additions and 7470 deletions

View File

@@ -119,8 +119,8 @@ const char * EMSdevice::device_type_2_device_name(const uint8_t device_type) {
return F_(connect);
case DeviceType::MIXER:
return F_(mixer);
case DeviceType::DALLASSENSOR:
return F_(dallassensor);
case DeviceType::TEMPERATURESENSOR:
return F_(temperaturesensor);
case DeviceType::ANALOGSENSOR:
return F_(analogsensor);
case DeviceType::CONTROLLER:
@@ -145,7 +145,7 @@ const char * EMSdevice::device_type_2_device_name(const uint8_t device_type) {
}
// returns the translated name of a specific EMS device
// excludes dallassensor, analogsensor and system
// excludes temperaturesensor, analogsensor and system
const char * EMSdevice::device_type_2_device_name_translated() {
switch (device_type_) {
case DeviceType::BOILER:
@@ -214,8 +214,8 @@ uint8_t EMSdevice::device_name_2_device_type(const char * topic) {
if (!strcmp(lowtopic, F_(mixer))) {
return DeviceType::MIXER;
}
if (!strcmp(lowtopic, F_(dallassensor))) {
return DeviceType::DALLASSENSOR;
if (!strcmp(lowtopic, F_(temperaturesensor))) {
return DeviceType::TEMPERATURESENSOR;
}
if (!strcmp(lowtopic, F_(analogsensor))) {
return DeviceType::ANALOGSENSOR;
@@ -520,7 +520,7 @@ void EMSdevice::add_device_value(uint8_t tag, // to b
// get fullname, getting translation if it exists
const char * const * fullname;
if (Helpers::count_items(name) == 1) {
fullname = nullptr; // no translations available, use empty
fullname = nullptr; // no translations available, use empty
} else {
fullname = &name[1]; // translations start at index 1
}
@@ -845,7 +845,7 @@ void EMSdevice::generate_values_web(JsonObject & output) {
JsonObject obj = data.createNestedObject(); // create the object, we know there is a value
uint8_t fahrenheit = 0;
// handle Booleans (true, false), use strings, no native true/false)
// handle Booleans (true, false), output as strings according to the user settings
if (dv.type == DeviceValueType::BOOL) {
auto value_b = (bool)*(uint8_t *)(dv.value_p);
char s[12];
@@ -929,20 +929,19 @@ void EMSdevice::generate_values_web(JsonObject & output) {
}
}
// handle INTs
// add steps to numeric values with numeric_operator
// add min and max values and steps, as integer values
else {
char s[10];
if (dv.numeric_operator > 0) {
obj["s"] = Helpers::render_value(s, (float)1 / dv.numeric_operator, 1);
obj["s"] = (float)1 / dv.numeric_operator;
} else if (dv.numeric_operator < 0) {
obj["s"] = Helpers::render_value(s, (float)(-1) * dv.numeric_operator, 0);
obj["s"] = (float)(-1) * dv.numeric_operator;
}
int16_t dv_set_min;
uint16_t dv_set_max;
if (dv.get_min_max(dv_set_min, dv_set_max)) {
obj["m"] = Helpers::render_value(s, dv_set_min, 0);
obj["x"] = Helpers::render_value(s, dv_set_max, 0);
obj["m"] = dv_set_min;
obj["x"] = dv_set_max;
}
}
}
@@ -1035,9 +1034,8 @@ void EMSdevice::generate_values_web_customization(JsonArray & output) {
int16_t dv_set_min;
uint16_t dv_set_max;
if (dv.get_min_max(dv_set_min, dv_set_max)) {
char s[10];
obj["mi"] = Helpers::render_value(s, dv_set_min, 0, fahrenheit);
obj["ma"] = Helpers::render_value(s, dv_set_max, 0, fahrenheit);
obj["mi"] = dv_set_min;
obj["ma"] = dv_set_max;
}
}
}
@@ -1312,7 +1310,7 @@ void EMSdevice::dump_value_info() {
if (dv.type == DeviceValueType::BOOL) {
snprintf(entityid, sizeof(entityid), "binary_sensor.%s", entity_with_tag); // binary sensor (for booleans)
} else {
snprintf(entityid, sizeof(entityid), "sensor.%s", entity_with_tag); // normal HA sensor
snprintf(entityid, sizeof(entityid), "sensor.%s", entity_with_tag); // normal HA sensor
}
}