-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support setting & reading system output power from Home Assistant
- Loading branch information
1 parent
e876b64
commit e3fc27e
Showing
8 changed files
with
113 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package homeassistant | ||
|
||
import "fmt" | ||
|
||
func generateDevice(info DeviceInfo) Device { | ||
return Device{ | ||
Identifiers: []string{fmt.Sprintf("noah_%s", info.SerialNumber)}, | ||
Name: info.Alias, | ||
Manufacturer: "Growatt", | ||
SwVersion: info.Version, | ||
Model: info.Model, | ||
SerialNumber: info.SerialNumber, | ||
} | ||
} | ||
|
||
func generateOrigin(appVersion string) Origin { | ||
return Origin{ | ||
Name: "noah-mqtt", | ||
SwVersion: appVersion, | ||
SupportUrl: "https://github.com/mtrossbach/noah-mqtt", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package homeassistant | ||
|
||
import "fmt" | ||
|
||
func generateNumberDiscoveryPayload(appVersion string, info DeviceInfo) []Number { | ||
device := generateDevice(info) | ||
origin := generateOrigin(appVersion) | ||
|
||
numbers := []Number{ | ||
{ | ||
Name: "System Output Power", | ||
UniqueId: fmt.Sprintf("%s_system_output_power", info.SerialNumber), | ||
CommandTemplate: "{\"output_power_w\": {{ value }}}", | ||
CommandTopic: info.ParameterCommandTopic, | ||
Device: device, | ||
Origin: origin, | ||
Icon: "", | ||
DeviceClass: DeviceClassPower, | ||
StateTopic: info.ParameterStateTopic, | ||
StateClass: StateClassMeasurement, | ||
Mode: ModeSlider, | ||
Step: 1, | ||
Min: 0, | ||
Max: 800, | ||
UnitOfMeasurement: UnitWatt, | ||
ValueTemplate: "{{ value_json.output_power_w }}", | ||
}, | ||
} | ||
|
||
return numbers | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters