diff --git a/fhem/contrib/YAF/CHANGED b/fhem/contrib/YAF/CHANGED index f6f0fb78e..7252944dd 100644 --- a/fhem/contrib/YAF/CHANGED +++ b/fhem/contrib/YAF/CHANGED @@ -1,3 +1,4 @@ +- added webcam widget (marcproe) - path to background image is now configurable via the YAF interface (marcproe) - Added regex capability for generic widget onclick function (marcproe) - Added foundation for modify dialog and modify dialog for generic widget (marcproe) diff --git a/fhem/contrib/YAF/FHEM/YAF/widgets/webcam/webcam.pm b/fhem/contrib/YAF/FHEM/YAF/widgets/webcam/webcam.pm new file mode 100644 index 000000000..9ef9014ec --- /dev/null +++ b/fhem/contrib/YAF/FHEM/YAF/widgets/webcam/webcam.pm @@ -0,0 +1,197 @@ +######################################################################################## +# +# webcam.pm +# +# YAF - Yet Another Floorplan +# FHEM Projektgruppe Hochschule Karlsruhe, 2013 +# Markus Mangei, Daniel Weisensee, Prof. Dr. Peter A. Henning +# +# webcam Widget: Marc Pro +# +######################################################################################## +# +# This program 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 3 of the License, or +# (at your option) any later version. +# +# This program 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 this program. If not, see . +# +######################################################################################## +package main; + +use strict; +use warnings; + +my $yaf_version = 0.41; + +use vars qw(%_GET); +use vars qw(%defs); + +####################################################################################### +# +# webcam_get_widgetcss - Create the CSS code for this widget +# +# no parameter +# +######################################################################################## +sub webcam_get_widgetcss() { + my $output = " + .widget_webcam { + width: 100px; + height: 100px; + background-repeat:no-repeat; + background-position:center center; + opacity:1 !important; + } + "; + return $output; +} + +######################################################################################## +# +# webcam_get_widgetjs - Create the javascript code for this widget +# +# no parameter +# +######################################################################################## + +sub webcam_get_widgetjs() { + my $output = ' + function webcam_endsWith(str, suffix) { + return str.indexOf(suffix, str.length - suffix.length) !== -1; + } + function webcam_on_click(view_id, widget_id) { + } + function webcam_update_widget(view_id, widget_id) { + $.ajax({ + type: "GET", + async: true, + url: "../../ajax/widget/webcam/get_state", + data: "view_id="+view_id+"&widget_id="+widget_id, + context: document.body, + success: function(get_state) { + var widget = $("#widget_"+view_id+"_"+widget_id); + widget.html(get_state); + } + }); + } + '; + return $output; +} + +######################################################################################## +# +# webcamt_getwidgethtml - HTML code for this widget +# +# no parameter +# +######################################################################################## + +sub webcam_get_widgethtml() { + my $output = " "; + return $output; +} + +######################################################################################## +# +# webcamt_get_addwidget_setup_html - Create the selection of devices for this widget +# +# no parameter +# +######################################################################################## + +sub webcam_get_addwidget_setup_html() { + my $output = " + "; + + return $output; +} + +######################################################################################## +# +# webcamt_get_addwidget_prepare_attributes - +# +# +# no parameter +# +######################################################################################## + +sub webcam_get_addwidget_prepare_attributes() { + my $output = ' + var temp_array = new Array(); + temp_array[0] = "fhemname"; + temp_array[1] = $("#combobox option:selected").val() + attributes_array[0] = temp_array; + '; + return $output; +} + +######################################################################################## +# +# webcamt_getwidget_html - HTML code for this widget. DO WE NEED THIS ? SEE ABOVE +# DO WE NEED IT? WHO KNOWS. (It looks like this one fills the initial html of the +# widget, so let's keep it for science.) +# +# no parameter +# +######################################################################################## + +sub webcam_getwidget_html() { + my $output = " "; + return $output; +} + +######################################################################################## +# +# webcamt_get_lamp_status - return the state of the lamp +# +# no parameter +# +######################################################################################## + +sub webcam_get_state() { + my $fhemname = YAF_getWidgetAttribute($_GET{"view_id"}, $_GET{"widget_id"}, "fhemname"); #get name of device + + my $showm = YAF_getWidgetAttribute($_GET{"view_id"}, $_GET{"widget_id"}, "showmethod", "img"); + my $spath = YAF_getWidgetAttribute($_GET{"view_id"}, $_GET{"widget_id"}, "path"); + my $hover = YAF_getWidgetAttribute($_GET{"view_id"}, $_GET{"widget_id"}, "hover", "0"); + my $proto = YAF_getWidgetAttribute($_GET{"view_id"}, $_GET{"widget_id"}, "protocol", "http"); + my $width = YAF_getWidgetAttribute($_GET{"view_id"}, $_GET{"widget_id"}, "width", "100"); + + my $address = YAF_getWidgetAttribute($_GET{"view_id"}, $_GET{"widget_id"}, "address", $defs{$fhemname}{ADDRESS}); + + my $d = $defs{$fhemname}; #get device + my $name = AttrVal($fhemname,"alias",undef); #get alias + if(!defined $name) { #if alias is defined, use it as name + $name = $fhemname; + } + if(defined $d) { + if(lc $showm eq "img") { + my $ret = ""; + return $ret; + } + } else { + return "Widget not found. Maybe reload this page?"; + } +} +1; \ No newline at end of file diff --git a/fhem/contrib/YAF/FHEM/YAF/widgets/webcam/www/.gitkeep b/fhem/contrib/YAF/FHEM/YAF/widgets/webcam/www/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/fhem/contrib/YAF/controls_yaf.txt b/fhem/contrib/YAF/controls_yaf.txt index 6757b5db7..721713a79 100644 --- a/fhem/contrib/YAF/controls_yaf.txt +++ b/fhem/contrib/YAF/controls_yaf.txt @@ -10,6 +10,8 @@ DIR FHEM/YAF/widgets/fhttk DIR FHEM/YAF/widgets/fhttk/www DIR FHEM/YAF/widgets/generic DIR FHEM/YAF/widgets/generic/www +DIR FHEM/YAF/widgets/webcam +DIR FHEM/YAF/widgets/webcam/www DIR FHEM/YAF/www DIR FHEM/YAF/www/css DIR FHEM/YAF/www/smoothness @@ -22,6 +24,7 @@ UPD 2013-05-15_20:00:00 6590 FHEM/YAF/widgets/fs20st/fs20st.pm UPD 2013-08-14_21:30:00 7471 FHEM/YAF/widgets/fht80/fht80.pm UPD 2013-07-31_15:30:00 6534 FHEM/YAF/widgets/fhttk/fhttk.pm UPD 2013-09-10_22:20:00 11387 FHEM/YAF/widgets/generic/generic.pm +UPD 2013-09-15_21:37:00 6172 FHEM/YAF/widgets/webcam/webcam.pm UPD 2013-05-15_20:00:00 6617 FHEM/YAF/widgets/fs20easylamp/fs20easylamp.pm UPD 2013-05-15_20:00:00 2608 FHEM/YAF/www/img/loading.gif UPD 2013-05-15_20:00:00 766 FHEM/YAF/www/img/lamp_off.png