|
@ -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,26 +101,54 @@ func (b *bridge) pushStateChange(ctx context.Context, deviceModel models.Device) |
|
|
if deviceModel.State.Power { |
|
|
if deviceModel.State.Power { |
|
|
status = 1 |
|
|
status = 1 |
|
|
} |
|
|
} |
|
|
powerReq := deviceControlReqBody{ |
|
|
|
|
|
SubDomain: deviceModel.DriverProperties["subDomain"].(string), |
|
|
|
|
|
DeviceID: b.luciferMillIDMap[deviceModel.ID], |
|
|
|
|
|
TestStatus: 1, |
|
|
|
|
|
Status: status, |
|
|
|
|
|
} |
|
|
|
|
|
err := b.command(ctx, "deviceControl", powerReq, nil) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tempReq := changeInfoReqBody{ |
|
|
|
|
|
DeviceID: b.luciferMillIDMap[deviceModel.ID], |
|
|
|
|
|
Value: deviceModel.State.Temperature, |
|
|
|
|
|
TimeZoneNum: "+02:00", |
|
|
|
|
|
Key: "holidayTemp", |
|
|
|
|
|
} |
|
|
|
|
|
err = b.command(ctx, "changeDeviceInfo", tempReq, nil) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
|
|
|
if subDomainIsGen2(subDomain) { |
|
|
|
|
|
powerReq := deviceControlReqBody{ |
|
|
|
|
|
SubDomain: subDomain, |
|
|
|
|
|
DeviceID: b.luciferMillIDMap[deviceModel.ID], |
|
|
|
|
|
TestStatus: 1, |
|
|
|
|
|
Status: status, |
|
|
|
|
|
} |
|
|
|
|
|
err := b.command(ctx, "deviceControl", powerReq, nil) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tempReq := changeInfoReqBody{ |
|
|
|
|
|
DeviceID: b.luciferMillIDMap[deviceModel.ID], |
|
|
|
|
|
Value: deviceModel.State.Temperature, |
|
|
|
|
|
TimeZoneNum: "+02:00", |
|
|
|
|
|
Key: "holidayTemp", |
|
|
|
|
|
} |
|
|
|
|
|
err = b.command(ctx, "changeDeviceInfo", tempReq, nil) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
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 |
|
|
|
|
|
} |