# Install instructions

## Resources

You'll need a rasbpiOs image, and the kernel and dtb for qemu 

## Procedure

### Enlarge img

The downloaded img is resized on the SD card during the installation. We will need more space on the img. Qemu has command for that :

```
qemu-img resize rpi.img +1G
```

Install dependencies :

```
apt install git sqlite3 python3-pip python3-click python3-requests python3-netifaces python3-serial
```

Deploy pyHeatpump. Replace MONITORING_SERVER with the address of your server :
```
mkdir /var/lib/pyheatpump
echo 'pip3 install --upgrade git+https://git.yannweb.net/cli/pyHeatpump.git' > /var/lib/pyheatpump/pyheatpump_upgrade.sh
chmod +x /var/lib/pyheatpump/pyheatpump_upgrade.sh
/var/lib/pyheatpump/pyheatpump_upgrade.sh

cp db/*.sql /var/lib/pyheatpump/
cp db/*.service /var/lib/pyheatpump/
cp db/*.timer /var/lib/pyheatpump/

sqlite3 -init /var/lib/pyheatpump/pyheatpump.sql /var/lib/pyheatpump/pyheatpump.sqlite3

cat << EOF > /var/lib/pyheatpump/pyheatpump.ini
[heatpump]
database = /var/lib/pyheatpump/pyheatpump.sqlite3

[supervisor]
scheme = https
host = MONITORING_SERVER
port = 8081
post_path = /Symfony/web/app_dev.php/boardws/insert
get_path = /Symfony/web/app_dev.php/boardws/orders
interval = 60
heatpump_id = 42

[api]
host = 0.0.0.0
port = 80
EOF

cd /etc/systemd/system
ln -s /var/lib/pyheatpump/pyheatpump_api.service
ln -s /var/lib/pyheatpump/pyheatpump_fetch.service
ln -s /var/lib/pyheatpump/pyheatpump_fetch.timer
ln -s /var/lib/pyheatpump/pyheatpump_supervise.service
ln -s /var/lib/pyheatpump/pyheatpump_supervise.timer

systemctl daemon-reload
systemctl enable pyheatpump_api.service pyheatpump_fetch.timer pyheatpump_supervise.timer
```