HomeMatic interface moduled based on the officially documented XML-RPC API
of the EQ-3 software (CCU or LAN "Konfigurationsadapter") git-svn-id: https://fhem.svn.sourceforge.net/svnroot/fhem/trunk/fhem@1063 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
105
contrib/HMRPC/01_HMDEV.pm
Normal file
105
contrib/HMRPC/01_HMDEV.pm
Normal file
@@ -0,0 +1,105 @@
|
||||
##############################################
|
||||
# HMRPC Device Handler
|
||||
# Written by Oliver Wagner <owagner@vapor.com>
|
||||
#
|
||||
# V0.2
|
||||
#
|
||||
##############################################
|
||||
#
|
||||
# This module handles individual devices via the
|
||||
# HMRPC provider.
|
||||
#
|
||||
package main;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub
|
||||
HMDEV_Initialize($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
|
||||
$hash->{Match} = "^HMDEV .* .* .*";
|
||||
$hash->{DefFn} = "HMDEV_Define";
|
||||
$hash->{ParseFn} = "HMDEV_Parse";
|
||||
$hash->{SetFn} = "HMDEV_Set";
|
||||
$hash->{AttrList} = "IODev do_not_notify:0,1";
|
||||
}
|
||||
|
||||
#############################
|
||||
sub
|
||||
HMDEV_Define($$)
|
||||
{
|
||||
my ($hash, $def) = @_;
|
||||
my @a = split("[ \t][ \t]*", $def);
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
return "wrong syntax: define <name> HMDEV deviceaddress" if int(@a)!=3;
|
||||
|
||||
my $addr=uc($a[2]);
|
||||
|
||||
$hash->{hmaddr}=$addr;
|
||||
$modules{HMDEV}{defptr}{$addr} = $hash;
|
||||
AssignIoPort($hash);
|
||||
|
||||
Log 5,"Assigned $name to $hash->{IODev}->{NAME}";
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#############################
|
||||
sub
|
||||
HMDEV_Parse($$)
|
||||
{
|
||||
my ($hash, $msg) = @_;
|
||||
|
||||
my @mp=split(" ",$msg);
|
||||
my $addr=$mp[1];
|
||||
|
||||
$hash=$modules{HMDEV}{defptr}{$addr};
|
||||
if(!$hash)
|
||||
{
|
||||
Log(2,"Received callback for unknown device $msg");
|
||||
return "UNDEFINED HMDEV_$addr HMDEV $addr";
|
||||
}
|
||||
|
||||
#
|
||||
# Ok update the relevant reading
|
||||
#
|
||||
my @changed;
|
||||
my $currentval=$hash->{READINGS}{$mp[2]}{VAL};
|
||||
$hash->{READINGS}{$mp[2]}{TIME}=TimeNow();
|
||||
# Note that we always trigger a change on PRESS_LONG/PRESS_SHORT events
|
||||
# (they are sent whenever a button is presed, and there is no change back)
|
||||
if(!$currentval || ($currentval ne $mp[3]) || ($currentval =~ m/^PRESS_/))
|
||||
{
|
||||
push @changed, "$mp[2]: $mp[3]";
|
||||
$hash->{READINGS}{$mp[2]}{VAL}=$mp[3];
|
||||
}
|
||||
$hash->{CHANGED}=\@changed;
|
||||
|
||||
return $hash->{NAME};
|
||||
}
|
||||
|
||||
################################
|
||||
sub
|
||||
HMDEV_Set($@)
|
||||
{
|
||||
my ($hash, @a) = @_;
|
||||
|
||||
return "invalid set call @a" if(@a != 3 && @a != 4);
|
||||
# We delegate this call to the IODev, after having added the device address
|
||||
if(@a==4)
|
||||
{
|
||||
return HMRPC_Set($hash->{IODev},$hash->{IODev}->{NAME},$hash->{hmaddr},$a[1],$a[2],$a[3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return HMRPC_Set($hash->{IODev},$hash->{IODev}->{NAME},$hash->{hmaddr},$a[1],$a[2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
Reference in New Issue
Block a user