This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@ import (
|
||||
func main() {
|
||||
db := config.DBX().DB
|
||||
|
||||
log.Printf("Target version: %s",time.Now().Format("20060102150405"))
|
||||
log.Printf("Target version: %s", time.Now().Format("20060102150405"))
|
||||
log.Printf("Database: %s:%d/%s", config.MySqlHost(), config.MySqlPort(), config.MySqlSchema())
|
||||
log.Printf("Authenticating as: %s", config.MySqlUsername())
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ func (b *bridge) pushStateChange(ctx context.Context, deviceModel models.Device)
|
||||
b.luciferMillIDMap = make(map[int]int, 4)
|
||||
b.millLuciferIDMap = make(map[int]int, 4)
|
||||
}
|
||||
subDomain := deviceModel.DriverProperties["subDomain"].(string)
|
||||
|
||||
if b.luciferMillIDMap[deviceModel.ID] == 0 {
|
||||
millID, _ := strconv.Atoi(deviceModel.InternalID)
|
||||
@@ -100,26 +101,54 @@ func (b *bridge) pushStateChange(ctx context.Context, deviceModel models.Device)
|
||||
if deviceModel.State.Power {
|
||||
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
|
||||
@@ -239,3 +268,15 @@ func addDefaultHeaders(req *http.Request) {
|
||||
req.Header.Add("X-Zc-Seq-Id", "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"`
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
func init() {
|
||||
|
||||
Reference in New Issue
Block a user