-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
virtualzone
committed
Apr 13, 2024
1 parent
038db55
commit 8653911
Showing
13 changed files
with
153 additions
and
68 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Col, Row } from "react-bootstrap"; | ||
import { BatteryCharging as IconCharging, Sun as IconSun, Battery as IconNotCharging, UtilityPole as IconGrid, CarFront as IconCarFront, Unplug as IconUnplugged, PlugZap as IconPluggedIn } from 'lucide-react'; | ||
|
||
// @ts-ignore: Object is possibly 'null'. | ||
export default function VehicleStatus({ vehicle, state }) { | ||
function getChargeState(state: any) { | ||
if (!state.pluggedIn) return <><IconUnplugged /> Disconnected</>; | ||
if (state.chargingState === 0) return <><IconPluggedIn /> Idle</>; | ||
if (state.chargingState === 1) return <><IconSun /> Solar-charging at {state.amps} A</>; | ||
if (state.chargingState === 2) return <><IconGrid /> Grid-charging at {state.amps} A</>; | ||
return <><IconNotCharging /></>; | ||
} | ||
|
||
function getSoCIcon(state: any) { | ||
if (state.chargingState === 0) return <IconNotCharging />; | ||
if (state.chargingState > 0) return <IconCharging />; | ||
return <IconNotCharging />; | ||
} | ||
|
||
if (state === null) state = {}; | ||
|
||
return ( | ||
<div> | ||
<Row> | ||
<Col style={{ 'flex': '0 0 100px' }}> | ||
<IconCarFront size={64} /> | ||
</Col> | ||
<Col style={{ 'flex': '1' }}> | ||
<h5>{vehicle.display_name}</h5> | ||
<Row> | ||
<Col sm={4}>{getSoCIcon(state)} {state.soc !== undefined ? state.soc + ' %' : 'SoC unknown'}</Col> | ||
<Col sm={8}>{getChargeState(state)}</Col> | ||
</Row> | ||
</Col> | ||
</Row> | ||
</div> | ||
) | ||
} |
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
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,2 +1,8 @@ | ||
#!/bin/sh | ||
PORT=8081 DEV_PROXY=1 CRYPT_KEY=12345678901234567890123456789012 TOKEN=f8f78ed5-204e-4e5b-a0cf-ceac819c3b2d PASSWORD=z2fxvdzMEOrqi1cB CMD_ENDPOINT="http://localhost:8080/api/1/user/{token}" TELEMETRY_ENDPOINT=ws://localhost:8080/api/1/user/{token}/ws go run `ls *.go | grep -v _test.go` | ||
if command -v sqlite3 -version &> /dev/null | ||
then | ||
rm -f /tmp/chargebot_node.db | ||
INIT_DB_ONLY=1 go run `ls *.go | grep -v _test.go` | ||
sqlite3 /tmp/chargebot_node.db "insert into vehicles (vin, display_name, enabled, target_soc, max_amps, surplus_charging, min_surplus, min_chargetime, lowcost_charging, max_price, tibber_token) values ('5YJXCBE24KF152671', 'Model Y', 0, 0, 0, 0, 0, 0, 0, 0, '')" | ||
fi | ||
DEMO_MODE=1 PORT=8081 DEV_PROXY=1 CRYPT_KEY=12345678901234567890123456789012 TOKEN=f8f78ed5-204e-4e5b-a0cf-ceac819c3b2d PASSWORD=z2fxvdzMEOrqi1cB CMD_ENDPOINT="http://localhost:8080/api/1/user/{token}" TELEMETRY_ENDPOINT=ws://localhost:8080/api/1/user/{token}/ws go run `ls *.go | grep -v _test.go` |
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
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,2 +1,9 @@ | ||
#!/bin/sh | ||
if command -v sqlite3 -version &> /dev/null | ||
then | ||
rm -f /tmp/chargebot.db | ||
INIT_DB_ONLY=1 go run `ls *.go | grep -v _test.go` | ||
sqlite3 /tmp/chargebot.db "insert into users (id, tesla_user_id) values ('8da4de32-8829-4a99-b5fe-2103e25be03b', 'bb1e0a53-a914-49a2-a939-b533eb05663a')" | ||
sqlite3 /tmp/chargebot.db "insert into api_tokens (token, user_id, passhash) values ('f8f78ed5-204e-4e5b-a0cf-ceac819c3b2d', '8da4de32-8829-4a99-b5fe-2103e25be03b', '56dca395afc313da732f78a8e2ef4059ac2260441c47f43f32642c732c19b814')" | ||
fi | ||
DOMAIN=localhost:8080 DEV_PROXY=1 go run `ls *.go | grep -v _test.go` |