Skip to content

Commit 03f56c0

Browse files
committed
Merge branch 'release/0.5.2'
2 parents 2d0749a + 60979ef commit 03f56c0

6 files changed

Lines changed: 5623 additions & 5691 deletions

File tree

Gemfile.lock

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
activesupport (7.2.2)
4+
activesupport (8.0.0)
55
base64
66
benchmark (>= 0.3)
77
bigdecimal
@@ -13,11 +13,12 @@ GEM
1313
minitest (>= 5.1)
1414
securerandom (>= 0.3)
1515
tzinfo (~> 2.0, >= 2.0.5)
16+
uri (>= 0.13.1)
1617
addressable (2.8.7)
1718
public_suffix (>= 2.0.2, < 7.0)
1819
ast (2.4.2)
1920
base64 (0.2.0)
20-
benchmark (0.3.0)
21+
benchmark (0.4.0)
2122
bigdecimal (3.1.8)
2223
concurrent-ruby (1.3.4)
2324
connection_pool (2.4.1)
@@ -70,7 +71,7 @@ GEM
7071
rubocop-ast (>= 1.32.2, < 2.0)
7172
ruby-progressbar (~> 1.7)
7273
unicode-display_width (>= 2.4.0, < 3.0)
73-
rubocop-ast (1.34.0)
74+
rubocop-ast (1.34.1)
7475
parser (>= 3.3.1.0)
7576
rubocop-rake (0.6.0)
7677
rubocop (~> 1.0)
@@ -89,6 +90,7 @@ GEM
8990
tzinfo-data (1.2024.2)
9091
tzinfo (>= 1.0.0)
9192
unicode-display_width (2.6.0)
93+
uri (1.0.1)
9294
vcr (6.3.1)
9395
base64
9496
webmock (3.24.0)

README.md

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -47,49 +47,31 @@ docker exec -it solectrus-redis-1 redis-cli FLUSHALL
4747

4848
Check the `.env` variable `INSTALLATION_DATE`. This must be set to the day your PV system was installed.
4949

50-
### SENEC: Dealing with missing wallbox measurements
51-
52-
The CSV data from mein-senec.de is not complete, there are no measurements for the wallbox. To get around this, wallbox charges are **estimated** using the following formula:
53-
54-
```
55-
wallbox_charge_power = inverter_power (Stromerzeugung)
56-
+ grid_power_plus (Netzbezug)
57-
+ bat_power_minus (Akkuentnahme)
58-
- grid_power_minus (Netzeinspeisung)
59-
- house_power (Stromverbrauch)
60-
- bat_power_plus (Akkubeladung)
61-
```
62-
63-
Please note that this method appears to be ineffective for processing CSV files that were created from July 2022 onwards. This is because wallbox charges are now being included in the overall house consumption since that time. Therefore, it seems that there is currently no way to import wallbox measurements.
64-
65-
The [senec-collector](https://github.com/solectrus/senec-collector) does not have this problem, as it obtains the wallbox measurements directly.
66-
6750
### Configuration
6851

6952
The following environment variables can be used to configure the importer:
7053

71-
| Variable | Description | Default |
72-
| --------------------------------------- | ----------------------------------------------- | ---------------------------- |
73-
| `INFLUX_HOST` | Hostname of InfluxDB | |
74-
| `INFLUX_SCHEMA` | Schema (http/https) of InfluxDB | `http` |
75-
| `INFLUX_PORT` | Port of InfluxDB | `8086` |
76-
| `INFLUX_TOKEN_WRITE` or `INFLUX_TOKEN` | Token for InfluxDB (requires write permissions) | |
77-
| `INFLUX_ORG` | Organization for InfluxDB | |
78-
| `INFLUX_BUCKET` | Bucket for InfluxDB | |
79-
| `INFLUX_OPEN_TIMEOUT` | Timeout for InfluxDB connection (in seconds) | `30` |
80-
| `INFLUX_READ_TIMEOUT` | Timeout for InfluxDB read (in seconds) | `30` |
81-
| `INFLUX_WRITE_TIMEOUT` | Timeout for InfluxDB write (in seconds) | `30` |
82-
| `INFLUX_SENSOR_INVERTER_POWER` | Measurement/field for inverter power | `SENEC:inverter_power` |
83-
| `INFLUX_SENSOR_HOUSE_POWER` | Measurement/field for house power | `SENEC:house_power` |
84-
| `INFLUX_SENSOR_GRID_IMPORT_POWER` | Measurement/field for grid import power | `SENEC:grid_power_plus` |
85-
| `INFLUX_SENSOR_GRID_EXPORT_POWER` | Measurement/field for grid export power | `SENEC:grid_power_minus` |
86-
| `INFLUX_SENSOR_BATTERY_CHARGE_POWER` | Measurement/field for battery charge power | `SENEC:bat_power_plus` |
87-
| `INFLUX_SENSOR_BATTERY_DISCHARGE_POWER` | Measurement/field for battery discharge power | `SENEC:bat_power_minus` |
88-
| `INFLUX_SENSOR_WALLBOX_POWER` | Measurement/field for wallbox power | `SENEC:wallbox_charge_power` |
89-
| `SENEC_IGNORE` | Optionally ignore some fields (comma-separated) | |
90-
| `IMPORT_FOLDER` | Folder where CSV files are located | `/data` |
91-
| `IMPORT_PAUSE` | Pause after each imported file (in seconds) | `0` |
92-
| `TZ` | Time zone to use when parsing times | `Europe/Berlin` |
54+
| Variable | Description | Default |
55+
| --------------------------------------- | ----------------------------------------------- | ------------------------ |
56+
| `INFLUX_HOST` | Hostname of InfluxDB | |
57+
| `INFLUX_SCHEMA` | Schema (http/https) of InfluxDB | `http` |
58+
| `INFLUX_PORT` | Port of InfluxDB | `8086` |
59+
| `INFLUX_TOKEN_WRITE` or `INFLUX_TOKEN` | Token for InfluxDB (requires write permissions) | |
60+
| `INFLUX_ORG` | Organization for InfluxDB | |
61+
| `INFLUX_BUCKET` | Bucket for InfluxDB | |
62+
| `INFLUX_OPEN_TIMEOUT` | Timeout for InfluxDB connection (in seconds) | `30` |
63+
| `INFLUX_READ_TIMEOUT` | Timeout for InfluxDB read (in seconds) | `30` |
64+
| `INFLUX_WRITE_TIMEOUT` | Timeout for InfluxDB write (in seconds) | `30` |
65+
| `INFLUX_SENSOR_INVERTER_POWER` | Measurement/field for inverter power | `SENEC:inverter_power` |
66+
| `INFLUX_SENSOR_HOUSE_POWER` | Measurement/field for house power | `SENEC:house_power` |
67+
| `INFLUX_SENSOR_GRID_IMPORT_POWER` | Measurement/field for grid import power | `SENEC:grid_power_plus` |
68+
| `INFLUX_SENSOR_GRID_EXPORT_POWER` | Measurement/field for grid export power | `SENEC:grid_power_minus` |
69+
| `INFLUX_SENSOR_BATTERY_CHARGE_POWER` | Measurement/field for battery charge power | `SENEC:bat_power_plus` |
70+
| `INFLUX_SENSOR_BATTERY_DISCHARGE_POWER` | Measurement/field for battery discharge power | `SENEC:bat_power_minus` |
71+
| `SENEC_IGNORE` | Optionally ignore some fields (comma-separated) | |
72+
| `IMPORT_FOLDER` | Folder where CSV files are located | `/data` |
73+
| `IMPORT_PAUSE` | Pause after each imported file (in seconds) | `0` |
74+
| `TZ` | Time zone to use when parsing times | `Europe/Berlin` |
9375

9476
## License
9577

app/adapters/senec_record.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def data
1818
battery_discharging_power
1919
grid_import_power
2020
grid_export_power
21-
wallbox_power
2221
].filter_map do |sensor_name|
2322
next if config.senec_ignore.include?(config.field(sensor_name))
2423

@@ -76,15 +75,6 @@ def grid_export_power
7675
parse_kw(row, 'Netzeinspeisung [kW]', 'Netzeinspeisung [kWh]')
7776
end
7877

79-
# Estimate wallbox power based on the other values
80-
def wallbox_power
81-
incoming = inverter_power + grid_import_power + battery_discharging_power
82-
outgoing = grid_export_power + house_power + battery_charging_power
83-
diff = incoming - outgoing
84-
85-
diff < 50 ? 0 : diff
86-
end
87-
8878
# KiloWatt
8979
def parse_kw(row, *)
9080
(cell(row, *).sub(',', '.').to_f * 1_000).round

app/config.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
grid_export_power
88
battery_charging_power
99
battery_discharging_power
10-
wallbox_power
1110
].freeze
1211

1312
Config =
@@ -30,7 +29,6 @@
3029
:influx_sensor_grid_export_power,
3130
:influx_sensor_battery_charging_power,
3231
:influx_sensor_battery_discharging_power,
33-
:influx_sensor_wallbox_power,
3432
### SENEC only: Optionally ignore some fields
3533
:senec_ignore,
3634
###
@@ -95,7 +93,6 @@ def self.sensors_from_env
9593
influx_sensor_battery_discharging_power: ENV.fetch(
9694
'INFLUX_SENSOR_BATTERY_DISCHARGING_POWER', 'SENEC:bat_power_minus',
9795
),
98-
influx_sensor_wallbox_power: ENV.fetch('INFLUX_SENSOR_WALLBOX_POWER', 'SENEC:wallbox_charge_power'),
9996
senec_ignore: ENV.fetch('SENEC_IGNORE', '').split(',').map(&:to_sym),
10097
}
10198
end

spec/adapters/senec_record_spec.rb

Lines changed: 28 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -50,76 +50,37 @@
5050
describe '#to_a' do
5151
subject(:to_a) { record.to_a }
5252

53-
context 'without wallbox calculation' do
54-
let(:fields) do
55-
[
56-
'14.03.2022 00:13:13',
57-
'0,197754',
58-
'0',
59-
'0,199219',
60-
'0',
61-
'0',
62-
'0',
63-
'0',
64-
'0',
65-
]
66-
end
67-
68-
let(:expected_fields) do
69-
{
70-
inverter_power: 0,
71-
house_power: 199,
72-
bat_power_plus: 0,
73-
bat_power_minus: 0,
74-
grid_power_plus: 198,
75-
grid_power_minus: 0,
76-
wallbox_charge_power: 0,
77-
}
78-
end
79-
80-
it do
81-
expect(to_a).to eq([
82-
time: 1_647_213_193,
83-
name: 'SENEC',
84-
fields: expected_fields,
85-
])
86-
end
53+
let(:fields) do
54+
[
55+
'14.03.2022 00:13:13',
56+
'0,197754',
57+
'0',
58+
'0,199219',
59+
'0',
60+
'0',
61+
'0',
62+
'0',
63+
'0',
64+
]
8765
end
8866

89-
context 'with wallbox calculation' do
90-
let(:fields) do
91-
[
92-
'21.03.2022 13:00:46',
93-
'0,00146',
94-
'0,840947',
95-
'0,227756',
96-
'0',
97-
'0',
98-
'7,311566',
99-
'0',
100-
'0',
101-
]
102-
end
103-
104-
let(:expected_fields) do
105-
{
106-
inverter_power: 7312,
107-
house_power: 228,
108-
bat_power_plus: 0,
109-
bat_power_minus: 0,
110-
grid_power_plus: 1,
111-
grid_power_minus: 841,
112-
wallbox_charge_power: 6244,
113-
}
114-
end
115-
116-
it {
117-
expect(to_a).to eq([
118-
time: 1_647_864_046,
119-
name: 'SENEC',
120-
fields: expected_fields,
121-
])
67+
let(:expected_fields) do
68+
{
69+
inverter_power: 0,
70+
house_power: 199,
71+
bat_power_plus: 0,
72+
bat_power_minus: 0,
73+
grid_power_plus: 198,
74+
grid_power_minus: 0,
12275
}
12376
end
77+
78+
it do
79+
expect(to_a).to eq([
80+
time: 1_647_213_193,
81+
name: 'SENEC',
82+
fields: expected_fields,
83+
])
84+
end
12485
end
12586
end

0 commit comments

Comments
 (0)