Heater: Difference between revisions

From FlowerHouseWiki
Line 156: Line 156:


== Update Script ==
== Update Script ==
<p>Bash script to update p4d:</p>
<syntaxhighlight lang="console" line>
#!/bin/bash
echo -e "-------------------------------------------------------------------------------------------"
echo -e "- Which version do you want to update to?"
echo -e "-------------------------------------------------------------------------------------------"
read version
echo -e "-------------------------------------------------------------------------------------------"
echo -e "- Update p4d to version ${version}?"
echo -e "-------------------------------------------------------------------------------------------"
echo -e -n "Continue? [y/N]"
echo ""
read -n 1 c
if [ "${c}" != "y" ]; then
    exit 0
fi
cd /usr/src
wget https://github.com/horchi/linux-p4d/archive/refs/tags/${version}.tar.gz || exit 1
tar -xvf ${version}.tar.gz || exit 1
cd linux-p4d-${version} || exit 1
make clean all NO_RASPBERRY_PI=1 || exit 1
make install NO_RASPBERRY_PI=1 || exit 1
cd .. || exit 1
rm -r linux-p4d-${version} || exit 1
systemctl restart p4d || exit 1
echo -e "-------------------------------------------------------------------------------------------"
echo -e "- Update to version ${version} completed!"
echo -e "-------------------------------------------------------------------------------------------"
</syntaxhighlight>


== Additional Configuration ==
== Additional Configuration ==

Revision as of 23:25, 21 February 2022

Froeling.jpg

Network


IP: 192.168.88.11
MAC: DA:62:17:83:4E:8F
Domain: heater.flowerhouse.at

System


OS: Debian Bullseye
RAM: 512MB
Cores: 1
Privileged: No

The Heater-LXC is reachable under 192.168.88.11 which is located in the ServerVLAN.

The subdomain is heater.flowerhouse.at which is handled by the ReverseProxy.

The Serial-IP-Konverter is reachable under 192.168.88.12 which is located in the ServerVLAN.

Basic Setup

Change locales to de_DE.UTF-8:

dpkg-reconfigure locales

libwebsockets

Install required packages:

apt install pkg-config cmake git build-essential libssl-dev

Clone libwebsockets repo:

cd /usr/src
git clone https://libwebsockets.org/repo/libwebsockets

Create build directory:

cd libwebsockets
mkdir build
cd build

Run make to build libwebsockets:

cmake ..
make
make install

Create the necessary links and cache:

ldconfig

Delete unnecessary files:

cd /usr/src
rm -r libwebsockets

p4d daemon

Install required packages:

apt install libssl-dev libjansson-dev libxml2-dev libcurl4-openssl-dev libssl-dev libmariadb-dev-compat uuid-dev python3-dev libcap-dev

Download latest version:

wget https://github.com/horchi/linux-p4d/archive/refs/tags/0.8.8.tar.gz
tar -xvf 0.8.8.tar.gz
rm 0.8.8.tar.gz
mv linux-p4d-0.8.8 linux-p4d
cd linux-p4d

Build it:

make clean all NO_RASPBERRY_PI=1
make install NO_RASPBERRY_PI=1

Delete build files:

cd /usr/src
rm -r linux-p4d

Create database at DataBase and add credentials to daemon.conf:

nano /etc/p4d/daemon.conf

Start p4d:

systemctl start p4d

Serial-IP-Converter

Access the Serial-IP-Converter-UI under 192.168.88.12 with user: admin and pw: admin and set the UART-settings:

Serial settings.png

Install socat:

apt install socat

Connect to Serial-IP-Converter with:

socat pty,link=/dev/HeaterCOM,raw tcp:192.168.88.12:8899&

For it to connect at boot we have create an service:

nano /etc/systemd/system/socat.service

Add to file:

[Unit]
Description=SOCAT Listen Service
After=network.target redis.service
Wants=redis.service

[Service]
Type=simple
StandardOutput=journal
StandardError=journal
SyslogIdentifier=socat-serial-log
User=root
ExecStart=/bin/bash -c '/usr/bin/socat pty,link=/dev/HeaterCOM,raw tcp:192.168.88.12:8899'
Restart=on-failure

[Install]
WantedBy=multi-user.target

Start and check if service is running:

systemctl start socat
systemctl status socat

Enable service to start at boot:

systemctl enable socat

Web Interface Setup

The default port of the web interface is 1111, the default username is p4d and the password is p4d.

Fist steps to enable data logging:

  1. Log in to the web interface
  2. Go to Setup and add to TTY Device: /dev/HeaterCOM
  3. Save and then click Init Messwerte
  4. Go to Aufzeichnung and select the values you like to record and store your selection and save
  5. Go to Setup and click 'Init Service Menü'

Update Script

Bash script to update p4d:

#!/bin/bash

echo -e "-------------------------------------------------------------------------------------------"
echo -e "- Which version do you want to update to?"
echo -e "-------------------------------------------------------------------------------------------"

read version

echo -e "-------------------------------------------------------------------------------------------"
echo -e "- Update p4d to version ${version}?"
echo -e "-------------------------------------------------------------------------------------------"

echo -e -n "Continue? [y/N]"
echo ""
read -n 1 c

if [ "${c}" != "y" ]; then
    exit 0
fi

cd /usr/src
wget https://github.com/horchi/linux-p4d/archive/refs/tags/${version}.tar.gz || exit 1
tar -xvf ${version}.tar.gz || exit 1
cd linux-p4d-${version} || exit 1
make clean all NO_RASPBERRY_PI=1 || exit 1
make install NO_RASPBERRY_PI=1 || exit 1
cd .. || exit 1
rm -r linux-p4d-${version} || exit 1
systemctl restart p4d || exit 1

echo -e "-------------------------------------------------------------------------------------------"
echo -e "- Update to version ${version} completed!"
echo -e "-------------------------------------------------------------------------------------------"

Additional Configuration

Mail Notification

Install required packages:

apt install msmtp-mta bsd-mailx

Create the msmspt configuration file:

nano /etc/msmtprc

And paste following entry:

# Set default values for all following accounts.
defaults
port 587
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt

account flowerhouse
host smtp.world4you.com
from heater@flowerhouse.at
auth on
user heater@flowerhouse.at
password XXXXXXX

# Set a default account
account default : flowerhouse

The setup can be tested with:

mail -s "test" address@email.com < /dev/null

If the setup is working, go to the webinterface and configure the mail notifications in the setup page.

Sources