fhem.de automatisch auf updates prüfen

Begonnen von housekeeper, 27 Mai 2013, 17:50:50

Vorheriges Thema - Nächstes Thema

housekeeper

Manchmal wäre der Eine oder Andere sicher froh, FHEM würde einfach melden, wenn es updates bereitstellt. Schon allein um der allfälligen Frage "haste schon update gemacht" mit einem fröhlichen "Ja,klar" begegnen zu können.

Dazu habe ich mal was ganz einfaches mit den Bordmitteln der Fritz!Box für mich eingerichtet:

define UpdatesAvailable dummy

define CheckUpdatesAvailable at +*12:00:00 { my $a = `wget -qO - http://fhem.de/fhemupdate4/svn/controls_fhem.txt | cat - FHEM/controls_fhem.txt | sort | uniq -u | cut -d " " -f 4 | uniq`."-"; fhem "set UpdateAvailable $a"; }


Bitte eventuell vom System erzeugte Zeilenumbrüche beachten. Das ."-" am Ende dient nur der Unterdrückung von Fehlernachrichten bei Übergabe einer leeren Zeichenkette.

Puschel74

Hallo,

das hatte ich bei mir mal so gelöst:

define update at *21:15:00 {\
if ($wday == 6) {\
fhem ("update;; sleep 20;; shutdown restart");;\
}\
}


Grüße

Edith: War früher noch mit dem updatefhem-Befehl. Da haben 20 Sekunden noch gereicht. Nun, mit dem Backup, reicht das evtl. nicht mehr. Man müsste also die Zeit verlängern.
Zotac BI323 als Server mit DBLog
CUNO für FHT80B, 3 HM-Lan per vCCU, RasPi mit CUL433 für Somfy-Rollo (F2F), RasPi mit I2C(LM75) (F2F), RasPi für Panstamp+Vegetronix +SONOS(F2F)
Ich beantworte keine Supportanfragen per PM! Bitte im Forum suchen oder einen Beitrag erstellen.

justme1968

der erste vorschlag zeit an ob es updates gibt. das finde ich gut.

der zweite macht die updates automatisch. ich für meinen teil würde das nicht gut finden.

gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

fh168

Mir gefällt die erste Version auch besser.
Die zweite Version habe ich bei mir für ein anderes Problem benötigt, vielen Dank dafür.

Die erste Version hat noch einen Deklarierungsfehler, UpdatesAvailable , so läuft es bei mir.

define UpdatesAvailable dummy
define CheckUpdatesAvailable at +*12:00:00 {\
my $a = `wget -qO - http://fhem.de/fhemupdate4/svn/controls_fhem.txt | cat - FHEM/controls_fhem.txt | sort | uniq -u | cut -d " " -f 4 | uniq`."-";;\
fhem ("set UpdatesAvailable $a");;\
}

Hue, Lacrosse, PCA301, MySensors, V 1.67 CUL 868 V3.4, Lacrosse-WLAN-Gateway, Tasmota RF-

justme1968

eine kleine ergänzung für alle systeme bei die fhem directory struktur etwas anders ist und fhem.pl nicht im gleichen verzeichnis liegt wie FHEM. z.b. alle synology diskstaions mit martin fischers fhem packet.

+*12:00:00 {
  my $c = "$attr{global}{modpath}/FHEM/controls_fhem.txt";
  my $a = `wget -qO - http://fhem.de/fhemupdate4/svn/controls_fhem.txt | cat - $c | sort | uniq -u | cut -d " " -f 4 | uniq`."-";
  fhem ("set UpdatesAvailable $a");
}


gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

housekeeper

Beim Stöbern in der Befehls-Referenz kam mir die Idee die Abfrage auch / oder manuell abrufbar zu gestalten:

define UpdateAvailable dummy
attr UpdateAvailable setList check
attr UpdateAvailable webCmd check


Dann ein notify erstellen, das das Ereignis "check" verwendet um verfügbare Updates anzuzeigen:

define SetUpdateAvailable notify UpdateAvailable:check { my $a = `wget -qO - http://fhem.de/fhemupdate4/svn/controls_fhem.txt | cat - FHEM/controls_fhem.txt | sort | uniq -u | cut -d "/" -f 2 | sort | uniq | tr "\n" " "`; if ( $a == "" ) { fhem "set UpdateAvailable none"; } else {  fhem "set UpdateAvailable $a"; } }

Da ich den Perl code in der Geräte-Definition eingegeben habe, ist nur ein Semikolon angegeben, in der fhem.cfg werden dann daraus zwei.

justme1968

man kann auch das at von weiter oben direkt von hand triggern:{ at_Exec( $defs{"CheckUpdatesAvailable"} ) }

gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

housekeeper

Zitat von: justme1968:man kann auch das at von weiter oben direkt von hand triggern
Stimmt, ich finde es allerdings bequemer auf ein Link zu klicken, als ständig Text einzugeben. Dann könnte ich ja auch update check eintippen, das ist noch kürzer.

justme1968

die idee war ja auch eher das at zu lassen und im notify das at aufzurufen.

aber das ist geschmackssache und am ende kommts fast aufs gleiche raus.

und was das anklicken geht... schau dir mal das an: Link

gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

housekeeper

Zitat von: justme1968:... schau dir mal das an: Link
Interessant, Danke für den Hinweis.

housekeeper

Zitat von: justme1968:und was das anklicken geht...

Dazu ist mir auch noch etwas eingefallen

define execute dummy
attr execute devStateIcon .*:noIcon
attr execute group -
attr execute room CUL_HM,CUL_MAX,EnOcean,Plots,Schalter,Verbindungen,Wetter,Unsorted
attr execute setList command:backup,reboot,rereadcfg,save,updatecheck,update
attr execute webCmd command

Damit erstelle ich ein dummy device, das qua "group -" ganz oben steht und das in jedem Raum.

Eine drop down Liste bietet FHEM Befehle zur Auswahl an.

Mit entsprechenden notify devices kann dann die jeweilige Aktion ausgelöst werden, etwa:

define Reboot notify execute:command.reboot shutdown restart
define UpdateCheck notify execute:command.updatecheck update check

und mit

set execute Nachricht
kann das Ergebnis der Aktion eingeblendet werden.

etwa

define UpdateCheck notify execute:command.updatecheck { my $a = fhem "update check"; fhem "set execute $a; attr execute devStateStyle style=\"color:blue;;\";" }

Nur mal so, als Denkanstoß...


Nachtrag:

Als kleines Beispiel hänge ich mal meine derzeitige execute.cfg an. Wer's ausprobieren möchte, kopiert die Datei nach

/var/InternerSpeicher/fhem
( auf der Fritz!Box ) und bindet sie mit

include execute.cfg
in FHEM ein.

Das wird erst dann dauerhaft, wenn es mit Texteditor als Zeile in fhem.cfg eingefügt wird, ansonsten ist es nach einem restart wieder weg.

Auch noch wichtig: Alle Änderungen die Ihr daran durchführt, werden in der execute.cfg abgelegt, Erweiterungen gehen nach fhem.cfg.


heinzfo

#11
Guten Morgen

Ich habe die definition in mein fhem eingebaut.
Es funktioniert auch, aber ich bekomme die Einträge doppelt, was kann das sein?

List

Internals:
   COMMAND    {
  my $c = "$attr{global}{modpath}/FHEM/controls_fhem.txt";
  my $a = `wget -qO - http://fhem.de/fhemupdate4/svn/controls_fhem.txt | cat - $c | sort | uniq -u | cut -d " " -f 4 | uniq`."-";
  fhem ("set HeinzMobil send $a");
}
   DEF        *07:50:00 {
  my $c = "$attr{global}{modpath}/FHEM/controls_fhem.txt";
  my $a = `wget -qO - http://fhem.de/fhemupdate4/svn/controls_fhem.txt | cat - $c | sort | uniq -u | cut -d " " -f 4 | uniq`."-";
  fhem ("set HeinzMobil send $a");
}
   NAME       CheckUpdatesAvailable
   NR         1132
   PERIODIC   yes
   RELATIVE   no
   REP        -1
   STATE      Next: 07:50:00
   TIMESPEC   07:50:00
   TRIGGERTIME 1498110600
   TRIGGERTIME_FMT 2017-06-22 07:50:00
   TYPE       at
   Readings:
     2017-06-22 06:21:36   state           Next: 07:50:00
Attributes:
   alias      fhem update check & wa message
   icon       RPi
   room       IT_Equipment


Das bekomme ich zugesandt
FHEM/21_SONOSPLAYER.pm
FHEM/lib/UPnP/ControlPoint.pm
FHEM/00_SONOS.pm
FHEM/93_DbLog.pm
FHEM/71_YAMAHA_AVR.pm
./CHANGED
FHEM/98_monitoring.pm
docs/commandref.html
docs/commandref_DE.html
FHEM/21_SONOSPLAYER.pm
FHEM/71_YAMAHA_AVR.pm
./CHANGED
FHEM/93_DbLog.pm
FHEM/lib/UPnP/ControlPoint.pm
FHEM/00_SONOS.pm
FHEM/98_monitoring.pm
docs/commandref.html
docs/commandref_DE.html
-


Ist es möglich das in Form eines fhem "update check" auszugeben?
Also so wie in der fhem Oberfläche.

fhem
List of new / modified files since last update:
UPD ./CHANGED
UPD FHEM/00_SONOS.pm
UPD FHEM/21_SONOSPLAYER.pm
UPD FHEM/71_YAMAHA_AVR.pm
UPD FHEM/93_DbLog.pm
UPD FHEM/98_monitoring.pm
UPD FHEM/lib/UPnP/ControlPoint.pm

New entries in the CHANGED file:
  - feature: 93_DbLog: V2.17.1, optional UTF-8 support for MySQL database
             (additional parameter in db.conf neccesary for activation)
  - feature: YAMAHA_AVR: new set commands / readings to control HDMI outputs
             (only for models with two HDMI outputs)

fhemtabletui
nothing to do...


Danke und beste Grüße
Heinz

nils_

hui 4 jahre alter thread  :o
ZitatEs funktioniert auch, aber ich bekomme die Einträge doppelt, was kann das sein?

na es steht ja auch zweimal da:
   COMMAND    {
  my $c = "$attr{global}{modpath}/FHEM/controls_fhem.txt";
  my $a = `wget -qO - http://fhem.de/fhemupdate4/svn/controls_fhem.txt | cat - $c | sort | uniq -u | cut -d " " -f 4 | uniq`."-";
  fhem ("set HeinzMobil send $a");
}
   DEF        *07:50:00 {
  my $c = "$attr{global}{modpath}/FHEM/controls_fhem.txt";
  my $a = `wget -qO - http://fhem.de/fhemupdate4/svn/controls_fhem.txt | cat - $c | sort | uniq -u | cut -d " " -f 4 | uniq`."-";
  fhem ("set HeinzMobil send $a");
}


da ich nicht genau weiß was du erreichen möchtest, würde ich sagen. du legst das at nochmal richtig an.
viele Wege in FHEM es gibt!

CoolTux

Zitat von: nils_ am 22 Juni 2017, 10:02:17
hui 4 jahre alter thread  :o
na es steht ja auch zweimal da:
   COMMAND    {
  my $c = "$attr{global}{modpath}/FHEM/controls_fhem.txt";
  my $a = `wget -qO - http://fhem.de/fhemupdate4/svn/controls_fhem.txt | cat - $c | sort | uniq -u | cut -d " " -f 4 | uniq`."-";
  fhem ("set HeinzMobil send $a");
}
   DEF        *07:50:00 {
  my $c = "$attr{global}{modpath}/FHEM/controls_fhem.txt";
  my $a = `wget -qO - http://fhem.de/fhemupdate4/svn/controls_fhem.txt | cat - $c | sort | uniq -u | cut -d " " -f 4 | uniq`."-";
  fhem ("set HeinzMobil send $a");
}


da ich nicht genau weiß was du erreichen möchtest, würde ich sagen. du legst das at nochmal richtig an.

Nicht ganz. Das eine ist das Internal Commands und das andere ist die DEF. Da die DEF auch das Command enthält steht es zweimal da. Ist bisschen doof kopiert worden.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

heinzfo

Zitat von: CoolTux am 22 Juni 2017, 10:24:42
Nicht ganz. Das eine ist das Internal Commands und das andere ist die DEF. Da die DEF auch das Command enthält steht es zweimal da. Ist bisschen doof kopiert worden.
Sorry aber da ist nix doof kopiert worden!
Es ist das kpl. List, wie es offt im Forum gefordert wird!

Gesendet von meinem SM-G930F mit Tapatalk