diff --git a/fhem/CHANGED b/fhem/CHANGED index 83c5f09b8..e06d83b20 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,6 +1,7 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. - SVN + - added: new module 55_weco.pm (betateilchen) - added: new module 70_Jabber.pm (BioS) - bugfix: Dashboard: use "loadScript" for load JavaScripts - feature: new module 00_NetzerI2C.pm, 51_Netzer.pm added (klausw) diff --git a/fhem/FHEM/55_weco.pm b/fhem/FHEM/55_weco.pm new file mode 100644 index 000000000..6a664fe4b --- /dev/null +++ b/fhem/FHEM/55_weco.pm @@ -0,0 +1,221 @@ +# $Id: $ +#################################################################################################### +# +# 55_weco.pm +# +# Copyright: betateilchen ® +# e-mail: fhem.development@betateilchen.de +# +# Based on an idea from Frank S. in fhem forum. +# +# This file 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 . +# +#################################################################################################### + +package main; + +use strict; +use warnings; +use Time::HiRes qw(gettimeofday); +use HttpUtils; + +#################################################################################################### +# +# Main routines +# +#################################################################################################### + +sub weco_Initialize($) { + my ($hash) = @_; + my $name = $hash->{NAME}; + my $found; + + $hash->{DefFn} = "weco_Define"; + $hash->{UndefFn} = "weco_Undef"; + $hash->{AttrList} = "disable:0,1 ". + "wecoInterval:600,1800,3600 wecotest:true,false ". + "wecohu wecote wecodp wecopr wecopcv wecopcf wecowd wecows wecowsbft wecowg wecopa ". + "wecopai wecopaest wecouv wecosd wecosc wecovi wecoch wecocm wecocl wecodc wecoww ". + $readingFnAttributes; + +} + +sub weco_Define($$$) { + my ($hash, $def) = @_; + my @a = split("[ \t][ \t]*", $def); + + return "syntax: define weco " if(int(@a) != 4 ); + my $name = $hash->{NAME}; + + $hash->{helper}{stationid} = $a[2]; + $hash->{helper}{password} = $a[3]; + $hash->{helper}{softwareid} = 'fhem'; + $hash->{helper}{url} = "http://interface.wetterarchiv.de/weather/"; + + Log3($name, 4, "weco $name: created"); + readingsSingleUpdate($hash, "state", "defined",1); + weco_send($hash); + + return undef; +} + +sub weco_Undef($$) { + my ($hash, $arg) = @_; + RemoveInternalTimer($hash); + return undef; +} + +sub weco_send($) { + my ($hash, $local) = @_; + my $name = $hash->{NAME}; + return if IsDisabled($name); + + $local = 0 unless(defined($local)); + my $url = $hash->{helper}{url}; + $url .= "?id=". $hash->{helper}{stationid}; + $url .= "&pwd=". $hash->{helper}{password}; + $url .= "&sid=". $hash->{helper}{softwareid}; + $url .= "&dtutc=".strftime "%Y%m%d%H%M", gmtime; + $url .= "&dt=". strftime "%Y%m%d%H%M", localtime; + + $attr{$name}{wecoInterval} = 600 if(AttrVal($name,"wecoInterval",0) < 600); + RemoveInternalTimer($hash); + + my ($data, $d, $r, $o); + my $a = $attr{$name}; + while ( my ($key, $value) = each($a) ) { + next if substr($key,4,1) ~~ ["I"] ; + $key = substr($key,4,length($key)-4); + ($d, $r, $o) = split(":", $value); + if(defined($r)) { + $o = 0 if(!defined($o)); + $value = ReadingsVal($d, $r, "") + $o; + } + $data .= "&$key=$value"; + } + + Log3 ($name, 4, "weco $name data sent: $data"); + $url .= $data; + my $response = GetFileFromURL($url); + Log3 ($name, 4, "weco $name server response: $response"); + + readingsBeginUpdate($hash); + readingsBulkUpdate($hash, "data", $data); + readingsBulkUpdate($hash, "response", $response); + readingsBulkUpdate($hash, "state", "active"); + readingsEndUpdate($hash, 1); + + InternalTimer(gettimeofday()+$attr{$name}{wecoInterval}, "weco_send", $hash, 0) unless($local == 1); + + return; +} + +1; + +#################################################################################################### +# +# Documentation +# +#################################################################################################### +# +# Changelog: +# +# 2014-04-12 initial release +# +#################################################################################################### + +=pod +=begin html + + +

weco

+
    + + + Define +
      + +
      + define <name> weco <stationId> <password> +

      + This module provides connection to www.wetter.com
      + to send data from your own weather station.
      + +
    +

    + + + Set-Commands
    +
      +
      + - not implemented -
      +
    +

    + + + Get-Commands
    +
      +
      + - not implemented -
      +
    +

    + + + Attributes

    +
      +
    • readingFnAttributes
    • +
      +
    • wecoInterval - Interval (seconds) to send data to www.wetter.com + Will be adjusted to 600 if set to a value lower than 600.
    • +
    • wecotest - If set to "true" data will not be stored on server. Used for development and testing.
    • +
    • weco.... - Attribute name corresponding to parameter name from api. + Each of this attributes contains information about weather data to be sent in format + sensorName:readingName[:offset]
      + Example: attr weco wecote outside:temperature will define the attribut wecote and
      + reading "temperature" from device "outside" will be sent to network as paramater "te" (which indicates current temperature)
      + Optional Parameter "offset" will be added to the read value + (e.g. sometimes necessary to send dewpoint - use offset 273.15 if needed in Kelvin) +
    • +
    +

    + + Generated Readings/Events: +

    +
      +
    • data - data string transmitted to www.wetter.com
    • +
    • response - response string received from server
    • +
    +

    + + Author's notes

    +
      +
    • Find complete api description here
    • +
    • Have fun!

    • +
    + +
+ +=end html +=begin html_DE + + +

weco

+
    +Sorry, keine deutsche Dokumentation vorhanden.

    +Die englische Doku gibt es hier: weco
    +
+=end html_DE +=cut diff --git a/fhem/MAINTAINER.txt b/fhem/MAINTAINER.txt index 6d5690b64..27298e160 100644 --- a/fhem/MAINTAINER.txt +++ b/fhem/MAINTAINER.txt @@ -132,6 +132,7 @@ FHEM/52_I2C_PCF8574 klausw http://forum.fhem.de FHEM Deve FHEM/52_I2C_SHT21 klausw http://forum.fhem.de FHEM Developement/Sonstige Systeme FHEM/55_GDS.pm betateilchen http://forum.fhem.de Unterstuetzende Dienste FHEM/55_PIFACE.pm klaus.schauer http://forum.fhem.de Einplatinencomputer +FHEM/55_weco.pm betateilchen http://forum.fhem.de Unterstuetzende Dienste FHEM/56_POKEYS.pm axelberner http://forum.fhem.de Sonstiges FHEM/57_Calendar.pm borisneubert http://forum.fhem.de Sonstiges FHEM/59_HCS.pm mfr69bs http://forum.fhem.de Automatisierung diff --git a/fhem/docs/commandref_frame.html b/fhem/docs/commandref_frame.html index dd5e9d8b1..cf1184dd7 100644 --- a/fhem/docs/commandref_frame.html +++ b/fhem/docs/commandref_frame.html @@ -130,6 +130,7 @@ WeekdayTimer   watchdog   weblink   + weco   WOL   diff --git a/fhem/docs/commandref_frame_DE.html b/fhem/docs/commandref_frame_DE.html index bc156b6a6..37fee052c 100644 --- a/fhem/docs/commandref_frame_DE.html +++ b/fhem/docs/commandref_frame_DE.html @@ -128,6 +128,7 @@ WeekdayTimer   watchdog   weblink   + weco   WOL   XmlList