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

[BUG] P001/P009/P019 do send bootstate differently #5122

Open
TD-er opened this issue Sep 15, 2024 · 1 comment
Open

[BUG] P001/P009/P019 do send bootstate differently #5122

TD-er opened this issue Sep 15, 2024 · 1 comment
Labels
Category: Plugin Related to supported sensors Type: Bug Considered a bug

Comments

@TD-er
Copy link
Member

TD-er commented Sep 15, 2024

When looking at the diffs of code between april and august build, it became clear that at least the implementation of P001 has changed regarding send bootstate.

Before, the uservar values were set after toggling the state and savePortStatus

This is referring to how the code was in April build:

bool GPIO_plugin_helper_data_t::init(
  struct EventStruct *event,
  int8_t              pinState,
  uint8_t             pinModeValue)
{
  // Read current status or create empty if it does not exist
  portStatusStruct newStatus = globalMapPortStatus[_portStatus_key];

  newStatus.state  = pinState;
  newStatus.output = newStatus.state; // FIXME TD-er: Is this correct to set output value based on pinState?
  newStatus.mode   = pinModeValue;

  // @giig1967g: if it is in the device list we assume it's an input pin
  // add this GPIO/port as a task
  if (newStatus.task < 3) {
    newStatus.task++;
  }

  // if boot pinState must be send, inverse default pinState
  // this is done to force the trigger in PLUGIN_TEN_PER_SECOND
  if (_sendBootState) {
    newStatus.state = !newStatus.state;

    if (_pluginNumber == PLUGIN_GPIO) {
      // FIXME TD-er: This was only done in P001, should this be done for PCF/MCP too?
      // Or maybe this is wrong to do for internal GPIO?
      newStatus.output = !newStatus.output;
    }
  }

  // setPinState(PLUGIN_ID_009, _mcpPin, PIN_MODE_INPUT, switchstate[event->TaskIndex]);
  savePortStatus(_portStatus_key, newStatus);

  // @giig1967g-20181022: set initial UserVar of the switch
  if ((newStatus.state != -1) && Settings.TaskDevicePin1Inversed[event->TaskIndex]) {
    UserVar.setFloat(event->TaskIndex, 0, !newStatus.state);
  } else {
    UserVar.setFloat(event->TaskIndex, 0, newStatus.state);
  }

  return true;
}

However the current implementation is more like how it was done in P009 and P019.
It is not sure which one is correct, but @thomastech reported some change in behavior which could be worked around by unchecking sendBootState.

@TD-er TD-er added Type: Bug Considered a bug Category: Plugin Related to supported sensors labels Sep 15, 2024
@TD-er
Copy link
Member Author

TD-er commented Sep 16, 2024

Applied suggested fix in this PR: #5124

So now the implementation of sending bootstates has been changed for P009 and P019 compared to the April build.

We still need to check if those bootstates are now sent correctly for those GPIO expanders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Plugin Related to supported sensors Type: Bug Considered a bug
Projects
None yet
Development

No branches or pull requests

1 participant