Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temperature sensor order in GUI and Home Assistant #57

Closed
nielsonm236 opened this issue Apr 14, 2021 · 5 comments
Closed

Temperature sensor order in GUI and Home Assistant #57

nielsonm236 opened this issue Apr 14, 2021 · 5 comments

Comments

@nielsonm236
Copy link
Owner

Right now temperature sensors are ordered according to their serial number.

But if a temperature sensor fails or is removed, this causes the remaining sensors to shift left in the order. And if that same sensor is repaired the sensors shift right into their original "serial number order". The shifting is confusing to the user and to automation.

Further, if a sensor fails and is replaced with a new sensor that has a different serial number it could end up anywhere in the serial number based order.

Is there a way to maintain the order of the sensors if one becomes intermittent?
And is there a way to allow the user to replace a sensor and force it to be in a given "slot" even though it may be out of order from a serial number perspective?

Initial answer: "Slots" for the sensors can be maintained in a table in Flash. A sensor that has gone missing can report a far out of range temperature like -185C, something obvious to the user as a missing sensor.

Being able to force a given order to the sensors that is not based on serial number ordering is more problematic. It would require some additional GUI interface - an item that is very expensive from a memory perspective. This will require some thought.

@nielsonm236
Copy link
Owner Author

A suggestion is that we use the two least significant bytes of the DS18B20 serial number as the Temperature Sensor identifier in the Browser and MQTT transmissions.
Thus, instead of Sensors numbered 1, 2, 3, 4, 5 we would have sensors numbered like this: 0123, 0ab3, abcd, d122, dd92 (just picked some random hex numbers for examples). The sensors would still appear in the browser in the order of their serial number (which is 48 bits, not just the 16 bits displayed in the example). But the advantage is that sensor 0123 would always be sensor 0123, even if it changed position in the display.
Likewise, MQTT based systems like Home Assistant would not see a sensor change its name even if it moved around in the "order". And there is very little effort in Home Assistant if someone completely replaces a sensor to adapt the HA displays to the new ID number.
While we would only use 4 hex characters (16 bits) instead of the entire 12 characters (48 bits) of the serial number as the identifier, in this application it is highly unlikely anyone will see a duplicate sensor ID number.
I think this is the best solution that has very little impact on code size. Open for comments if anyone has one.

@nielsonm236
Copy link
Owner Author

I'm moving ahead with the 4 character ID (based on the serial number) for the temperature sensors.

@nielsonm236
Copy link
Owner Author

This has been addressed and will be released soon. I will close the issue once the release number is identified.

@nielsonm236
Copy link
Owner Author

Further testing reveals that only using the least significant 16 bits of the serial number as the ID will not work. It looks like some DS18B20 manufacturers are incrementing the middle bytes of the serial number, and others have some other scheme but often leave the least significant bytes at the same value. So, we'll have to use the entire 48 bit serial number as the temperature sensor ID. This clutters the displays a bit, but is the most reliable approach.

nielsonm236 added a commit that referenced this issue May 9, 2021
Fixed Issue #55: Home Assistant; Auto Discovery; MQTT; Temp Sensors do not get deleted and redefined properly when added/removed
Fixed Issue #56: Temperature Sensor accuracy improvement
Fixed Issue #57: Temperature sensor order in GUI and Home Assistant. Fixed by changing Temperature Sensor ID’s from “1, 2, 3, 4, 5” to a 12 character ID per sensor that is based on the sensor serial number
Fixed Issue #58: Home Assistant; Auto Discovery; MQTT; Should a temperature sensor be deleted in HA if it fails during runtime?
Fixed Issue #62: Browser Only; Timers don’t work with Invert setting. Included in fix is a correction for “Timer values not saved correctly” and “Timer value being set to 256 in error”.
Fixed Issue #63: REST commands preventing IO Control page from making pin state changes.
Fixed Issue #66: MQTT doesn’t report temperature sensors
@nielsonm236
Copy link
Owner Author

Fixed with release 20210509 2031

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

No branches or pull requests

1 participant