Skip to content

[1Wire] Fix not always showing 1-wire sensor & correct saving sensor - #5636

Merged
TD-er merged 8 commits into
letscontrolit:megafrom
TD-er:bugfix/1wire_show_sensors
Sep 16, 2026
Merged

TD-er merged 8 commits into
letscontrolit:megafrom
TD-er:bugfix/1wire_show_sensors

Conversation

@TD-er

@TD-er TD-er commented Sep 16, 2026

Copy link
Copy Markdown
Member

Fixes: #5309

@TD-er
TD-er merged commit b1ecd19 into letscontrolit:mega Sep 16, 2026
178 of 354 checks passed
@TD-er
TD-er deleted the bugfix/1wire_show_sensors branch September 16, 2026 21:58
@wutz-ESP

Copy link
Copy Markdown

ESP_Easy_mega_20260916_display_B_ESP32_4M316k

image

after submit

image

@TD-er

TD-er commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

And if you go then to another page and then load the task page again?
So no refresh after submitting, as you then submit again, but I want to make sure it is just a 'viewing' issue, not a saving issue.

@wutz-ESP

wutz-ESP commented Sep 17, 2026 •

Copy link
Copy Markdown

maybe option value is the problem

<option value=-1>- None -</option>
<option value=0>

in ESP_Easy_mega_20260916_display_B_ESP32_4M316k changed to

<option value='-1'>**- None -</option>
<option value='2954339766987260677'>28-ff-ec-5d-85-16-03-05 [DS18B20] (task 14 [TempSensor#temperature3])                                                                                                                <option value='2954314937781322897'>

in Firmware ESP_Easy_mega_20240822_normal_ESP32_4M316k_LittleFS_ETH

<div class='note'>Note: Auto Select can only be used for 1 Dallas sensor per GPIO pin.</div> <TR> <TD>Device Address 1:</td> <TD> <select class='wide' name='dallas_addr0' id='dallas_addr0'> <option value=-1>- None -</option> **<option value=0>**28-ff-10-0c-34-16-04-41 [DS18B20] (task 3 [TH#VL_Therme])</option> **<option value=1>**28-ff-a8-1d-34-16-04-87 [DS18B20] (task 1 [VL#HK_VL1])</option> **<option value=2 selected>**28-ff-38-5d-50-15-01-81 [DS18B20] (task 1 [VL#FB_VL])</option> <option value=3>28-ff-1c-aa-73-15-02-03 [DS18B20] (task 2 [RL#FB_RL])</option> <option value=4>28-ff-a2-77-74-15-03-56 [DS18B20] (task 2 [RL#HK_RL])</option> <option value=5>28-ff-b2-a9-73-15-02-1a [DS18B20] (task 4 [WW#SP300_VL])</option> <option value=6>28-ff-72-f2-00-17-03-b0 [DS18B20] (task 4 [WW#RLWW])</option> <option value=7>28-ff-8a-0c-34-16-04-4b [DS18B20] (task 5 [AT#Temp_Aussen])</option> <option value=8>28-ff-9a-39-73-15-02-3d [DS18B20] (task 2 [RL#FB_RL1])</option> <option value=9>28-ff-16-be-73-15-02-88 [DS18B20] (task 1 [VL#HK_VL])</option> <option value=10>28-ff-a1-39-73-15-02-c9 [DS18B20] (task 1 [VL#FB_VL1])</option> <option value=11>28-ff-a9-fd-00-17-03-04 [DS18B20] (task 4 [WW#VLWW])</option> <option value=12>28-ff-ed-1e-34-16-04-34 [DS18B20] (task 4 [WW#SP300_RL])</option> <option value=13>28-ff-1d-1a-50-15-03-71 [DS18B20] (task 3 [TH#RL_Therme])</option> </select>

Firmware ESP_Easy_mega_20260916_display_B_ESP32_4M316k

<div class='note'>Note: Auto Select can only be used for 1 Dallas sensor per GPIO pin.</div> <TR> <TD>Device Address 1:</td> <TD> <select class='wide' name='dallas_addr0' id='dallas_addr0'> **<option value='-1'>**- None -</option> **<option value='2954339766987260677'>**28-ff-ec-5d-85-16-03-05 [DS18B20] (task 14 [TempSensor#temperature3])</option> **<option value='2954314937781322897'>**28-ff-d5-c8-85-16-04-91 [DS18B20] (task 14 [TempSensor#temperature2])</option> **<option value='2954279688984724647' selected>**28-ff-b5-b9-85-16-04-a7 [DS18B20] (task 14 [TempSensor#temperature])</option> <option value='2954145144839209731'>28-ff-3b-5b-85-16-03-03 [DS18B20] (task 14 [TempSensor#temperature4])</option> </select> <TR> <TD>Device Address 2:</td> <TD> <select class='wide' name='dallas_addr1' id='dallas_addr1'> <option value='-1'>- None -</option> <option value='2954339766987260677'>28-ff-ec-5d-85-16-03-05 [DS18B20] (task 14 [TempSensor#temperature3])</option> <option value='2954314937781322897' selected>28-ff-d5-c8-85-16-04-91 [DS18B20] (task 14 [TempSensor#temperature2])</option> <option value='2954279688984724647'>28-ff-b5-b9-85-16-04-a7 [DS18B20] (task 14 [TempSensor#temperature])</option> <option value='2954145144839209731'>28-ff-3b-5b-85-16-03-03 [DS18B20] (task 14 [TempSensor#temperature4])</option> </select>

@wutz-ESP

wutz-ESP commented Sep 17, 2026 •

Copy link
Copy Markdown

And if you go then to another page and then load the task page again? So no refresh after submitting, as you then submit again, but I want to make sure it is just a 'viewing' issue, not a saving issue.

than it is loading normal and displaying the address - that is what i explained all the time

in firmware without that problem option value is numbered -1 to 0, 1, 2, 3, ...

<option value=-1>- None -</option>
<option value=0>28-ff-10-0c-34-16-04-41 [DS18B20] (task 3 [TH#VL_Therme])</option>
<option value=1>28-ff-a8-1d-34-16-04-87 [DS18B20] (task 1 [VL#HK_VL1])</option>
<option value=2 selected>28-ff-38-5d-50-15-01-81 [DS18B20] (task 1 [VL#FB_VL])</option>
<option value=3>28-ff-1c-aa-73-15-02-03 [DS18B20] (task 2 [RL#FB_RL])</option>
<option value=4>28-ff-a2-77-74-15-03-56 [DS18B20] (task 2 [RL#HK_RL])</option>
<option value=5>28-ff-b2-a9-73-15-02-1a [DS18B20] (task 4 [WW#SP300_VL])</option>
<option value=6>28-ff-72-f2-00-17-03-b0 [DS18B20] (task 4 [WW#RLWW])</option>
<option value=7>28-ff-8a-0c-34-16-04-4b [DS18B20] (task 5 [AT#Temp_Aussen])</option>
<option value=8>28-ff-9a-39-73-15-02-3d [DS18B20] (task 2 [RL#FB_RL1])</option>
<option value=9>28-ff-16-be-73-15-02-88 [DS18B20] (task 1 [VL#HK_VL])</option>
<option value=10>28-ff-a1-39-73-15-02-c9 [DS18B20] (task 1 [VL#FB_VL1])</option>
<option value=11>28-ff-a9-fd-00-17-03-04 [DS18B20] (task 4 [WW#VLWW])</option>
<option value=12>28-ff-ed-1e-34-16-04-34 [DS18B20] (task 4 [WW#SP300_RL])</option>
<option value=13>28-ff-1d-1a-50-15-03-71 [DS18B20] (task 3 [TH#RL_Therme])</option>
</select>

New one is option value is numbered -1 to 2954339766987260677, 2954314937781322897, 2954279688984724647, ...

<option value='-1'>- None -</option>
<option value='2954339766987260677'>28-ff-ec-5d-85-16-03-05 [DS18B20] (task 14 [TempSensor#temperature3])</option>
<option value='2954314937781322897'>28-ff-d5-c8-85-16-04-91 [DS18B20] (task 14 [TempSensor#temperature2])</option>
<option value='2954279688984724647' selected>28-ff-b5-b9-85-16-04-a7 [DS18B20] (task 14 [TempSensor#temperature])</option>
<option value='2954145144839209731'>28-ff-3b-5b-85-16-03-03 [DS18B20] (task 14 [TempSensor#temperature4])</option>
</select>

@TD-er

TD-er commented Sep 17, 2026 •

Copy link
Copy Markdown
Member Author

Yep, if you enter those long numbers in your calculator and convert to HEX, you will see a recognizable value.
But the '-1' might indeed be wrong here, as I parse the incoming values as an uint64_t

image

@wutz-ESP

Copy link
Copy Markdown

but in older firmware there is for first recognized sensor and then the hex value (28-ff-10-0c-34-16-04-41)

in new one this hex value is twice there and not the number of recognized sensor 0 (first), 1 (second), 2 (third), ...

@TD-er

TD-er commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

Hmm looking at this list you posted:

<option value=-1>- None -</option>
<option value=0>28-ff-10-0c-34-16-04-41 [DS18B20] (task 3 [TH#VL_Therme])</option>
<option value=1>28-ff-a8-1d-34-16-04-87 [DS18B20] (task 1 [VL#HK_VL1])</option>
<option value=2 selected>28-ff-38-5d-50-15-01-81 [DS18B20] (task 1 [VL#FB_VL])</option>
<option value=3>28-ff-1c-aa-73-15-02-03 [DS18B20] (task 2 [RL#FB_RL])</option>
<option value=4>28-ff-a2-77-74-15-03-56 [DS18B20] (task 2 [RL#HK_RL])</option>
<option value=5>28-ff-b2-a9-73-15-02-1a [DS18B20] (task 4 [WW#SP300_VL])</option>
<option value=6>28-ff-72-f2-00-17-03-b0 [DS18B20] (task 4 [WW#RLWW])</option>
<option value=7>28-ff-8a-0c-34-16-04-4b [DS18B20] (task 5 [AT#Temp_Aussen])</option>
<option value=8>28-ff-9a-39-73-15-02-3d [DS18B20] (task 2 [RL#FB_RL1])</option>
<option value=9>28-ff-16-be-73-15-02-88 [DS18B20] (task 1 [VL#HK_VL])</option>
<option value=10>28-ff-a1-39-73-15-02-c9 [DS18B20] (task 1 [VL#FB_VL1])</option>
<option value=11>28-ff-a9-fd-00-17-03-04 [DS18B20] (task 4 [WW#VLWW])</option>
<option value=12>28-ff-ed-1e-34-16-04-34 [DS18B20] (task 4 [WW#SP300_RL])</option>
<option value=13>28-ff-1d-1a-50-15-03-71 [DS18B20] (task 3 [TH#RL_Therme])</option>
</select>

I thought the order would be guaranteed to be the same, but I can't see any logical ordering in these numbers. At least not in the order they are posted here.
So I think setting the address as value is a good change, as that guarantees the correct behavior.

@TD-er

TD-er commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

but in older firmware there is for first recognized sensor and then the hex value (28-ff-10-0c-34-16-04-41)

in new one this hex value is twice there and not the number of recognized sensor 0 (first), 1 (second), 2 (third), ...

Yep that's what I changed, the smaller values (0...x) were indices of the order the sensor was found.
And then when saving, the scan was performed again and the submitted index was then used to pick the alledged address from the new scan results.

Now I add a 64-bit uint representation of that address as value, so I can literally decode the intended address from the value and there is no chance a new scan will result in a different ordered set of scan results.

@wutz-ESP

Copy link
Copy Markdown

### response on ESP8266

ESP8266

[bit]
<TR id='tr_err'>
<TD>Error State Value:</td>
<TD>
<select class='wide' name='err' id='err'>
<option value='0' selected>NaN</option>
<option value='1'>-127</option>
<option value='2'>0</option>
<option value='3'>125</option>
<option value='4'>Ignore</option>
</select>
<TR>
<TD></td>
<TD>
<div class='note'>Note: External pull up resistor is needed, see docs!</div>
<TR>
<TD colspan="2">
<H3>Statistics</H3>
</TD>
</TR>
<TR>
<TD>Data pin Rise Time:</td>
<TD>
1 [usec]
<TR>
<TD colspan="2">
<hr>
<TR>
<TD>Address:</td>
<TD>
28-ff-b5-b9-85-16-04-a7 [DS18B20]

<TR>
<TD>Resolution:</td>
<TD>
10

<TR>
<TD>Parasite Powered:</td>
<TD>
false

<TR>
<TD>Read Success:</td>
<TD>
67

<TR>
<TD>Sensor No Reply:</td>
<TD>
0

<TR>
<TD>Sensor Power Lost:</td>
<TD>
0
<TR>
<TD>Read CRC error:</td>
<TD>
0

<TR>
<TD>Read Retry:</td>
<TD>
0

<TR>
<TD>Read Failed:</td>
<TD>
0
<TR>
<TD colspan="2">
<hr>
<TR>
<TD>Address:</td>
<TD>
28-ff-d5-c8-85-16-04-91 [DS18B20]

<TR>
<TD>Resolution:</td>
<TD>
10

<TR>
<TD>Parasite Powered:</td>
<TD>
false
<TR>
<TD>Read Success:</td>
67

<TD>Sensor No Reply:</td>
<TD>
0

<TR>
<TD>Sensor Power Lost:</td>
<TD>
0

<TR>
<TD>Read CRC error:</td>
<TD>
0

<TR>
<TD>Read Retry:</td>
<TD>
0

<TR>
<TD>Read Failed:</td>
<TD>
0
<TR>
<TD colspan="2">
<hr>
<TR>
<TD>Address:</td>
<TD>
28-ff-ec-5d-85-16-03-05 [DS18B20]

<TR>
<TD>Resolution:</td>
<TD>
10

<TR>
<TD>Parasite Powered:</td>
<TD>
false

<TR>
<TD>Read Success:</td>
<TD>
67

<TR>
<TD>Sensor No Reply:</td>
<TD>
0

<TR>
<TD>Sensor Power Lost:</td>
<TD>
0
                                                                                                                                                                                                                                                                                                                                                                                            <TR>
<TD>Read CRC error:</td>
<TD>
0

<TR>
<TD>Read Retry:</td>
<TD>
0

<TR>
<TD>Read Failed:</td>
<TD>
0
<TR>
<TD colspan="2">
<hr>
<TR>
<TD>Address:</td>
<TD>
28-ff-3b-5b-85-16-03-03 [DS18B20]
                                                                                                                                                                                                                                                                                                                                                                                                                                    <TR>
<TD>Resolution:</td>
<TD>
10
                                                                                                                                                                                                                                                                                                                                                                                                                                            <TR>
<TD>Parasite Powered:</td>
<TD>
false

<TR>
<TD>Read Success:</td>
<TD>
67
                                                                                                                                                                                                                                                                                                                                                                                                                                                            <TR>
<TD>Sensor No Reply:</td>
<TD>
0

<TR>
<TD>Sensor Power Lost:</td>
<TD>
0

<TR>
<TD>Read CRC error:</td>
<TD>
0
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <TR>
<TD>Read Retry:</td>
<TD>
0
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <TR>
<TD>Read Failed:</td>
<TD>
0
<TR>
<TD colspan="2">
<H3>Output Configuration</H3>
</TD>
</TR>
<TR>
<TD>Number Output Values:</td>
<TD>
<select class='wide' name='pconfigIndex_2' id='pconfigIndex_2'>
<option value='1'>Single</option>
<option value='5'>Dual</option>
<option value='6'>Triple</option>
<option value='7' selected>Quad</option>
</select>
<TR>
<TD></td>
<TD>
<div class='note'>Note: Changing 'Number Output Values' may affect behavior of some controllers (e.g. Domoticz)</div>
<TR>
<TD colspan="2">
<H3>Data Acquisition</H3>
</TD>
</TR>
<TR id='tr_TVSE'>
<TD>Single event with all values:</td>
<TD>
<label class='container'>
&nbsp;<input type='checkbox' id='TVSE' name='TVSE'>
<span id='csTVSE' class='checkmark'></span>
</label>
<TR>
<TD></td>
<TD>
<div class='note'>Note: Unchecked: Send event per value. Checked: Send single event (TempSensor#All) containing all values</div>
<TR id='tr_TSDV'>
<TD>Show derived values:</td>
<TD>
<label class='container'>
&nbsp;<input type='checkbox' id='TSDV' name='TSDV'>
<span id='csTSDV' class='checkmark'></span>
</label>
<TR id='tr_TELD'>
<TD>Event &amp; Log derived values:</td>
<TD>
<label class='container'>
&nbsp;<input type='checkbox' id='TELD' name='TELD'>
<span id='csTELD' class='checkmark'></span>
</label>
<TR>
<TD colspan="2">
<hr>
<TR>
<TD>
Send to Controller <span style='font-size:20px; background: #00000000;'>&#10102;</span>
<div class='note'>(PiDome MQTT, enabled)</div>
<TD>
<table style='padding-left:0;'>
<TD style="width:50px;padding-left:0;">
<label class='container'>
&nbsp;<input type='checkbox' id='TDSD1' name='TDSD1'>
<span id='csTDSD1' class='checkmark'></span>
</label>
<TD>Send derived:
<label class='container'>
&nbsp;<input type='checkbox' id='TSND1' name='TSND1'>
<span id='csTSND1' class='checkmark' title='Send derived values'></span>
</label>
</table>
<TR>
Send to Controller <span style='font-size:20px; background: #00000000;'>&#10103;</span>
<div class='note'>(FHEM HTTP, enabled)</div>
<TD>
<table style='padding-left:0;'>
<TD style="width:50px;padding-left:0;">
<label class='container'>
&nbsp;<input type='checkbox' id='TDSD2' name='TDSD2'>
<span id='csTDSD2' class='checkmark'></span>
</label>
</table>
<TD>
Send to Controller <span style='font-size:20px; background: #00000000;'>&#10104;</span>
<div class='note'>(ESPEasy P2P Networking, enabled)</div>
<TD>
<table style='padding-left:0;'>
<TD style="width:50px;padding-left:0;">
<label class='container'>
&nbsp;<input type='checkbox' id='TDSD3' name='TDSD3'>
<span id='csTDSD3' class='checkmark'></span>
</label>

</table>
<TR>
<TD colspan="2">
<hr>
<TR id='tr_TDT'>
<TD>Interval:</td>
<TD>
<input class='widenumber' type='number' name='TDT' id='TDT' min=0 max=65535 value=60>
[sec]
<TR>
<TD colspan="2">
<H3>Values</H3>
</TD>
</TR>
</table>
<table class='normal'>
<TR>
<TH style='width:30px;' align='center'>#
<TH style='width:500px;'>Name</TH>

### on ESP32

ESP32

[bit]
<TR id='tr_err'>
<TD>Error State Value:</td>
<TD>
<select class='wide' name='err' id='err'>
<option value='0' selected>NaN</option>
<option value='1'>-127</option>
<option value='2'>0</option>
<option value='3'>125</option>
<option value='4'>Ignore</option>
</select>
<TR>
<TD colspan="2">
<H3>Output Configuration</H3>
</TD>
</TR>
<TR>
<TD>Number Output Values:</td>
<TD>
<select class='wide' name='pconfigIndex_2' id='pconfigIndex_2'>
<option value='1'>Single</option>
<option value='5' selected>Dual</option>
<option value='6'>Triple</option>
<option value='7'>Quad</option>
</select>
<TR>
<TD></td>
<TD>
<div class='note'>Note: Changing 'Number Output Values' may affect behavior of some controllers (e.g. Domoticz)</div>
<TR>
<TD colspan="2">
<H3>Data Acquisition</H3>
</TR>
<TR id='tr_TVSE'>
<TD>Single event with all values:</td>
<TD>
<label class='container'>
&nbsp;<input type='checkbox' id='TVSE' name='TVSE'>
<span id='csTVSE' class='checkmark'></span>
</label>
<TR>
<TD></td>
<TD>
<div class='note'>Note: Unchecked: Send event per value. Checked: Send single event (TempSensor#All) containing all values</div>
<TR>
<TD colspan="2">
<hr>
<TR id='tr_TDT'>
<TD>Interval:</td>
<TD>
<input class='widenumber' type='number' name='TDT' id='TDT' min=0 max=65535 value=30>
[sec]
<TR>
<TD colspan="2">
<H3>Values</H3>
</TD>
</TR>
</table>
<table class='normal'>
<TR>
<TH style='width:30px;' align='center'>#
<TH style='width:500px;'>Name</TH>

@TD-er

TD-er commented Sep 17, 2026 •

Copy link
Copy Markdown
Member Author

Not 100% sure what you try to tell me with that HTML.
It seems there is a section missing on the ESP32 part?

Is the task even enabled? (or has been running for a while to collect at least 1 measurement)

@wutz-ESP

Copy link
Copy Markdown

this part is missing in (browser) response at esp32 that is the difference to esp8266

the task is enabled at esp32 - esp8266 running a few minutes, esp32 running more than 1 hour after updating from 20260915 firmware

@wutz-ESP

wutz-ESP commented Sep 17, 2026 •

Copy link
Copy Markdown

Uptime: | 05h55m

Task edit
devices_esp32_first.htm

pressing submit
devices_esp32_submit.htm

reloading task by paste http://192.168.10.185/devices?index=14&page=1 to browser gives the addresses back

same thing Google Chrome, Firefox or Microsoft Edge

image

@TD-er

TD-er commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

OK, I think this might be a thing that has unintentionally become timing-critical as the bus is now not scanned when the page is reloaded after submitting.

When submitting a change on a task, the task is stopped and restarted again.
Previously when loading the page, there was also a full scan performed, which also initializes stuff in the plugin_data_struct for that plugin.
But now it might be things are not yet initialized when that section of the webpage is being rendered by ESPEasy.

I will have a look at it.

@TD-er

TD-er commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

Yep, no selector with the found modules on reload (ESP32 here)
image
And even after reload (without re-submit) the page:
image
It is working when setup, but not possible to setup right now.

@wutz-ESP

Copy link
Copy Markdown

yes, but resolution or error state can be changed and also only pressing submit clears device address

reloading page did not change this but loading device and then this task again or filling task-address in browser address bar an load -> work

this behavior is only on my unit´s esp32 - esp8266 work normal

@TD-er

TD-er commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

this behavior is only on my unit´s esp32 - esp8266 work normal

OK, this remark appears to be the actual clue to where the bug very likely is.
You stumbled upon a bug which would otherwise have been extremely hard to reproduce or find, as it seems to be a bug in the caching of the ExtraTaskSettings.

The stored 1-wire addresses are in the ExtraTaskSettings.
On ESP8266 this is always loaded from the settings, since that is quite fast to load from a SPIFFS file system and we don't have that much free memory on the ESP8266.
On ESP32, there is a quite elaborate cache mechanism with all kinds of optimizations to load stuff from the cache as fast as possible and only keep in memory what actually matters.

It seems like there is a bug in this caching for storing exactly those values as used for the 1-wire sensor addresses.
Maybe more bugs, but at least that's now under investigation.

So will keep you posted and please keep making those 'casual remarks' as they may seem unimportant, but they can also be just the clue I need to find the bug :)

@wutz-ESP

Copy link
Copy Markdown

sorry, for this late discovery
my other unit´s mostly using ethernet on esp32 and this time tested one esp8266 on my desk

@TD-er

TD-er commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

Not totally happy with the fix, but at least on my test system it now works...
See: #5637

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] DS18B20 Not Detected with New Firmware (ESP_Easy_mega_20250430 on WT32-ETH01)

2 participants