Compare commits

..

No commits in common. "a61f9f2d2d2101b9cdb564cbe74b7e239086f0a9" and "59e5ffc91a75a28e36dd37a2643faadfaf5d3bdf" have entirely different histories.

4 changed files with 23 additions and 92 deletions

View File

@ -14,21 +14,16 @@ export PATH=$PATH:/data/data/com.termux/files/usr/bin
# Array with the desired languages in order
lang_order=("es" "de" "es-l")
category_order=("date" "time" "weather")
# Create Directories
mkdir -p /sdcard/.mp3/
mkdir -p /sdcard/.text/
category_order=("date" "time")
# Directories
txt_dir="/sdcard/.text"
mp3_dir="/sdcard/.mp3"
txt_dir="/data/scripts/.text"
mp3_dir="/data/scripts/.mp3"
# remove old files
rm -f "$txt_dir"/*complete.txt
# open handout.md file
#am start --user 0 -a android.intent.action.VIEW -d content://pl.solidexplorer2.files/storage/emulated/0/.text/handout.html -t text/html
am start --user 0 -n org.bromite.chromium/org.chromium.chrome.browser.ChromeTabbedActivity -d content://pl.solidexplorer2.files/storage/emulated/0/.text/handout.html -t text/html
am start --user 0 -a android.intent.action.VIEW -d file:///sdcard/handout.html -t text
# Function to create MP3 files
create_mp3_files() {

View File

@ -11,7 +11,7 @@
text_dir="/root/iobroker_scripts/general/.text"
html_file="$text_dir/handout.html"
all=("date" "time" "weather") # Add more elements as needed
all=("date" "time") # Add more elements as needed
# remove files in text_dir
rm -f $text_dir/*
@ -51,67 +51,44 @@ generate_text() {
echo "$date_de" > "$text_dir/date_de.txt"
time_de=$(date '+Es ist %H:%M Uhr.')
echo "$time_de" > "$text_dir/time_de.txt"
weather_de=$(trans -b :en :de "$(/root/iobroker_scripts/general/weather.sh)")
echo "$weather_de" > "$text_dir/weather_de.txt"
# Spanish
date_es=$(trans -b :de :es "$date_de")
echo "$date_es" > "$text_dir/date_es.txt"
time_es=$(trans -b :de :es "$time_de")
echo "$time_es" > "$text_dir/time_es.txt"
weather_es=$(trans -b :en :es "$(/root/iobroker_scripts/general/weather.sh)")
echo "$weather_es" > "$text_dir/weather_es.txt"
}
# Call the generate_text function
generate_text
# Create HTML file
echo "<!DOCTYPE html>" >> "$html_file"
echo "<html>" >> "$html_file"
echo "<head>" >> "$html_file"
echo "<title>Handout</title>" >> "$html_file"
echo "<meta charset="UTF-8">" >> "$html_file"
echo "<style>" >> "$html_file"
echo "body {" >> "$html_file"
echo "font-size: 24px;" >> "$html_file"
echo "}" >> "$html_file"
echo "table {" >> "$html_file"
echo " border-collapse: collapse;" >> "$html_file"
echo " width: 100%;" >> "$html_file"
echo " margin: auto;" >> "$html_file"
echo "}" >> "$html_file"
echo "th, td {" >> "$html_file"
echo " border: 3px solid black;" >> "$html_file"
echo " padding: 8px;" >> "$html_file"
echo " text-align: center;" >> "$html_file"
echo "}" >> "$html_file"
echo "th {" >> "$html_file"
echo " background-color: #00ff00;" >> "$html_file"
echo "}" >> "$html_file"
echo "</style>" >> "$html_file"
echo "</head>" >> "$html_file"
echo "<body>" >> "$html_file"
echo "<h1>Handout:</h1>" >> "$html_file"
echo "<table>" >> "$html_file"
echo "<h2><tr><th>Deutsch</th><th>Español</th></tr></h2>" >> "$html_file"
# Create Markdown content
markdown_content="**Handout:**
\n
| Deutsch | Español |
| ------- | -------- |"
for component in "${all[@]}"; do
echo "processing: $component"
german_output=$(cat "$text_dir/${component}_de.txt")
spanish_output=$(cat "$text_dir/${component}_es.txt")
echo "<tr><td>$german_output</td><td>$spanish_output</td></tr>" >> "$html_file"
markdown_content+="\n| $german_output | $spanish_output |"
done
echo "</table>" >> "$html_file"
echo "</body>" >> "$html_file"
echo "</html>" >> "$html_file"
# Send Notification to A72 with Markdown content
curl_command="curl -u 'Michaelis:u5ptufUFuDL6q4yEcSN3iqas5gtXNkN77Lx3cy3oX8UoSgFWdifYy9FVopv2Zwtu' \
-H 'Priority:High' \
-d \"$markdown_content\" \
-H 'Markdown: yes' \
https://ntfy.michaelis.digital/ioBroker"
# Get ip of a72
check_ip
echo "curl_command: $curl_command"
eval "$curl_command" # Execute the constructed curl command
# Transfer files to A72
scp -r -i /root/.ssh/A72 "$text_dir" root@$A72_ip:/sdcard/
# Display Markdown content
echo -e "$markdown_content"
# Start generate_mp3.sh on A72
nohup ssh -i /root/.ssh/A72 -f root@$A72_ip '/data/scripts/generate_mp3.sh' > /root/generate_mp3.log &

View File

@ -1,40 +0,0 @@
#!/bin/bash
################################################################################
# OpenWeatherMap Weather Script
# Author: Michael Haider
# Date: 2024-02-08
#
# This script retrieves current weather information from OpenWeatherMap API
# based on the specified city and country. It then extracts relevant data,
# converts temperature from Kelvin to Celsius, and outputs the information
# in a formatted English text.
################################################################################
# OpenWeatherMap API key
api_key="da7765a8c6d2975b7dfe68f2a1775631"
# Location settings
city="Pfarrkirchen"
country="de"
# Make API request and retrieve data
weather_data=$(curl -s "http://api.openweathermap.org/data/2.5/weather?q=${city},${country}&appid=${api_key}")
# Extract relevant information from the JSON response
description=$(echo "$weather_data" | jq -r '.weather[0].description')
temperature=$(echo "$weather_data" | jq -r '.main.temp')
humidity=$(echo "$weather_data" | jq -r '.main.humidity')
wind_speed=$(echo "$weather_data" | jq -r '.wind.speed')
# Convert temperature from Kelvin to Celsius
temperature_celsius=$(awk "BEGIN {print $temperature - 273.15}")
# Formulate the text in English
weather="Current weather in $city: $description.
The temperature is ${temperature_celsius}°C, humidity is ${humidity}%.
Wind speed is ${wind_speed} m/s."
# Output the text
echo "$weather"

View File

@ -135,10 +135,8 @@ check_notification() {
elif [[ $output == *"com.urbandroid.sleep"* && $output != *"AlarmKlaxon"* ]]; then
# Alarm turned off
date && echo "Alarm turned off."
echo "$output"
ssh -i /root/.ssh/A72 root@$A72_ip 'killall mpv'
iobroker state set zigbee.0.04cd15fffee03198.state false
/root/iobroker_scripts/general/generate_text.sh # Call generate_text.sh script
exit # Exit the script when the alarm is turned off
else
# Phone unreachable
@ -281,6 +279,7 @@ if [ $current_brightness -eq $end_brightness ] && [ $current_colortemp -eq $end_
fi
if [ "$alarm_dismissed" = true ]; then
echo "Alarm dismissed"
/root/iobroker_scripts/general/generate_text.sh # Call generate_text.sh script
exit # Exit the script when the alarm is dismissed
fi
done