ngx-mqtt icon indicating copy to clipboard operation
ngx-mqtt copied to clipboard

Issue while getting Value not ack'd

Open th3112 opened this issue 2 years ago • 5 comments

Hi, I have a short Async procedure to get a value from ioBroker:

public async GetVal(topicname: string): Promise<string> {
    const source$: Observable<string> = this._mqttClt.observe(topicname, {qos: 1}).pipe(
      map((msg) => msg.payload.toString()),
      take(1)
    );
    let val = await lastValueFrom(source$);
    this.logMsg('GetVal >' + topicname + '< Value: >' + val + '<');
    return val;
  }

Unfortunately this only works if the Values has been set with Acknowledge. Otherwise this procedure will return noting.

Is there a way to get this also working for values that has been set without ACK? Or am I totally wrong and this not the right way?

Best regards Thomas

th3112 avatar Jan 23 '23 09:01 th3112