Home Assistant7 min read

Mastering Home Assistant Solar Automation: Your Guide to Smart Energy

Automate your solar and battery system with Home Assistant to maximize self-consumption, shift loads, and cut energy costs year-round.

In this article 10
  1. Key Takeaways
  2. Home Assistant solar automation in 2026
  3. Why Automate Your Solar & Battery System?
  4. Prerequisites: Building Your Home Assistant Energy Foundation
  5. Core Concepts for Home Assistant Solar Automation
  6. Essential Home Assistant Battery Automations
  7. Keeping Your Automations Reliable
  8. Conclusion
  9. FAQ
  10. Recommended Gear

Key Takeaways

  • By 2026, Home Assistant solar automation gives homeowners a practical path to energy independence and lower bills through intelligent energy management.
  • Home Assistant facilitates real-time orchestration of solar panels, battery banks, and appliances, optimizing energy flow based on production, consumption, grid tariffs, and weather forecasts.
  • Automating solar and battery systems well cuts costs by using off-peak tariff hours and excess solar generation.
  • Open-source blueprints for Home Lab Automation are readily available on GitHub, providing practical resources for implementing these advanced energy management solutions.

Home Assistant solar automation in 2026

In 2026, the dream of energy independence is more attainable than ever, thanks to advancements in solar technology and the powerful capabilities of smart home platforms. For tech-savvy homeowners, integrating solar and battery storage with Home Assistant offers unparalleled control, optimization, and savings. This guide walks you through setting up home assistant solar automation to manage your energy flow, reduce grid reliance, and get more out of your investment.

Open Source: The blueprints from this article are available on GitHub: Home Lab Automation Blueprints.

Gone are the days of simply generating power and hoping for the best. With Home Assistant, you can orchestrate your solar panels, battery bank, and household appliances to work in harmony, making real-time decisions based on production, consumption, grid tariffs, and even weather forecasts. Here’s how to turn your home into a smart energy hub.

Why Automate Your Solar & Battery System?

Automating your solar and battery setup isn’t just about convenience; it’s about strategic energy management. Here’s why it matters for any modern smart home:

  • Cost Savings: By intelligently charging your battery during off-peak tariff hours (if applicable) or with excess solar, and discharging during peak rates, you significantly reduce your electricity bill.
  • Increased Self-Consumption: Maximize the use of the clean energy you produce, rather than exporting it for minimal credit or importing grid power when your solar panels are idle.
  • Grid Independence & Resilience: A well-managed battery provides backup power during outages and reduces your reliance on the grid, enhancing energy security.
  • Optimized Battery Lifespan: Smart charging and discharging cycles can help prolong the life of your expensive battery storage system.
  • Environmental Impact: Directly contribute to a greener planet by using more of your self-generated renewable energy.

Prerequisites: Building Your Home Assistant Energy Foundation

Before you can implement sophisticated home assistant solar automation, you need a solid foundation. If you’re new to Home Assistant, ensure you have a stable installation. For energy management, the following are essential:

  1. Home Assistant Instance: Running on a Raspberry Pi, mini PC, or virtual machine.
  2. Solar Inverter Integration: Your solar inverter (e.g., Fronius, SolarEdge, Enphase, SMA, Huawei) must be integrated into Home Assistant. Many have official integrations, while others might require custom components (HACS) or Modbus TCP/RTU integrations.
  3. Battery System Integration: Similarly, your battery management system (BMS) needs to expose its data (state of charge, charge/discharge rates) to Home Assistant. This often comes via the inverter integration or a separate battery integration.
  4. Energy Dashboard Setup: Configure Home Assistant’s built-in Energy Dashboard. This provides sensors for total production, consumption, grid import/export, and battery charge/discharge, which are the data your automation triggers and conditions rely on.
  5. Smart Plugs/Switches (Optional but Recommended): For controlling high-draw appliances based on energy availability.

Ensure you have sensors for:

  • sensor.solar_production_w (current solar power in Watts)
  • sensor.grid_import_export_w (current grid import/export in Watts, positive for import, negative for export)
  • sensor.battery_soc (battery state of charge, 0-100%)
  • sensor.battery_charge_discharge_w (current battery charge/discharge power in Watts)
  • sensor.house_consumption_w (current total house consumption in Watts)

Core Concepts for Home Assistant Solar Automation

Effective solar automation hinges on understanding your energy flows and defining clear goals. Home Assistant allows you to monitor and act upon several key metrics:

  • Solar Production: How much power your panels are generating in real-time.
  • House Consumption: How much power your home is currently using.
  • Grid Interaction: Importing from or exporting to the grid.
  • Battery State of Charge (SoC): The current charge level of your battery.
  • Time-of-Use (ToU) Tariffs: Different electricity prices based on the time of day.

Your automation goals might include:

  • Maximizing Self-Consumption: Use all generated solar power within your home or store it in the battery, minimizing grid interaction.
  • Time-of-Use Arbitrage: Charge the battery from the grid when electricity is cheapest (off-peak) and discharge it when prices are highest (peak).
  • Weather-Aware Optimization: Adjust charging/discharging based on upcoming sunny or cloudy days.
  • Critical Load Management: Ensure essential devices have power even during outages by prioritizing battery usage.

Essential Home Assistant Battery Automations

Let’s explore some practical automations you can implement to achieve these goals.

1. Prioritizing Self-Consumption: Charging from Excess Solar

This is a fundamental automation. When your solar production exceeds your immediate home consumption, the surplus energy should ideally go into your battery rather than being exported to the grid for a low feed-in tariff.

Automation Goal: Charge the battery when there’s excess solar power and SoC is below a threshold.

# automation.yaml
- alias: "Solar: Charge Battery from Excess Solar"
  description: "Enable battery charging when excess solar is available and SoC is below target"
  trigger:
    - platform: numeric_state
      entity_id: sensor.grid_import_export_w
      below: -200
      for:
        minutes: 2
  condition:
    - condition: numeric_state
      entity_id: sensor.battery_soc
      below: 95
  action:
    - service: number.set_value
      target:
        entity_id: number.battery_charge_rate
      data:
        value: "{{ [((states('sensor.grid_import_export_w') | float | abs) - 100) | int, 3000] | min }}"
    - service: switch.turn_on
      target:
        entity_id: switch.battery_charge_mode_solar
  mode: single

The trigger fires when you are exporting more than 200W to the grid for two consecutive minutes, which avoids rapid switching during passing clouds. The action calculates a charge rate that absorbs most of the surplus while keeping a 100W buffer, capped at 3000W. Rename number.battery_charge_rate and switch.battery_charge_mode_solar to match your inverter’s actual entity IDs.

2. Time-of-Use Tariff Arbitrage

If your utility uses time-of-use pricing, you can charge the battery cheaply overnight and discharge it during peak hours. This works alongside solar: the battery fills from the grid during cheap hours, tops up from solar during the day, and discharges when grid power is most expensive.

- alias: "Battery: Charge from Grid at Off-Peak Rate"
  trigger:
    - platform: time
      at: "01:00:00"
  condition:
    - condition: numeric_state
      entity_id: sensor.battery_soc
      below: 80
  action:
    - service: switch.turn_on
      target:
        entity_id: switch.battery_charge_mode_grid
    - service: number.set_value
      target:
        entity_id: number.battery_charge_rate
      data:
        value: 2500
  mode: single

- alias: "Battery: Stop Grid Charging at End of Off-Peak Window"
  trigger:
    - platform: time
      at: "06:00:00"
  action:
    - service: switch.turn_off
      target:
        entity_id: switch.battery_charge_mode_grid
  mode: single

Adjust the times to match your tariff schedule. If your utility exposes a current-price sensor (the Nordpool or Octopus Energy integrations both do this), replace the fixed time trigger with a numeric_state trigger on that price sensor. That way the automation adapts automatically when the utility changes its schedule.

3. Shifting High-Draw Appliances to Solar Hours

The automations above manage the battery. The next layer is running high-draw appliances, such as a dishwasher, washing machine, or EV charger, when solar production is strong. This reduces how much energy has to flow through the battery.

- alias: "Appliance: Start Dishwasher When Solar Surplus Is High"
  trigger:
    - platform: numeric_state
      entity_id: sensor.grid_import_export_w
      below: -800
      for:
        minutes: 5
  condition:
    - condition: state
      entity_id: input_boolean.dishwasher_pending
      state: "on"
    - condition: time
      after: "09:00:00"
      before: "16:00:00"
  action:
    - service: switch.turn_on
      target:
        entity_id: switch.dishwasher_smart_plug
    - service: input_boolean.turn_off
      target:
        entity_id: input_boolean.dishwasher_pending
  mode: single

Set input_boolean.dishwasher_pending to on when you load the dishwasher but want Home Assistant to pick the right moment to start it. You can extend this pattern to an EV charger by replacing the smart plug entity and raising the surplus threshold to match the charger’s minimum draw.

Keeping Your Automations Reliable

A few practical notes:

  • Test with Developer Tools first. Manually fire each automation before trusting it to run on its own. Check the trace to verify every condition evaluated as expected.
  • Guard against sensor dropouts. Inverter integrations that poll over Modbus or a local API occasionally return unavailable. Add a not state condition for unavailable on any numeric sensor you use as a trigger to avoid mis-fires during a restart.
  • Add mobile notifications. Append a notify.mobile_app call to battery mode changes. Silent failures in energy automations are hard to catch until you check your electricity bill.
  • Let data guide your thresholds. The Energy Dashboard accumulates daily statistics. After a few weeks you will have enough history to tune surplus thresholds, tariff windows, and SoC targets based on your actual usage patterns rather than guesswork.

Conclusion

Home Assistant gives you the tools to build a practical solar and battery management system without vendor lock-in or subscription fees. Start with the self-consumption automation, confirm it behaves correctly in the Energy Dashboard, then add tariff arbitrage and appliance shifting once your sensor data is stable. The entity IDs in this guide follow naming conventions common to popular inverter integrations, but you will need to adapt them to your specific hardware. Work through one automation at a time, watch the energy flow graphs, and adjust thresholds based on what the data shows rather than what sounds good in theory.

FAQ

What is Home Assistant solar automation?

It’s the integration of solar panels and battery storage with the Home Assistant smart home platform to intelligently manage energy flow, reduce grid reliance, and optimize energy usage. It allows for real-time decision-making based on various factors.

Why is automating my solar and battery system important?

Automation is crucial for strategic energy management, moving beyond simple power generation to actively orchestrate your system. This leads to significant cost savings by optimizing battery charging during off-peak hours and utilizing excess solar power efficiently.

What benefits can I expect from Home Assistant solar automation?

You can expect unparalleled control over your energy system, optimized energy usage, reduced reliance on the grid, and substantial cost savings. It transforms your home into a truly smart energy hub.

Are there resources available to help set up this automation?

Yes, open-source blueprints for Home Lab Automation are available on GitHub, providing practical guidance and configurations to help homeowners implement these advanced solar and battery automation strategies.

If you want to build this setup, this is where I would start:

Affiliate links: if you buy through them I earn a small commission, at no extra cost to you.

The end. Thanks for reading.

Keep reading.