Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierZal committed Dec 8, 2024
1 parent 79e1061 commit aa3f752
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
22 changes: 11 additions & 11 deletions drivers/base-device.mts
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,24 @@ export abstract class BaseMELCloudDevice<

#device?: IDeviceFacade<T>

protected abstract readonly EnergyReportRegular:
| (new (device: BaseMELCloudDevice<T>) => EnergyReportRegular<T>)
| null

protected abstract readonly EnergyReportTotal:
| (new (device: BaseMELCloudDevice<T>) => EnergyReportTotal<T>)
| null

protected abstract readonly fromDevice: Partial<
Record<keyof OpCapabilities<T>, ConvertFromDevice<T>>
>

protected abstract readonly thermostatMode: object | null

protected abstract toDevice: Partial<
Record<keyof SetCapabilities<T>, ConvertToDevice<T>>
>

protected abstract readonly EnergyReportRegular?: new (
device: BaseMELCloudDevice<T>,
) => EnergyReportRegular<T>

protected abstract readonly EnergyReportTotal?: new (
device: BaseMELCloudDevice<T>,
) => EnergyReportTotal<T>

protected abstract readonly thermostatMode?: object

public get id(): number {
return this.getData().id
}
Expand Down Expand Up @@ -337,7 +337,7 @@ export abstract class BaseMELCloudDevice<
}

#isThermostatModeSupportingOff(): boolean {
return this.thermostatMode !== undefined && 'off' in this.thermostatMode
return this.thermostatMode !== null && 'off' in this.thermostatMode
}

#registerCapabilityListeners(): void {
Expand Down
2 changes: 1 addition & 1 deletion drivers/melcloud_atw/device.mts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default class MELCloudDeviceAtw extends BaseMELCloudDevice<DeviceType.Atw
'thermostat_mode.zone2': convertFromDeviceOperationZone,
} as const

protected readonly thermostatMode = undefined
protected readonly thermostatMode = null

protected readonly toDevice: Partial<
Record<
Expand Down
4 changes: 2 additions & 2 deletions drivers/melcloud_erv/device.mts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import type {
} from '../../types/common.mts'

export default class MELCloudDeviceErv extends BaseMELCloudDevice<DeviceType.Erv> {
protected readonly EnergyReportRegular = undefined
protected readonly EnergyReportRegular = null

protected readonly EnergyReportTotal = undefined
protected readonly EnergyReportTotal = null

protected readonly fromDevice: Partial<
Record<
Expand Down
6 changes: 3 additions & 3 deletions widgets/charts/public/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const handleChartAndOptions = async (
}: { chart: HomeySettings['chart']; height: number; days?: number },
): Promise<ApexCharts.ApexOptions> => {
const hiddenSeries = (options.series ?? []).map((serie) =>
typeof serie === 'number' || serie.hidden !== true ? undefined : serie.name,
typeof serie === 'number' || serie.hidden !== true ? null : serie.name,
)
const newOptions = getChartOptions(
await getChartFunction(homey, chart)(days),
Expand All @@ -226,9 +226,9 @@ const handleChartAndOptions = async (
if (
hiddenSeries.some(
(name) =>
name !== undefined &&
name !== null &&
!(newOptions.series ?? [])
.map((serie) => (typeof serie === 'number' ? undefined : serie.name))
.map((serie) => (typeof serie === 'number' ? null : serie.name))
.includes(name),
)
) {
Expand Down

0 comments on commit aa3f752

Please sign in to comment.