Running Home Assistant in Docker with Octopus Energy Integration
Home Assistant is an open-source home automation platform that lets you control smart devices, monitor your home, and integrate with various services. In this post, I’ll show you how to run Home Assistant using Docker Compose, install HACS (Home Assistant Community Store) for community integrations, and add the Octopus Energy integration to track your electricity and gas usage with beautiful graphs.
Why Docker?
Running Home Assistant in Docker makes it easy to manage, update, and isolate from your host system. Docker Compose simplifies the setup with a single configuration file.
Prerequisites
Before we start, ensure you have:
- Docker and Docker Compose installed
- An Octopus Energy account
- Your Octopus API key, account number, and meter details (see below)
Getting Your Octopus Energy API Key and Details
- API Key: Visit the Octopus Developer Portal, sign in, and generate a new API key.
- Account Number: Found on your Octopus bill or dashboard.
- Electricity Meter Details (two numbers for smart meters):
- MPAN (Meter Point Administration Number): On your bill or meter.
- Serial Number: On the meter itself.
- Gas Meter Details (two numbers for smart meters, if applicable):
- MPRN (Meter Point Reference Number): On your bill.
- Serial Number: On the meter.
These details are required for the integration to fetch accurate data.
Setting Up Home Assistant with Docker Compose
Create a new directory for your Home Assistant setup:
mkdir hassio cd hassio Create a docker-compose.yml file:
version: "3" services: homeassistant: image: homeassistant/home-assistant:latest container_name: homeassistant restart: unless-stopped ports: - "8123:8123" volumes: - ./config:/config - /etc/localtime:/etc/localtime:ro environment: - TZ=Europe/London privileged: true Start Home Assistant:
docker-compose up -d Access it at http://localhost:8123 and complete the initial setup.
Installing HACS
HACS allows you to easily install community-developed integrations. Download and install it:
curl -L -o hacs.zip https://github.com/hacs/integration/releases/latest/download/hacs.zip unzip hacs.zip -d config/custom_components/hacs docker-compose restart In Home Assistant, you’ll now see HACS in the sidebar.
Adding the Octopus Energy Integration
- In HACS, go to Settings > Add Custom Repository.
- Add:
https://github.com/BottlecapDave/HomeAssistant-OctopusEnergyas an Integration. - Install it from HACS > Integrations.
- Restart Home Assistant.
- Go to Settings > Devices & Services > Add Integration > Octopus Energy.
- Enter your API key, account number, and meter details (MPAN, serial numbers, etc.).
Graphing Your Energy Data
Use the built-in Energy Dashboard:
- Go to Settings > Dashboards > Energy.
- Add your electricity and gas sensors from the Octopus integration.
- View charts for usage, costs, and trends.
Tips
- The config volume persists your data.
- Update integrations via HACS.
- If issues arise, check logs:
docker-compose logs homeassistant.
Conclusion
With this setup, you can monitor your energy usage in real-time. Home Assistant with Octopus Energy provides valuable insights into your consumption patterns. Give it a try and start optimizing your energy use!