mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
24_TPLinkHS110: Release 2018-11-01 SetExtension
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@15848 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
80b1186ebf
commit
2500f422a5
@ -1,6 +1,8 @@
|
|||||||
################################################################
|
################################################################
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
|
# Release 2018-11-01 SetExtension
|
||||||
|
#
|
||||||
# Copyright notice
|
# Copyright notice
|
||||||
#
|
#
|
||||||
# (c) 2016 Copyright: Volker Kettenbach
|
# (c) 2016 Copyright: Volker Kettenbach
|
||||||
@ -34,6 +36,7 @@ use warnings;
|
|||||||
use IO::Socket::INET;
|
use IO::Socket::INET;
|
||||||
use IO::Socket::Timeout;
|
use IO::Socket::Timeout;
|
||||||
use JSON;
|
use JSON;
|
||||||
|
use SetExtensions;
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
sub TPLinkHS110_Initialize($)
|
sub TPLinkHS110_Initialize($)
|
||||||
@ -199,19 +202,26 @@ sub TPLinkHS110_Get($$)
|
|||||||
#####################################
|
#####################################
|
||||||
sub TPLinkHS110_Set($$)
|
sub TPLinkHS110_Set($$)
|
||||||
{
|
{
|
||||||
my ( $hash, @a ) = @_;
|
my ( $hash, $name, $cmd, @args ) = @_;
|
||||||
my $name= $hash->{NAME};
|
my $cmdList = "on off";
|
||||||
|
return "\"set $name\" needs at least one argument" unless(defined($cmd));
|
||||||
return "Device disabled in config" if ($attr{$name}{"disable"} eq "1");
|
return "Device disabled in config" if ($attr{$name}{"disable"} eq "1");
|
||||||
Log3 $hash, 3, "TPLinkHS110: $name Set <". $a[1] ."> called";
|
Log3 $hash, 3, "TPLinkHS110: $name Set <". $cmd ."> called";
|
||||||
return "Unknown argument $a[1], choose one of on off " if($a[1] ne "on" & $a[1] ne "off");
|
|
||||||
|
|
||||||
my $command;
|
my $command="";
|
||||||
if($a[1] eq "on") {
|
if($cmd eq "on")
|
||||||
|
{
|
||||||
$command = '{"system":{"set_relay_state":{"state":1}}}';
|
$command = '{"system":{"set_relay_state":{"state":1}}}';
|
||||||
}
|
}
|
||||||
if($a[1] eq "off") {
|
elsif($cmd eq "off")
|
||||||
|
{
|
||||||
$command = '{"system":{"set_relay_state":{"state":0}}}';
|
$command = '{"system":{"set_relay_state":{"state":0}}}';
|
||||||
}
|
}
|
||||||
|
else # wenn der übergebene Befehl nicht durch X_Set() verarbeitet werden kann, Weitergabe an SetExtensions
|
||||||
|
{
|
||||||
|
return SetExtensions($hash, $cmdList, $name, $cmd, @args);
|
||||||
|
}
|
||||||
|
|
||||||
my $remote_host = $hash->{HOST};
|
my $remote_host = $hash->{HOST};
|
||||||
my $remote_port = 9999;
|
my $remote_port = 9999;
|
||||||
my $c = encrypt($command);
|
my $c = encrypt($command);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user