-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from valiquette/update
Update
- Loading branch information
Showing
11 changed files
with
729 additions
and
671 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,42 @@ | ||
let wallboxAPI=require('../wallboxapi') | ||
|
||
function battery (platform,log){ | ||
this.log=log | ||
this.platform=platform | ||
this.wallboxapi=new wallboxAPI(this,log) | ||
} | ||
|
||
battery.prototype={ | ||
|
||
createBatteryService(device){ | ||
class battery { | ||
constructor(platform, log) { | ||
this.log = log | ||
this.platform = platform | ||
this.wallboxapi = new wallboxAPI(this, log) | ||
} | ||
|
||
createBatteryService(device) { | ||
this.log.info('Adding battery service for %s charger ', device.name) | ||
this.log.debug("create battery service for %s", device.name) | ||
let batteryStatus | ||
let stateOfCharge=0 | ||
if(device.stateOfCharge){stateOfCharge=device.stateOfCharge} | ||
batteryStatus=new Service.Battery(device.name, device.id) | ||
let stateOfCharge = 0 | ||
if (device.stateOfCharge) { stateOfCharge = device.stateOfCharge} | ||
batteryStatus = new Service.Battery(device.name, device.id) | ||
batteryStatus | ||
.setCharacteristic(Characteristic.StatusLowBattery,Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL) | ||
.setCharacteristic(Characteristic.StatusLowBattery, Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL) | ||
.setCharacteristic(Characteristic.BatteryLevel, stateOfCharge) | ||
.setCharacteristic(Characteristic.ChargingState, Characteristic.ChargingState.NOT_CHARGING) | ||
.setCharacteristic(Characteristic.ActiveIdentifier, device.maxAvailableCurrent) | ||
return batteryStatus | ||
}, | ||
return batteryStatus | ||
} | ||
|
||
configureBatteryService(batteryStatus){ | ||
this.log.debug("configured battery service for %s",batteryStatus.getCharacteristic(Characteristic.Name).value) | ||
batteryStatus | ||
configureBatteryService(batteryStatus) { | ||
this.log.debug("configured battery service for %s", batteryStatus.getCharacteristic(Characteristic.Name).value) | ||
batteryStatus | ||
.getCharacteristic(Characteristic.StatusLowBattery) | ||
}, | ||
} | ||
|
||
getStatusLowBattery(batteryStatus,callback){ | ||
let batteryValue=batteryStatus.getCharacteristic(Characteristic.BatteryLevel).value | ||
getStatusLowBattery(batteryStatus, callback) { | ||
let batteryValue = batteryStatus.getCharacteristic(Characteristic.BatteryLevel).value | ||
let currentValue = batteryStatus.getCharacteristic(Characteristic.StatusLowBattery).value | ||
if(batteryValue<=10){ | ||
this.log.warn('Battery Status Low %s%',batteryValue) | ||
batteryStatus.setCharacteristic(Characteristic.StatusLowBattery,Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW) | ||
if (batteryValue <= 10) { | ||
this.log.warn('Battery Status Low %s%', batteryValue) | ||
batteryStatus.setCharacteristic(Characteristic.StatusLowBattery, Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW) | ||
currentValue = Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW | ||
} | ||
callback(null,currentValue) | ||
} | ||
callback(null, currentValue) | ||
} | ||
|
||
} | ||
|
||
module.exports = battery |
Oops, something went wrong.