From 4e90f31610b42e1582d716254772bd06499b9513 Mon Sep 17 00:00:00 2001 From: DS_Starter Date: Mon, 19 Nov 2018 21:44:43 +0000 Subject: [PATCH] 60_Watches.pm: contrib version 0.3.0 git-svn-id: https://svn.fhem.de/fhem/trunk@17790 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/60_Watches.pm | 1744 +++++++++++++++++++++++++ 1 file changed, 1744 insertions(+) create mode 100644 fhem/contrib/DS_Starter/60_Watches.pm diff --git a/fhem/contrib/DS_Starter/60_Watches.pm b/fhem/contrib/DS_Starter/60_Watches.pm new file mode 100644 index 000000000..0c23113a5 --- /dev/null +++ b/fhem/contrib/DS_Starter/60_Watches.pm @@ -0,0 +1,1744 @@ +######################################################################################################################## +# $Id: $ +######################################################################################################################### +# 60_Watches.pm +# +# (c) 2018 by Heiko Maaz +# e-mail: Heiko dot Maaz at t-online dot de +# +# This script is part of fhem. +# +# Fhem is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# Fhem is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with fhem. If not, see . +# +# The script is based on sources from following sites: +# # modern clock: https://www.w3schools.com/graphics/canvas_clock_start.asp +# # station clock: http://www.3quarks.com/de/Bahnhofsuhr/ +# # digital clock: http://www.3quarks.com/de/Segmentanzeige/index.html +# +######################################################################################################################### + +package main; + +use strict; +use warnings; + +# Versions History intern +our %Watches_vNotesIntern = ( + "0.3.0" => "19.11.2018 digital clock added ", + "0.2.0" => "14.11.2018 station clock added ", + "0.1.0" => "13.11.2018 initial Version with modern analog clock" +); + +sub Watches_modern($); + +################################################################ +sub Watches_Initialize($) { + my ($hash) = @_; + + $hash->{DefFn} = "Watches_Define"; + $hash->{AttrList} = "digitalColorBackground:colorpicker ". + "digitalColorDigits:colorpicker ". + "modernColorBackground:colorpicker ". + "modernColorHand:colorpicker ". + "modernColorFigure:colorpicker ". + "modernColorFace:colorpicker ". + "modernColorRing:colorpicker ". + "modernColorRingEdge:colorpicker ". + "stationSecondHand:Bar,HoleShaped,NewHoleShaped,No ". + "stationSecondHandBehavoir:Bouncing,Overhasty,Creeping,ElasticBouncing ". + "stationMinuteHandBehavoir:Bouncing,Creeping,ElasticBouncing ". + "stationBoss:Red,Black,Vienna,No ". + "stationMinuteHand:Bar,Pointed,Swiss,Vienna ". + "stationHourHand:Bar,Pointed,Swiss,Vienna ". + "stationStrokeDial:GermanHour,German,Austria,Swiss,Vienna,No ". + "stationBody:Round,SmallWhite,RoundGreen,Square,Vienna,No ". + "disable:1,0 ". + "htmlattr ". + "hideDisplayName:1,0 " + ; + $hash->{FW_summaryFn} = "Watches_FwFn"; + $hash->{FW_detailFn} = "Watches_FwFn"; + $hash->{AttrFn} = "Watches_Attr"; + $hash->{FW_hideDisplayName} = 1; # Forum 88667 + # $hash->{FW_addDetailToSummary} = 1; + # $hash->{FW_atPageEnd} = 1; # wenn 1 -> kein Longpoll ohne informid in HTML-Tag +} + + +################################################################ +sub Watches_Define($$) { + my ($hash, $def) = @_; + my $name = $hash->{NAME}; + + my @a = split("[ \t][ \t]*", $def); + + if(!$a[2]) { + return "You need to specify more parameters.\n". "Format: define Watches [Modern | Station | Digital]"; + } + + $hash->{MODEL} = $a[2]; + $hash->{VERSION} = $hash->{VERSION} = (reverse sort(keys %Watches_vNotesIntern))[0]; + + readingsSingleUpdate($hash,"state", "initialized", 1); # Init für "state" + +return undef; +} + +################################################################ +sub Watches_Attr($$$$) { + my ($cmd,$name,$aName,$aVal) = @_; + my $hash = $defs{$name}; + my ($do,$val); + + # $cmd can be "del" or "set" + # $name is device name + # aName and aVal are Attribute name and value + + if ($cmd eq "set" && $hash->{MODEL} !~ /modern/i && $aName =~ /^modern.*/) { + return "\"$aName\" is only valid for Watches model \"Modern\""; + } + + if ($cmd eq "set" && $hash->{MODEL} !~ /station/i && $aName =~ /^station.*/) { + return "\"$aName\" is only valid for Watches model \"Station\""; + } + + if ($cmd eq "set" && $hash->{MODEL} !~ /digital/i && $aName =~ /^digital.*/) { + return "\"$aName\" is only valid for Watches model \"Digital\""; + } + + if ($aName eq "disable") { + if($cmd eq "set") { + $do = ($aVal) ? 1 : 0; + } + $do = 0 if($cmd eq "del"); + $val = ($do == 1 ? "disabled" : "initialized"); + + readingsSingleUpdate($hash, "state", $val, 1); + } + +return undef; +} + +################################################################ +sub Watches_FwFn($$$$) { + my ($FW_wname, $d, $room, $pageHash) = @_; # pageHash is set for summaryFn. + my $hash = $defs{$d}; + + my $alias = AttrVal($d, "alias", $d); # Linktext als Aliasname oder Devicename setzen + my $dlink = "$alias"; + + my $ret = ""; + $ret .= "$dlink
" if(!AttrVal($d,"hideDisplayName",0)); + if(IsDisabled($d)) { + if(AttrVal($d,"hideDisplayName",0)) { + $ret .= "Watch $d is disabled"; + } else { + $ret .= "Watch is disabled"; + } + } else { + $ret .= Watches_modern($d) if($hash->{MODEL} =~ /modern/i); + $ret .= Watches_station($d) if($hash->{MODEL} =~ /station/i); + $ret .= Watches_digital($d) if($hash->{MODEL} =~ /digital/i); + } + +return $ret; +} + +################################################################ +sub Watches_digital($) { + my ($d) = @_; + my $hash = $defs{$d}; + my $hattr = AttrVal($d,"htmlattr","width='150' height='50'"); + my $bgc = AttrVal($d,"digitalColorBackground","C4C4C4"); + my $dcd = AttrVal($d,"digitalColorDigits","000000"); + + # Segmentanzeige aus: http://www.3quarks.com/de/Segmentanzeige/index.html + + return " + + + + + + + + + "; +} + +################################################################ +sub Watches_station($) { + my ($d) = @_; + my $hash = $defs{$d}; + my $ssh = AttrVal($d,"stationSecondHand","Bar")."SecondHand"; + my $shb = AttrVal($d,"stationSecondHandBehavoir","Bouncing")."SecondHand"; + my $smh = AttrVal($d,"stationMinuteHand","Pointed")."MinuteHand"; + my $mhb = AttrVal($d,"stationMinuteHandBehavoir","Bouncing")."MinuteHand"; + my $shh = AttrVal($d,"stationHourHand","Pointed")."HourHand"; + my $sb = AttrVal($d,"stationBoss","Red")."Boss"; + my $ssd = AttrVal($d,"stationStrokeDial","Swiss")."StrokeDial"; + my $sbody = AttrVal($d,"stationBody","Round")."Body"; + my $hattr = AttrVal($d,"htmlattr","width='150' height='150'"); + + # Bahnhofsuhr aus http://www.3quarks.com/de/Bahnhofsuhr/ + return " + + + + + + + + + + "; +} + +################################################################ +sub Watches_modern($) { + my ($d) = @_; + my $hash = $defs{$d}; + my $facec = AttrVal($d,"modernColorFace","FFFEFA"); + my $bgc = AttrVal($d,"modernColorBackground","333"); + my $fc = AttrVal($d,"modernColorFigure","333"); + my $hc = AttrVal($d,"modernColorHand","333"); + my $fr = AttrVal($d,"modernColorRing","FFFFFF"); + my $fre = AttrVal($d,"modernColorRingEdge","333"); + my $hattr = AttrVal($d,"htmlattr","width='150' height='150'"); + + # moderne Uhr aus https://www.w3schools.com/graphics/canvas_clock_start.asp + return " + + + + + + + + + + + "; +} + +1; + +=pod +=item helper +=item summary create a watch in modern, station or digital style +=item summary_DE erstellt eine Uhr: Modern, Bahnhofsuhr oder Digital + + +=begin html + + +

Watches

+ +
+Das Modul Watches stellt eine Modern-, Bahnhofs- oder Digitaluhr als Device zur Verfügung.
+Die Uhren basieren auf Skripten dieser Seiten:
+moderne Uhr, +Bahnhofsuhr, +Digitaluhr +
+
+ +
    + + Define + +
      + define <name> Watches [Modern | Station | Digital] +

      + + + + + + +
      Modern : erstellt eine analoge Uhr im modernen Design
      Station : erstellt eine Bahnhofsuhr
      Digital : erstellt eine Digitaluhr
      +
      +
      +
    + + + Set
      N/A

    + + + Get
      N/A

    + + + Attribute +

    + +
      +
        + + +
      • disable
        + Aktiviert/deaktiviert das Device. +
      • +
        + + +
      • hideDisplayName
        + Verbirgt den Device/Alias-Namen (Link zur Detailansicht). +
      • +
        + + +
      • htmlattr
        + Zusätzliche HTML Tags zur Größenänderung de Uhr.

        +
          + Beispiel:
          + attr <name> htmlattr width="125" height="125"
          +
        +
      • +
        +
      + + Die nachfolgenden Attribute sind spezifisch für einen Uhrentyp zu setzen.
      +
      + + Model: Modern

      + +
        + +
      • modernColorBackground
        + Hintergrundfarbe der Uhr. +
      • +
        + + +
      • modernColorFace
        + Einfärbung des Ziffernblattes. +
      • +
        + + +
      • modernColorFigure
        + Farbe der Ziffern im Ziffernblatt und der Zeigerachsabdeckung. +
      • +
        + + +
      • modernColorHand
        + Farbe der UhrenZeiger. +
      • +
        + + +
      • modernColorRing
        + Farbe des Ziffernblattrahmens. +
      • +
        + + +
      • modernColorRingEdge
        + Farbe des Außenringes vom Ziffernblattrahmen. +
      • +
        +
      +
      + + Model: Station

      + +
        + +
      • stationBody
        + Art des Uhrengehäuses. +
      • +
        + + +
      • stationBoss
        + Art und Farbe der Zeigerachsabdeckung. +
      • +
        + + +
      • stationHourHand
        + Art des Stundenzeigers. +
      • +
        + + +
      • stationMinuteHand
        + Art des Minutenzeigers. +
      • +
        + + +
      • stationMinuteHandBehavoir
        + Verhalten des Minutenzeigers. +
      • +
        + + +
      • stationSecondHand
        + Art des Sekundenzeigers. +
      • +
        + + +
      • stationSecondHandBehavoir
        + Verhalten des Sekundenzeigers. +
      • +
        + + +
      • stationStrokeDial
        + Auswahl des Ziffernblattes. +
      • +
        + +
      +
      + + Model: Digital

      + +
        + +
      • digitalColorBackground
        + Digitaluhr Hintergrundfarbe. +
      • +
        + + +
      • digitalColorDigits
        + Farbe der Balkenanzeige in einer Digitaluhr. +
      • +
        + +
      + +
    + +
+ +=end html +=begin html_DE + + +

Watches

+ +
+Das Modul Watches stellt eine Modern-, Bahnhofs- oder Digitaluhr als Device zur Verfügung.
+Die Uhren basieren auf Skripten dieser Seiten:
+moderne Uhr, +Bahnhofsuhr, +Digitaluhr +
+
+ +
    + + Define + +
      + define <name> Watches [Modern | Station | Digital] +

      + + + + + + +
      Modern : erstellt eine analoge Uhr im modernen Design
      Station : erstellt eine Bahnhofsuhr
      Digital : erstellt eine Digitaluhr
      +
      +
      +
    + + + Set
      N/A

    + + + Get
      N/A

    + + + Attribute +

    + +
      +
        + + +
      • disable
        + Aktiviert/deaktiviert das Device. +
      • +
        + + +
      • hideDisplayName
        + Verbirgt den Device/Alias-Namen (Link zur Detailansicht). +
      • +
        + + +
      • htmlattr
        + Zusätzliche HTML Tags zur Größenänderung de Uhr.

        +
          + Beispiel:
          + attr <name> htmlattr width="125" height="125"
          +
        +
      • +
        +
      + + Die nachfolgenden Attribute sind spezifisch für einen Uhrentyp zu setzen.
      +
      + + Model: Modern

      + +
        + +
      • modernColorBackground
        + Hintergrundfarbe der Uhr. +
      • +
        + + +
      • modernColorFace
        + Einfärbung des Ziffernblattes. +
      • +
        + + +
      • modernColorFigure
        + Farbe der Ziffern im Ziffernblatt und der Zeigerachsabdeckung. +
      • +
        + + +
      • modernColorHand
        + Farbe der UhrenZeiger. +
      • +
        + + +
      • modernColorRing
        + Farbe des Ziffernblattrahmens. +
      • +
        + + +
      • modernColorRingEdge
        + Farbe des Außenringes vom Ziffernblattrahmen. +
      • +
        +
      +
      + + Model: Station

      + +
        + +
      • stationBody
        + Art des Uhrengehäuses. +
      • +
        + + +
      • stationBoss
        + Art und Farbe der Zeigerachsabdeckung. +
      • +
        + + +
      • stationHourHand
        + Art des Stundenzeigers. +
      • +
        + + +
      • stationMinuteHand
        + Art des Minutenzeigers. +
      • +
        + + +
      • stationMinuteHandBehavoir
        + Verhalten des Minutenzeigers. +
      • +
        + + +
      • stationSecondHand
        + Art des Sekundenzeigers. +
      • +
        + + +
      • stationSecondHandBehavoir
        + Verhalten des Sekundenzeigers. +
      • +
        + + +
      • stationStrokeDial
        + Auswahl des Ziffernblattes. +
      • +
        + +
      +
      + + Model: Digital

      + +
        + +
      • digitalColorBackground
        + Digitaluhr Hintergrundfarbe. +
      • +
        + + +
      • digitalColorDigits
        + Farbe der Balkenanzeige in einer Digitaluhr. +
      • +
        + +
      + +
    + +
+ +=end html_DE +=cut