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

[shelly] Fix UNI support up to three DS18B20 sensors #15530

Merged
merged 1 commit into from
Oct 8, 2023

Conversation

bofakin
Copy link
Contributor

@bofakin bofakin commented Aug 31, 2023

Description

For the Shelly UNI a small fix needs to be applied to the JSON that is received form the device. When two or more temperature sensors are attached, the array is not sorted and the sensor "1" is first, causes the string replacement to fail.

With this patch all tree possible variants are checked, so that the JSON fix is applied for all possible sortings.

Note: The Shelly UNI supports only up to three DS18B20.

Testing

Here is the build artifact:
https://openhab.jfrog.io/artifactory/libs-pullrequest-local/org/openhab/addons/bundles/org.openhab.binding.shelly/4.1.0-SNAPSHOT/org.openhab.binding.shelly-4.1.0-SNAPSHOT.jar

Installed and tested on my local system - Shelly gets ONLINE and all three DS18B20 are detected and working.

Note: This is my first pull request, I hope I'll got everything correct.

… in order

Signed-off-by: Anton Hattendorf <anton@hattendoerfer.de>
@jlaur jlaur linked an issue Sep 3, 2023 that may be closed by this pull request
@lsiepel lsiepel added the bug An unexpected problem or unintended behavior of an add-on label Sep 4, 2023
@lsiepel lsiepel changed the title [shelly] Fix openhab#15514: UNI with three DS18B20 sensors doesn't initialize [shelly] Fix UNI support up to three DS18B20 sensors Sep 4, 2023
Copy link
Contributor

@lsiepel lsiepel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lolodomo
Copy link
Contributor

lolodomo commented Sep 9, 2023

@markus7017: could you please review ?

Comment on lines +131 to +132
if (json.contains("\"ext_temperature\":{\"0\":[{") || json.contains("\"ext_temperature\":{\"1\":[{")
|| json.contains("\"ext_temperature\":{\"2\":[{")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this be sufficient ?

if (json.contains("\"ext_temperature\":{\"")) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't tell.

I assume there was a reason, the JSON string is checked including the array index. So I just added the two other possible cases, but keeping as close to the original condition as possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's wait for @markus7017 feedback

@lolodomo
Copy link
Contributor

@markus7017 : are you there ?

@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/oh4-runs-out-of-memory/148699/66

@markus7017
Copy link
Contributor

LGTM
thanks @bofakin

@lolodomo lolodomo merged commit f1ccd72 into openhab:main Oct 8, 2023
3 checks passed
@lolodomo lolodomo added this to the 4.1 milestone Oct 8, 2023
pat-git023 pushed a commit to pat-git023/openhab-addons that referenced this pull request Oct 13, 2023
… in order (openhab#15530)

Signed-off-by: Anton Hattendorf <anton@hattendoerfer.de>
querdenker2k pushed a commit to querdenker2k/openhab-addons that referenced this pull request Oct 21, 2023
… in order (openhab#15530)

Signed-off-by: Anton Hattendorf <anton@hattendoerfer.de>
querdenker2k pushed a commit to querdenker2k/openhab-addons that referenced this pull request Oct 29, 2023
… in order (openhab#15530)

Signed-off-by: Anton Hattendorf <anton@hattendoerfer.de>
Signed-off-by: querdenker2k <querdenker2k@gmx.de>
austvik pushed a commit to austvik/openhab-addons that referenced this pull request Mar 27, 2024
… in order (openhab#15530)

Signed-off-by: Anton Hattendorf <anton@hattendoerfer.de>
Signed-off-by: Jørgen Austvik <jaustvik@acm.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[shelly] UNI with three DS18B20 sensors doesn't initialize
5 participants