mirror of
https://github.com/MickMake/GoSungrow.git
synced 2025-04-11 13:20:28 +02:00
v3.0.0-alpha - MQTT fixes
This commit is contained in:
parent
25c9146d11
commit
1ad86d4395
54
.idea/workspace.xml
generated
54
.idea/workspace.xml
generated
@ -5,7 +5,15 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="76adadc9-ae71-42a6-82a1-66dbc8ecb14c" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cmd/cmd_mqtt.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_mqtt.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/getPsList/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/getPsList/data.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/point.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/point.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/struct_data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/struct_data.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/data.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/highlevel_ps.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/highlevel_ps.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/mmHa/binary_sensor.go" beforeDir="false" afterPath="$PROJECT_DIR$/mmHa/binary_sensor.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/mmHa/struct.go" beforeDir="false" afterPath="$PROJECT_DIR$/mmHa/struct.go" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -79,7 +87,7 @@
|
||||
<configuration name="GoSungrow" type="GoApplicationRunConfiguration" factoryName="Go Application">
|
||||
<module name="GoSungrow" />
|
||||
<working_directory value="$PROJECT_DIR$" />
|
||||
<parameters value="show device points" />
|
||||
<parameters value="mqtt run" />
|
||||
<envs>
|
||||
<env name="GOCACHE" value="/Volumes/Media/GoCache" />
|
||||
</envs>
|
||||
@ -135,12 +143,12 @@
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/cmd/cmd_mqtt.go</url>
|
||||
<line>326</line>
|
||||
<line>333</line>
|
||||
<option name="timeStamp" value="437" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/cmd/cmd_mqtt.go</url>
|
||||
<line>325</line>
|
||||
<line>332</line>
|
||||
<option name="timeStamp" value="446" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
@ -228,11 +236,6 @@
|
||||
<line>669</line>
|
||||
<option name="timeStamp" value="4201" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/mmHa/binary_sensor.go</url>
|
||||
<line>34</line>
|
||||
<option name="timeStamp" value="4666" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/mmHa/binary_sensor.go</url>
|
||||
<line>103</line>
|
||||
@ -273,21 +276,6 @@
|
||||
<line>280</line>
|
||||
<option name="timeStamp" value="5999" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/cmd/cmd_mqtt.go</url>
|
||||
<line>387</line>
|
||||
<option name="timeStamp" value="6316" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/cmd/cmd_mqtt.go</url>
|
||||
<line>381</line>
|
||||
<option name="timeStamp" value="6395" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/cmd/cmd_mqtt.go</url>
|
||||
<line>409</line>
|
||||
<option name="timeStamp" value="6436" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go</url>
|
||||
<line>83</line>
|
||||
@ -365,7 +353,7 @@
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go</url>
|
||||
<line>637</line>
|
||||
<line>627</line>
|
||||
<option name="timeStamp" value="7135" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
@ -513,11 +501,6 @@
|
||||
<line>506</line>
|
||||
<option name="timeStamp" value="7958" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go</url>
|
||||
<line>325</line>
|
||||
<option name="timeStamp" value="7960" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go</url>
|
||||
<line>675</line>
|
||||
@ -605,7 +588,7 @@
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go</url>
|
||||
<line>485</line>
|
||||
<line>475</line>
|
||||
<option name="timeStamp" value="8080" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
@ -625,12 +608,12 @@
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go</url>
|
||||
<line>591</line>
|
||||
<line>581</line>
|
||||
<option name="timeStamp" value="8129" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go</url>
|
||||
<line>509</line>
|
||||
<line>499</line>
|
||||
<option name="timeStamp" value="8144" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
@ -658,6 +641,11 @@
|
||||
<line>139</line>
|
||||
<option name="timeStamp" value="8165" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/cmd/cmd_mqtt.go</url>
|
||||
<line>295</line>
|
||||
<option name="timeStamp" value="8197" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
<default-breakpoints>
|
||||
<breakpoint type="DlvErrorBreakpoint" />
|
||||
|
@ -159,21 +159,15 @@ func (ca *Cmds) MqttArgs(_ *cobra.Command, _ []string) error {
|
||||
}
|
||||
|
||||
cmdLog.LogPrintDate("Connecting to SunGrow...\n")
|
||||
// ca.Mqtt.Client.SungrowDevices, ca.Error = ca.Api.SunGrow.GetDevices()
|
||||
fmt.Println("FIX THIS UP")
|
||||
fmt.Println("FIX THIS UP")
|
||||
fmt.Println("FIX THIS UP")
|
||||
fmt.Println("FIX THIS UP")
|
||||
fmt.Println("FIX THIS UP")
|
||||
fmt.Println("FIX THIS UP")
|
||||
fmt.Println("FIX THIS UP")
|
||||
fmt.Println("FIX THIS UP")
|
||||
time.Sleep(time.Hour * 24)
|
||||
ca.Mqtt.Client.SungrowDevices, ca.Error = ca.Api.SunGrow.GetDeviceList()
|
||||
// ca.Mqtt.Client.SungrowDevices, ca.Error = ca.Api.SunGrow.GetPsKeys()
|
||||
// ca.Mqtt.Client.SungrowDevices, ca.Error = ca.Api.SunGrow.GetPsIds()
|
||||
// ca.Mqtt.Client.SungrowDevices, ca.Error = ca.Api.SunGrow.GetPsTreeMenu()
|
||||
if ca.Error != nil {
|
||||
break
|
||||
}
|
||||
cmdLog.LogPrintDate("Found SunGrow %d devices\n", len(ca.Mqtt.Client.SungrowDevices))
|
||||
|
||||
cmdLog.LogPrintDate("Found SunGrow %d devices\n", len(ca.Mqtt.Client.SungrowDevices))
|
||||
ca.Mqtt.Client.DeviceName = "GoSungrow"
|
||||
ca.Error = ca.Mqtt.Client.SetDeviceConfig(
|
||||
ca.Mqtt.Client.DeviceName,
|
||||
@ -219,6 +213,19 @@ func (ca *Cmds) MqttArgs(_ *cobra.Command, _ []string) error {
|
||||
if ca.Error != nil {
|
||||
break
|
||||
}
|
||||
ca.Error = ca.Mqtt.Client.SetDeviceConfig(
|
||||
"GoSungrow",
|
||||
"GoSungrow",
|
||||
psId.PsId.String(),
|
||||
psId.FactoryName.Value(),
|
||||
psId.FactoryName.Value(),
|
||||
psId.FactoryName.Value(),
|
||||
"Roof",
|
||||
)
|
||||
if ca.Error != nil {
|
||||
break
|
||||
}
|
||||
|
||||
ca.Mqtt.Client.SungrowPsIds[psId.PsId] = true
|
||||
}
|
||||
|
||||
@ -362,7 +369,7 @@ func (ca *Cmds) MqttCron() error {
|
||||
break
|
||||
}
|
||||
|
||||
All := []string{ "queryDeviceList", "getPsList", "getPsDetailWithPsType", "getPsDetail"} //, queryMutiPointDataList, getDevicePointMinuteDataList }
|
||||
All := []string{ "queryDeviceList", "getPsList", "getPsDetailWithPsType", "getPsDetail", "getKpiInfo"} //, queryMutiPointDataList, getDevicePointMinuteDataList }
|
||||
// All := []string{ "queryDeviceList", "WebIscmAppService.queryDeviceListForBackSys", "WebIscmAppService.getDeviceModel" }
|
||||
// All := []string{ "WebIscmAppService.getDeviceModel" }
|
||||
data.SetEndpoints(All...)
|
||||
@ -374,7 +381,8 @@ func (ca *Cmds) MqttCron() error {
|
||||
// results := data.GetResults()
|
||||
|
||||
for _, result := range data.Results {
|
||||
ca.Error = result.ProcessMapForMqtt()
|
||||
// ca.Error = result.ProcessMapForMqtt()
|
||||
ca.Error = result.Process()
|
||||
if ca.Error != nil {
|
||||
continue
|
||||
}
|
||||
@ -403,14 +411,16 @@ func (ca *Cmds) Update(endpoint string, data api.DataMap, newDay bool) error {
|
||||
entries := data.Map[o]
|
||||
r := entries.GetEntry(api.LastEntry) // Gets the last entry
|
||||
|
||||
if strings.Contains(r.Current.FieldPath.String(), "AllFactoryList") {
|
||||
fmt.Printf("")
|
||||
}
|
||||
|
||||
fullId := r.EndPoint
|
||||
if r.Point.GroupName == "alias" {
|
||||
fullId = mmHa.JoinStringsForId(r.Parent.Key, r.Point.Parents.Index[0], r.Point.Id)
|
||||
}
|
||||
if r.Point.Unit == "" {
|
||||
r.Point.Unit = r.Point.ValueType
|
||||
}
|
||||
if r.Point.Unit == "Bool" {
|
||||
r.Point.Unit = mmHa.LabelBinarySensor
|
||||
}
|
||||
|
||||
re := mmHa.EntityConfig {
|
||||
Name: mmHa.JoinStringsForName(" - ", fullId), // r.Point.Name, // PointName,
|
||||
@ -435,7 +445,7 @@ func (ca *Cmds) Update(endpoint string, data api.DataMap, newDay bool) error {
|
||||
}
|
||||
|
||||
if !r.Point.Valid {
|
||||
cmdLog.LogPrintDate("[%s] - invalid value - %s ...\n", r.Current.FieldPath.String(), r.Value.String()[:80])
|
||||
cmdLog.LogPrintDate("\n[%s] - invalid value - %s ...\n", r.Current.FieldPath.String(), r.Value.String())
|
||||
// re.Value = r.Value.String()
|
||||
// // var mapIt map[string]string
|
||||
// // ca.Error = json.Unmarshal([]byte(r.Value.String()), &mapIt)
|
||||
@ -446,6 +456,10 @@ func (ca *Cmds) Update(endpoint string, data api.DataMap, newDay bool) error {
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.Contains(r.Current.DataStructure.Endpoint.String(), "active") {
|
||||
fmt.Printf("")
|
||||
}
|
||||
|
||||
if newDay {
|
||||
fmt.Printf("C")
|
||||
ca.Error = ca.Mqtt.Client.BinarySensorPublishConfig(re)
|
||||
|
@ -25,7 +25,7 @@ func (rd RequestData) Help() string {
|
||||
}
|
||||
|
||||
type ResultData struct {
|
||||
PageList []Common.Device `json:"pageList" PointId:"page_list"`
|
||||
PageList []Common.Device `json:"pageList" PointId:"devices"`
|
||||
RowCount valueTypes.Count `json:"rowCount" PointId:"row_count"`
|
||||
}
|
||||
|
||||
|
@ -630,6 +630,10 @@ func (t *PsKeys) MatchString(pskey string) bool {
|
||||
return yes
|
||||
}
|
||||
|
||||
func (t *PsKeys) Length() int {
|
||||
return len(t.PsKeys)
|
||||
}
|
||||
|
||||
func SetPsKeysString(values string) PsKeys {
|
||||
var t PsKeys
|
||||
t.Set(strings.Split(values, ",")...)
|
||||
|
@ -291,11 +291,6 @@ func (dm *DataMap) ProcessMap() {
|
||||
when = valueTypes.SetDateTimeValue(dm.TimeStamp)
|
||||
}
|
||||
|
||||
// pdi := dm.parentDeviceId
|
||||
// if Child.DataStructure.PointDevice != "" {
|
||||
// pdi = Child.DataStructure.PointDevice
|
||||
// }
|
||||
|
||||
dm.AddPointUnitValues(Child, dm.parentDeviceId, when)
|
||||
}
|
||||
|
||||
@ -312,11 +307,6 @@ func (dm *DataMap) ProcessMap() {
|
||||
when = valueTypes.SetDateTimeValue(dm.TimeStamp)
|
||||
}
|
||||
|
||||
// pdi := dm.parentDeviceId
|
||||
// if Child.DataStructure.PointDevice != "" {
|
||||
// pdi = Child.DataStructure.PointDevice
|
||||
// }
|
||||
|
||||
if Child.DataStructure.PointVirtualShift > 0 {
|
||||
Child.DataStructure.Endpoint.ShiftLeft(Child.DataStructure.PointVirtualShift)
|
||||
Child.DataStructure.Endpoint.InsertFirst("virtual")
|
||||
@ -328,48 +318,48 @@ func (dm *DataMap) ProcessMap() {
|
||||
}
|
||||
}
|
||||
|
||||
func (dm *DataMap) ProcessMapForMqtt() {
|
||||
for range Only.Once {
|
||||
// Convert StructMap to DataMap
|
||||
for _, Child := range dm.StructMap.Map {
|
||||
if Child.IsPointIgnore() {
|
||||
fmt.Printf("[%s] - IGNORE\n", Child.FieldPath.String())
|
||||
continue
|
||||
}
|
||||
|
||||
if Child.CurrentReflect.IsPointListFlatten() {
|
||||
// fmt.Printf("[%s] - PointListFlatten", Child.FieldPath.String())
|
||||
// if len(de.Current.ChildReflect) > 0 {
|
||||
// continue // We already have the children.
|
||||
// }
|
||||
if len(Child.ChildReflect) == 0 {
|
||||
// fmt.Printf(" - IGNORE\n")
|
||||
// fmt.Printf(" - ignore\n")
|
||||
continue // Ignore points with no children.
|
||||
}
|
||||
// fmt.Println("")
|
||||
}
|
||||
|
||||
if Child.DataStructure.DataTable {
|
||||
continue // We are a datatable parent.
|
||||
}
|
||||
|
||||
var when valueTypes.DateTime
|
||||
if Child.IsPointTimestampNotZero() {
|
||||
when = valueTypes.SetDateTimeValue(Child.DataStructure.PointTimestamp)
|
||||
} else {
|
||||
when = valueTypes.SetDateTimeValue(dm.TimeStamp)
|
||||
}
|
||||
|
||||
pdi := dm.parentDeviceId
|
||||
if Child.DataStructure.PointDevice != "" {
|
||||
pdi = Child.DataStructure.PointDevice
|
||||
}
|
||||
|
||||
dm.AddPointUnitValues(Child, pdi, when)
|
||||
}
|
||||
}
|
||||
}
|
||||
// func (dm *DataMap) ProcessMapForMqtt() {
|
||||
// for range Only.Once {
|
||||
// // Convert StructMap to DataMap
|
||||
// for _, Child := range dm.StructMap.Map {
|
||||
// if Child.IsPointIgnore() {
|
||||
// fmt.Printf("[%s] - IGNORE\n", Child.FieldPath.String())
|
||||
// continue
|
||||
// }
|
||||
//
|
||||
// if Child.CurrentReflect.IsPointListFlatten() {
|
||||
// // fmt.Printf("[%s] - PointListFlatten", Child.FieldPath.String())
|
||||
// // if len(de.Current.ChildReflect) > 0 {
|
||||
// // continue // We already have the children.
|
||||
// // }
|
||||
// if len(Child.ChildReflect) == 0 {
|
||||
// // fmt.Printf(" - IGNORE\n")
|
||||
// // fmt.Printf(" - ignore\n")
|
||||
// continue // Ignore points with no children.
|
||||
// }
|
||||
// // fmt.Println("")
|
||||
// }
|
||||
//
|
||||
// if Child.DataStructure.DataTable {
|
||||
// continue // We are a datatable parent.
|
||||
// }
|
||||
//
|
||||
// var when valueTypes.DateTime
|
||||
// if Child.IsPointTimestampNotZero() {
|
||||
// when = valueTypes.SetDateTimeValue(Child.DataStructure.PointTimestamp)
|
||||
// } else {
|
||||
// when = valueTypes.SetDateTimeValue(dm.TimeStamp)
|
||||
// }
|
||||
//
|
||||
// pdi := dm.parentDeviceId
|
||||
// if Child.DataStructure.PointDevice != "" {
|
||||
// pdi = Child.DataStructure.PointDevice
|
||||
// }
|
||||
//
|
||||
// dm.AddPointUnitValues(Child, pdi, when)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
type Tables GoStruct.StructTables
|
||||
|
@ -461,11 +461,11 @@ func (sgd *SunGrowDataResult) Process() error {
|
||||
return sgd.Error
|
||||
}
|
||||
|
||||
func (sgd *SunGrowDataResult) ProcessMapForMqtt() error {
|
||||
sgd.Response.Data.ProcessMapForMqtt()
|
||||
sgd.Error = sgd.Response.Data.Error
|
||||
return sgd.Error
|
||||
}
|
||||
// func (sgd *SunGrowDataResult) ProcessMapForMqtt() error {
|
||||
// sgd.Response.Data.ProcessMapForMqtt()
|
||||
// sgd.Error = sgd.Response.Data.Error
|
||||
// return sgd.Error
|
||||
// }
|
||||
|
||||
// func (sgd *SunGrowDataResult) CreateResultTable(full bool) output.Table {
|
||||
// ret := sgd.Response.CreateResultTable(full)
|
||||
|
@ -177,7 +177,11 @@ func (sg *SunGrow) PsPoints(psIds []string, deviceType string) (string, error) {
|
||||
// PsPointsData - Return all points associated with psIds and device_type filter.
|
||||
func (sg *SunGrow) PsPointsData(psIds []string, deviceType string, startDate string, endDate string, interval string) error {
|
||||
for range Only.Once {
|
||||
pskeys := sg.GetPsKeys()
|
||||
var pskeys valueTypes.PsKeys
|
||||
pskeys, sg.Error = sg.GetPsKeys()
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
_, _ = fmt.Fprintf(os.Stderr, "Found ps_keys: %s\n", pskeys)
|
||||
|
||||
var points []getDevicePointAttrs.Point
|
||||
@ -202,7 +206,7 @@ func (sg *SunGrow) PsPointsData(psIds []string, deviceType string, startDate str
|
||||
}
|
||||
|
||||
|
||||
func (sg *SunGrow) GetPsKeys() valueTypes.PsKeys {
|
||||
func (sg *SunGrow) GetPsKeys() (valueTypes.PsKeys, error) {
|
||||
var ret valueTypes.PsKeys
|
||||
|
||||
for range Only.Once {
|
||||
@ -274,7 +278,7 @@ func (sg *SunGrow) GetPsKeys() valueTypes.PsKeys {
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
return ret, sg.Error
|
||||
}
|
||||
|
||||
func (sg *SunGrow) GetDevices() []queryDeviceListForBackSys.Device {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package mmHa
|
||||
|
||||
import (
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
"encoding/json"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -112,6 +112,11 @@ func (m *Mqtt) BinarySensorPublishValue(config EntityConfig) error {
|
||||
LastReset: m.GetLastReset(config.UniqueId),
|
||||
Value: config.Value,
|
||||
}
|
||||
if config.Units == LabelBinarySensor {
|
||||
payload = MqttState {
|
||||
Value: config.Value,
|
||||
}
|
||||
}
|
||||
t := m.client.Publish(tag, 0, true, payload.Json())
|
||||
if !t.WaitTimeout(m.Timeout) {
|
||||
m.err = t.Error()
|
||||
|
@ -1,13 +1,13 @@
|
||||
package mmHa
|
||||
|
||||
import (
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
"GoSungrow/iSolarCloud/AppService/getDeviceList"
|
||||
"GoSungrow/iSolarCloud/api"
|
||||
"GoSungrow/iSolarCloud/api/GoStruct/valueTypes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
"net/url"
|
||||
"time"
|
||||
@ -29,6 +29,9 @@ type Mqtt struct {
|
||||
clientOptions *mqtt.ClientOptions
|
||||
LastRefresh time.Time `json:"-"`
|
||||
SungrowDevices getDeviceList.Devices `json:"-"`
|
||||
// SungrowDevices valueTypes.PsKeys `json:"-"`
|
||||
// SungrowDevices valueTypes.PsIds `json:"-"`
|
||||
// SungrowDevices getPsTreeMenu.ResultData `json:"-"`
|
||||
SungrowPsIds map[valueTypes.PsId]bool
|
||||
|
||||
DeviceName string
|
||||
@ -519,6 +522,10 @@ func (config *EntityConfig) IsBinarySensor() bool {
|
||||
ok = true
|
||||
break
|
||||
}
|
||||
if config.Units == "Bool" {
|
||||
ok = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return ok
|
||||
@ -566,6 +573,8 @@ func (config *EntityConfig) FixConfig() {
|
||||
// mdi:check-circle-outline | mdi:arrow-right-bold
|
||||
|
||||
switch config.Units {
|
||||
case "Bool":
|
||||
fallthrough
|
||||
case LabelBinarySensor:
|
||||
config.DeviceClass = SetDefault(config.DeviceClass, "power")
|
||||
config.Icon = SetDefault(config.Icon, "mdi:check-circle-outline")
|
||||
@ -642,10 +651,10 @@ func (config *EntityConfig) FixConfig() {
|
||||
break
|
||||
}
|
||||
|
||||
pt := api.GetDevicePoint(config.FullId)
|
||||
if !pt.Valid {
|
||||
break
|
||||
}
|
||||
// pt := api.GetDevicePoint(config.FullId)
|
||||
// if !pt.Valid {
|
||||
// break
|
||||
// }
|
||||
|
||||
if config.StateClass == "instant" {
|
||||
config.StateClass = "measurement"
|
||||
@ -657,7 +666,7 @@ func (config *EntityConfig) FixConfig() {
|
||||
break
|
||||
}
|
||||
|
||||
config.LastReset = pt.WhenReset()
|
||||
// config.LastReset = pt.WhenReset()
|
||||
config.LastResetValueTemplate = SetDefault(config.LastResetValueTemplate, "{{ value_json.last_reset | as_datetime() }}")
|
||||
// config.LastResetValueTemplate = SetDefault(config.LastResetValueTemplate, "{{ value_json.last_reset | int | timestamp_local | as_datetime }}")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user