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

Add timeout handling for RG15 #22768

Closed
wants to merge 7 commits into from
Closed

Conversation

Noschvie
Copy link
Contributor

@Noschvie Noschvie commented Jan 5, 2025

Description:

Add timeout handling for RG15 (rain sensor).

Related issue (if applicable): fixes #
Rainsensor Optical Rain Gauge RG-15 #22612

Checklist:

  • The pull request is done against the latest development branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • The code change is tested and works with Tasmota core ESP8266 V.2.7.8
  • The code change is tested and works with Tasmota core ESP32 V.3.1.0.241206
  • I accept the CLA.

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

tasmota/include/i18n.h Outdated Show resolved Hide resolved
// if the parsing wasn't completely successful then skip the update
if( !isnan(Rg15.acc) && !isnan(Rg15.event) && !isnan(Rg15.total) && !isnan(Rg15.rate) ) {
ResponseAppend_P(PSTR(",\"" RG15_NAME "\":{"));
ResponseAppend_P(PSTR("\"%s\":%s,"), D_JSON_VALID, &aString);
Copy link
Owner

Choose a reason for hiding this comment

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

How about

ResponseAppend_P(PSTR("\"%s\":%d,"), D_JSON_VALID, Rg15.isSensorAvailable);

and getting rid off BOOL_TO_STRING and supporting code.

ResponseAppend_P(PSTR("\"%s\":%2_f,"), D_JSON_ACTIVE, &Rg15.acc);
ResponseAppend_P(PSTR("\"%s\":%2_f,"), D_JSON_EVENT, &Rg15.event);
ResponseAppend_P(PSTR("\"%s\":%2_f,"), D_JSON_TOTAL, &Rg15.total);
ResponseAppend_P(PSTR("\"%s\":%2_f"), D_JSON_FLOWRATE, &Rg15.rate);
ResponseAppend_P(PSTR("}"));
} else {
Copy link
Owner

Choose a reason for hiding this comment

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

Pls remove the else clause; Having Valid with the other values makes enough sense (and saves code space).

@arendst
Copy link
Owner

arendst commented Jan 6, 2025

Thx.

Based on your work I will update the driver with your suggested functionality. You don't have to respond to the questions I asked today.

Hold on....

@arendst arendst self-assigned this Jan 6, 2025
arendst added a commit that referenced this pull request Jan 6, 2025
@arendst
Copy link
Owner

arendst commented Jan 6, 2025

(Some kind of) Merged in latest branch

@arendst arendst closed this Jan 6, 2025
@Noschvie
Copy link
Contributor Author

Noschvie commented Jan 6, 2025

Thanks!
However, if no sensor is connected or if it is not connected during boot, no "invalid" is sent. Right?

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.

2 participants