-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathopen.go
24 lines (20 loc) · 926 Bytes
/
open.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package nuki
import (
"context"
"fmt"
"github.com/tarent/go-nuki/communication"
"github.com/tarent/go-nuki/communication/command"
)
// PerformOpen will trigger the electric strike actuation to open the door and return the result.
func (c *Client) PerformOpen(ctx context.Context, appId command.ClientId) error {
return c.PerformOpenAction(ctx, appId, command.OpenActionElectricStrikeActuation)
}
// PerformOpenAction will request the connected and paired nuki opener to perform the given open action.
func (c *Client) PerformOpenAction(ctx context.Context, appId command.ClientId, action command.OpenAction) error {
if c.udioCom.GetDeviceType() != communication.DeviceTypeOpener {
return fmt.Errorf("unexpected device type: this operation is only available for opener")
}
return c.PerformAction(ctx, func(nonce []byte) command.Command {
return command.NewOpenAction(action, uint32(appId), 0, nil, nonce)
})
}