Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ae3e616
Save token to file
hyzteric Jun 12, 2024
69ef352
Update README.md
hyzteric Jun 12, 2024
2d7896a
Store token and reuse it (Todo : send refresh token)
hyzteric Jun 13, 2024
7e40439
Merge branch 'master' of https://github.com/hyzteric/Smappee-NodeJS
hyzteric Jun 13, 2024
2f9b354
Update README.md
hyzteric Jun 16, 2024
0e25fc2
Refresh token if current is expired
hyzteric Jun 16, 2024
5a59f0e
Update README.md
hyzteric Jun 16, 2024
a94f033
Update README.md
hyzteric Jun 16, 2024
174deb9
Update mqtt methods
hyzteric Jun 16, 2024
7d4036d
Update README.md
hyzteric Jun 16, 2024
ea672c8
Fix mqtt publish for charging session
hyzteric Jun 17, 2024
06c11c2
Merge branch 'master' of https://github.com/hyzteric/Smappee-NodeJS
hyzteric Jun 17, 2024
50db9e2
chargingstations session api response contains extra [ ] that needed …
hyzteric Jun 20, 2024
4fd9778
add timestamp to charging sessions manually
hyzteric Jun 20, 2024
e775226
Add negative session ID when there is no charging session
hyzteric Jun 20, 2024
e5f1a69
Update README.md
hyzteric Jul 3, 2024
9983072
less log
hyzteric Jul 10, 2024
64194e7
Merge branch 'master' of https://github.com/hyzteric/Smappee-NodeJS
hyzteric Jul 10, 2024
651665b
Update README.md
hyzteric Jul 10, 2024
37743fa
Update README.md
hyzteric Jul 10, 2024
cf7be7e
update package info with new git name
hyzteric Jul 10, 2024
ea4361c
update version number
hyzteric Jul 10, 2024
e3f9389
add mqtt trace
hyzteric Jul 10, 2024
284801f
add version
hyzteric Jul 10, 2024
d371d08
Async fix
hyzteric Jul 16, 2024
eb4342a
update readme on node.js
hyzteric Jul 16, 2024
456183e
Better error handling
hyzteric Jul 18, 2024
f57b525
Update README.md
hyzteric Jul 18, 2024
88d8429
Fix getCurrentChargingSession return when charging session is over
hyzteric Sep 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 46 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,55 @@
# Smappee-NodeJS
Smappee nodejs project to read smappee data.
Please note : this fork is just sending the last 5 min consumption and current charging session to mqtt at this stage. I did never code in Node JS so I'll see what I can do...
Todo list :
- Store token in file ✅
- Read token from file ✅
- Request new token if token is expired ✅
- Implement EV line API requests ✅ (read current session only)
- Send data to MQTT server : partial
- Remove deprecated dependency : https://github.com/request/request/issues/3142

# Smappee2MQTT (with NodeJS)
This nodejs project allows to read data from the smappee API and send it to an MQTT server. Tested with Mosquitto MQTT server and openHab to import Electric Car (EV) charging session status and house consumption.

Based on https://support.smappee.com/hc/en-us/articles/202153935-Where-can-I-find-the-API-documentation-

## Installation
```bash
npm install smappee-nodejs --save
npm install smappee2mqtt --save
```

## Usage
### Create a new file 'my-smappee.js'
```javascript
var SmappeeAPI = require('smappee-nodejs');
var SmappeeAPI = require('smappee2mqtt');

var smappee = new SmappeeAPI({
debug: false,
noAPIcall: false,

clientId: "xxx",
clientSecret: "xxx",

username: "xxx",
password: "xxx"
password: "xxx",

mqtt_server: "xxx",
mqtt_port: "xxx",
mqtt_baseTopic : "smappee/"
});

module.exports = smappee;
```

### In another nodejs file
### In another nodejs file : test.js
```javascript
var smappee = require('./my-smappee');

smappee.getServiceLocations(function(output) {
console.log(output);
})
```
### To run your test.js file type :
> node test.js

The following functions are available:
`getServiceLocations(callback)`, `getServiceLocationInfo(serviceLocationId, callback)`, ...
Expand Down Expand Up @@ -73,4 +89,27 @@ var to = moment().utc().valueOf();
smappee.getConsumptions("0000", smappee.AGGREGATION_TYPES.MONTHLY, from, to, function(output) {
console.log(output);
})
```
```

### getLatestConsumption(serviceLocationId, callback)
Get a list of latest consumptions

```javascript
var smappee = require('./my-smappee');

smappee.getLatestConsumption(serviceLocationId, function(output) {
console.log("getLatestConsumption (multiply WH by 12 if aggregate by 5 minutes since 5*12 = one hour to get Watts) : ",output);
})
```

### getCurrentChargingSession(serviceLocationId,aggregation, from, to, callback)
Get a list of current charging session (will return -1 if no car is charging)

```javascript
var smappee = require('./my-smappee');
smappee.getCurrentChargingSession(chargingStationSN, function(output){
console.log(output);
})
```

TIP: To convert the 5 minute interval from Energy [Wh] to Power [W], like the Smappee Dashboard reports these, you have to do these values times 12 as there are 12 x 5 minute intervals in an hour.
8 changes: 6 additions & 2 deletions example/my-smappee.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var SmappeeAPI = require('smappee-nodejs');
var SmappeeAPI = require('smappee2mqtt');

var smappee = new SmappeeAPI({
debug: true,
Expand All @@ -7,7 +7,11 @@ var smappee = new SmappeeAPI({
clientSecret: "xxx",

username: "xxx",
password: "xxx"
password: "xxx",

mqtt_server: "192.168.0.1",
mqtt_port: "1883",
mqtt_baseTopic : "smappee/"
});

module.exports = smappee;
Loading