Sunday 29 October 2017

A money making smart heater!


Intro and TL;DR

I got 3 low energy desktop computers and got them mining Verium. These computer now makes both money in the form of Verium and saves me money on heat. Not much but some. On hot days my office gets too hot with all of them mining so I'll automated them to shutdown and restart based on electricity price, the weather forecast and temperature sensor.

Hardware

Toss out everything not needed like extra graphics cards, DVD rom, remove hdd leds etc. removing all these components will save you some watts. In bios disable everything not needed like serial ports, audio etc. Use 2,5" HDD instead of 3,5". If on board graphics card has a ram selection enabled choose the lowest possible option.
I started with a simple Debian installation with only ssh server.

Miners


First do a : sudo apt-get git

The easy way is to use docker you find a great guide at https://github.com/Roykk/veriumMinerDocker.

If you want to go the "hard" route you will find the miner at https://github.com/effectsToCause/veriumMiner
For profit calculation use this google doc : Profitability Calculator Computer Hash/Watt estimate

Setting up WOL(Wake on Lan)

This was the time consuming part. first check that wake up over lan is enabled. The name varies from bios to bios. The most common term is wake on pci. Enable it.

sudo apt-get install ethtool net-tools
(
net-tools isnt nessecay unless you need to debug or a skilled with other commands)


First check that WOL are enabled
Run the command sudo ethtool eth0

Supports Wake-on: pumbg
Wake-on: g

To make the changes persistent we must change the /etc/network/interfaces file
and "add ethernet-wol g" to the network card. So it should look something like this:

auto em1
iface em1 inet dhcp
        ethernet-wol g


 If you get a g on wake-on is what we should look for. if other value check https://wiki.debian.org/WakeOnLan
Now we need the mac adress on the network card

ifconfig -a|grep ether

We need the mac address and ip for the next steps.
On the homeassistant you you can install wol with apt-get install wakeonlan
to test wol on the miners shut them down a do wakeonlan <<MACADRESS>> if they start up you are good to go.

Homeassistant

sudo apt-get install pm-tools
Follow the guide at https://home-assistant.io/components/switch.wake_on_lan/

The guide will use pm-suspend. The only thing to change if you want to use shutdown is change the command in the shell_command and change ass ALL=NOPASSWD:/usr/sbin/pm-suspend to hass ALL=NOPASSWD:/sbin/shutdown in step 7 in the
Suspending Linux exsample Note: some computer don't work with the command shutdown if that's the case use pm-suspend
I THINK shutdown will save you some power consume so i used it on two of my machines.

Switches:
- platform: wake_on_lan
  name: deb-veriton
  host: <>
  mac_address: '44:87:fc:6a:dd:7b'
  turn_off:
    service: shell_command.turnoffdebveriton
- platform: wake_on_lan
  name: debthink
  host: <>
  mac_address: '8c:89:a5:22:73:c3'
  turn_off:
    service: shell_command.turnoffdebthink
- platform: wake_on_lan
  name: debdesk
  host: <>
  mac_address: '10:78:d2:e5:9e:aa'
  turn_off:
    service: shell_command.turnoffdebdesk

Shell Commands:


shell_command:
  turnoffdebveriton: 'ssh hass@<<IP>> sudo shutdown'
  turnoffdebthink: 'ssh homeassistant@<<IP>> sudo shutdown'
  turnoffdebdesk: 'ssh homeassistant@<<IP>> sudo pm-suspend' 

Automation



Now you should have a wol switch for each computer. so we can start automating.



In my case first I want to stop mining if my electricity cost is above 0.4 NOK/kWh i get the price from the Tibber sensor component.
- alias: 'Disable Mining When High Price'
  trigger:
    - platform: numeric_state
      entity_id: sensor.electricity_price_yri_14
      above: 0.4
  action:
  - service: homeassistant.turn_off
    entity_id: switch.debveriton
  - service: homeassistant.turn_off
    entity_id: switch.debthink
  - service: light.turn_off
    entity_id: homeassistant.turn_off
Use miners to heat the room
- alias: 'Enable all miners '
  trigger:
    - platform: numeric_state
      entity_id: sensor.fibaro_system_fgsd002_smoke_sensor_temperature
      below: 20
  action:
  - service: homeassistant.turn_on
    entity_id: switch.debveriton
  - service: homeassistant.turn_on
    entity_id: switch.debthink
  - service: light.turn_off
    entity_id: homeassistant.turn_on
Turn off all miners due to heat.
- alias: 'disable all miners because of heat'
  trigger:
    - platform: numeric_state
      entity_id: sensor.fibaro_system_fgsd002_smoke_sensor_temperature
      above: 32
  action:
  - service: homeassistant.turn_off
    entity_id: switch.debveriton
  - service: homeassistant.turn_off
    entity_id: switch.debthink
  - service: light.turn_off
    entity_id: homeassistant.turn_off

Note: In my example my smoke sensor with temperature sensor if located behind the computers so temperature is much higher than the rest of the room


No comments:

Post a Comment