Skip to content

Commit

Permalink
fix: Add serial number (#62)
Browse files Browse the repository at this point in the history
Use device id as unique serial number for the device
  • Loading branch information
nt0xa authored Jan 19, 2021
1 parent 0b9f529 commit 85db74a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/devices/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export async function createHumidifier(

return new BaseHumidifier(
protocol,
[...feat.accessoryInfo(model), ...feats],
[...feat.accessoryInfo(model, device.id), ...feats],
new Logger(log, `[${address}] `),
);
}
Expand Down
8 changes: 7 additions & 1 deletion src/devices/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type AnyCharacteristicConfig<PropsType> = CharacteristicConfig<
export interface Features<PropsType extends BasePropsType> {
accessoryInfo(
model: HumidifierModel,
deviceId: number,
): Array<AnyCharacteristicConfig<PropsType>>;

currentState<PropKey extends keyof PropsType>(
Expand Down Expand Up @@ -128,7 +129,7 @@ export function features<PropsType extends BasePropsType>(
log: hb.Logging,
): Features<PropsType> {
return {
accessoryInfo(model) {
accessoryInfo(model, deviceId) {
return [
{
service: Service.AccessoryInformation,
Expand All @@ -140,6 +141,11 @@ export function features<PropsType extends BasePropsType>(
characteristic: Characteristic.Model,
value: model,
},
{
service: Service.AccessoryInformation,
characteristic: Characteristic.SerialNumber,
value: `${deviceId}`,
},
];
},

Expand Down

0 comments on commit 85db74a

Please sign in to comment.