#!/bin/sh
#
echo z > /dev/serial/by-id/usb-Atric_Development_GbR_Atric_IR-Wakeup_USB-if00
# bootup system 60 sec. before timer
safe_margin=60
# modyfy if different location for tvheadend dvr/log path
cd /storage/.kodi/userdata/addon_data/service.tvheadend42/dvr/log/
start_timestamp=0
stop_timestamp=0
current_timestamp=`date +"%s"`
for i in $( ls ); do
tmp_start="$(grep -o '"start": [0-9]*' "$i" | head -n 1 | grep -o '[0-9]*')"
tmp_stop="$(grep -o '"stop": [0-9]*' "$i" | head -n 1 | grep -o '[0-9]*')"
if [ "$tmp_stop" -gt "$current_timestamp" -a "$tmp_start" -gt "$current_timestamp" ]; then
if [ "$start_timestamp" -eq 0 -o "$tmp_start" -lt "$start_timestamp" ]; then
start_timestamp=$tmp_start
stop_timestamp=$tmp_stop
fi
fi
done
wake_start_timestamp=$((start_timestamp-safe_margin))
if [ "$wake_start_timestamp" -gt 0 ]; then
wake_start_time=`date -d@$wake_start_timestamp +%y%m%d%H%M`
actual_date=`date +"%y%m%d%H%M%S"`
time_correction=0
time_command=TSACS
complete_command=$time_command$actual_date$time_correction
#echo $actual_date
echo $complete_command > /dev/serial/by-id/usb-Atric_Development_GbR_Atric_IR-Wakeup_USB-if00
#echo $wake_start_time
waketime_command=WSACS
complete_command=$waketime_command$wake_start_time
echo $complete_command > /dev/serial/by-id/usb-Atric_Development_GbR_Atric_IR-Wakeup_USB-if00
wake_start_timestamp=$((start_timestamp-safe_margin-safe_margin))
wake_start_time=`date -d@$wake_start_timestamp +%d-%m-%Y\ %H:%M`
curl -X PATCH --silent --header "Content-Type:application/json" --data '{"type": "value", "valueOrExpression": "'$wake_start'"}' --user "a:a" http://smarthome:5001/api/variables/variable_string_htpc_startrecordingtime >/dev/null
wake_stop_time=`date -d@$stop_timestamp +%d-%m-%Y\ %H:%M`
curl -X PATCH --silent --header "Content-Type:application/json" --data '{"type": "value", "valueOrExpression": "'$wake_stop'"}' --user "a:a" http://smarthome:5001/api/variables/variable_string_htpc_startrecordingtime >/dev/null
fi
echo z > /dev/serial/by-id/usb-Atric_Development_GbR_Atric_IR-Wakeup_USB-if00
and the files looks like:
{
"enabled": true,
"start": 1493842500,
"start_extra": 0,
"stop": 1493844300,
"stop_extra": 0,
"channel": "d3751afe7fb68fb4a19fb1d482b52787",
"channelname": "Das Erste HD",
"title": {
"ger": "Tagesthemen"
},
"subtitle": {
"ger": "mit Wetter"
},
"description": {
"ger": "Themen u.a.:\n* Vor der Wahl: TV-Duell in Frankreich\n* Unter Druck: Eingeschüchterte Journalisten\n* Auf der Hut: Cybercrime bedroht Deutschland\n* Kommentar von Thomas Baumann (MDR) zum Tag der Pressefreiheit\n\nModeration: Caren Miosga\nProduziert in H"
},
"pri": 2,
"retention": 2147483646,
"removal": 92,
"playposition": 0,
"playcount": 0,
"config_name": "8d0f5b7ae354d956d7fe5db25f5d0d24",
"owner": "kodi",
"creator": "kodi",
"errorcode": 103,
"errors": 1,
"data_errors": 0,
"dvb_eid": 22433,
"noresched": false,
"norerecord": false,
"fileremoved": 0,
"autorec": "",
"timerec": "",
"parent": "",
"child": "",
"content_type": 2,
"broadcast": 37561,
"files": [
{
"filename": "/storage/recordings/Tagesthemen/Tagesthemen-Das Erste HD2017-05-0322-15.ts",
"info": [
{
"type": "H264",
"width": 1280,
"height": 720,
"duration": 1800,
"aspect_num": 0,
"aspect_den": 0
},
{
"type": "MPEG2AUDIO",
"language": "ger",
"audio_type": 0
},
{
"type": "MPEG2AUDIO",
"language": "mis",
"audio_type": 0
},
{
"type": "AC3",
"language": "ger",
"audio_type": 0
},
{
"type": "TELETEXT"
},
{
"type": "DVBSUB",
"language": "ger",
"composition_id": 1,
"ancillary_id": 1
}
],
"start": 1493842500,
"stop": 1493844164
}
]
}
everything is fine if I use
wake_start_time=`date -d@$wake_start_timestamp +%d-%m-%Y/%H:%M`
instead of
wake_start_time=`date -d@$wake_start_timestamp +%d-%m-%Y\ %H:%M`