I have recently posted a number of questions on how to create a AVD for my EV Charger.
Now it’s my time to share the result.
EV Charger Status Device Tile
The device should:
- show an enabled/disabled status to understand whether or not the charger is active
- show the total accumulated energy (kWh) of the current / previous charging session - I assume that it is the total amount of power of the previous charging session when the device is inactive.
- show the current charging power (the flow will set the charging power to 0 if <30W)
- show the duration of the ongoing/previous charging session in HHhMMm notation
Apps used:
- I have a smart sensor that watched for power consumption on the EV charger. I have a Shelly EM1 but any power sensor should work
- I use Homey Advanced Flows to manage the device.
- Homeyscript is needed to make the time calculation work
- Logic is used to manage variables: intEVChargerEnergyStart/End/Delta and intEVChargerPowerRounded (to avoid fraction numbers in the tile)
Picture of the flow used:
This is just for reference so you understand what it does:
- set the start/end power measurement variables at start and end of charging session
- calculate the delta variables in Logic at the appropriate times (at start and end of charging session, and every 10 seconds while active)
- set the charging state active/inactive
- calculate the duration using milliseconds measurements (and translate to HHMM using homeyscript)
The scripts:
Milliseconds timestamp:
const milliseconds = await Date.now();
return milliseconds;
Duration at end of charging session:
const d = new Date(1*args[0]);
let hours = d.getHours();
let minutes = d.getMinutes();
if (hours < 10) {hours = “0”+hours;}
if (minutes < 10) {minutes = “0”+minutes;}
let duration = hours+‘h’+minutes+‘m’;
return duration;
Duration every 10 seconds update:
const start = new Date(1*args[0]);
const now = new Date();
d = new Date(now-start);
let hours = d.getHours();
let minutes = d.getMinutes();
if (hours < 10) {hours = “0”+hours;}
if (minutes < 10) {minutes = “0”+minutes;}
let duration = hours+‘h’+minutes+‘m’;
return duration;
Hope these are helpful - have fun!
TEF:
H4sIAAAAAAACA+1aaXPiyJb9Kx7iRXT3UGpy0eqe94F9M2YHQ7XDkVKmQEZIoIWtXv33SUmAMV6eprtipjti6gMYZepm3pPnnnuvVN8ylG0sg9UN18ncZmqiX88n/4r5AxqAsVJs5XcVU31YF+TeDqwHjUJp798d9t0VVgqrMvTBs97tNgYdR9boorh2KJE2g+UOGsqCyqZyyD1spnSVe5BzS1uRqG0MA7BStOeacsCb/kwOHaj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