Skip to content

Commit

Permalink
New EnergyMeter class for Wifi module, replace counter from OpenEvse …
Browse files Browse the repository at this point in the history
…module

Published properties:
 - session_elapsed : sec
 - session_energy  : wh
 - total_energy    : kwh
 - total_day       : kwh
 - total_week      : kwh
 - total_month     : kwh
 - total_year      : kwh
 - total_switches  : number of times the relay has been commutated

Evse counter is imported one time only. If counter is manually reset again, it won't import it the second time.

add new api endpoint /emeter
 DELETE { "hard": 0|1 , "import": 0|1}

edited api.yml
  • Loading branch information
KipK committed Mar 8, 2023
1 parent aa7fab5 commit 7cdd51e
Show file tree
Hide file tree
Showing 15 changed files with 892 additions and 88 deletions.
48 changes: 46 additions & 2 deletions api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ paths:
temp3: -2560
state: 254
elapsed: 3473
wattsec: 22493407
watthour: 51536
session_energy: 25034
total_energy: 998
total_day: 23
total_week: 68
total_month: 126
total_year: 998
gfcicount: 0
nogndcount: 0
stuckcount: 0
Expand Down Expand Up @@ -617,6 +621,46 @@ paths:
operationId: limit_clear
tags:
- Limit
/emeter:
delete:
summary: Reset Energy Meter
description: This will clear the Energy Meter
requestBody:
content:
application/json:
schema:
type: object
properties:
hard:
type: int
description: 0|1 Enable hard reset ( reset total_counter & total_switches)
import:
type: int
description: 0|1 Import OpenEvse module total kwh.
responses:
'200':
description: Reset counter ok
content:
application/json:
schema:
type: object
properties:
msg:
type: string
description: Reset done
'500':
description: Failed to reset counter
content:
application/json:
schema:
type: object
properties:
msg:
type: string
description: Reset failed
operationId: energymeter-reset
tags:
- Energy Meter

/tesla/vehicles:
get:
Expand Down
24 changes: 18 additions & 6 deletions models/Status.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,24 @@ properties:
elapsed:
type: number
description: 'The duration of the current charge session, in seconds'
wattsec:
type: integer
description: 'The amount of energy transfered in this charge session, in W/sec'
watthour:
type: integer
description: 'The total amount of energy transfered, in W/hour'
session_energy:
type: number
description: 'The total amount of energy accumulated for current session (in wh)'
total_energy:
type: number
description: 'The total amount of energy accumulated (in kwh)'
total_day:
type: number
description: 'The total amount of energy accumulated today (in kwh)'
total_week:
type: number
description: 'The total amount of energy accumulated this week (in kwh)'
total_month:
type: number
description: 'The total amount of energy accumulated this month (in kwh)'
total_yaer:
type: number
description: 'The total amount of energy accumulated the year (in kwh)'
gfcicount:
type: integer
description: Number of GFCI errors
Expand Down
5 changes: 3 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ lib_ignore = WebSockets ; ArduinoOcpp: don't compile built-in WS library
extra_scripts = scripts/extra_script.py
debug_flags =
-ggdb
-D ENABLE_DEBUG
#-D ENABLE_DEBUG
#-D ENABLE_DEBUG_WEB
#-D ENABLE_DEBUG_WEB_REQUEST
#-D ENABLE_DEBUG_SCHEDULER
Expand All @@ -62,6 +62,7 @@ debug_flags =
#-D ENABLE_PROFILE
#-D ENABLE_NOISY_PROFILE
#-D ENABLE_DEBUG_MICROTASKS
#-D ENABLE_DEBUG_ENERGY_METER
src_build_flags =
# -D ARDUINOJSON_USE_LONG_LONG
# -D ENABLE_ASYNC_WIFI_SCAN
Expand All @@ -77,7 +78,7 @@ build_flags =
#-D MG_SSL_IF_MBEDTLS_MAX_FRAG_LEN=2048
#-D ARDUINO_MONGOOSE_DEFAULT_STREAM_BUFFER=2048
#-D ARDUINO_MONGOOSE_SEND_BUFFER_SIZE=2048
#-D ENABLE_DEBUG
-D ENABLE_DEBUG
#-D CS_ENABLE_DEBUG
#-D MBEDTLS_DEBUG_C
-D MG_ENABLE_SNTP=1
Expand Down
4 changes: 4 additions & 0 deletions src/emonesp.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@
#define AMPS_SCALE_FACTOR 1000.0
#endif

#ifndef POWER_SCALE_FACTOR
#define POWER_SCALE_FACTOR 1.0
#endif

#ifndef TEMP_SCALE_FACTOR
#define TEMP_SCALE_FACTOR 10.0
#endif
Expand Down
Loading

0 comments on commit 7cdd51e

Please sign in to comment.