Skip to content

Commit

Permalink
remove DISCRETE, rename NAMUR to MECHANIC
Browse files Browse the repository at this point in the history
  • Loading branch information
dontsovcmc committed May 31, 2024
1 parent a9882a6 commit be1547c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
14 changes: 6 additions & 8 deletions ESP8266/data/input_setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,23 @@ <h2 id="input_color">Синий вход</h2>
<p class="text">Какой счётчик вы хотите подключить</p>
<p class="form-error hd"></p>
<div class="f-row">
<label for="counter_name">Тип счётчика</label>
<label for="counter_name">Что считает</label>
<select class="slct" id="counter_name" name="counter_name" option-value="%counter_name%">
<option selected="" value="0">Холодная вода</option>
<option value="1">Горячая вода</option>
<option selected="" value="0">Холодную воду</option>
<option value="1">Горячую воду</option>
<option value="2">Электричество</option>
<option value="3">Газ</option>
<option value="4">Тепло</option>
<option value="5">Питьевая вода</option>
<option value="5">Питьевую воду</option>
<option value="6">Другой</option>
</select>
<p class="error hd" id="counter_name-error">Некорректное значение</p>
</div>

<p class="text mt20">Выберите тип входа. Для механических счётчиков воды и газа выберите Намур, для других - Электронный</p>
<div class="f-row">
<label for="counter_type">Тип входа</label>
<label for="counter_type">Тип счётчика</label>
<select class="slct" id="counter_type" name="counter_type" option-value="%counter_type%">
<option selected="" value="0">Намур</option>
<option value="1">Дискретный</option>
<option selected="" value="0">Механический</option>
<option value="2">Электронный</option>
<option value="3">Датчик Холла (красный вход!)</option>
<option value="255">Выключен</option>
Expand Down
2 changes: 1 addition & 1 deletion ESP8266/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ lib_deps =
build_flags =
-DFIRMWARE_VERSION=${this.firmware_version}
-DLOG_FREE_HEAP
-DLOG_LEVEL_DEBUG ; LOG_LEVEL_INFO логирование в Serial
-DLOG_LEVEL_INFO ; LOG_LEVEL_INFO DLOG_LEVEL_DEBUG логирование в Serial
; -DDEBUG_ESP_WIFI
; -DDEBUG_ESP_CORE
; -DDEBUG_ESP_PORT=Serial
Expand Down
8 changes: 3 additions & 5 deletions ESP8266/src/ha/discovery_entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,15 @@ String build_entity_discovery(const char *mqtt_topic,

JsonArray options = json_doc.createNestedArray("options");

options.add("NAMUR");
options.add("DISCRETE");
options.add("MECHANIC");
options.add("ELECTRONIC");
options.add("HALL");
options.add("NOT_USED");

//"value_template": "{% set values = { \"0\":\"WATER_COLD\", \"1\":\"WATER_HOT\", \"2\":\"ELECTRO\", \"3\":\"GAS\", \"4\":\"HEAT\", \"5\":\"PORTABLE_WATER\", \"6\": \"OTHER\" } %} {{ values[ value_json.cname0 ] if value_json.cname0 in values.keys() else \"6\" }}",
//String value_template = String(F("{% set values = { '0':\"WATER_COLD\", '1':\"WATER_HOT\", '2':\"ELECTRO\", '3':\"GAS\", '4':\"HEAT\", '5':\"PORTABLE_WATER\", '6': \"OTHER\" } %} {{ values[ value_json.")) + entity_id + F(" ] if value_json.") + entity_id + F(" in values.keys() else '6' }}");
String value_template = String("") +
F("{% if value_json.") + entity_id + F("==0 %} NAMUR ") +
F("{% elif value_json.") + entity_id + F("==1 %} DISCRETE ") +
F("{% if value_json.") + entity_id + F("==0 %} MECHANIC ") +
F("{% elif value_json.") + entity_id + F("==2 %} ELECTRONIC ") +
F("{% elif value_json.") + entity_id + F("==3 %} HALL ") +
F("{% elif value_json.") + entity_id + F("==255 %} NOT_USED ") +
Expand All @@ -226,7 +224,7 @@ String build_entity_discovery(const char *mqtt_topic,
entity[F("val_tpl")] = value_template;

//"command_template": "{% set values = { \"WATER_COLD\":0, \"WATER_HOT\":1, \"ELECTRO\":2, \"GAS\":3, \"HEAT\":4, \"PORTABLE_WATER\":5, \"OTHER\":6} %} {{ values[value] if value in values.keys() else 6 }}",
String cmd_tpl = F("{% set values = { \"NAMUR\":0, \"DISCRETE\":1, \"ELECTRONIC\":2, \"HALL\":3, \"NOT_USED\":255} %} {{ values[value] if value in values.keys() else 255 }}");
String cmd_tpl = F("{% set values = { \"MECHANIC\":0, \"ELECTRONIC\":2, \"HALL\":3, \"NOT_USED\":255} %} {{ values[value] if value in values.keys() else 255 }}");
entity[F("cmd_tpl")] = cmd_tpl;

entity[F("optimistic")] = true; // optimistic
Expand Down

0 comments on commit be1547c

Please sign in to comment.