Skip to content

Commit

Permalink
Changed stateOfCapacity to stateOfCharge, added docs page
Browse files Browse the repository at this point in the history
  • Loading branch information
daolis committed Mar 1, 2024
1 parent 22183f9 commit c2524eb
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 11 deletions.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@ Read data from Huawei SUN2000 inverter and LUNA2000 Storage using Modbus TCP.

Huawei products page: [solar.huawei.com](https://solar.huawei.com/at/professionals/all-products)

## Settings

* `address`: Inverters IP address
* `port`: Inverter modbus port (default: 502)
* `modbusUnitId`: Modbus unit id (default: 1)
* `updateIntervalHigh`: Fast update interval (default: 5 sec)
* `updateIntervalLow`: Slower update interval (default: 20 sec)
## Documentation

see the [documentation page](./docs/README.md)

## Changelog
### **WORK IN PROGRESS**
* [#26](https://github.com/daolis/ioBroker.sun2000-modbus/issues/26) Renamed stateOfCapacity to stateOfCharge\
Migration of historical data: see [Migration of historical data (on state name change)](docs/migration.md)

### 0.0.2 (2024-01-08)

Expand Down
2 changes: 1 addition & 1 deletion build/lib/states.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions build/lib/states.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ioBroker SUN2000 Documentation

* [Configuration](./configuration.md)
* [Migration of historical data](./migration.md)

WIP
11 changes: 11 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Configuration

![Admin config](./images/admin-config.png)

1. Inverter IP address
(IP of the Dongle connected to the inverter)
2. Modbus Port
3. Modbus UnitID
4. Faster update interval in seconds
5. Slower update interval in seconds

Binary file added docs/images/admin-config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions docs/migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Migration of historical data (on state name change)

## InfluxDB

1. Stop Adapter
2. Copy the measurement to new one. (`stateOfCapacity` -> `stateOfCharge`)\
https://www.laub-home.de/wiki/InfluxDB_2_Measurements_umbenennen (DE)
* Open InfluxDB 2 web interface (`http://<INFLUXDB2>:8086`)
* On 'DataExplorer' tab click on 'Script Editor'
* Replace `old`, `new` and the bucket name with your values.
```
from(bucket: "example-bucket")
|> range(start: 2021-11-21T00:00:00Z, stop: 2021-11-22T00:00:00Z)
|> filter(fn: (r) => r._measurement == "old")
|> set(key: "_measurement", value: "new")
|> to(bucket: "example-bucket")
```
3. Delete the old one (`stateOfCapacity`)
```shell
# InfluxDB Host
INFLUXHOST=localhost
# openHAB Database
INFLUXDB=openhab_db
# InflusDB API Key
INFLUXDBAUTH="TkrV8yQ8adcwwwwedsiuhf5V1OhXasdfadfeGgtzsb_bfucYeHSeTID-JlB7AKBZjE47TCwf8w-jGCFzpChw=="
# Measurement to delete
MEASUREMENT="LaubIot07BME680_Temperature"

curl -s --get http://$INFLUXHOST:8086/query?db=$INFLUXDB \
--header "Authorization: Token $INFLUXDBAUTH" \
--data-urlencode "q=DROP MEASUREMENT $MEASUREMENT"
```
4. Install new adapter. Write to new state
2 changes: 1 addition & 1 deletion src/lib/states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class InverterStates {
},
{
interval: UpdateIntervalID.HIGH,
state: {id: 'storage.stateOfCapacity', name: 'State of capacity', type: 'number', unit: '%', role: 'value.battery', desc: 'SOC'},
state: {id: 'storage.stateOfCharge', name: 'State of charge', type: 'number', unit: '%', role: 'value.battery', desc: 'SOC'},
register: {reg: 37760, type: ModbusDatatype.uint16, length: 1, gain: 10}
},
{
Expand Down

0 comments on commit c2524eb

Please sign in to comment.