2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

99_weekprofile: add support for CCU2 (experimental)

git-svn-id: https://svn.fhem.de/fhem/trunk@15568 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Risiko 2017-12-08 13:23:55 +00:00
parent f4529ed50f
commit 7b16870ced
2 changed files with 77 additions and 3 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # 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. # Do not insert empty lines here, update check depends on it.
- feature: 99_weekprofile: add support for CCU2 (experimental)
- change: 93_DbRep: V6.3.2 ,changelist to last version: - change: 93_DbRep: V6.3.2 ,changelist to last version:
- new command delSeqDoublets - new command delSeqDoublets
- add last command option to internal LASTCMD - add last command option to internal LASTCMD

View File

@ -20,7 +20,7 @@ use vars qw($init_done);
my @shortDays = ("Mon","Tue","Wed","Thu","Fri","Sat","Sun"); my @shortDays = ("Mon","Tue","Wed","Thu","Fri","Sat","Sun");
my @DEVLIST_SEND = ("MAX","CUL_HM","weekprofile","dummy"); my @DEVLIST_SEND = ("MAX","CUL_HM","HMCCUDEV","weekprofile","dummy");
my $CONFIG_VERSION = "1.1"; my $CONFIG_VERSION = "1.1";
@ -43,9 +43,42 @@ $DEV_READINGS{"Fri"}{"CUL_HM"} = "6_tempListFri";
$DEV_READINGS{"Sat"}{"CUL_HM"} = "0_tempListSat"; $DEV_READINGS{"Sat"}{"CUL_HM"} = "0_tempListSat";
$DEV_READINGS{"Sun"}{"CUL_HM"} = "1_tempListSun"; $DEV_READINGS{"Sun"}{"CUL_HM"} = "1_tempListSun";
# HMCCUDEV
$DEV_READINGS{"Mon"}{"HMCCUDEV"} = "MONDAY";
$DEV_READINGS{"Tue"}{"HMCCUDEV"} = "TUESDAY";
$DEV_READINGS{"Wed"}{"HMCCUDEV"} = "WEDNESDAY";
$DEV_READINGS{"Thu"}{"HMCCUDEV"} = "THURSDAY";
$DEV_READINGS{"Fri"}{"HMCCUDEV"} = "FRIDAY";
$DEV_READINGS{"Sat"}{"HMCCUDEV"} = "SATURDAY";
$DEV_READINGS{"Sun"}{"HMCCUDEV"} = "SUNDAY";
sub weekprofile_findPRF($$$$); sub weekprofile_findPRF($$$$);
##############################################
sub weekprofile_minutesToTime($)
{
my ($minutes) = @_;
my $hours = $minutes / 60;
$minutes = $minutes - $hours * 60;
if (length($hours) eq 1){
$hours = "0$hours";
}
if (length($minutes) eq 1){
$minutes = "0$minutes";
}
return "$hours:$minutes";
}
##############################################
sub weekprofile_timeToMinutes($)
{
my ($time) = @_;
my ($hours, $minutes) = split(':',$time, 2);
return $hours * 60 + $minutes;
}
############################################## ##############################################
sub weekprofile_getDeviceType($$;$) sub weekprofile_getDeviceType($$;$)
{ {
@ -96,6 +129,10 @@ sub weekprofile_getDeviceType($$;$)
$type = "MAX" if ($device =~ m/.*MAX.*FAKE.*/); #dummy (FAKE WT) with name MAX inside for testing $type = "MAX" if ($device =~ m/.*MAX.*FAKE.*/); #dummy (FAKE WT) with name MAX inside for testing
$type = "CUL_HM" if ($device =~ m/.*CUL_HM.*FAKE.*/); #dummy (FAKE WT) with name CUL_HM inside for testing $type = "CUL_HM" if ($device =~ m/.*CUL_HM.*FAKE.*/); #dummy (FAKE WT) with name CUL_HM inside for testing
} }
elsif ( $devHash->{TYPE} =~ /HMCCUDEV/){
my $model = $devHash->{ccutype};
$type = "HMCCUDEV" if ( $model =~ /HmIP-eTRV-2/ );
}
return $type if ($sndrcv eq "RCV"); return $type if ($sndrcv eq "RCV");
@ -149,8 +186,26 @@ sub weekprofile_readDayProfile($@)
push(@temps, $timeTemp[$i+1]); push(@temps, $timeTemp[$i+1]);
} }
} }
elsif ($type eq "HMCCUDEV"){
my $lastTime = "";
for (my $i = 1; $i < 14; $i+=1){
my $prfTemp = ReadingsVal($device, "R-1.P1_TEMPERATURE_" . $reading . "_$i", "");
my $prfTime = ReadingsVal($device, "R-1.P1_ENDTIME_" . $reading . "_$i", "");
$prfTime = weekprofile_minutesToTime($prfTime);
if ($lastTime ne $prfTime){
$lastTime = $prfTime;
push(@temps, $prfTemp);
push(@times, $prfTime);
}
}
}
for(my $i = 0; $i < scalar(@temps); $i+=1){ for(my $i = 0; $i < scalar(@temps); $i+=1){
Log3 $me, 4, "$me(ReadDayProfile): temp $i $temps[$i]";
$temps[$i] =~s/[^\d.]//g; #only numbers $temps[$i] =~s/[^\d.]//g; #only numbers
my $tempON = AttrVal($me, "tempON", undef); my $tempON = AttrVal($me, "tempON", undef);
my $tempOFF = AttrVal($me, "tempOFF", undef); my $tempOFF = AttrVal($me, "tempOFF", undef);
@ -275,7 +330,7 @@ sub weekprofile_sendDevProfile(@)
$cmd.=$prf->{DATA}->{$day}->{"temp"}[$i].$endTime; $cmd.=$prf->{DATA}->{$day}->{"temp"}[$i].$endTime;
} }
} }
} else { #Homatic } elsif ($type eq "CUL_HM") {
my $k=0; my $k=0;
my $dayCnt = scalar(@dayToTransfer); my $dayCnt = scalar(@dayToTransfer);
foreach my $day (@dayToTransfer){ foreach my $day (@dayToTransfer){
@ -290,8 +345,26 @@ sub weekprofile_sendDevProfile(@)
$cmd .= ($k < $dayCnt-1) ? "; ": ""; $cmd .= ($k < $dayCnt-1) ? "; ": "";
$k++; $k++;
} }
} elsif ($type eq "HMCCUDEV"){
my $k=0;
my $dayCnt = scalar(@dayToTransfer);
$cmd .= "set $device config 1";
foreach my $day (@dayToTransfer){
#Usage: set <device> datapoint [{channel-number}.]{datapoint} {value}
my $reading = $DEV_READINGS{$day}{$type};
my $dpTime = "P1_ENDTIME_$reading";
my $dpTemp = "P1_TEMPERATURE_$reading";
my $tmpCnt = scalar(@{$prf->{DATA}->{$day}->{"temp"}});
for (my $i = 0; $i < $tmpCnt; $i++) {
$cmd .= " " . $dpTemp . "_" . ($i + 1) . "=" . $prf->{DATA}->{$day}->{"temp"}[$i];
$cmd .= " " . $dpTime . "_" . ($i + 1) . "=" . weekprofile_timeToMinutes($prf->{DATA}->{$day}->{"time"}[$i]);
}
#$cmd .= ($k < $dayCnt-1) ? "; ": "";
$k++;
}
} }
my $ret = undef; my $ret = undef;
if ($cmd) { if ($cmd) {
$cmd =~ s/^\s+|\s+$//g; $cmd =~ s/^\s+|\s+$//g;