HA addon
5
.gitignore
vendored
@ -2,3 +2,8 @@ bin/GoSungrow
|
||||
AppService_*.json
|
||||
WebAppService_*.json
|
||||
|
||||
/*.txt
|
||||
/GoSungrow
|
||||
/data/
|
||||
/dist/
|
||||
|
||||
|
145
.idea/workspace.xml
generated
@ -5,36 +5,9 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="76adadc9-ae71-42a6-82a1-66dbc8ecb14c" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/iSolarCloud/api/struct_points.go" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/iSolarCloud/points.go" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/mmMqtt/cron.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" 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.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cmd/cmd_config.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_config.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cmd/cmd_cron.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_cron.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cmd/cmd_data.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_data.go" 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$/cmd/const.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/const.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cmd/struct.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/struct.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cmd/viper.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/viper.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/examples.txt" beforeDir="false" afterPath="$PROJECT_DIR$/examples.txt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/getPsDetailWithPsType/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/getPsDetailWithPsType/data.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/login/auth.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/login/auth.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/login/struct.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/login/struct.go" 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/AppService/queryDeviceRealTimeDataByPsKeys/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceRealTimeDataByPsKeys/data.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/WebAppService/struct.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/WebAppService/struct.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/apiReflect/reflect.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/apiReflect/reflect.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/datetime.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/datetime.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/struct_response.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/struct_response.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/types.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/types.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/utils.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/utils.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/highlevel.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/highlevel.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iSolarCloud/struct.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/struct.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/mmMqtt/sensors.go" beforeDir="false" afterPath="$PROJECT_DIR$/mmMqtt/sensors.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" />
|
||||
@ -100,7 +73,7 @@
|
||||
<configuration name="GoSungrow" type="GoApplicationRunConfiguration" factoryName="Go Application">
|
||||
<module name="GoSungrow" />
|
||||
<working_directory value="$PROJECT_DIR$" />
|
||||
<parameters value="data get realtime 1129147" />
|
||||
<parameters value="data get template 8092 20220301" />
|
||||
<kind value="PACKAGE" />
|
||||
<package value="$PROJECT_DIR$" />
|
||||
<directory value="$PROJECT_DIR$" />
|
||||
@ -108,14 +81,6 @@
|
||||
<output_directory value="$PROJECT_DIR$/bin" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration default="true" type="GoApplicationRunConfiguration" factoryName="Go Application">
|
||||
<module name="GoSungrow" />
|
||||
<working_directory value="$PROJECT_DIR$" />
|
||||
<kind value="FILE" />
|
||||
<directory value="$PROJECT_DIR$" />
|
||||
<filePath value="$PROJECT_DIR$" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@ -162,36 +127,11 @@
|
||||
<line>95</line>
|
||||
<option name="timeStamp" value="115" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
|
||||
<line>119</line>
|
||||
<option name="timeStamp" value="190" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
|
||||
<line>124</line>
|
||||
<option name="timeStamp" value="191" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
|
||||
<line>134</line>
|
||||
<option name="timeStamp" value="192" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceList/data.go</url>
|
||||
<line>200</line>
|
||||
<line>201</line>
|
||||
<option name="timeStamp" value="202" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/funcs.go</url>
|
||||
<line>135</line>
|
||||
<option name="timeStamp" value="210" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/funcs.go</url>
|
||||
<line>123</line>
|
||||
<option name="timeStamp" value="211" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/api/struct_endpoint.go</url>
|
||||
<line>105</line>
|
||||
@ -219,24 +159,14 @@
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/cmd/cmd_mqtt.go</url>
|
||||
<line>239</line>
|
||||
<line>207</line>
|
||||
<option name="timeStamp" value="437" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/cmd/cmd_mqtt.go</url>
|
||||
<line>238</line>
|
||||
<line>206</line>
|
||||
<option name="timeStamp" value="446" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
|
||||
<line>375</line>
|
||||
<option name="timeStamp" value="476" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
|
||||
<line>391</line>
|
||||
<option name="timeStamp" value="477" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceRealTimeDataByPsKeys/data.go</url>
|
||||
<line>107</line>
|
||||
@ -247,31 +177,11 @@
|
||||
<line>142</line>
|
||||
<option name="timeStamp" value="479" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
|
||||
<line>412</line>
|
||||
<option name="timeStamp" value="480" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
|
||||
<line>422</line>
|
||||
<option name="timeStamp" value="481" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
|
||||
<line>405</line>
|
||||
<option name="timeStamp" value="483" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/AppService/getPsDetailWithPsType/data.go</url>
|
||||
<line>260</line>
|
||||
<option name="timeStamp" value="511" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
|
||||
<line>461</line>
|
||||
<option name="timeStamp" value="521" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/api/struct_points.go</url>
|
||||
<line>288</line>
|
||||
@ -284,33 +194,48 @@
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/cmd/cmd_mqtt.go</url>
|
||||
<line>170</line>
|
||||
<line>138</line>
|
||||
<option name="timeStamp" value="562" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/cmd/cmd_mqtt.go</url>
|
||||
<line>266</line>
|
||||
<line>234</line>
|
||||
<option name="timeStamp" value="564" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/cmd/cmd_mqtt.go</url>
|
||||
<line>259</line>
|
||||
<option name="timeStamp" value="565" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceList/data.go</url>
|
||||
<line>290</line>
|
||||
<option name="timeStamp" value="566" />
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
|
||||
<line>492</line>
|
||||
<option name="timeStamp" value="570" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
|
||||
<line>417</line>
|
||||
<option name="timeStamp" value="567" />
|
||||
<line>54</line>
|
||||
<option name="timeStamp" value="580" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceRealTimeDataByPsKeys/struct.go</url>
|
||||
<line>123</line>
|
||||
<option name="timeStamp" value="568" />
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
|
||||
<line>136</line>
|
||||
<option name="timeStamp" value="581" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceList/data.go</url>
|
||||
<line>485</line>
|
||||
<option name="timeStamp" value="586" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/api/web.go</url>
|
||||
<line>58</line>
|
||||
<option name="timeStamp" value="589" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
|
||||
<line>79</line>
|
||||
<option name="timeStamp" value="592" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
|
||||
<line>75</line>
|
||||
<option name="timeStamp" value="593" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
|
4
HA/CHANGELOG.md
Normal file
@ -0,0 +1,4 @@
|
||||
## [2.1.3] - 2022-03-14
|
||||
### Changed
|
||||
- GoSunGrow for HA ([fixes #1](https://github.com/MickMake/GoSunGrow/issues/1))
|
||||
|
47
HA/Dockerfile
Normal file
@ -0,0 +1,47 @@
|
||||
ARG BUILD_FROM
|
||||
FROM $BUILD_FROM
|
||||
|
||||
# FROM alpine:latest
|
||||
MAINTAINER MickMake <embed@mickmake.com>
|
||||
USER root
|
||||
|
||||
LABEL \
|
||||
io.hass.version="VERSION" \
|
||||
io.hass.type="addon" \
|
||||
io.hass.arch="armhf|aarch64|i386|amd64"
|
||||
|
||||
|
||||
ARG SUNGROW_APPKEY
|
||||
ENV SUNGROW_APPKEY ${SUNGROW_APPKEY}
|
||||
ARG SUNGROW_DEBUG
|
||||
ENV SUNGROW_DEBUG ${SUNGROW_DEBUG}
|
||||
ARG SUNGROW_HOST
|
||||
ENV SUNGROW_HOST ${SUNGROW_HOST}
|
||||
ARG SUNGROW_USER
|
||||
ENV SUNGROW_USER ${SUNGROW_USER}
|
||||
ARG SUNGROW_PASSWORD
|
||||
ENV SUNGROW_PASSWORD ${SUNGROW_PASSWORD}
|
||||
ARG SUNGROW_TIMEOUT
|
||||
ENV SUNGROW_TIMEOUT ${SUNGROW_TIMEOUT}
|
||||
|
||||
ARG SUNGROW_MQTT_HOST
|
||||
ENV SUNGROW_MQTT_HOST ${SUNGROW_MQTT_HOST}
|
||||
ARG SUNGROW_MQTT_PASSWORD
|
||||
ENV SUNGROW_MQTT_PASSWORD ${SUNGROW_MQTT_PASSWORD}
|
||||
ARG SUNGROW_MQTT_PORT
|
||||
ENV SUNGROW_MQTT_PORT ${SUNGROW_MQTT_PORT}
|
||||
ARG SUNGROW_MQTT_USER
|
||||
ENV SUNGROW_MQTT_USER ${SUNGROW_MQTT_USER}
|
||||
|
||||
ARG TZ
|
||||
ENV TZ ${TZ}
|
||||
|
||||
COPY src/GoSungrow /usr/local/bin/GoSungrow
|
||||
COPY src/run.sh /usr/local/bin/run.sh
|
||||
RUN chmod a+x /usr/local/bin/GoSungrow /usr/local/bin/run.sh
|
||||
|
||||
# ENTRYPOINT ["/usr/local/bin/GoSungrow"]
|
||||
# CMD ["crond", "-f", "-l", "2", "-L", "/var/log/cronlogs"]
|
||||
# CMD ["/usr/local/bin/GoSungrow", "mqtt", "sync"]
|
||||
CMD ["/usr/local/bin/run.sh"]
|
||||
|
BIN
HA/GoSungrow
Executable file
10
HA/build.yaml
Normal file
@ -0,0 +1,10 @@
|
||||
build_from:
|
||||
aarch64: ghcr.io/home-assistant/aarch64-base:3.13
|
||||
amd64: ghcr.io/home-assistant/amd64-base:3.13
|
||||
armhf: ghcr.io/home-assistant/armhf-base:3.13
|
||||
armv7: ghcr.io/home-assistant/armv7-base:3.13
|
||||
codenotary:
|
||||
signer: mick@mickmake.com
|
||||
base_image: mick@mickmake.com
|
||||
args:
|
||||
GOSUNGROW_VERSION: 2.1.3
|
42
HA/config.yaml
Normal file
@ -0,0 +1,42 @@
|
||||
name: "GoSungrow"
|
||||
description: "Fetch data from isolarcloud.com and push to HA."
|
||||
version: "2.1.3"
|
||||
stage: stable
|
||||
slug: "gosungrow"
|
||||
url: "https://github.com/MickMake/GoSunGrow/"
|
||||
codenotary: mick@mickmake.com
|
||||
arch:
|
||||
- amd64
|
||||
- aarch64
|
||||
- armhf
|
||||
- armv7
|
||||
map:
|
||||
- config:rw
|
||||
panel_icon: mdi:puzzle
|
||||
auth_api: true
|
||||
startup: services
|
||||
hassio_api: true
|
||||
|
||||
options:
|
||||
sungrow_host: "https://augateway.isolarcloud.com"
|
||||
sungrow_user: ""
|
||||
sungrow_password: ""
|
||||
sungrow_mqtt_host: "localhost"
|
||||
sungrow_mqtt_port: "1883"
|
||||
sungrow_mqtt_password: ""
|
||||
sungrow_mqtt_user: ""
|
||||
sungrow_debug: false
|
||||
sungrow_appkey: "93D72E60331ABDCDC7B39ADC2D1F32B3"
|
||||
sungrow_timeout: 60
|
||||
schema:
|
||||
log_level: list(trace|debug|info|notice|warning|error|fatal)?
|
||||
sungrow_host: str?
|
||||
sungrow_user: str?
|
||||
sungrow_password: str?
|
||||
sungrow_mqtt_host: str?
|
||||
sungrow_mqtt_port: str?
|
||||
sungrow_mqtt_password: str?
|
||||
sungrow_mqtt_user: str?
|
||||
sungrow_debug: bool
|
||||
sungrow_appkey: str?
|
||||
sungrow_timeout: int
|
BIN
HA/src/GoSungrow
Executable file
41
HA/src/run.sh
Normal file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bashio
|
||||
set -e
|
||||
|
||||
CONFIG_PATH="/data/options.json"
|
||||
|
||||
bashio::log.info "Setting up GoSungrow config ..."
|
||||
|
||||
export SUNGROW_HOST=$(bashio::config 'sungrow_host')
|
||||
export SUNGROW_USER=$(bashio::config 'sungrow_user')
|
||||
export SUNGROW_PASSWORD=$(bashio::config 'sungrow_password')
|
||||
export SUNGROW_APPKEY=$(bashio::config 'sungrow_appkey')
|
||||
export SUNGROW_DEBUG=$(bashio::config 'sungrow_debug')
|
||||
export SUNGROW_TIMEOUT=$(bashio::config 'sungrow_timeout')
|
||||
|
||||
export SUNGROW_MQTT_HOST=$(bashio::config 'sungrow_mqtt_host')
|
||||
export SUNGROW_MQTT_PORT=$(bashio::config 'sungrow_mqtt_port')
|
||||
export SUNGROW_MQTT_USER=$(bashio::config 'sungrow_mqtt_user')
|
||||
export SUNGROW_MQTT_PASSWORD=$(bashio::config 'sungrow_mqtt_password')
|
||||
|
||||
bashio::log.info "Writing GoSungrow config ..."
|
||||
|
||||
/usr/local/bin/GoSungrow config write \
|
||||
--host="${SUNGROW_HOST}" \
|
||||
--user="${SUNGROW_USER}" \
|
||||
--password="${SUNGROW_PASSWORD}" \
|
||||
--appkey="${SUNGROW_APPKEY}" \
|
||||
--timeout="${SUNGROW_TIMEOUT}s" \
|
||||
--mqtt-host="${SUNGROW_MQTT_HOST}" \
|
||||
--mqtt-port="${SUNGROW_MQTT_PORT}" \
|
||||
--mqtt-user="${SUNGROW_MQTT_USER}" \
|
||||
--mqtt-password="${SUNGROW_MQTT_PASSWORD}" \
|
||||
--debug="${SUNGROW_DEBUG}"
|
||||
|
||||
bashio::log.info "Login to iSolarCloud using gateway ${SUNGROW_HOST} ..."
|
||||
|
||||
/usr/local/bin/GoSungrow api login
|
||||
|
||||
bashio::log.info "Syncing data from gateway ${SUNGROW_HOST} ..."
|
||||
|
||||
/usr/local/bin/GoSungrow mqtt sync
|
||||
|
@ -6,7 +6,7 @@ import "time"
|
||||
//goland:noinspection SpellCheckingInspection
|
||||
const (
|
||||
DefaultBinaryName = "GoSungrow"
|
||||
EnvPrefix = "SunGrow"
|
||||
EnvPrefix = "SUNGROW"
|
||||
defaultConfigFile = "config.json"
|
||||
defaultTokenFile = "AuthToken.json"
|
||||
|
||||
|
BIN
docs/SungrowEnergy-Arrows+45.gif
Normal file
After Width: | Height: | Size: 119 KiB |
BIN
docs/SungrowEnergy-Arrows+90.gif
Normal file
After Width: | Height: | Size: 60 KiB |
BIN
docs/SungrowEnergy-Arrows-45.gif
Normal file
After Width: | Height: | Size: 116 KiB |
BIN
docs/SungrowEnergy-Arrows-90.gif
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
docs/SungrowEnergy-Arrows.gif
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
docs/SungrowEnergy.png
Normal file
After Width: | Height: | Size: 158 KiB |
BIN
docs/SungrowEnergy.xcf
Normal file
BIN
docs/SungrowEnergy2-BatteryOff.png
Normal file
After Width: | Height: | Size: 40 KiB |
BIN
docs/SungrowEnergy2-BatteryToGrid.png
Normal file
After Width: | Height: | Size: 94 KiB |
BIN
docs/SungrowEnergy2-BatteryToLoad.png
Normal file
After Width: | Height: | Size: 90 KiB |
BIN
docs/SungrowEnergy2-GridOff.png
Normal file
After Width: | Height: | Size: 67 KiB |
BIN
docs/SungrowEnergy2-GridToLoad.png
Normal file
After Width: | Height: | Size: 90 KiB |
BIN
docs/SungrowEnergy2-LoadOff.png
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
docs/SungrowEnergy2-PVOff.png
Normal file
After Width: | Height: | Size: 55 KiB |
BIN
docs/SungrowEnergy2-PVToBattery.png
Normal file
After Width: | Height: | Size: 96 KiB |
BIN
docs/SungrowEnergy2-PVToGrid.png
Normal file
After Width: | Height: | Size: 96 KiB |
BIN
docs/SungrowEnergy2-PVToLoad.png
Normal file
After Width: | Height: | Size: 89 KiB |
BIN
docs/SungrowEnergy2.png
Normal file
After Width: | Height: | Size: 205 KiB |
BIN
docs/SungrowEnergy2.xcf
Normal file
@ -7,6 +7,7 @@ import (
|
||||
"GoSungrow/iSolarCloud/api/output"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const Url = "/v1/devService/queryDeviceList"
|
||||
@ -276,18 +277,52 @@ func (e *EndPoint) GetData() api.Data {
|
||||
var ret api.Data
|
||||
|
||||
for range Only.Once {
|
||||
// Used for virtual entries.
|
||||
// 0 - sungrow_battery_charging_power
|
||||
var BatteryChargingPower float64
|
||||
// sensor.sungrow_battery_discharging_power
|
||||
var BatteryDischargingPower float64
|
||||
// 0 - sensor.sungrow_total_export_active_power
|
||||
var TotalExportActivePower float64
|
||||
// sensor.sungrow_purchased_power
|
||||
var PurchasedPower float64
|
||||
|
||||
// 0 - sensor.sungrow_daily_battery_charging_energy_from_pv
|
||||
var DailyBatteryChargingEnergyFromPv float64
|
||||
// sensor.sungrow_daily_battery_discharging_energy
|
||||
var DailyBatteryDischargingEnergy float64
|
||||
// 0 - sensor.sungrow_daily_feed_in_energy_pv
|
||||
var DailyFeedInEnergyPv float64
|
||||
// sensor.sungrow_daily_purchased_energy
|
||||
var DailyPurchasedEnergy float64
|
||||
|
||||
var TotalDcPower float64
|
||||
|
||||
index := 0
|
||||
for _, d := range e.Response.ResultData.PageList {
|
||||
for _, p := range d.PointData {
|
||||
if p.Unit == "W" {
|
||||
fv, err := strconv.ParseFloat(p.Value, 64)
|
||||
fv = fv / 1000
|
||||
fv, err := api.DivideByThousand(p.Value)
|
||||
// fv, err := strconv.ParseFloat(p.Value, 64)
|
||||
// fv = fv / 1000
|
||||
if err == nil {
|
||||
p.Value = fmt.Sprintf("%.3f", fv)
|
||||
// p.Value = fmt.Sprintf("%.3f", fv)
|
||||
p.Value = fv
|
||||
p.Unit = "kW"
|
||||
}
|
||||
}
|
||||
|
||||
if p.Unit == "Wh" {
|
||||
fv, err := api.DivideByThousand(p.Value)
|
||||
// fv, err := strconv.ParseFloat(p.Value, 64)
|
||||
// fv = fv / 1000
|
||||
if err == nil {
|
||||
// p.Value = fmt.Sprintf("%.3f", fv)
|
||||
p.Value = fv
|
||||
p.Unit = "kWh"
|
||||
}
|
||||
}
|
||||
|
||||
ret.Entries = append(ret.Entries, api.DataEntry {
|
||||
Date: api.NewDateTime(p.TimeStamp),
|
||||
PointId: api.NameDevicePointInt(d.PsKey, p.PointID),
|
||||
@ -300,8 +335,152 @@ func (e *EndPoint) GetData() api.Data {
|
||||
})
|
||||
|
||||
index++
|
||||
|
||||
// Handle virtual results.
|
||||
switch strings.ReplaceAll(p.PointName, " ", "") {
|
||||
case "BatteryChargingPower":
|
||||
BatteryChargingPower, _ = strconv.ParseFloat(p.Value, 64)
|
||||
case "BatteryDischargingPower":
|
||||
BatteryDischargingPower, _ = strconv.ParseFloat(p.Value, 64)
|
||||
case "TotalExportActivePower":
|
||||
TotalExportActivePower, _ = strconv.ParseFloat(p.Value, 64)
|
||||
case "PurchasedPower":
|
||||
PurchasedPower, _ = strconv.ParseFloat(p.Value, 64)
|
||||
case "DailyBatteryChargingEnergyFromPv":
|
||||
DailyBatteryChargingEnergyFromPv, _ = strconv.ParseFloat(p.Value, 64)
|
||||
case "DailyBatteryDischargingEnergy":
|
||||
DailyBatteryDischargingEnergy, _ = strconv.ParseFloat(p.Value, 64)
|
||||
case "DailyFeedInEnergyPv":
|
||||
DailyFeedInEnergyPv, _ = strconv.ParseFloat(p.Value, 64)
|
||||
case "DailyPurchasedEnergy":
|
||||
DailyPurchasedEnergy, _ = strconv.ParseFloat(p.Value, 64)
|
||||
case "TotalDCPower":
|
||||
TotalDcPower, _ = strconv.ParseFloat(p.Value, 64)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(ret.Entries) == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
// Add virtual entries.
|
||||
ts := ret.Entries[0].Date
|
||||
var value string
|
||||
|
||||
if BatteryChargingPower > 0 {
|
||||
value = api.Float64ToString(0 - BatteryChargingPower)
|
||||
} else {
|
||||
value = api.Float64ToString(BatteryDischargingPower)
|
||||
}
|
||||
ret.Entries = append(ret.Entries, api.DataEntry {
|
||||
Date: ts,
|
||||
PointId: "virtual.battery_power",
|
||||
PointGroupName: "Virtual",
|
||||
PointName: "Battery Power",
|
||||
Value: value,
|
||||
Unit: "kW",
|
||||
ValueType: &api.Point {
|
||||
PsKey: "virtual",
|
||||
Id: "battery_power",
|
||||
Description: "Battery Power",
|
||||
Unit: "kW",
|
||||
Type: "PointTypeInstant",
|
||||
},
|
||||
Index: index,
|
||||
})
|
||||
index++
|
||||
|
||||
if TotalExportActivePower > 0 {
|
||||
value = api.Float64ToString(0 - TotalExportActivePower)
|
||||
} else {
|
||||
value = api.Float64ToString(PurchasedPower)
|
||||
}
|
||||
ret.Entries = append(ret.Entries, api.DataEntry {
|
||||
Date: ts,
|
||||
PointId: "virtual.grid_power",
|
||||
PointGroupName: "Virtual",
|
||||
PointName: "Grid Power",
|
||||
Value: value,
|
||||
Unit: "kW",
|
||||
ValueType: &api.Point {
|
||||
PsKey: "virtual",
|
||||
Id: "grid_power",
|
||||
Description: "Grid Power",
|
||||
Unit: "kW",
|
||||
Type: "PointTypeInstant",
|
||||
},
|
||||
Index: index,
|
||||
})
|
||||
index++
|
||||
|
||||
|
||||
if DailyBatteryChargingEnergyFromPv > 0 {
|
||||
value = api.Float64ToString(0 - DailyBatteryChargingEnergyFromPv)
|
||||
} else {
|
||||
value = api.Float64ToString(DailyBatteryDischargingEnergy)
|
||||
}
|
||||
ret.Entries = append(ret.Entries, api.DataEntry {
|
||||
Date: ts,
|
||||
PointId: "virtual.battery_energy",
|
||||
PointGroupName: "Virtual",
|
||||
PointName: "Battery Energy",
|
||||
Value: value,
|
||||
Unit: "kWh",
|
||||
ValueType: &api.Point {
|
||||
PsKey: "virtual",
|
||||
Id: "battery_energy",
|
||||
Description: "Battery Energy",
|
||||
Unit: "kWh",
|
||||
Type: "PointTypeInstant",
|
||||
},
|
||||
Index: index,
|
||||
})
|
||||
index++
|
||||
|
||||
if DailyFeedInEnergyPv > 0 {
|
||||
value = api.Float64ToString(0 - DailyFeedInEnergyPv)
|
||||
} else {
|
||||
value = api.Float64ToString(DailyPurchasedEnergy)
|
||||
}
|
||||
ret.Entries = append(ret.Entries, api.DataEntry {
|
||||
Date: ts,
|
||||
PointId: "virtual.grid_energy",
|
||||
PointGroupName: "Virtual",
|
||||
PointName: "Grid Energy",
|
||||
Value: value,
|
||||
Unit: "kWh",
|
||||
ValueType: &api.Point {
|
||||
PsKey: "virtual",
|
||||
Id: "grid_energy",
|
||||
Description: "Grid Energy",
|
||||
Unit: "kWh",
|
||||
Type: "PointTypeInstant",
|
||||
},
|
||||
Index: index,
|
||||
})
|
||||
index++
|
||||
|
||||
|
||||
value = api.Float64ToString(TotalDcPower - BatteryChargingPower - TotalExportActivePower)
|
||||
ret.Entries = append(ret.Entries, api.DataEntry {
|
||||
Date: ts,
|
||||
PointId: "virtual.pv_to_load",
|
||||
PointGroupName: "Virtual",
|
||||
PointName: "PV To Load Power",
|
||||
Value: value,
|
||||
Unit: "kW",
|
||||
ValueType: &api.Point {
|
||||
PsKey: "virtual",
|
||||
Id: "pv_to_load",
|
||||
Description: "PV To Load Power",
|
||||
Unit: "kW",
|
||||
Type: "PointTypeInstant",
|
||||
},
|
||||
Index: index,
|
||||
})
|
||||
index++
|
||||
|
||||
}
|
||||
|
||||
return ret
|
||||
|