I decided to re-do how my system performs zero export. Instead of that potential going to waste, I decided to get creative. I was able to get my hands on a bitcoin miner. There is a plugin for Home Assistant that allows you to control and monitor almost any popular bitcoin miner on the market. I decided to use this to my advantage. My system currently does pay me for the excess energy I generate, the process to do that is long, expensive and for the size of my system, would not be worth it in the long run. I have played with mining various crypto currencies in the past and it is neat how it all works and their is potential to earn a lot of money with very little effort. Here is the issue, Mining crypto is very intensive and to be profitable, you often need specific hardware. I was able to score a second hand Antminer A9 which is an older miner and normally would not turn a profit with the 1500+ watts of power needed to run it. Normally it costs more to run in electricity than I would see in return. When I mine, I use nicehash which is a mining pool. I could solo mine, however the chances of mining a block is very small. Pool mining, you get paid as share based on how much computing power you contributed and the earnings are more stable. Newer miners are more efficient and can net a decent profit, however they cost sometimes thousands of dollars. Used ones can be had for much less. I bought mine for around $100.
One of the reasons I like the Antminers is the huge support they have and they have many active communities. The firmware is actively maintained and they have an API connection for third party monitoring and control. Using a plugin for Home Assistant called “Miner”
My inspiration was this thread I came across…
https://community.home-assistant.io/t/controlling-bitcoin-antminer-for-house-heating/753510
After reading this, My idea was at least a very real possibility and thanks to the Home Assistant Community, can be done very easily. Here is the code I used to make it happen!
First create a template sensor that will compare the energy being used by my home and the energy being produced by my solar inverter.
template:
- sensor:
- name: "Excess Solar Power"
unit_of_measurement: "W"
state_class: measurement
state: >
{% set solar = states('sensor.solar_output') | float(0) %}
{% set house = states('sensor.house_energy_use') | float(0) %}
{{ (solar - house) | round(0) }}
Then create the automation.
alias: Control Crypto Miner
description: Adjust miner power using excess solar with 150W hysteresis
mode: single
trigger:
- platform: state
entity_id:
- sensor.excess_solar_power
for: "00:00:10"
condition: []
action:
- variables:
excess_power: "{{ states('sensor.excess_solar_power') | float(0) }}"
max_miner_power: 1000
current_miner_power: "{{ states('number.crypto_miner_power_level') | float(0) }}"
proposed_power: >
{% set raw = [excess_power, max_miner_power] | min %}
{% if raw < 0 %}
0
{% else %}
{{ raw | round(0) }}
{% endif %}
power_diff: "{{ (proposed_power - current_miner_power) | abs }}"
- choose:
- conditions:
- condition: template
value_template: "{{ power_diff > 150 }}"
sequence:
- service: number.set_value
target:
entity_id: number.crypto_miner_power_level
data:
value: "{{ proposed_power }}"
Then if you want to say turn on an indicator in your HA dashboard or some kind of physical indicator, create a Binary sensor. This part isn’t needed, but I have a “light” that comes on in my solar dashboard when I am actively mining.
template:
- binary_sensor:
- name: "Enough Solar for Miner"
state: >
{{ states('sensor.excess_solar_power') | float(0) > 100 }}
Just make sure if you use this code to change the names of your sensors to match your particular setup. I used generic names here to make the code easier to understand. You can control more than one miner and if you used something different than an Antminer, you may have to tweak the code further.