mirror of
https://github.com/MickMake/GoSungrow.git
synced 2025-04-11 13:20:28 +02:00
v1.4.0 docs
This commit is contained in:
parent
0dac734545
commit
a15e5cde91
19
.idea/workspace.xml
generated
19
.idea/workspace.xml
generated
@ -5,27 +5,12 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="76adadc9-ae71-42a6-82a1-66dbc8ecb14c" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/mmMqtt/config.go" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/mmMqtt/funcs.go" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/mmMqtt/lights.go" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/mmMqtt/sensors.go" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/mmMqtt/struct.go" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/mmMqtt/switch.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cmd/cmd_data_sub.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_data_sub.go" 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$/docs/SunGrowOnHASSIO.png" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/examples.txt" beforeDir="false" afterPath="$PROJECT_DIR$/examples.txt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/go.mod" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/go.sum" beforeDir="false" afterPath="$PROJECT_DIR$/go.sum" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceList/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceList/data.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/output/file.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/output/file.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/output/struct_table.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/output/struct_table.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/output/struct_table2.go" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/web.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/web.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/funcs.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/funcs.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/struct_output.go" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/struct_template.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/highlevel.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/mmMqtt/struct.go" beforeDir="false" afterPath="$PROJECT_DIR$/mmMqtt/struct.go" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
10
README.md
10
README.md
@ -16,7 +16,15 @@ Note:
|
||||
|
||||
I'm currently using it in my [HomeAssistant](https://www.home-assistant.io/) instance.
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
## What state is it in?
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
"github.com/spf13/cobra"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -111,62 +110,20 @@ func cmdMqttFunc(cmd *cobra.Command, args []string) error {
|
||||
|
||||
data := ep.GetData()
|
||||
for i, r := range data.Entries {
|
||||
point_id := strings.ReplaceAll(r.PointId, ".", "-")
|
||||
id := "sungrow_" + point_id
|
||||
fmt.Println(id)
|
||||
|
||||
err = foo.SensorPublishConfig(id, r.PointName, r.Unit, i)
|
||||
// time.Sleep(time.Second)
|
||||
err = foo.SensorPublishState(id, r.Value)
|
||||
fmt.Printf("%s ", r.PointId)
|
||||
err = foo.SensorPublishConfig(r.PointId, r.PointName, r.Unit, i)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
err = foo.SensorPublishState(r.PointId, r.Value)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
fmt.Println()
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
// sensor1 := mmMqtt.Sensor {
|
||||
// Device: mmMqtt.Device {
|
||||
// Connections: [][]string{{"sungrow_address", "1"}},
|
||||
// Identifiers: []string{"sungrow_battery_Level", "sungrow_address_1"},
|
||||
// Manufacturer: "MickMake",
|
||||
// Model: "SunGrow inverter",
|
||||
// Name: "SunGrow battery level",
|
||||
// SwVersion: "GoSunGrow https://github.com/MickMake/GoSungrow",
|
||||
// ViaDevice: "GoSunGrow",
|
||||
// },
|
||||
// Name: "SunGrow battery level",
|
||||
// StateTopic: "homeassistant/sensor/SunGrow/sungrow_battery_Level/state",
|
||||
// UniqueID: "sungrow_battery_Level",
|
||||
// UnitOfMeasurement: "%",
|
||||
// }
|
||||
|
||||
// err = foo.SensorPublishConfig("sungrow_battery_Level", "SunGrow battery level", "%", "1")
|
||||
// if err != nil {
|
||||
// break
|
||||
// }
|
||||
// err = foo.SensorPublishState("sungrow_battery_Level", randoPercent())
|
||||
// if err != nil {
|
||||
// break
|
||||
// }
|
||||
|
||||
// sensor2 := mmMqtt.Sensor {
|
||||
// Device: mmMqtt.Device {
|
||||
// Connections: [][]string{{"sungrow_address", "2"}},
|
||||
// Identifiers: []string{"sungrow_pv_energy", "sungrow_address_2"},
|
||||
// Manufacturer: "MickMake",
|
||||
// Model: "SunGrow inverter",
|
||||
// Name: "SunGrow PV Energy",
|
||||
// SwVersion: "GoSunGrow https://github.com/MickMake/GoSungrow",
|
||||
// ViaDevice: "GoSunGrow",
|
||||
// },
|
||||
// Name: "SunGrow PV Energy",
|
||||
// StateTopic: "homeassistant/sensor/SunGrow/sungrow_pv_energy/state",
|
||||
// UniqueID: "sungrow_pv_energy",
|
||||
// UnitOfMeasurement: "kWh",
|
||||
// }
|
||||
|
||||
// err = foo.SensorPublishConfig("sungrow_pv_energy", "SunGrow PV Energy", "kWh", "2")
|
||||
// if err != nil {
|
||||
// break
|
||||
// }
|
||||
// err = foo.SensorPublishState("sungrow_pv_energy", randoKWh())
|
||||
|
||||
|
||||
updateCounter := 0
|
||||
timer := time.NewTicker(10 * time.Second)
|
||||
@ -187,12 +144,16 @@ func cmdMqttFunc(cmd *cobra.Command, args []string) error {
|
||||
|
||||
data = ep.GetData()
|
||||
for _, r := range data.Entries {
|
||||
point_id := strings.ReplaceAll(r.PointId, ".", "-")
|
||||
id := "sungrow_" + point_id
|
||||
fmt.Println(id)
|
||||
err = foo.SensorPublishState(id, r.Value)
|
||||
fmt.Printf("%s ", r.PointId)
|
||||
err = foo.SensorPublishState(r.PointId, r.Value)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
}
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 339 KiB |
BIN
docs/SunGrowOnHASSIO1.png
Normal file
BIN
docs/SunGrowOnHASSIO1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 215 KiB |
BIN
docs/SunGrowOnHASSIO2.png
Normal file
BIN
docs/SunGrowOnHASSIO2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 218 KiB |
BIN
docs/SunGrowOnHASSIO3.png
Normal file
BIN
docs/SunGrowOnHASSIO3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 203 KiB |
BIN
docs/SunGrowOnHASSIO4.png
Normal file
BIN
docs/SunGrowOnHASSIO4.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 208 KiB |
BIN
docs/SunGrowOnHASSIO5.png
Normal file
BIN
docs/SunGrowOnHASSIO5.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 200 KiB |
@ -7,6 +7,7 @@ import (
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -199,6 +200,8 @@ func (m *Mqtt) SensorPublish(subtopic string, payload interface{}) error {
|
||||
func (m *Mqtt) SensorPublishConfig(id string, name string, units string, address int) error {
|
||||
for range Only.Once {
|
||||
a := strconv.Itoa(address)
|
||||
id = strings.ReplaceAll("sungrow_" + id, ".", "-")
|
||||
|
||||
class := ""
|
||||
switch units {
|
||||
case "MW":
|
||||
@ -263,9 +266,10 @@ func (m *Mqtt) SensorPublishConfig(id string, name string, units string, address
|
||||
return m.err
|
||||
}
|
||||
|
||||
func (m *Mqtt) SensorPublishState(sensor string, payload interface{}) error {
|
||||
func (m *Mqtt) SensorPublishState(id string, payload interface{}) error {
|
||||
for range Only.Once {
|
||||
m.client.Publish(SensorBaseTopic + "/" + sensor + "/state", 0, true, payload)
|
||||
id = strings.ReplaceAll("sungrow_" + id, ".", "-")
|
||||
m.client.Publish(SensorBaseTopic + "/" + id + "/state", 0, true, payload)
|
||||
}
|
||||
return m.err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user