Skip to content

Commit

Permalink
Merge pull request #20 from valiquette/update
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
valiquette authored Dec 3, 2023
2 parents 6c8a2d7 + b06ee0d commit b0653be
Show file tree
Hide file tree
Showing 11 changed files with 729 additions and 671 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changes

## 1.1.20
Update
- Bumped dependencies.

## 1.1.19
Update
- Refactor code to allow use of cached accessories
- Bumped dependencies.

## 1.1.18
Update
- Added suppport for node.js v20.
Expand Down
2 changes: 1 addition & 1 deletion config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"liveRefreshRate": {
"title": "Live Refresh Rate",
"description": "Polling time in seconds to refresh data during an active session. Default 20 <br>Setting this less than 20 seconds may casue display to toggle back once if the car is slow to respond.",
"description": "Polling time in seconds to refresh data during an active session. Default 20 <br>Setting this less than 20 seconds may cause display to toggle back once if the car is slow to respond.",
"type": "integer",
"minimum": 5,
"maximum": 30,
Expand Down
53 changes: 25 additions & 28 deletions devices/battery.js
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
Loading

0 comments on commit b0653be

Please sign in to comment.