Skip to content

Commit

Permalink
v3.26
Browse files Browse the repository at this point in the history
  • Loading branch information
pvtom committed Jul 14, 2024
1 parent dd00f6e commit a71132e
Show file tree
Hide file tree
Showing 13 changed files with 1,101 additions and 452 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
build-args: |
Expand Down
2 changes: 1 addition & 1 deletion INFLUXDB.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ INFLUXDB_2_TOKEN=<my_token>

Please use the web admin tool of the InfluxDB v2.x to configure the bucket, the orga and the token.

### TLS encryption
### TLS Encryption

rscp2mqtt uses the library libcurl for the connection to InfluxDB. To establish a TLS connection, please use the following configuration parameters.
```
Expand Down
6 changes: 3 additions & 3 deletions MQTT_TLS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MQTT_TLS_CERTFILE=/home/pi/client.crt
MQTT_TLS_KEYFILE=/home/pi/client.key
```

### Certificates and broker configuration
### Certificates and Broker Configuration

Please follow these commands to create an example environment on your computer with a running Mosquitto broker:

Expand Down Expand Up @@ -53,7 +53,7 @@ openssl x509 -req -in client.csr -CA /etc/mosquitto/ca_certificates/ca.crt -CAke
chmod a+r *
```

### Broker configuration
### Broker Configuration
```
cd /etc/mosquitto/conf.d
Expand All @@ -74,7 +74,7 @@ Restart the MQTT broker
systemctl restart mosquitto.service
```

### Prepare client
### Prepare Client

Copy client key and certificate
```
Expand Down
157 changes: 157 additions & 0 deletions NEWTAGS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
## New Tags and Topics

The following options are available to support the clarification and integration of further topics:

- Raw data mode
- Configuration of tags that can be queried
- Configuration of new topics
- One-time execution

### Raw Data Mode

The raw data mode helps to find out which data is output when configuring new query tags.

It can be configured in the .config with
```
RAW_DATA=true
```
rscp2mqtt will generate additional output such as
```
e3dc/raw/TAG_EMS_POWER_PV
e3dc/raw/TAG_EMS_POWER_BAT
e3dc/raw/TAG_EMS_POWER_HOME
e3dc/raw/TAG_EMS_POWER_GRID
e3dc/raw/TAG_BAT_DATA/TAG_BAT_RSOC
```

The tag names are used to build the topic names.
Raw data is only published via MQTT.

### Configuration of Tags

All tags that are listed in RscpTags.h and have "REQ" in their name can be used.
ADD_NEW_REQUEST and ADD_NEW_REQUEST_AT_START (for one-time execution at program start) are usable for configuration in the .config.

```
ADD_NEW_REQUEST=<container>:<tag>[:value]-<sequence>
ADD_NEW_REQUEST_AT_START=<container>:<tag>[:value]-<sequence>
```

Containers are substructured tags. But containers are not labeled as such and therefore cannot be distinguished from other tags. The root container has the value 0.
If several tags are queried for a container, a query sequence can be specified, otherwise use "0".
In some cases it is necessary to set a "value" first, e.g. to specify a battery pack, a wallbox or a photovoltaic inverter.

#### Example "IP address"
```
ADD_NEW_REQUEST_AT_START=0:TAG_INFO_REQ_IP_ADDRESS-0
# root container, tag for querying the IP address
```

#### Example "Battery info for the battery package with index 0"
```
ADD_NEW_REQUEST=TAG_BAT_REQ_DATA:TAG_BAT_INDEX:0-0
ADD_NEW_REQUEST=TAG_BAT_REQ_DATA:TAG_BAT_REQ_INFO-1
# battery data container, index value 0 as sequence 0 and request info as sequence 1
```

### Configuration of New Topics

If you have successfully configured a new tag and were able to find the output in the raw data, you can configure a new topic for it.

```
ADD_NEW_TOPIC=<container>:<tag>:<unit>:<divisor>:<bit_to_bool>:<topic>
```
Float values are divided by the divisor. In this way power values in Watt can be converted into kW.
Integer values can be converted to a boolean value (true/false) with "bit_to_bool" using a boolean AND.

unit = "_" will be handled as "no unit".

Please enter the topic without the prefix.

#### Example "IP address"
```
ADD_NEW_TOPIC=0:TAG_INFO_IP_ADDRESS:_:1:0:system/ip_address
```

rscp2mqtt always requests container and tag, no further levels. If further levels are output in the raw data, please specify the last two levels with ADD_NEW_TOPIC.

#### Example "Max DC Power"
```
ADD_NEW_REQUEST=0:TAG_EMS_REQ_MAX_DC_POWER-0
ADD_NEW_TOPIC=TAG_EMS_MAX_DC_POWER:TAG_EMS_PARAM_POWER_VALUE_L1:W:1:0:system/max_dc_power_L1
ADD_NEW_TOPIC=TAG_EMS_MAX_DC_POWER:TAG_EMS_PARAM_POWER_VALUE_L2:W:1:0:system/max_dc_power_L2
ADD_NEW_TOPIC=TAG_EMS_MAX_DC_POWER:TAG_EMS_PARAM_POWER_VALUE_L3:W:1:0:system/max_dc_power_L3
```

### Configuration of New Set Topics

```
ADD_NEW_SET_TOPIC=<container>:<tag>:<topic>:<regex>-<datatype<
# or
ADD_NEW_SET_TOPIC=<container>:<tag>:<topic>:<true_regex>:<true_value>:<false_regex>:<false_value>-<datatype<
```
You can use "regex" to define a regular expression that checks the input payload, e.g. for permitted numbers.

To check boolean values use the fields "true_regex" and "false_regex" to check the input payload for true and false. "true_value" and "false_value" define the values that are to be sent to the home power station.

Possible data types are "Bool", "Char8", "UChar8", "Int32", "UInt32" and "Float32".

See various examples in RscpMqttMapping.h

#### Example "Other set command for weather regulation"
```
ADD_NEW_SET_TOPIC=TAG_EMS_REQ_SET_POWER_SETTINGS:TAG_EMS_WEATHER_REGULATED_CHARGE_ENABLED:set/weather:^true|on|1$:1:^false|off|0$:0-UChar8
```

### One-time Execution

The program can be started that it executes only one entire interval.
```
./rscp2mqtt -1
```
### Remarks

The procedure for integrating new tags is always trial and error. The structure of the tags is not standardized. There is no guarantee that you will get the expected values. Sometimes you receive multiple tags or tag structures in response to a single query. A look at the list of generated errors can be very helpful.

RscpTags.h is based on the old portal, so new features may not be available.

If you have made a big catch and it makes sense to integrate what you have found directly into the tool, let the community know.

### Further Examples
```
ADD_NEW_REQUEST=0:TAG_EMS_REQ_IS_PV_DERATING-0
ADD_NEW_TOPIC=0:TAG_EMS_IS_PV_DERATING:_:1:0:system/is_pv_derating
# Network
ADD_NEW_REQUEST_AT_START=0:TAG_INFO_REQ_IP_ADDRESS-0
ADD_NEW_TOPIC=0:TAG_INFO_IP_ADDRESS:_:1:0:system/ip_address
ADD_NEW_REQUEST_AT_START=0:TAG_INFO_REQ_SUBNET_MASK-0
ADD_NEW_TOPIC=0:TAG_INFO_SUBNET_MASK:_:1:0:system/subnet_mask
ADD_NEW_REQUEST_AT_START=0:TAG_INFO_REQ_GATEWAY-0
ADD_NEW_TOPIC=0:TAG_INFO_GATEWAY:_:1:0:system/gateway
ADD_NEW_REQUEST_AT_START=0:TAG_INFO_REQ_DHCP_STATUS-0
ADD_NEW_TOPIC=0:TAG_INFO_DHCP_STATUS:_:1:0:system/dhcp_status
ADD_NEW_REQUEST_AT_START=0:TAG_INFO_REQ_DNS-0
ADD_NEW_TOPIC=0:TAG_INFO_DNS:_:1:0:system/dns
ADD_NEW_REQUEST_AT_START=0:TAG_INFO_REQ_MAC_ADDRESS-0
ADD_NEW_TOPIC=0:TAG_INFO_MAC_ADDRESS:_:1:0:system/mac_address
# Info Tag
ADD_NEW_REQUEST=0:TAG_INFO_REQ_INFO-0
ADD_NEW_REQUEST=TAG_NETWORK_REQ_INFO:TAG_NETWORK_PARAM_IP-0
# DC/DC
ADD_NEW_REQUEST=TAG_DCDC_REQ_DATA:TAG_DCDC_INDEX:0-0
ADD_NEW_REQUEST=TAG_DCDC_REQ_DATA:TAG_DCDC_REQ_STATUS-1
ADD_NEW_REQUEST=TAG_DCDC_REQ_DATA:TAG_DCDC_REQ_STATUS_AS_STRING-1
ADD_NEW_REQUEST=TAG_DCDC_REQ_DATA:TAG_DCDC_REQ_GET_BAT_CONNECTED-1
ADD_NEW_REQUEST=TAG_DCDC_REQ_DATA:TAG_DCDC_REQ_I_BAT-1
ADD_NEW_REQUEST=TAG_DCDC_REQ_DATA:TAG_DCDC_REQ_U_BAT-1
ADD_NEW_REQUEST=TAG_DCDC_REQ_DATA:TAG_DCDC_REQ_P_BAT-1
ADD_NEW_REQUEST=TAG_DCDC_REQ_DATA:TAG_DCDC_REQ_I_DCL-1
ADD_NEW_REQUEST=TAG_DCDC_REQ_DATA:TAG_DCDC_REQ_U_DCL-1
ADD_NEW_REQUEST=TAG_DCDC_REQ_DATA:TAG_DCDC_REQ_P_DCL-1
ADD_NEW_REQUEST=TAG_DCDC_REQ_DATA:TAG_DCDC_REQ_ON_GRID-1
ADD_NEW_REQUEST=TAG_DCDC_REQ_DATA:TAG_DCDC_REQ_DERATING-1
ADD_NEW_REQUEST=TAG_DCDC_REQ_DATA:TAG_DCDC_REQ_DERATING_VALUE-1
```
43 changes: 24 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Supported topic areas are:
- Values of the power meter (PM)
- Values of the photovoltaic inverter (PVI)
- Values of the emergency power supply (EP)
- Values of the wallbox (WB)
- Values of wallboxes (WB)

For continuous provision of values, you can configure several topics that are published in each cycle. Default: Only modified values will be published.

Expand All @@ -45,8 +45,10 @@ For continuous provision of values, you can configure several topics that are pu
- Historical data for past years
- Query of historical daily values
- Multiple power meters
- Switch between wallboxes
- TLS connections ([MQTT broker](MQTT_TLS.md), InfluxDB)
- Multiple wallboxes
- TLS connections ([MQTT broker](MQTT_TLS.md), [InfluxDB](INFLUXDB.md))
- [Additional tags and topics](NEWTAGS.md) by configuration
- Raw data mode

Please also take a look at the [release notes](RELEASE.md).

Expand Down Expand Up @@ -135,7 +137,7 @@ To do this, set in the .config file: `LOG_MODE=BUFFERED`.
You can also switch off the logging of such messages completely with `LOG_MODE=OFF`.
If every event is to be logged: `LOG_MODE=ON`.

## Program start
## Program Start

Start the program:
```
Expand All @@ -153,19 +155,10 @@ or to show the help page
If everything works properly, you will see something like this:

```
rscp2mqtt [3.25]
rscp2mqtt [3.26]
E3DC system >192.168.178.111:5033< user: >your E3DC user<
MQTT broker >localhost:1883< qos = >0< retain = >false< tls >✗< client id >✗< prefix >e3dc<
Fetching data every second.
Requesting PVI ✓ | PM (0) | DCB ✓ (1 battery string) | Wallbox (0) ✗ | Autorefresh ✓
Log Level = 2 (BUFFERED)
Stdout to terminal
[2024-06-08 08:00:00] pid=30250 ppid=1 RscpMqttMain.cpp(3022) Connecting to server 192.168.178.111:5033
[2024-06-08 08:00:00] pid=30250 ppid=1 RscpMqttMain.cpp(3029) Success: E3DC connected.
[2024-06-08 08:00:00] pid=30250 ppid=1 RscpMqttMain.cpp(1903) RSCP authentication level 10
[2024-06-08 08:00:00] pid=30250 ppid=1 RscpMqttMain.cpp(2435) Connecting to broker localhost:1883
[2024-06-08 08:00:00] pid=30250 ppid=1 RscpMqttMain.cpp(2456) Success: MQTT broker connected.
MQTT broker >localhost:1883< qos = >0< retain = >✗< tls >✗< client id >✗< prefix >e3dc<
Requesting PVI ✓ | PM (0) | DCB ✓ (1 battery string) | Wallbox ✗ | Interval 2 | Autorefresh ✓ | Raw data ✗ | Logging OFF
```

Check the configuration if the connections are not established.
Expand Down Expand Up @@ -356,11 +349,11 @@ Turn on the functionality in the configuration file .config, add/change the foll
AUTO_REFRESH=true
```

## Wallbox Control
### Wallbox Control

The commands for controlling an E3/DC wallbox can be found [here](WALLBOX.md).

## Historical daily data
### Historical Daily Data

Historical data for a specific day (format "YYYY-MM-DD") can be queried by
```
Expand All @@ -372,7 +365,7 @@ Please use the script `request_days.sh` to request data for a time span.
./request_days.sh localhost 1883 e3dc 2024-01-01 2024-01-13
```

## System Commands
### System Commands

Refresh all topics
```
Expand Down Expand Up @@ -406,6 +399,14 @@ Turn DCB requests on or off (true/1/false/0)
```
mosquitto_pub -h localhost -p 1883 -t "e3dc/set/requests/dcb" -m true
```
Turn EMS requests on or off (true/1/false/0)
```
mosquitto_pub -h localhost -p 1883 -t "e3dc/set/requests/ems" -m true
```
Turn history requests on or off (true/1/false/0)
```
mosquitto_pub -h localhost -p 1883 -t "e3dc/set/requests/history" -m true
```
Turn SOC limiter on or off (true/1/false/0)
```
mosquitto_pub -h localhost -p 1883 -t "e3dc/set/soc_limiter" -m true
Expand All @@ -418,6 +419,10 @@ Turn statistic values on or off (true/1/false/0)
```
mosquitto_pub -h localhost -p 1883 -t "e3dc/set/statistic_values" -m true
```
Turn raw data mode on or off (true/1/false/0)
```
mosquitto_pub -h localhost -p 1883 -t "e3dc/set/raw_mode" -m true
```

## Used Libraries and Licenses

Expand Down
11 changes: 11 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
## Release Notes

### Release v3.26 (14.07.2024)

Features:
- Issue #76: Multiple wallboxes
- Additional tags and topics by configuration
- Raw data mode
- Deletion of deprecated wallbox commands (e3dc/set/wallbox/control)

Pull request:
- #78 (build workflow)

### Release v3.25 (08.06.2024)

Features:
Expand Down
23 changes: 21 additions & 2 deletions RscpMqttConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@
#define MAX_PM_COUNT 8
#define MAX_WB_COUNT 8

typedef struct _wb_t {
int day_add_total[MAX_WB_COUNT];
int day_total[MAX_WB_COUNT];
int day_add_solar[MAX_WB_COUNT];
int day_solar[MAX_WB_COUNT];
int last_wallbox_energy_total_start[MAX_WB_COUNT];
int last_wallbox_energy_solar_start[MAX_WB_COUNT];
int last_wallbox_plugged_last[MAX_WB_COUNT];
int last_diff_total[MAX_WB_COUNT];
int last_diff_solar[MAX_WB_COUNT];
int last_add_total[MAX_WB_COUNT];
int last_add_solar[MAX_WB_COUNT];
} wb_t;

typedef struct _config_t {
char e3dc_ip[20];
uint32_t e3dc_port;
Expand Down Expand Up @@ -51,6 +65,7 @@ typedef struct _config_t {
char *logfile;
char *historyfile;
bool verbose;
bool once;
int interval;
int log_level;
bool save_memory;
Expand All @@ -62,14 +77,17 @@ typedef struct _config_t {
int bat_dcb_start[MAX_DCB_COUNT];
bool pm_extern;
int pm_number;
int pm_index[MAX_PM_COUNT];
int pm_indexes[MAX_PM_COUNT];
bool pm_requests;
bool ems_requests;
bool hst_requests;
bool dcb_requests;
bool soc_limiter;
bool daily_values;
bool statistic_values;
bool wallbox;
int wb_index;
int wb_number;
int wb_indexes[MAX_WB_COUNT];
bool daemon;
bool mqtt_pub;
#ifdef INFLUXDB
Expand All @@ -79,6 +97,7 @@ typedef struct _config_t {
bool store_setup;
char true_value[5];
char false_value[6];
bool raw_mode;
} config_t;

#endif
Loading

0 comments on commit a71132e

Please sign in to comment.