mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-21 01:46:08 +00:00
fixed: wrong URL creation
added: documentation git-svn-id: https://svn.fhem.de/fhem/trunk@3546 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
57bfccd612
commit
007fe42b88
@ -1,30 +1,34 @@
|
||||
# $Id$
|
||||
################################################################
|
||||
#
|
||||
# Copyright notice
|
||||
# This module will connect a webbased thermometer
|
||||
# to your fhem installation.
|
||||
#
|
||||
# Further informations about required hardware:
|
||||
# http://www.wut.de/e-57w0w-ww-dade-000.php
|
||||
#
|
||||
# (c) 2010 Sacha Gloor (sacha@imp.ch)
|
||||
#
|
||||
# This script is free software; you can redistribute it and/or modify
|
||||
# corrections & documentation added for fhem
|
||||
# 2013-07-30 by betateilchen ®
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# The GNU General Public License can be found at
|
||||
# http://www.gnu.org/copyleft/gpl.html.
|
||||
# A copy is found in the textfile GPL.txt and important notices to the license
|
||||
# from the author is found in LICENSE.txt distributed with these scripts.
|
||||
#
|
||||
# This script is distributed in the hope that it will be useful,
|
||||
# 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.
|
||||
#
|
||||
# This copyright notice MUST APPEAR in all copies of the script!
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with fhem. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################
|
||||
# $Id$
|
||||
|
||||
##############################################
|
||||
package main;
|
||||
|
||||
use strict;
|
||||
@ -51,21 +55,19 @@ WEBTHERM_Define($$)
|
||||
|
||||
my $host = $a[2];
|
||||
my $host_port = $a[3];
|
||||
my $delay=$a[4];
|
||||
$attr{$name}{delay}=$delay if $delay;
|
||||
my $interval=$a[4];
|
||||
$attr{$name}{interval}=$interval if $interval;
|
||||
|
||||
return "Wrong syntax: use define <name> WEBTHERM <ip-address> <port-nr> <poll-delay>" if(int(@a) != 5);
|
||||
return "Usage: define <name> WEBTHERM <ip-address> <port-nr> <poll-interval>" if(int(@a) != 5);
|
||||
|
||||
$hash->{Host} = $host;
|
||||
$hash->{Host_Port} = $host_port;
|
||||
|
||||
InternalTimer(gettimeofday()+$delay, "WEBTHERM_GetStatus", $hash, 0);
|
||||
InternalTimer(gettimeofday()+$interval, "WEBTHERM_GetStatus", $hash, 0);
|
||||
|
||||
return undef;
|
||||
return;
|
||||
}
|
||||
|
||||
#####################################
|
||||
|
||||
sub
|
||||
WEBTHERM_GetStatus($)
|
||||
{
|
||||
@ -76,13 +78,16 @@ WEBTHERM_GetStatus($)
|
||||
my $name = $hash->{NAME};
|
||||
my $host = $hash->{Host};
|
||||
|
||||
my $delay=$attr{$name}{delay}||300;
|
||||
InternalTimer(gettimeofday()+$delay, "WEBTHERM_GetStatus", $hash, 0);
|
||||
my $interval=$attr{$name}{interval}||300;
|
||||
InternalTimer(gettimeofday()+$interval, "WEBTHERM_GetStatus", $hash, 0);
|
||||
|
||||
if(!defined($hash->{Host_Port})) { return(""); }
|
||||
my $host_port = $hash->{Host_Port};
|
||||
|
||||
my $URL="http://".$host."/Single".$host_port;
|
||||
### 2013-07-30 corrected by betateilchen
|
||||
# my $URL="http://".$host."/Single".$host_port;
|
||||
my $URL="http://".$host.":".$host_port."/Single";
|
||||
### end-of-correction
|
||||
my $agent = LWP::UserAgent->new(env_proxy => 1,keep_alive => 1, timeout => 3);
|
||||
my $header = HTTP::Request->new(GET => $URL);
|
||||
my $request = HTTP::Request->new('GET', $URL, $header);
|
||||
@ -93,13 +98,13 @@ WEBTHERM_GetStatus($)
|
||||
|
||||
if($err_log ne "")
|
||||
{
|
||||
Log GetLogLevel($name,2), "WEBTHERM ".$err_log;
|
||||
return("");
|
||||
Log GetLogLevel($name,2), "WEBTHERM $name ".$err_log;
|
||||
return;
|
||||
}
|
||||
|
||||
my $body = $response->content;
|
||||
my $text='';
|
||||
# print $body."\n";
|
||||
|
||||
my @values=split(/;/,$body);
|
||||
my $last=$values[$#values];
|
||||
my $state=$last;
|
||||
@ -111,11 +116,54 @@ WEBTHERM_GetStatus($)
|
||||
|
||||
$text="Temperature: ".$state;
|
||||
$hash->{STATE} = "T: ".$state;
|
||||
|
||||
$hash->{CHANGED}[0] = $text;
|
||||
$hash->{READINGS}{$sensor}{TIME} = TimeNow();
|
||||
$hash->{READINGS}{$sensor}{VAL} = $state." (Celsius)";
|
||||
DoTrigger($name, undef) if($init_done);
|
||||
|
||||
readingsSingleUpdate($name, $sensor, $state, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
=begin html
|
||||
|
||||
<a name="WEBTHERM"></a>
|
||||
<h3>WEBTHERM</h3>
|
||||
<ul>
|
||||
This module connects a <a href="http://www.wut.de/e-57w0w-ww-dade-000.php">Web-Thermometer made by W&T</a> to your FHEM installation.<br/>
|
||||
Currently this module is no longer maintained, but it should work in its current state.<br/>
|
||||
It is provided "as is" for backward compatibility.<br/>
|
||||
<br />
|
||||
<a name="WEBTHERM_Define"></a>
|
||||
<b>Define</b>
|
||||
<ul><br/>
|
||||
<code>define <name> WEBTHERM <ip-address> <port-nr> <interval></code><br/>
|
||||
<br/>
|
||||
Defines a WEBTHERM device at given ip and port.</br>
|
||||
Values are polled periodically defined by given interval (in seconds).<br/>
|
||||
Read temperature is written into reading "state".<br/>
|
||||
</ul>
|
||||
<br/><br />
|
||||
|
||||
<a name="WEBTHERM_Set"></a>
|
||||
<b>Set</b>
|
||||
<ul>
|
||||
N/A
|
||||
</ul>
|
||||
<br/><br />
|
||||
|
||||
<a name="WEBTHERM_Get"></a>
|
||||
<b>Get</b>
|
||||
<ul>
|
||||
N/A
|
||||
</ul>
|
||||
<br/><br />
|
||||
|
||||
<a name="WEBTHERM_Attr"></a>
|
||||
<b>Attr</b>
|
||||
<ul>
|
||||
N/A
|
||||
</ul>
|
||||
</ul>
|
||||
=end html
|
||||
=cut
|
||||
|
Loading…
x
Reference in New Issue
Block a user