Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bluetooth-low-energy): add RSSI and measuredPower to entity
Tuning BLE values is tricky if the measured RSSI and the measuredPower used for calculation are not visible anywhere. Putting them into the attributes would cause a lot of data to be constantly updated in the other integrations, so now they are just available in the API as an additional field of the entity. Closes #140, #177 and #203
- Loading branch information
Showing
4 changed files
with
87 additions
and
11 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/integrations/bluetooth-low-energy/bluetooth-low-energy-presence.sensor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { RoomPresenceDistanceSensor } from '../room-presence/room-presence-distance.sensor'; | ||
|
||
class BluetoothLowEnergyMeasurement { | ||
rssi: number; | ||
measuredPower: number; | ||
|
||
constructor(rssi: number, measuredPower: number) { | ||
this.rssi = rssi; | ||
this.measuredPower = measuredPower; | ||
} | ||
} | ||
|
||
export class BluetoothLowEnergyPresenceSensor extends RoomPresenceDistanceSensor { | ||
measuredValues: { [instance: string]: BluetoothLowEnergyMeasurement } = {}; | ||
|
||
handleNewMeasurement( | ||
instanceName: string, | ||
rssi: number, | ||
measuredPower: number, | ||
distance: number, | ||
outOfRange: boolean | ||
): void { | ||
this.measuredValues[instanceName] = new BluetoothLowEnergyMeasurement( | ||
rssi, | ||
measuredPower | ||
); | ||
this.handleNewDistance(instanceName, distance, outOfRange); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters