Digitaler Bilderrahmen mit lcd4linux: Unterschied zwischen den Versionen

Aus FHEMWiki
Keine Bearbeitungszusammenfassung
 
(6 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 2: Zeile 2:


Auf der Seite [[Digitaler Bilderrahmen]] wird ein Ansatz beschrieben, der mit komplexeren DPF arbeitet.
Auf der Seite [[Digitaler Bilderrahmen]] wird ein Ansatz beschrieben, der mit komplexeren DPF arbeitet.
 
[[Datei:20140909_123726.jpg]]
=Voraussetzungen=
=Voraussetzungen=
*Digitaler Bilderrahmen, der über lcd4linux ansteuerbar ist, z.B. Samsung SPF85H.
*Digitaler Bilderrahmen, der über lcd4linux ansteuerbar ist, z.B. Samsung SPF85H.
Zeile 68: Zeile 68:
Diese Datei wird nun mit ''crontab -e'' in die Tabelle des ''cron''-Dämons eingetragen. Mit der folgenden Zeile wird das Skript automatisch jede Minute ausgeführt.
Diese Datei wird nun mit ''crontab -e'' in die Tabelle des ''cron''-Dämons eingetragen. Mit der folgenden Zeile wird das Skript automatisch jede Minute ausgeführt.
* * * * * /opt/fhem/getFHEM.sh
* * * * * /opt/fhem/getFHEM.sh
==Erzeugung eines Alarmbildes==
==lcd4linux konfigurieren==
Hier wird eine Bilddatei mit Alarmmeldungen aus FHEM erzeugt.
Dazu wird in die Datei /etc/lcd4linux.conf folgendes geschrieben:
  !/bin/bash
Display dpf {
    Driver    'SamsungSPF'
    Port      'usb0'   
    Model      'SPF-85H'
    Font      '96x128'
    Foreground 'ffffff'
    Background '000000'
    Basecolor  '000000'
    Backlight 7
    Orientation 1
}
Variables {
  tick 1000
  dick 2000
  pick 10000
  minute 60000
  hminute 30000
}
Widget Foto {
  class  'Image'
  file  '/root/back.png'
  update hminute
  reload  1
  visible 1
  inverted 0
}
Widget Alarm {
  class  'Image'
  file  '/root/alarm.png'+
  update hminute
  reload  1
  visible 1
  inverted 0
}
Widget Solar {
  class  'Image'
  file  '/root/solar.png'
  update hminute
  reload  1
  visible 1
  inverted 0
}
Widget Strom {
  class  'Image'
  file  '/root/strom.png'
  update hminute
  reload  1
  visible 1
  inverted  0
}
Widget Gas {
  class  'Image'
  file  '/root/gas.png'
  update hminute
  reload  1
  visible 1
  inverted  0
Widget Temp {
  class  'Image'
  file  '/root/temp.png'
  update hminute
  reload  1
  visible 1
  inverted 0
}
Widget Date {
  class  'Image'
  file  '/root/date.png'
  update hminute
  reload  1
  visible 1
  inverted 0
}
#####################################################################
Display 'DPF'
#####################################################################
Layout Normal {
# X/Y exchanged !!
  Layer 1 {
    X0.Y0 'Foto'
    X450.Y0 'Alarm'
    X0.Y600 'Date'
    X150.Y600 'Temp'
    X450.Y600 'Strom'
    X450.Y400 'Solar'
    X450.Y200 'Gas'
  }
}
 
 
==Erzeugung einer Fotodatei==
Erzeugung eines PNG-Files aus einer aus einem Ordner zufällig ausgewählten anderen Datei. Dazu wird im Verzeichnis /opt/fhem die Datei ''createPic.sh'' angelegt:
  #!/bin/bash
  #
  #
  #  script to produce an alarm PNG file using ImageMagick convert
  #  script to produce a photo PNG file using ImageMagick convert
  #
  #
  #  Prof.Dr. Peter A. Henning, July 2014
  #  Prof.Dr. Peter A. Henning, July 2014
  #
  #
#
#-- Directory Containing Pictures
DIR="/root/Bilder"
#
# Command to Select a random jpg file from directory
pic=$(ls $DIR | shuf -n1)
#
#-- Correct the size
convert $DIR/$pic -resize 600x450 back.png
#convert $DIR/$pic -rotate -90 -resize 450x600 back.png
==Erzeugung einer Datumsanzeige==
Erzeugung eines Bildes mit dem gegenwärtigen Datum und der jetzigen Zeit. Dazu wird im Verzeichnis /opt/fhem die Datei ''createDate.sh'' angelegt:
#!/bin/bash
#
#  script to produce a date PNG file using ImageMagick convert
#
#  Prof.Dr. Peter A. Henning, July 2014
  #
  #
# parameter for internal string
# if missing, only rename files
alarm=$1
warn="$2"
scharf=$3
  #
  #
  if [ "$scharf" == "scharf" ]; then
  #--date pieces
  colalarm1="red"
ddate=`date +%a%_3e.%_4b%_5Y`
  colalarm2="firebrick3"
  dtime=`date +%k:%M`
  else
  colalarm1="black"
  colalarm2="darkslategray"
fi
  #
  #
  ########################################## Keine Störung ##################################
  convert -size 320x240 canvas:none -stroke snow4 -size 1x90 -tile gradient:white-snow4 \
 
  if [ "$alarm" == "no_alarm" -a "$warn" == "no_warning" ]; then
  convert -size 320x240 canvas:none -stroke snow4 -size 1x90 -tile gradient:white-snow4 \
       \( +clone -background snow4 -shadow 80x3+3+3 \) \
       \( +clone -background snow4 -shadow 80x3+3+3 \) \
   +swap -background none -layers merge \
   +swap -background none -layers merge \
       \( +size -font Helvetica \
       \( +size -font Helvetica \
           -pointsize 25 -strokewidth 1 -fill black label:"Keine Störung" -trim -repage 0x0+20+60 \
           -pointsize 75 -strokewidth 1 -fill red label:"$dtime" -trim -repage 0x0+25+60 \
               \( +clone -background darkslategray -shadow 80x1+1+1 \) \
               \( +clone -background firebrick3 -shadow 80x3+3+3 \) \
      \( +clone -background darkslategray -shadow 80x1+1+1 \) \
           +swap -background none -layers merge \) \
           +swap -background none -layers merge \) \
   -insert 1 -layers merge \
   -insert 1 -layers merge \
       \( +size -font Helvetica \
       \( +size -font Helvetica \
           -pointsize 25 -strokewidth 1 -fill $colalarm1 label:"Alarmanlage $scharf" -trim -repage 0x0+20+120 \
           -pointsize 35 -strokewidth 1 -fill blue label:"$ddate" -trim -repage 0x0+25+150 \
               \( +clone -background $colalarm2 -shadow 80x1+1+1 \) \
               \( +clone -background slateblue4 -shadow 80x1+2+2 \) \
           +swap -background none -layers merge \) \
           +swap -background none -layers merge \) \
   -insert 1 -layers merge \
   -insert 1 -layers merge \
   -append -background white -gravity center -extent 320x240 \
   -append -background white -gravity center -extent 320x240 \
   b_alarm.png  
   b_date.png
  fi
#-- correct the size
convert b_date.png -resize 200x150 date.png


  ########################################## Störungmeldung #################################
==Erzeugen einer Temperaturanzeige==
 
Dazu wird im Verzeichnis /opt/fhem die Shell-Datei ''createTemp.sh'' angelegt.
  if [ "$alarm" == "no_alarm" -a "$warn" != "no_warning" ]; then
  #!/bin/bash
    todate=`date +"%H%M"`
#
  #-- serious warning during nighttime
#   script to produce a temperature PNG file using ImageMagick convert
  if [ $todate -ge 2200 ] || [ $todate -le 600 ] ; then
#
 
#   Prof.Dr. Peter A. Henning, July 2014
  convert -size 320x240 canvas:none -stroke gold2 -size 1x90 -tile gradient:yellow-gold2 \
#  
       \( +clone -background gold2 -shadow 80x3+3+3 \) \
#
# parameters for internal temperature/humidity
ti=$1
rhi=$2
# parameters for external temperature/humidity/pressure
ta=$3
rha=$4
pa=$5
#
#-- formatted temperature valuesa
deg=`printf "\u00B0C"`
tif="$ti $deg"
taf="$ta $deg"
#
#-- formatted humidity values
rif="$rhi %"
raf="$rha %"
#
#-- formatted pressure
paf="$pa hPa"
  #
convert -size 320x480 canvas:none -stroke snow4 -size 1x90 -tile gradient:white-snow4 \
       \( +clone -background snow4 -shadow 80x3+3+3 \) \
   +swap -background none -layers merge \
   +swap -background none -layers merge \
      \( +size -font Helvetica \
      \( +size -font Helvetica \
           -pointsize 35 -strokewidth 1 -fill red label:"$warn" -trim -repage 0x0+20+60 \
           -pointsize 25 -strokewidth 1 -fill black label:"Innen" -trim -repage 0x0+20+20 \
    \( +clone -background darkslategray -shadow 80x1+1+1 \) \
          +swap -background none -layers merge \) \
  -insert 1 -layers merge \
      \( +size -font Helvetica \
          -pointsize 75 -strokewidth 1 -fill red label:"$tif" -trim -repage 0x0+20+60 \
               \( +clone -background firebrick3 -shadow 80x3+3+3 \) \
               \( +clone -background firebrick3 -shadow 80x3+3+3 \) \
           +swap -background none -layers merge \) \
           +swap -background none -layers merge \) \
   -insert 1 -layers merge \
   -insert 1 -layers merge \
       \( +size -font Helvetica \
       \( +size -font Helvetica \
           -pointsize 25 -strokewidth 1 -fill $colalarm1 label:"Alarmanlage $scharf" -trim -repage 0x0+20+120 \
          -pointsize 50 -strokewidth 1 -fill blue label:"$rif" -trim -repage 0x0+20+140 \
               \( +clone -background $colalarm2 -shadow 80x1+1+1 \) \
              \( +clone -background slateblue4 -shadow 80x1+2+2 \) \
          +swap -background none -layers merge \) \
  -insert 1 -layers merge \
      \( +size -font Helvetica \
           -pointsize 25 -strokewidth 1 -fill black label:"Außen" -trim -repage 0x0+20+240 \
               \( +clone -background darkslategray -shadow 80x1+1+1 \) \
           +swap -background none -layers merge \) \
           +swap -background none -layers merge \) \
   -insert 1 -layers merge \
   -insert 1 -layers merge \
       \( +clone -background darkslategray -shadow 80x1+1+1 \) \
       \( +size -font Helvetica \
          -pointsize 75 -strokewidth 1 -fill red label:"$taf" -trim -repage 0x0+20+280 \
              \( +clone -background firebrick3 -shadow 80x3+3+3 \) \
           +swap -background none -layers merge \) \
           +swap -background none -layers merge \) \
   -insert 1 -layers merge \
   -insert 1 -layers merge \
       \( +size -font Helvetica \
       \( +size -font Helvetica \
           -pointsize 25 -strokewidth 1 -fill $colalarm1 label:"Alarmanlage $scharf" -trim -repage 0x0+20+120 \
           -pointsize 50 -strokewidth 1 -fill blue label:"$raf" -trim -repage 0x0+20+360 \
               \( +clone -background $colalarm2 -shadow 80x1+1+1 \) \
               \( +clone -background slateblue4 -shadow 80x1+2+2 \) \
           +swap -background none -layers merge \) \
           +swap -background none -layers merge \) \
   -insert 1 -layers merge \
   -insert 1 -layers merge \
  -append -background white -gravity center -extent 320x240 \
       \( +size -font Helvetica \
  b_alarm.png
           -pointsize 50 -strokewidth 1 -fill blue label:"$paf" -trim -repage 0x0+20+420 \
  fi
               \( +clone -background slateblue4 -shadow 80x1+2+2 \) \
 
########################################## Störungmeldung #################################
 
  if [ "$alarm" == "no_alarm" -a "$warn" != "no_warning" ]; then
    todate=`date +"%H%M"`
  #-- serious warning during nighttime
  if [ $todate -ge 2200 ] || [ $todate -le 600 ] ; then
 
  convert -size 320x240 canvas:none -stroke gold2 -size 1x90 -tile gradient:yellow-gold2 \
       \( +clone -background gold2 -shadow 80x3+3+3 \) \
  +swap -background none -layers merge \
      \( +size -font Helvetica \
           -pointsize 35 -strokewidth 1 -fill red label:"$warn" -trim -repage 0x0+20+60 \
               \( +clone -background firebrick3 -shadow 80x3+3+3 \) \
           +swap -background none -layers merge \) \
           +swap -background none -layers merge \) \
   -insert 1 -layers merge \
   -insert 1 -layers merge \
       \( +size -font Helvetica \
       \( +size -font Helvetica \
           -pointsize 25 -strokewidth 1 -fill $colalarm1 label:"Alarmanlage $scharf" -trim -repage 0x0+20+120 \
           -pointsize 50 -strokewidth 1 -fill blue label:"$rif" -trim -repage 0x0+20+140 \
               \( +clone -background $colalarm2 -shadow 80x1+1+1 \) \
               \( +clone -background slateblue4 -shadow 80x1+2+2 \) \
           +swap -background none -layers merge \) \
           +swap -background none -layers merge \) \
   -insert 1 -layers merge \
   -insert 1 -layers merge \
-append -background gold2 -gravity center -extent 320x240 \
       \( +size -font Helvetica \
  b_alarm.png
           -pointsize 25 -strokewidth 1 -fill black label:"Außen" -trim -repage 0x0+20+240 \
 
  #-- just information during daytime
  else
 
  convert -size 320x240 canvas:none -stroke snow4 -size 1x90 -tile gradient:white-snow4 \
       \( +clone -background snow4 -shadow 80x3+3+3 \) \
  +swap -background none -layers merge \
      \( +size -font Helvetica \
           -pointsize 25 -strokewidth 1 -fill black label:"$warn" -trim -repage 0x0+20+60 \
               \( +clone -background darkslategray -shadow 80x1+1+1 \) \
               \( +clone -background darkslategray -shadow 80x1+1+1 \) \
           +swap -background none -layers merge \) \
           +swap -background none -layers merge \) \
   -insert 1 -layers merge \
   -insert 1 -layers merge \
       \( +size -font Helvetica \
       \( +size -font Helvetica \
           -pointsize 25 -strokewidth 1 -fill $colalarm1 label:"Alarmanlage $scharf" -trim -repage 0x0+20+120 \
           -pointsize 75 -strokewidth 1 -fill red label:"$taf" -trim -repage 0x0+20+280 \
               \( +clone -background $colalarm2 -shadow 80x1+1+1 \) \
               \( +clone -background firebrick3 -shadow 80x3+3+3 \) \
           +swap -background none -layers merge \) \
           +swap -background none -layers merge \) \
   -insert 1 -layers merge \
   -insert 1 -layers merge \
  -append -background white -gravity center -extent 320x240 \
       \( +size -font Helvetica \
  b_alarm.png
          -pointsize 50 -strokewidth 1 -fill blue label:"$raf" -trim -repage 0x0+20+360 \
  fi 
               \( +clone -background slateblue4 -shadow 80x1+2+2 \) \
fi
########################################## Alarm ##########################################
 
  if [ "$alarm" != "no_alarm" ]; then
  convert -size 320x240 canvas:none -stroke firebrick3 -size 1x90 -tile gradient:red-firebrick3 \
       \( +clone -background firebrick3 -shadow 80x3+3+3 \) \
  +swap -background none -layers merge \
-pointsize 35 -strokewidth 1 -fill white label:"$alarm" -trim -repage 0x0+20+60 \
               \( +clone -background snow4 -shadow 80x3+3+3 \) \
           +swap -background none -layers merge \) \
           +swap -background none -layers merge \) \
   -insert 1 -layers merge \
   -insert 1 -layers merge \
       \( +size -font Helvetica \
       \( +size -font Helvetica \
           -pointsize 25 -strokewidth 1 -fill $colalarm1 label:"Alarmanlage $scharf" -trim -repage 0x0+20+120 \
           -pointsize 50 -strokewidth 1 -fill blue label:"$paf" -trim -repage 0x0+20+420 \
               \( +clone -background $colalarm2 -shadow 80x1+1+1 \) \
               \( +clone -background slateblue4 -shadow 80x1+2+2 \) \
           +swap -background none -layers merge \) \
           +swap -background none -layers merge \) \
   -insert 1 -layers merge \
   -insert 1 -layers merge \
   -append -background red -gravity center -extent 320x240 \
   -append -background white -gravity center -extent 320x480 \
   b_alarm.png  
   b_temp.png
  fi
#
 
  # correct the size
  # correct the size
  convert b_alarm.png -resize 200x150 alarm.png
  convert b_temp.png -resize 200x300 temp.png
 
#convert b_temp.png -rotate -90 -resize 300x200 temp.png
 
 


==Erzeugen von Balkendiagrammen==
==Erzeugen von Balkendiagrammen==
Balkendiagramme hier erzeugt, indem die von FHEM übermittelten Werte mittels eines weiteren Skripts als Eingabeparameter für das Programm ''convert'' aus der ImageMagick-Suite benutzt werden. Drei verschiedene Farbschemata für diese Diagramme - genannt ''green'', ''red'' und ''blue'' -- sind hier vordefiniert
Balkendiagramme werden erzeugt, indem die von FHEM übermittelten Werte mittels eines weiteren Skripts als Eingabeparameter für das Programm ''convert'' aus der ImageMagick-Suite benutzt werden. Drei verschiedene Farbschemata für diese Diagramme - genannt ''green'', ''red'' und ''blue'' -- sind hier vordefiniert


Hierzu wird  (z.B. im Verzeichnis /opt/fhem) eine Skriptdatei ''createBar.sh'' angelegt:
Hierzu wird  (z.B. im Verzeichnis /opt/fhem) eine Skriptdatei ''createBar.sh'' angelegt:
Zeile 313: Zeile 410:
  #-- correct the size
  #-- correct the size
  convert b_$fname -resize $6 $fname
  convert b_$fname -resize $6 $fname
==  
==Erzeugung eines Alarmbildes==
Hier wird eine Bilddatei mit Alarmmeldungen aus FHEM erzeugt. Der Name der Skriptdatei ist ''createAlarm.sh''
!/bin/bash
#
#  script to produce an alarm PNG file using ImageMagick convert
#
#  Prof.Dr. Peter A. Henning, July 2014
#
#
# parameter for internal string
# if missing, only rename files
alarm=$1
warn="$2"
scharf=$3
#
if [ "$scharf" == "scharf" ]; then
  colalarm1="red"
  colalarm2="firebrick3"
else
  colalarm1="black"
  colalarm2="darkslategray"
fi
#
########################################## Keine Störung ##################################
#
  if [ "$alarm" == "no_alarm" -a "$warn" == "no_warning" ]; then
  convert -size 320x240 canvas:none -stroke snow4 -size 1x90 -tile gradient:white-snow4 \
      \( +clone -background snow4 -shadow 80x3+3+3 \) \
  +swap -background none -layers merge \
      \( +size -font Helvetica \
          -pointsize 25 -strokewidth 1 -fill black label:"Keine Störung" -trim -repage 0x0+20+60 \
              \( +clone -background darkslategray -shadow 80x1+1+1 \) \
      \( +clone -background darkslategray -shadow 80x1+1+1 \) \
          +swap -background none -layers merge \) \
  -insert 1 -layers merge \
      \( +size -font Helvetica \
          -pointsize 25 -strokewidth 1 -fill $colalarm1 label:"Alarmanlage $scharf" -trim -repage 0x0+20+120 \
              \( +clone -background $colalarm2 -shadow 80x1+1+1 \) \
          +swap -background none -layers merge \) \
  -insert 1 -layers merge \
  -append -background white -gravity center -extent 320x240 \
  b_alarm.png
  fi
#
########################################## Störungmeldung #################################
#
  if [ "$alarm" == "no_alarm" -a "$warn" != "no_warning" ]; then
    todate=`date +"%H%M"`
  #-- serious warning during nighttime
  if [ $todate -ge 2200 ] || [ $todate -le 600 ] ; then
  convert -size 320x240 canvas:none -stroke gold2 -size 1x90 -tile gradient:yellow-gold2 \
      \( +clone -background gold2 -shadow 80x3+3+3 \) \
  +swap -background none -layers merge \
      \( +size -font Helvetica \
          -pointsize 35 -strokewidth 1 -fill red label:"$warn" -trim -repage 0x0+20+60 \
              \( +clone -background firebrick3 -shadow 80x3+3+3 \) \
          +swap -background none -layers merge \) \
  -insert 1 -layers merge \
      \( +size -font Helvetica \
          -pointsize 25 -strokewidth 1 -fill $colalarm1 label:"Alarmanlage $scharf" -trim -repage 0x0+20+120 \
              \( +clone -background $colalarm2 -shadow 80x1+1+1 \) \
          +swap -background none -layers merge \) \
  -insert 1 -layers merge \
      \( +clone -background darkslategray -shadow 80x1+1+1 \) \
          +swap -background none -layers merge \) \
  -insert 1 -layers merge \
      \( +size -font Helvetica \
          -pointsize 25 -strokewidth 1 -fill $colalarm1 label:"Alarmanlage $scharf" -trim -repage 0x0+20+120 \
              \( +clone -background $colalarm2 -shadow 80x1+1+1 \) \
          +swap -background none -layers merge \) \
  -insert 1 -layers merge \
  -append -background white -gravity center -extent 320x240 \
  b_alarm.png
  fi
#
########################################## Störungmeldung #################################
#
  if [ "$alarm" == "no_alarm" -a "$warn" != "no_warning" ]; then
    todate=`date +"%H%M"`
  #-- serious warning during nighttime
  if [ $todate -ge 2200 ] || [ $todate -le 600 ] ; then
 
  convert -size 320x240 canvas:none -stroke gold2 -size 1x90 -tile gradient:yellow-gold2 \
      \( +clone -background gold2 -shadow 80x3+3+3 \) \
  +swap -background none -layers merge \
      \( +size -font Helvetica \
          -pointsize 35 -strokewidth 1 -fill red label:"$warn" -trim -repage 0x0+20+60 \
              \( +clone -background firebrick3 -shadow 80x3+3+3 \) \
          +swap -background none -layers merge \) \
  -insert 1 -layers merge \
      \( +size -font Helvetica \
          -pointsize 25 -strokewidth 1 -fill $colalarm1 label:"Alarmanlage $scharf" -trim -repage 0x0+20+120 \
              \( +clone -background $colalarm2 -shadow 80x1+1+1 \) \
          +swap -background none -layers merge \) \
  -insert 1 -layers merge \
-append -background gold2 -gravity center -extent 320x240 \
  b_alarm.png
  #
  #-- just information during daytime
  else
  #
  convert -size 320x240 canvas:none -stroke snow4 -size 1x90 -tile gradient:white-snow4 \
      \( +clone -background snow4 -shadow 80x3+3+3 \) \
  +swap -background none -layers merge \
      \( +size -font Helvetica \
          -pointsize 25 -strokewidth 1 -fill black label:"$warn" -trim -repage 0x0+20+60 \
              \( +clone -background darkslategray -shadow 80x1+1+1 \) \
          +swap -background none -layers merge \) \
  -insert 1 -layers merge \
      \( +size -font Helvetica \
          -pointsize 25 -strokewidth 1 -fill $colalarm1 label:"Alarmanlage $scharf" -trim -repage 0x0+20+120 \
              \( +clone -background $colalarm2 -shadow 80x1+1+1 \) \
          +swap -background none -layers merge \) \
  -insert 1 -layers merge \
  -append -background white -gravity center -extent 320x240 \
  b_alarm.png
  fi 
fi
#
########################################## Alarm ##########################################
#
  if [ "$alarm" != "no_alarm" ]; then
  convert -size 320x240 canvas:none -stroke firebrick3 -size 1x90 -tile gradient:red-firebrick3 \
      \( +clone -background firebrick3 -shadow 80x3+3+3 \) \
  +swap -background none -layers merge \
-pointsize 35 -strokewidth 1 -fill white label:"$alarm" -trim -repage 0x0+20+60 \
              \( +clone -background snow4 -shadow 80x3+3+3 \) \
          +swap -background none -layers merge \) \
  -insert 1 -layers merge \
      \( +size -font Helvetica \
          -pointsize 25 -strokewidth 1 -fill $colalarm1 label:"Alarmanlage $scharf" -trim -repage 0x0+20+120 \
              \( +clone -background $colalarm2 -shadow 80x1+1+1 \) \
          +swap -background none -layers merge \) \
  -insert 1 -layers merge \
  -append -background red -gravity center -extent 320x240 \
  b_alarm.png
  fi
#
# correct the size
convert b_alarm.png -resize 200x150 alarm.png


[[Kategorie:HOWTOS]]
[[Kategorie:HOWTOS]]

Aktuelle Version vom 9. September 2014, 13:45 Uhr

Diese Seite beschreibt die Verwendung eines Digitalen Bilderrahmens (DPF) als Display für FHEM. Die Anbindung erfolgt dabei an einen separaten Raspberry Pi, auf welchem lcd4linux läuft. Dies ermöglicht die Verwendung einer Vielzahl von verschiedenen preiswerten Displays, die keine großartigen Fähigkeiten aufweisen müssen.

Auf der Seite Digitaler Bilderrahmen wird ein Ansatz beschrieben, der mit komplexeren DPF arbeitet. 20140909 123726.jpg

Voraussetzungen

  • Digitaler Bilderrahmen, der über lcd4linux ansteuerbar ist, z.B. Samsung SPF85H.
  • Raspberry Pi mit LAN oder WLAN Interface.

Achtung: Prinzipiell ließe sich das lcd4linux auch auf FHEM-Rechner installieren - allerdings sind Performance-Probleme auf den hier verwendeten Kleinstrechnern nicht ausgeschlossen.

Installation

Auf dem Raspberry Pi sind die Anwendungen socat, ImageMagick und lcd4linux zu installieren. lcd4linux sollte beim Hochfahren des Raspberry Pi automatisch starten.

Werte holen von FHEM

Zunächst wird (z.B. im Verzeichnis /opt/fhem) eine Skriptdatei getFHEM.sh angelegt.

#!/bin/bash
#
#   script to read FHEM values
#
#   Prof.Dr. Peter A. Henning, July 2014
#
round()
{
echo $(LANG=C printf %.$2f $(echo "scale=$2;(((10^$2)*$1)+0.5)/(10^$2)" | bc))
};
#
arg=$1
#
#-- get FHEM values
alarm='{Value("WZ.SPF.alarm")."|"}'
warn='{Value("WZ.SPF.warn")."|"}'
scharf='{AttrVal("AAA","level6xec","")}'
aowb='{Value("A.OWB")}'
aowbt='{Value("A.OWB.T")}'
wzowm='{Value("WZ.OWM")}'
nt5000a='{$defs{"nt5000"}{"STATE"}}'
nt5000b='{$defs{"nt5000"}{"READINGS"}{"Wd"}{"VAL"}}'
everb='{Value("E.Verb")}'
gverb='{Value("G.Verb")}'
FHEM=`echo -e "$alarm;$warn;$scharf;$aowb;$aowbt;$wzowm;$everb;$gverb;$nt5000b;$nt5000a" | socat -t50 - TCP:<IP-Adresse von FHEM> 
#
#--isolate separate values
alarm=`echo $FHEM | cut -d '|' -f1`
warn=`echo $FHEM | cut -d '|' -f2 | sed 's/^ *//'`
FHEM3=`echo $FHEM |  cut -d '|' -f3`
scharf=`echo $FHEM3 | awk '{print $1}' | sed 's/sharp/scharf/'`
rHa=$(round `echo $FHEM3 | awk '{print $3}'` 0)
Ta=$(round `echo $FHEM3 | awk '{print $15}'` 1)
pa=$(round `echo $FHEM3 | awk '{print $12}'` 0)
rHi=$(round `echo $FHEM3 | awk '{print $18}'` 0)
Ti=$(round `echo $FHEM3 | awk '{print $21}'` 1)
evp=$(round `echo $FHEM3 | awk '{print $27}'` 2)
evw=$(round `echo $FHEM3 | awk '{print $24}'` 1)
gvp=$(round `echo $FHEM3 | awk '{print $36}'` 2)
gvw=$(round `echo $FHEM3 | awk '{print $33}'` 2)
pvpraw=`echo $FHEM3 | awk '{print $42}'`
pvp=$(round $pvpraw 2)
pvw=$(round `echo $FHEM3 | awk '{print $41}'` 1)
#
if [ "$arg" == "show" ]; then
  echo "alarm=$alarm warn=$warn => $scharf; Climate=>$rHa $Ta $pa $rHi $Ti; PV=> $pvpraw $pvp $pvw; EV=> $evp $evw; GV=>$gvp $gvw" 
fi
#
#--create bar graphs
./createAlarm.sh "$alarm" "$warn" $scharf &
./createBar.sh $pvw 35 kWh $pvp kW 200x150 green PV solar.png &
./createBar.sh $evw 35 kWh $evp kW 200x150 blue EV strom.png &
./createBar.sh $gvw 20 m³ $gvp m³/h 200x150 red GV gas.png &
./createTemp.sh $Ti $rHi $Ta $rHa $pa &
./createDate.sh & 

Diese Datei wird nun mit crontab -e in die Tabelle des cron-Dämons eingetragen. Mit der folgenden Zeile wird das Skript automatisch jede Minute ausgeführt.

  • * * * * /opt/fhem/getFHEM.sh

lcd4linux konfigurieren

Dazu wird in die Datei /etc/lcd4linux.conf folgendes geschrieben:

Display dpf {
   Driver     'SamsungSPF'
   Port       'usb0'    
   Model      'SPF-85H'
   Font       '96x128'
   Foreground 'ffffff'
   Background '000000'
   Basecolor  '000000'
   Backlight 7 
   Orientation 1
}
Variables {
 tick 1000
 dick 2000 
 pick 10000
 minute 60000
 hminute 30000
}
Widget Foto {
 class  'Image'
 file   '/root/back.png'
 update hminute
 reload  1
 visible 1
 inverted 0
}
Widget Alarm {
 class  'Image'
 file   '/root/alarm.png'+
 update hminute
 reload  1
 visible 1
 inverted 0
}
Widget Solar {
 class  'Image'
 file   '/root/solar.png'
 update hminute 
 reload  1
 visible 1
 inverted 0
}
Widget Strom {
 class  'Image'
 file   '/root/strom.png'
 update hminute 
 reload  1
 visible 1
 inverted  0
}
Widget Gas {
 class  'Image'
 file   '/root/gas.png'
 update hminute
 reload  1
 visible 1
 inverted  0
Widget Temp {
 class  'Image'
 file   '/root/temp.png'
 update hminute 
 reload  1
 visible 1
 inverted 0
} 
Widget Date {
 class  'Image'
 file   '/root/date.png'
 update hminute
 reload  1
 visible 1
 inverted 0
}
#####################################################################
Display 'DPF'
#####################################################################
Layout Normal {
# X/Y exchanged !!
 Layer 1 {
   X0.Y0 'Foto'
   X450.Y0 'Alarm'
   X0.Y600 'Date'
   X150.Y600 'Temp'
   X450.Y600 'Strom'
   X450.Y400 'Solar'
   X450.Y200 'Gas'
 }
}


Erzeugung einer Fotodatei

Erzeugung eines PNG-Files aus einer aus einem Ordner zufällig ausgewählten anderen Datei. Dazu wird im Verzeichnis /opt/fhem die Datei createPic.sh angelegt:

#!/bin/bash
#
#   script to produce a photo PNG file using ImageMagick convert
#
#   Prof.Dr. Peter A. Henning, July 2014
#
# 
#-- Directory Containing Pictures
DIR="/root/Bilder"
#
# Command to Select a random jpg file from directory
pic=$(ls $DIR | shuf -n1)
#
#-- Correct the size
convert $DIR/$pic -resize 600x450 back.png
#convert $DIR/$pic -rotate -90 -resize 450x600 back.png

Erzeugung einer Datumsanzeige

Erzeugung eines Bildes mit dem gegenwärtigen Datum und der jetzigen Zeit. Dazu wird im Verzeichnis /opt/fhem die Datei createDate.sh angelegt:

#!/bin/bash
#
#   script to produce a date PNG file using ImageMagick convert
#
#   Prof.Dr. Peter A. Henning, July 2014
#
#
#--date pieces
ddate=`date +%a%_3e.%_4b%_5Y`
dtime=`date +%k:%M`
#
convert -size 320x240 canvas:none -stroke snow4 -size 1x90 -tile gradient:white-snow4 \
      \( +clone -background snow4 -shadow 80x3+3+3 \) \
 +swap -background none -layers merge \
      \( +size -font Helvetica \
         -pointsize 75 -strokewidth 1 -fill red label:"$dtime" -trim -repage 0x0+25+60 \
             \( +clone -background firebrick3 -shadow 80x3+3+3 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +size -font Helvetica \
         -pointsize 35 -strokewidth 1 -fill blue label:"$ddate" -trim -repage 0x0+25+150 \
             \( +clone -background slateblue4 -shadow 80x1+2+2 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
 -append -background white -gravity center -extent 320x240 \
 b_date.png
#  
#-- correct the size
convert b_date.png -resize 200x150 date.png

Erzeugen einer Temperaturanzeige

Dazu wird im Verzeichnis /opt/fhem die Shell-Datei createTemp.sh angelegt.

#!/bin/bash
#
#   script to produce a temperature PNG file using ImageMagick convert
#
#   Prof.Dr. Peter A. Henning, July 2014
# 
#
# parameters for internal temperature/humidity
ti=$1
rhi=$2
# parameters for external temperature/humidity/pressure 
ta=$3
rha=$4
pa=$5
#
#-- formatted temperature valuesa
deg=`printf "\u00B0C"`
tif="$ti $deg"
taf="$ta $deg"
#
#-- formatted humidity values
rif="$rhi %"
raf="$rha %"
#
#-- formatted pressure
paf="$pa hPa"
 #
convert -size 320x480 canvas:none -stroke snow4 -size 1x90 -tile gradient:white-snow4 \
      \( +clone -background snow4 -shadow 80x3+3+3 \) \
 +swap -background none -layers merge \
      \( +size -font Helvetica \
         -pointsize 25 -strokewidth 1 -fill black label:"Innen" -trim -repage 0x0+20+20 \
   \( +clone -background darkslategray -shadow 80x1+1+1 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +size -font Helvetica \
         -pointsize 75 -strokewidth 1 -fill red label:"$tif" -trim -repage 0x0+20+60 \
             \( +clone -background firebrick3 -shadow 80x3+3+3 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +size -font Helvetica \
         -pointsize 50 -strokewidth 1 -fill blue label:"$rif" -trim -repage 0x0+20+140 \
             \( +clone -background slateblue4 -shadow 80x1+2+2 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +size -font Helvetica \
         -pointsize 25 -strokewidth 1 -fill black label:"Außen" -trim -repage 0x0+20+240 \
             \( +clone -background darkslategray -shadow 80x1+1+1 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +size -font Helvetica \
         -pointsize 75 -strokewidth 1 -fill red label:"$taf" -trim -repage 0x0+20+280 \
             \( +clone -background firebrick3 -shadow 80x3+3+3 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +size -font Helvetica \
         -pointsize 50 -strokewidth 1 -fill blue label:"$raf" -trim -repage 0x0+20+360 \
             \( +clone -background slateblue4 -shadow 80x1+2+2 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +size -font Helvetica \
         -pointsize 50 -strokewidth 1 -fill blue label:"$paf" -trim -repage 0x0+20+420 \
             \( +clone -background slateblue4 -shadow 80x1+2+2 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +size -font Helvetica \
         -pointsize 50 -strokewidth 1 -fill blue label:"$rif" -trim -repage 0x0+20+140 \
             \( +clone -background slateblue4 -shadow 80x1+2+2 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +size -font Helvetica \
         -pointsize 25 -strokewidth 1 -fill black label:"Außen" -trim -repage 0x0+20+240 \
             \( +clone -background darkslategray -shadow 80x1+1+1 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +size -font Helvetica \
         -pointsize 75 -strokewidth 1 -fill red label:"$taf" -trim -repage 0x0+20+280 \
             \( +clone -background firebrick3 -shadow 80x3+3+3 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +size -font Helvetica \
         -pointsize 50 -strokewidth 1 -fill blue label:"$raf" -trim -repage 0x0+20+360 \
             \( +clone -background slateblue4 -shadow 80x1+2+2 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +size -font Helvetica \
         -pointsize 50 -strokewidth 1 -fill blue label:"$paf" -trim -repage 0x0+20+420 \
             \( +clone -background slateblue4 -shadow 80x1+2+2 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
 -append -background white -gravity center -extent 320x480 \
 b_temp.png
#
# correct the size
convert b_temp.png -resize 200x300 temp.png
#convert b_temp.png -rotate -90 -resize 300x200 temp.png

Erzeugen von Balkendiagrammen

Balkendiagramme werden erzeugt, indem die von FHEM übermittelten Werte mittels eines weiteren Skripts als Eingabeparameter für das Programm convert aus der ImageMagick-Suite benutzt werden. Drei verschiedene Farbschemata für diese Diagramme - genannt green, red und blue -- sind hier vordefiniert

Hierzu wird (z.B. im Verzeichnis /opt/fhem) eine Skriptdatei createBar.sh angelegt:

!/bin/bash
#
#   script to produce a bar graph PNG file using ImageMagick convert
#
#   Prof.Dr. Peter A. Henning, July 2014
#
# parameters for bar graph
value=$1
maxim=$2
unita=$3
# parameters for top number
numbr=$4
unitb=$5
# picture size, color scheme, label and filename
picsz=$6
color=$7
label=$8
fname=$9
#
#-- color scheme
case $color in
       "green" )
               gradient1="gradient:chartreuse-green"
               gradient2="gradient:chartreuse1-chartreuse3"
               labcol1="springgreen4"
               labcol2="darkolivegreen"
               labcol3="darkslategray"
               labcol4="white"
               ;;
       "red" )
               gradient1="gradient:lightsalmon-red"
               gradient2="gradient:lightsalmon1-lightsalmon3"
               labcol1="firebrick4"
               labcol2="lightsalmon3"
               labcol3="indianred4"
               labcol4="white"
               ;;
       "blue" )
               gradient1="gradient:cyan-blue"
               gradient2="gradient:cyan1-cyan3"
               labcol1="blue"
               labcol2="slateblue4"
               labcol3="darkslateblue"
               labcol4="white"
               ;;
esac
#
#-- bar graph
bvalue="$1 $3"
xvalue=`echo "($1*248)/$2+36" | bc`
lvalue=`echo "$xvalue-20" | bc`
rvalue=`echo "$xvalue+20" | bc`
# 
#-- position and color bar graph number
if [ $xvalue -lt 160 ]; then
  labx="0x0+160+35"
  labcolf=$labcol1
  labcols=$labcol2
else
  labx="0x0+40+35"
  labcolf=$labcol3
  labcols=$labcol4
fi 
#
#-- formatted top value
tvalue="$4 $5"
#
convert -size 320x90 canvas:none -stroke snow4 -size 1x90 -tile gradient:white-snow4 \
 -draw "roundrectangle 16, 5, 304, 85 20,40" +tile -fill snow \
 -draw "roundrectangle 264, 5, 304, 85  20,40" -tile $gradient1 \
 -draw "roundrectangle 16,  5, $rvalue, 85  20,40" -tile $gradient2 \
 -draw "roundrectangle $lvalue, 5, $rvalue, 85  20,40" +tile -fill none \
 -draw "roundrectangle 264, 5, 304, 85 20,40" -strokewidth 2 \
 -draw "roundrectangle 16, 5, 304, 85 20,40" \
    \( +clone -background snow4 \
       -shadow 80x3+3+3 \) \
 +swap -background none -layers merge \
    \( +size -font Helvetica \
       -pointsize 25 -strokewidth 1 -fill $labcolf label:"$bvalue" -trim -repage $labx \
           \( +clone -background $labcols -shadow 80x1+2+2 \) \
       +swap -background none -layers merge \) \
 -insert 1 -layers merge \
    \( +size -font Helvetica \
         -pointsize 25 -strokewidth 1 -fill black label:"$label" -trim -repage 0x0+20+92 \
                     \( +clone -background gray40 -shadow 80x1+2+2 \) \
                             +swap -background none -layers merge \) \
 -insert 1 -layers merge \
    \( +size -font Helvetica \
       -pointsize 65 -strokewidth 1 -fill red label:"$tvalue" -trim +repage \
           \( +clone -background firebrick3 -shadow 80x3+3+3 \) \
       +swap -background none -layers merge \) \
 -insert 0 -gravity center -append -background white -gravity center -extent 320x240 \
 b_$fname
#
#-- correct the size
convert b_$fname -resize $6 $fname

Erzeugung eines Alarmbildes

Hier wird eine Bilddatei mit Alarmmeldungen aus FHEM erzeugt. Der Name der Skriptdatei ist createAlarm.sh

!/bin/bash
#
#   script to produce an alarm PNG file using ImageMagick convert
#
#   Prof.Dr. Peter A. Henning, July 2014
#
#
# parameter for internal string
# if missing, only rename files
alarm=$1
warn="$2"
scharf=$3
#
if [ "$scharf" == "scharf" ]; then
  colalarm1="red"
  colalarm2="firebrick3"
else
  colalarm1="black"
  colalarm2="darkslategray"
fi
#
########################################## Keine Störung ##################################
#
 if [ "$alarm" == "no_alarm" -a "$warn" == "no_warning" ]; then
 convert -size 320x240 canvas:none -stroke snow4 -size 1x90 -tile gradient:white-snow4 \
      \( +clone -background snow4 -shadow 80x3+3+3 \) \
 +swap -background none -layers merge \
      \( +size -font Helvetica \
         -pointsize 25 -strokewidth 1 -fill black label:"Keine Störung" -trim -repage 0x0+20+60 \
             \( +clone -background darkslategray -shadow 80x1+1+1 \) \
      \( +clone -background darkslategray -shadow 80x1+1+1 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +size -font Helvetica \
         -pointsize 25 -strokewidth 1 -fill $colalarm1 label:"Alarmanlage $scharf" -trim -repage 0x0+20+120 \
             \( +clone -background $colalarm2 -shadow 80x1+1+1 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
 -append -background white -gravity center -extent 320x240 \
 b_alarm.png 
 fi
#
########################################## Störungmeldung #################################
#
 if [ "$alarm" == "no_alarm" -a "$warn" != "no_warning" ]; then
   todate=`date +"%H%M"`
 #-- serious warning during nighttime
 if [ $todate -ge 2200 ] || [ $todate -le 600 ] ; then
 convert -size 320x240 canvas:none -stroke gold2 -size 1x90 -tile gradient:yellow-gold2 \
      \( +clone -background gold2 -shadow 80x3+3+3 \) \
 +swap -background none -layers merge \
     \( +size -font Helvetica \
         -pointsize 35 -strokewidth 1 -fill red label:"$warn" -trim -repage 0x0+20+60 \
             \( +clone -background firebrick3 -shadow 80x3+3+3 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +size -font Helvetica \
         -pointsize 25 -strokewidth 1 -fill $colalarm1 label:"Alarmanlage $scharf" -trim -repage 0x0+20+120 \
             \( +clone -background $colalarm2 -shadow 80x1+1+1 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +clone -background darkslategray -shadow 80x1+1+1 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +size -font Helvetica \
         -pointsize 25 -strokewidth 1 -fill $colalarm1 label:"Alarmanlage $scharf" -trim -repage 0x0+20+120 \
             \( +clone -background $colalarm2 -shadow 80x1+1+1 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
 -append -background white -gravity center -extent 320x240 \
 b_alarm.png 
 fi
#
########################################## Störungmeldung #################################
#
 if [ "$alarm" == "no_alarm" -a "$warn" != "no_warning" ]; then
   todate=`date +"%H%M"`
 #-- serious warning during nighttime
 if [ $todate -ge 2200 ] || [ $todate -le 600 ] ; then
 convert -size 320x240 canvas:none -stroke gold2 -size 1x90 -tile gradient:yellow-gold2 \
      \( +clone -background gold2 -shadow 80x3+3+3 \) \
 +swap -background none -layers merge \
     \( +size -font Helvetica \
         -pointsize 35 -strokewidth 1 -fill red label:"$warn" -trim -repage 0x0+20+60 \
             \( +clone -background firebrick3 -shadow 80x3+3+3 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +size -font Helvetica \
         -pointsize 25 -strokewidth 1 -fill $colalarm1 label:"Alarmanlage $scharf" -trim -repage 0x0+20+120 \
             \( +clone -background $colalarm2 -shadow 80x1+1+1 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
-append -background gold2 -gravity center -extent 320x240 \
 b_alarm.png
 #
 #-- just information during daytime 
 else
 #
 convert -size 320x240 canvas:none -stroke snow4 -size 1x90 -tile gradient:white-snow4 \
      \( +clone -background snow4 -shadow 80x3+3+3 \) \
 +swap -background none -layers merge \
     \( +size -font Helvetica \
         -pointsize 25 -strokewidth 1 -fill black label:"$warn" -trim -repage 0x0+20+60 \
             \( +clone -background darkslategray -shadow 80x1+1+1 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +size -font Helvetica \
         -pointsize 25 -strokewidth 1 -fill $colalarm1 label:"Alarmanlage $scharf" -trim -repage 0x0+20+120 \
             \( +clone -background $colalarm2 -shadow 80x1+1+1 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
 -append -background white -gravity center -extent 320x240 \
 b_alarm.png
 fi  
fi
#
########################################## Alarm ##########################################
#
 if [ "$alarm" != "no_alarm" ]; then
 convert -size 320x240 canvas:none -stroke firebrick3 -size 1x90 -tile gradient:red-firebrick3 \
      \( +clone -background firebrick3 -shadow 80x3+3+3 \) \
 +swap -background none -layers merge \
-pointsize 35 -strokewidth 1 -fill white label:"$alarm" -trim -repage 0x0+20+60 \
             \( +clone -background snow4 -shadow 80x3+3+3 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
      \( +size -font Helvetica \
         -pointsize 25 -strokewidth 1 -fill $colalarm1 label:"Alarmanlage $scharf" -trim -repage 0x0+20+120 \
             \( +clone -background $colalarm2 -shadow 80x1+1+1 \) \
         +swap -background none -layers merge \) \
 -insert 1 -layers merge \
 -append -background red -gravity center -extent 320x240 \
 b_alarm.png 
 fi
#
# correct the size
convert b_alarm.png -resize 200x150 alarm.png