CCU Trend Diagramme (PNG) automatisch auf FTP Server sichern

Das Langzeitarchiv für HomeMatic

Moderator: Co-Administratoren

jaysee
Beiträge: 4
Registriert: 21.02.2013, 11:01

Re: CCU Trend Diagramme (PNG) automatisch auf FTP Server sic

Beitrag von jaysee » 03.04.2014, 20:15

ich versuche schon einige Zeit das den Code con https://leinich.net/pages/391 auf meinem Raspberry zum laufen zu bekommen.
Beim manuellem Start der Cache Datei kommt immer eine Fehlermeldung local:not in a function.
Es wird keine Datei angelegt.
Kann jemand einen Tipp geben woran das liegen könnte ?

leinich
Beiträge: 157
Registriert: 03.09.2012, 22:30

Re: CCU Trend Diagramme (PNG) automatisch auf FTP Server sic

Beitrag von leinich » 04.04.2014, 17:25

jaysee hat geschrieben: Beim manuellem Start der Cache Datei kommt immer eine Fehlermeldung local:not in a function.
Kann es sein dass du ein Debian Linux verwendest?

dash sollte local eigentlich können.
Folgende 2 Optionen fallen mir so spontan ein;

Option 1:
alle local einfach aus der sh Datei löschen
Option 2:
Die Zeilen entsprechend anpassen..
local variable=...
Wird zu
local variable; variable=...

Bin grad unterwegs und habe keinen Linux PC zum testen.

jaysee
Beiträge: 4
Registriert: 21.02.2013, 11:01

Re: CCU Trend Diagramme (PNG) automatisch auf FTP Server sic

Beitrag von jaysee » 04.04.2014, 17:35

Vielen Dank für die HInweise! Ich bin zur Zeit noch am arbeiten und werde wohl erst heute Nacht dazu kommen das zu testen.

saxbav
Beiträge: 112
Registriert: 01.08.2012, 15:17

Re: CCU Trend Diagramme (PNG) automatisch auf FTP Server sic

Beitrag von saxbav » 04.04.2014, 20:46

Code: Alles auswählen

#!/bin/sh
performcache(){
local url=$2
local name=$1
local now="$(date --rfc-3339=ns)"
echo $now - $name Starting
local start_time=`date +%s`
sudo wget -q -O "/opt/ccu-historian/webapp/cache/temp.png" "$url"

jetzt=$(date '+%Y%m%d%H%M%S')
echo $jetzt
sudo cp /opt/ccu-historian/webapp/cache/temp.png /var/www/ccu.grafiken/${name}.${jetzt}.png
sudo mv /opt/ccu-historian/webapp/cache/temp.png /var/www/ccu.grafiken/${name}.png

local end_time=`date +%s` now="$(date --rfc-3339=ns)"
echo $now - $name End with `expr $end_time - $start_time` sec
echo "\"${now}\";\"${name}\";\"`expr $end_time - $start_time`\"" >> /var/www/ccu.grafiken/protokol.csv
}
echo Start caching CCU-historian images
performcache temp_all_last_day "http://.../query/trend.gy?i=16&i=22&i=28&i=73&i=34&i=24&i=84&w=1600&h=700"
performcache feuc_all_last_day "http://.../query/trend.gy?i=17&i=23&i=29&i=74&i=35&i=25&i=85&w=1600&h=700"
performcache temp_wohnzimmer_last_day "http://.../query/trend.gy?i=81&i=25&i=24&i=48&w=1600&h=700"
performcache temp_kueche_last_day "http://.../query/trend.gy?i=32&i=29&i=28&i=47&w=1600&h=700"
performcache temp_bad_last_day "http://.../query/trend.gy?i=18&i=17&i=16&i=50&w=1600&h=700"
performcache temp_schlafzimmer_last_day "http://.../query/trend.gy?i=8&i=35&i=34&i=49&w=1600&h=700"

 exit 
Hallo vielleicht kannst damit was Anfangen.
So läuft es bei mir auf Raspberry mit (Raspbian Debian Wheezy)

grüße saxbav
Homematic System Stand[03.12.2019]
RaspberryMatic PI 3 , ioBroker PI 3 , ca 40 HM Geräte
2x Wemos d1 mini , 2 x Raspberry Octoprint , Shelly ...
-------------------------------
1x HM-CCU-1 schwarz ... in Rente

flyword
Beiträge: 54
Registriert: 16.02.2016, 13:25

Re: CCU Trend Diagramme (PNG) automatisch auf FTP Server sic

Beitrag von flyword » 29.02.2016, 16:28

Hallo,

kann mir jemand helfen dies auch auf einem Synology NAS und mit CCU Historian zum laufen zu bringen?

Freundlich Grüsst
flyword

flyword
Beiträge: 54
Registriert: 16.02.2016, 13:25

Re: CCU Trend Diagramme (PNG) automatisch auf FTP Server sic

Beitrag von flyword » 01.02.2018, 15:23

Hier meine Code

Code: Alles auswählen

#!/bin/sh
performcache(){
local url=$2
local name=$1
local now="$(date --rfc-3339=ns)"
echo $now - $name Starting
local start_time=`date +%s`
sudo wget -q -O "/opt/ccu-historian/webapp/cache/temp.png" "$url"
sudo mv /opt/ccu-historian/webapp/cache/temp.png /opt/ccu-historian/webapp/cache/${name}.png
sudo curl -T /opt/ccu-historian/webapp/cache/${name}.png ftp://ftp.DOMAIN.lu --user historian@DOMAIN.lu:PASSWORT
local end_time=`date +%s` now=$(date --rfc-3339=ns)

echo $now - $name End with `expr $end_time - $start_time` sec
echo "\"${now}\";\"${name}\";\"`expr $end_time - $start_time`\"" >> /opt/ccu-historian/webapp/cache/protokol.csv
}
echo Start caching CCU-historian images
performcache wetterstation_temp_day "http://localhost/query/trend.gy?i=20&d=1D"
performcache wetterstation_temp_week "http://localhost/query/trend.gy?i=20&d=1W"
performcache wetterstation_wind_day "http://localhost/query/trend.gy?i=24&d=1D"
performcache wetterstation_wind_week "http://localhost/query/trend.gy?i=24&d=1W"
performcache wetterstation_rain_day "http://localhost/query/trend.gy?i=22&d=1D"
performcache wetterstation_rain_week "http://localhost/query/trend.gy?i=22&d=1W" exit
Leider wird bei mir das Protokoll nicht gespeichert und nur die erste Zeile wird erfolgreich gespeichert,

Code: Alles auswählen

performcache wetterstation_temp_day "http://localhost/query/trend.gy?i=20&d=1D"
performcache wetterstation_temp_week "http://localhost/query/trend.gy?i=20&d=1W"
performcache wetterstation_wind_day "http://localhost/query/trend.gy?i=24&d=1D"
performcache wetterstation_wind_week "http://localhost/query/trend.gy?i=24&d=1W"
performcache wetterstation_rain_day "http://localhost/query/trend.gy?i=22&d=1D"
performcache wetterstation_rain_week "http://localhost/query/trend.gy?i=22&d=1W" exit
der Rest bzw. die weiteren Zeilen

Code: Alles auswählen

performcache wetterstation_temp_week "http://localhost/query/trend.gy?i=20&d=1W"
performcache wetterstation_wind_day "http://localhost/query/trend.gy?i=24&d=1D"
performcache wetterstation_wind_week "http://localhost/query/trend.gy?i=24&d=1W"
performcache wetterstation_rain_day "http://localhost/query/trend.gy?i=22&d=1D"
performcache wetterstation_rain_week "http://localhost/query/trend.gy?i=22&d=1W" exit
wird nicht gespeichert.

Bild

Manuelles ausführen:

Code: Alles auswählen

pi@raspberrypi:/opt/ccu-historian $ sudo sh /opt/ccu-historian/ccu-cache
Start caching CCU-historian images
2018-02-01 18:30:36.938336201+01:00 - wetterstation_temp_day Starting
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 16540    0     0  100 16540      0  73633 --:--:-- --:--:-- --:--:-- 73839
/opt/ccu-historian/ccu-cache: 11: local: 18:30:38.698712537+01:00: bad variable name
FEHLER:

Code: Alles auswählen

/opt/ccu-historian/ccu-cache: 11: local: 18:30:38.698712537+01:00: bad variable name
Jemand eine Idee?
Zuletzt geändert von flyword am 02.02.2018, 07:41, insgesamt 1-mal geändert.

flyword
Beiträge: 54
Registriert: 16.02.2016, 13:25

Re: CCU Trend Diagramme (PNG) automatisch auf FTP Server sic

Beitrag von flyword » 01.02.2018, 19:03

Ich habe den Fehler gefunden.

Bei der Zeile 11 fehlten " "
Von

Code: Alles auswählen

local end_time=`date +%s` now=$(date --rfc-3339=ns)
zu

Code: Alles auswählen

local end_time=`date +%s` now="$(date --rfc-3339=ns)"
ändern.

Code: Alles auswählen

#!/bin/sh
performcache(){
local url=$2
local name=$1
local now="$(date --rfc-3339=ns)"
echo $now - $name Starting
local start_time=`date +%s`
sudo wget -q -O "/opt/ccu-historian/webapp/cache/temp.png" "$url"
sudo mv /opt/ccu-historian/webapp/cache/temp.png /opt/ccu-historian/webapp/cache/${name}.png
sudo curl -T /opt/ccu-historian/webapp/cache/${name}.png ftp://ftp.DOMAIN.lu --user historian@DOMAIN.lu:PASSWORT
local end_time=`date +%s` now="$(date --rfc-3339=ns)"

echo $now - $name End with `expr $end_time - $start_time` sec
echo "\"${now}\";\"${name}\";\"`expr $end_time - $start_time`\"" >> /opt/ccu-historian/webapp/cache/protokol.csv
}
echo Start caching CCU-historian images
performcache wetterstation_temp_day "http://localhost/query/trend.gy?i=20&d=1D"
performcache wetterstation_temp_week "http://localhost/query/trend.gy?i=20&d=1W"
performcache wetterstation_wind_day "http://localhost/query/trend.gy?i=24&d=1D"
performcache wetterstation_wind_week "http://localhost/query/trend.gy?i=24&d=1W"
performcache wetterstation_rain_day "http://localhost/query/trend.gy?i=22&d=1D"
performcache wetterstation_rain_week "http://localhost/query/trend.gy?i=22&d=1W" exit

Blubbel
Beiträge: 80
Registriert: 16.01.2016, 17:38
System: CCU
Hat sich bedankt: 3 Mal

Re: CCU Trend Diagramme (PNG) automatisch auf FTP Server sic

Beitrag von Blubbel » 12.02.2018, 18:30

Coole Sache, DANKE :)

Ich reiche die Werte vom Pi an die CCU2 per XML weiter. CCU Historian habe ich sowieso im Einsatz, deshalb nun danke für den Tipp, wie ich das auf die Homepage bekomme!
Es sieht bei mir so aus.

http://webcam.traumgold.at/feinstaubwerte.html

LG, Andi :)

Antworten

Zurück zu „CCU-Historian“