This commit is contained in:
@@ -88,6 +88,7 @@ func (b *bridge) pushStateChange(ctx context.Context, deviceModel models.Device)
|
|||||||
b.luciferMillIDMap = make(map[int]int, 4)
|
b.luciferMillIDMap = make(map[int]int, 4)
|
||||||
b.millLuciferIDMap = make(map[int]int, 4)
|
b.millLuciferIDMap = make(map[int]int, 4)
|
||||||
}
|
}
|
||||||
|
subDomain := deviceModel.DriverProperties["subDomain"].(string)
|
||||||
|
|
||||||
if b.luciferMillIDMap[deviceModel.ID] == 0 {
|
if b.luciferMillIDMap[deviceModel.ID] == 0 {
|
||||||
millID, _ := strconv.Atoi(deviceModel.InternalID)
|
millID, _ := strconv.Atoi(deviceModel.InternalID)
|
||||||
@@ -100,8 +101,10 @@ func (b *bridge) pushStateChange(ctx context.Context, deviceModel models.Device)
|
|||||||
if deviceModel.State.Power {
|
if deviceModel.State.Power {
|
||||||
status = 1
|
status = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if subDomainIsGen2(subDomain) {
|
||||||
powerReq := deviceControlReqBody{
|
powerReq := deviceControlReqBody{
|
||||||
SubDomain: deviceModel.DriverProperties["subDomain"].(string),
|
SubDomain: subDomain,
|
||||||
DeviceID: b.luciferMillIDMap[deviceModel.ID],
|
DeviceID: b.luciferMillIDMap[deviceModel.ID],
|
||||||
TestStatus: 1,
|
TestStatus: 1,
|
||||||
Status: status,
|
Status: status,
|
||||||
@@ -121,6 +124,32 @@ func (b *bridge) pushStateChange(ctx context.Context, deviceModel models.Device)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
sd, _ := strconv.Atoi(subDomain)
|
||||||
|
|
||||||
|
tempReq := deviceControlGen3Body{
|
||||||
|
Operation: "SINGLE_CONTROL",
|
||||||
|
Status: status,
|
||||||
|
SubDomain: sd,
|
||||||
|
DeviceId: b.luciferMillIDMap[deviceModel.ID],
|
||||||
|
HoldTemp: deviceModel.State.Temperature,
|
||||||
|
}
|
||||||
|
err := b.command(ctx, "deviceControlGen3ForApp", tempReq, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
powerReq := deviceControlGen3Body{
|
||||||
|
Operation: "SWITCH",
|
||||||
|
Status: status,
|
||||||
|
SubDomain: sd,
|
||||||
|
DeviceId: b.luciferMillIDMap[deviceModel.ID],
|
||||||
|
}
|
||||||
|
err = b.command(ctx, "deviceControlGen3ForApp", powerReq, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -239,3 +268,15 @@ func addDefaultHeaders(req *http.Request) {
|
|||||||
req.Header.Add("X-Zc-Seq-Id", "1")
|
req.Header.Add("X-Zc-Seq-Id", "1")
|
||||||
req.Header.Add("X-Zc-Version", "1")
|
req.Header.Add("X-Zc-Version", "1")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var gen2subDomains = []string{"863", "5316", "5317", "5332", "5333", "6933"}
|
||||||
|
|
||||||
|
func subDomainIsGen2(subDomain string) bool {
|
||||||
|
for _, gen2sd := range gen2subDomains {
|
||||||
|
if subDomain == gen2sd {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|||||||
@@ -65,6 +65,14 @@ type deviceControlReqBody struct {
|
|||||||
PowerLevel int `json:"powerLevel"`
|
PowerLevel int `json:"powerLevel"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type deviceControlGen3Body struct {
|
||||||
|
Operation string `json:"operation"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
SubDomain int `json:"subDomain"`
|
||||||
|
DeviceId int `json:"deviceId"`
|
||||||
|
HoldTemp int `json:"holdTemp,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
var location *time.Location
|
var location *time.Location
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
Reference in New Issue
Block a user