stheves / denon4j

A high-level Java API for interaction with Denon Audio Video receivers via TCP/IP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

masterVolume() returns OFF because events are not filtered by regex Condition

tuxBurner opened this issue · comments

When i try to get masterVolume() from my denon i always get the value OFF.

The reason for this is that my denon returns for some reason:

Event{asciiValue='SVOFF'}
Event{asciiValue='SVOFF'}
Event{asciiValue='MV53'}

when requesting: MV

My suggestion is to filter the events before picking the first one in io.theves.denon4j.DenonReceiver#send(java.lang.String, java.lang.String)

return send(command, Condition.regex(regex)) .stream() .filter(event -> event.asciiValue().matches(regex)) .findFirst().orElseThrow(() -> new TimeoutException( format("No response received after %s milliseconds. Receiver may be too busy to respond.", RECV_TIMEOUT) ));