Skip to content

Commit

Permalink
added AC night mode support
Browse files Browse the repository at this point in the history
  • Loading branch information
Binozo committed Aug 18, 2024
1 parent f0a09df commit 9796f62
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pkg/ac/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,31 @@ func (a *AC) GetIsTurboEnabled() (bool, error) {
return false, errors.New(fmt.Sprintf("dps index %s not contained in: %s", onDpsIndex, currentStatus))
}
}

func (a *AC) SetNightMode(nightMode bool) error {
if !a.IsConnected() {
if err := a.Connect(); err != nil {
return err
}
defer a.Disconnect()
}
return a.Set(map[string]interface{}{
onDpsIndex: true,
nightModeDpsIndex: nightMode,
})
}

func (a *AC) GetIsNightModeEnabled() (bool, error) {
if !a.IsConnected() {
if err := a.Connect(); err != nil {
return false, err
}
defer a.Disconnect()
}
currentStatus := a.GetCurrentStatus()
if nightValue, ok := currentStatus[nightModeDpsIndex]; ok {
return nightValue.(bool), nil
} else {
return false, errors.New(fmt.Sprintf("dps index %s not contained in: %s", onDpsIndex, currentStatus))
}
}
1 change: 1 addition & 0 deletions pkg/ac/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package ac
const onDpsIndex = "1"
const temperatureDpsIndex = "2"
const fanIntensityDpsIndex = "5" // Ranges from 1 to 4
const nightModeDpsIndex = "101"
const turboModeDpsIndex = "102"
const fanSwingDpsIndex = "104"

0 comments on commit 9796f62

Please sign in to comment.