Easy way to add all devices to the energy monitoring dashboard?

Is there an easy way to add all devices to the energy monitoring dashboard’s " Individual devices" section? or a way to flip it from a whitelist to a blacklist?

Nope.

for SENSOR in $(find /path/to/homeassistant/configdir/ -type f -print0 | xargs -0 egrep "entity_id.*sensor.*_energy\"" | awk '{ print $3 }' | cut -d \" -f 2 | grep -v "battery" | sort | uniq); do 
   echo "      {";
   echo "        \"stat_consumption\": \"$SENSOR\"";
   echo "      },"; 
done

paste that into the device_consumption key in /path/to/homeassistant/configdir/.storage/energy, make sure you didn’t add any sensors you don’t want to be tracked in energy dashboard and restart home assistant.

Is it dirty? Absolutely. Does it save you hours of work? Absolutely.

If you regularly update the file that way, I’d suggest managing your config in Git or at least doing regular backups.

2 Likes

Or put this into developer template, copy all then use some find and replace, to add the proper code

{{ states | selectattr('entity_id', 'search', '_energy') | rejectattr('entity_id', 'search', '_cost') | map(attribute='entity_id') | sort | join('\n') }}

2 Likes

I hereby state this as a feature request, having whitelisting (by default: all supporting devices) and blacklisting (specific ones to exclude) for the energy dashboard´s devices. Please join me by voting for it :slight_smile:

1 Like