Skip to content

Commit

Permalink
v3.7: prefix, dcb, units
Browse files Browse the repository at this point in the history
  • Loading branch information
pvtom committed Aug 26, 2023
1 parent 79c19c9 commit 7e7eda7
Show file tree
Hide file tree
Showing 9 changed files with 557 additions and 241 deletions.
22 changes: 22 additions & 0 deletions HA_MQTT_DISCOVERY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Home Assistant - MQTT Discovery

Here are a few examples to connect rscp2mqtt with the tool Home Assistant. The Home Assistant offers "MQTT Discovery" for this purpose. Please adapt to your own needs.
For the Home Assistant, the MQTT integration must be configured with discovery prefix "homeassistent". Follow the manual on https://www.home-assistant.io/integrations/mqtt/

Power
```
mosquitto_pub -h localhost -p 1883 -r -t "homeassistant/sensor/rscp2mqtt/solar_power/config" -m '{ "state_topic": "e3dc/solar/power", "device": { "identifiers": "e3dc", "name": "e3dc", "model": "S10", "manufacturer": "E3/DC", "sa": "S10" }, "unique_id": "e3dc_solar_power", "name": "Solar Power", "unit_of_measurement": "W", "device_class": "power" }'
```

Energy
```
mosquitto_pub -h localhost -p 1883 -r -t "homeassistant/sensor/rscp2mqtt/solar_energy/config" -m '{ "state_topic": "e3dc/solar/energy", "device": { "identifiers": "e3dc", "name": "e3dc", "model": "S10", "manufacturer": "E3/DC", "sa": "S10" }, "unique_id": "e3dc_solar_energy", "name": "Solar Energy", "unit_of_measurement": "kWh", "device_class": "energy" }'
```

Switch
```
mosquitto_pub -h localhost -p 1883 -r -t "homeassistant/switch/rscp2mqtt/set_weather_regulation/config" -m '{ "state_topic": "e3dc/ems/weather_regulation", "command_topic": "e3dc/set/weather_regulation", "payload_on": "true", "payload_off": "false", "state_on": "true", "state_off": "false", "device": { "identifiers": "e3dc", "name": "e3dc", "model": "S10", "manufacturer": "E3/DC", "sa": "S10" }, "unique_id": "set_e3dc_weather_regulation", "name": "Weather Regulation", "device_class": "switch" }'
```

If the MQTT broker runs on another server, please use its name instead of `localhost` and change the port if it is different.
Please adjust the calls if you use a different prefix.
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ Supported topic areas are:

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

## New Features
## Features

- (new) Topic prefix is configurable
- E3/DC [wallbox](WALLBOX.md) topics
- [InfluxDB](INFLUXDB.md) support
- Topics for temperatures (battery, PVI)
- Idle periods
- System error messages
- (new) Details of the battery modules (DCB)
- (new) Additional topics for PVI
- (new) Units as InfluxDB tags
- Docker image at https://hub.docker.com/r/pvtom/rscp2mqtt

## Docker
Expand Down Expand Up @@ -114,7 +118,7 @@ E3DC_PASSWORD=your_e3dc_password
// AES password
E3DC_AES_PASSWORD=your_aes_password
// Target MQTT broker
MQTT_HOST=localhost
MQTT_HOST=your_mqtt_broker
// Default port is 1883
MQTT_PORT=1883
// MQTT user / password authentication necessary? Depends on the MQTT broker configuration.
Expand All @@ -125,6 +129,8 @@ MQTT_PASSWORD=
// MQTT parameters
MQTT_QOS=0
MQTT_RETAIN=false
// Topic prefix (max 24 characters), default is e3dc
PREFIX=e3dc
// log file
LOGFILE=/tmp/rscp2mqtt.log
// Interval requesting the E3/DC S10 device in seconds (1..10)
Expand All @@ -135,8 +141,10 @@ PVI_REQUESTS=true
PVI_TRACKER=2
// enable PM requests, default is true
PM_REQUESTS=true
// use external PM (S10 Mini)
// use external PM (S10 Mini), default is false
PM_EXTERN=false
// enable DCB (details for battery modules) requests, default is true
DCB_REQUESTS=true
// Auto refresh, default is false
AUTO_REFRESH=false
// Disable MQTT publish support (dryrun mode)
Expand All @@ -148,6 +156,8 @@ FORCE_PUB=e3dc/[a-z]+/power
FORCE_PUB=e3dc/battery/soc
```

The prefix of the topics can be configured by the attribute PREFIX. By default all topics start with "e3dc". This can be changed to any other string that MQTT accepts as a topic, max. 24 characters. E.g. "s10" or "s10/1".

Find InfluxDB configurations in [InfluxDB](INFLUXDB.md).

The parameter FORCE_PUB can occur several times. You can use it to define topics that will be published in each cycle, even if the values do not change. To check the definition, look at the log output after the program start.
Expand Down Expand Up @@ -189,6 +199,9 @@ MQTT: publish topic >e3dc/coupling/mode< payload >3<

Check the configuration if the connections are not established.

Notes: In the following examples I assume that the MQTT broker runs on the same machine as `rscp2mqtt` under port 1883. If the MQTT broker runs on another server, please use its name instead of `localhost` and change the port if it is different.
The default prefix `e3dc` is used for the topics. Please adjust the calls if you use a different prefix.

If you use the Mosquitto tools you can subscribe the topics with (here without user / password)

```
Expand Down Expand Up @@ -232,7 +245,7 @@ If stdout is redirected to another process or rscp2mqtt is started with option -

## Device Control

rscp2mqtt subscribes to the root topic "e3dc/set/#" and forwards incoming requests to the S10 home power station. In this way, the unit can be controlled and changes made to its configuration.
rscp2mqtt subscribes to the root topic "prefix/set/#" and forwards incoming requests to the S10 home power station. In this way, the device can be controlled and changes made to its configuration.

### Battery Charging

Expand Down Expand Up @@ -376,6 +389,10 @@ Set PVI requests on or off (true/1/false/0)
```
mosquitto_pub -h localhost -p 1883 -t "e3dc/set/requests/pvi" -m true
```
Set DCB requests on or off (true/1/false/0)
```
mosquitto_pub -h localhost -p 1883 -t "e3dc/set/requests/dcb" -m true
```

## Used Libraries and Licenses

Expand Down
3 changes: 3 additions & 0 deletions RscpMqttConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ typedef struct _config_t {
char influxdb_bucket[128];
char influxdb_token[128];
#endif
char prefix[25];
char *logfile;
bool verbose;
int interval;
bool pvi_requests;
int pvi_tracker;
int pvi_temp_count;
int bat_dcb_count;
bool pm_extern;
bool pm_requests;
bool dcb_requests;
bool wallbox;
bool daemon;
bool mqtt_pub;
Expand Down
Loading

0 comments on commit 7e7eda7

Please sign in to comment.