Skip to content

Commit

Permalink
Updating installation instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
enesbcs committed Jan 22, 2024
1 parent 2eedeb4 commit 73c9d8f
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 37 deletions.
37 changes: 26 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,38 @@ as the Domoticz and this program.

## How to install

1. Please use the precompiled windows binary if you are not familiar with Linux:
A. Please use the precompiled windows binary if you are not familiar with Linux:
https://github.com/enesbcs/shellyteacher4domo/releases

> The Teacher can be run on ANY machine on the network, which accessing the MQTT IP addres, does not need to run on the Domoticz server directly!!!
3. For Linux users for any platform that capable to run python3:
B. For Linux users for any platform capable of running python3:

-Install git (Debian/Ubuntu if user has root right)
```
apt install git
```
-OR install git (Debian/Ubuntu if user has sudo right)
```
sudo apt install git
```
-Download application with git
```
sudo apt install python3-pip git
sudo pip3 install paho-mqtt
git clone https://github.com/enesbcs/shellyteacher4domo.git
```
In case you are using Debian 12, please remove 'EXTERNALLY-MANAGED' file from your system to be able to use pip3. https://www.jeffgeerling.com/blog/2023/how-solve-error-externally-managed-environment-when-installing-pip3
-Run the installation script first, and only once (which will deal python venv)
```
sudo pip3 install paho-mqtt --break-system-packages
cd shellyteacher4domo
./preinstall.sh
```
-If installation was succesful, ShellyTeacher now can be run from the venv named 'paho' with this command:
```
./run.sh
```

In case you want to save the configurations after rebooting, please make sure that MQTT broker [persistence settings](https://pagefault.blog/2020/02/05/how-to-set-up-persistent-storage-for-mosquitto-mqtt-broker/) configured correctly!

In case you are unable to install or run the program, please download the windows binary!
If you are unable to install or run the program, please download the windows binary!
ˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇ

Windows and Linux x64 binary builds published and can be downloaded from releases:
Expand All @@ -59,12 +71,12 @@ git pull
3. Start Teacher
```
cd shellyteacher4domo
python3 shellyteacher4domo.py
./run.sh
```
4. Power Shelly device or restart it
5. If Teacher finds the device ID in the mqtt_templates.txt, those will be automatically forwarded for the Discovery topic, and as the default publish method is 'RETAIN', it will survive reboot, and Teacher application is not needed to run, until you wants a new Shelly device to be installed

(In case of Gen2 device, the device has to be started before the Teacher, and make sure to enable "Generic status update over MQTT" at MQTT settings page)
(In case of Gen2/Gen3 device, the device has to be started before the Teacher, and make sure to enable "Generic status update over MQTT" at MQTT settings page)

Windows and Linux x64 binary builds published and can be downloaded from releases:
https://github.com/enesbcs/shellyteacher4domo/releases
Expand Down Expand Up @@ -108,7 +120,10 @@ Gen2:
- Shelly Pro 4PM
- Shelly Pro Dual Cover PM

Gen3:
- Shelly 1 Mini G3 / 1PM Mini G3
- Shelly PM Mini G3
- Shelly HT G3

## Known problems with devices
- Every Gen1 RGB devices will not work (see https://github.com/enesbcs/shellyteacher4domo/issues/7)
- Energy reporting needs at least Domoticz 2023 beta 15530 (watt-minute and watt-hour now supported, see https://github.com/enesbcs/shellyteacher4domo/issues/6)
- Gen2 Cover needs local position fix on device [(* see position fix)](https://github.com/enesbcs/shellyteacher4domo/wiki/Shelly-2PM-Cover-Position)
76 changes: 51 additions & 25 deletions preinstall.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#!/bin/bash
echo "ShellyTeacher dependency solver"
echo "-------------------------------"
DISPLAY=`printenv DISPLAY`
SUDO=`command -v sudo`
_SYSTEM=""
if [ "$(id -u)" -eq 0 ]; then
echo "Virtualenv only installs packages to the actual user!"
exit
fi
if [ -z `command -v command` ]
then
echo "Command not found!"
exit
fi
_SUDO=`command -v sudo`
_SYSTEM=""
_ROOT=""
if [ "$(id -u)" -eq 0 ]; then
_ROOT="y"
fi
if [ ! -z `command -v apt-get` ]
then
_SYSTEM="apt-get"
Expand All @@ -25,46 +26,71 @@ else
echo "Not supported system!"
exit
fi

echo "If you are not root, the system may now ask root password several times. (You may consider to use sudo)"
if [ "$_SYSTEM" = "apt-get" ]
then
if [ ! -z `command -v sudo` ]
if [ ! -z "$_SUDO" ]
then
_SYSTEM="sudo $_SYSTEM"
fi
$_SYSTEM update
$_SYSTEM install -y python3 python3-pip python3-venv
if [ ! -z "$DISPLAY" ]
then
$_SYSTEM install -y python3-tk
if [ -z "$_SUDO" ] && [ -z "$_ROOT" ]; then
su - root -c "$_SYSTEM update ; $_SYSTEM install -y python3 python3-pip python3-venv"
if [ ! -z "$DISPLAY" ]
then
su - root -c "$_SYSTEM install -y python3-tk"
fi
else
$_SYSTEM update
$_SYSTEM install -y python3 python3-pip python3-venv
if [ ! -z "$DISPLAY" ]
then
$_SYSTEM install -y python3-tk
fi
fi
fi
if [ "$_SYSTEM" = "pacman" ]
then
if [ ! -z `command -v sudo` ]
if [ ! -z "$_SUDO" ]
then
_SYSTEM="sudo $_SYSTEM"
fi
echo -ne '\n' | $_SYSTEM -S python python-pip
if [ ! -z "$DISPLAY" ]
then
echo -ne '\n' | $_SYSTEM -S tk
if [ -z "$_SUDO" ] && [ -z "$_ROOT" ]; then
su - root -c "echo -ne '\n' | $_SYSTEM -S python python-pip"
if [ ! -z "$DISPLAY" ]
then
su - root -c "echo -ne '\n' | $_SYSTEM -S tk"
fi
else
echo -ne '\n' | $_SYSTEM -S python python-pip
if [ ! -z "$DISPLAY" ]
then
echo -ne '\n' | $_SYSTEM -S tk
fi
fi
fi
if [ "$_SYSTEM" = "apk" ]
then
_SED="sed"
if [ ! -z `command -v sudo` ]
if [ ! -z "$_SUDO" ]
then
_SYSTEM="sudo $_SYSTEM"
_SED="sudo sed"
fi
_SED= -i '/community/s/^#//' /etc/apk/repositories
$_SYSTEM update
$_SYSTEM add python3 py3-pip
if [ ! -z "$DISPLAY" ]
then
$_SYSTEM add python3-tkinter
if [ -z "$_SUDO" ] && [ -z "$_ROOT" ]; then
su - root -c "$_SED -i '/community/s/^#//' /etc/apk/repositories"
su - root -c "$_SYSTEM update ; $_SYSTEM add python3 py3-pip"
if [ ! -z "$DISPLAY" ]
then
su - root -c "$_SYSTEM add python3-tkinter"
fi
else
$_SED -i '/community/s/^#//' /etc/apk/repositories
$_SYSTEM update
$_SYSTEM add python3 py3-pip
if [ ! -z "$DISPLAY" ]
then
$_SYSTEM add python3-tkinter
fi
fi
fi
if [ ! -z `command -v python3` ]
Expand Down
3 changes: 2 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
FILE=/etc/mosquitto/mosquitto.conf
#Checking if the script running on the server itself...
if [ -f "$FILE" ]; then
SUDO=`command -v sudo`
echo "Mosquitto conf found. "
_MOSQ=`cat $FILE | grep persistence | grep true`
_MOSQ=`$SUDO cat $FILE | grep persistence | grep true`
if [ -z "$_MOSQ" ]
then
echo "persistence DISABLED - RETAIN settings wont survive reboot!"
Expand Down

0 comments on commit 73c9d8f

Please sign in to comment.