Da wohl die wenigsten von uns auf dem flachen Land wohnen und eine Aussicht bis zum Horizont haben, möchte hier gerrne meinen ,,Codeschnippsel" zur Beschattung durch das ASC-Modul unter berücksichtigung der ,,Skyline" teilen.
Benötigte wird:
- Twilight-Modul
- Info ob die Sonne scheint. ( wird bei mir von einem Differenzthermometer ermittelt )
- eine CSV-Datei die jedem Azimuth-Winkel den Elevationswinkel der Skyline zuordnet.
- ein DOIF das in einem dummy einen manipulierten helligkeitswert hinterlegt.
- Zum einlesen einer CSV-Datei wird auf dem Raspberry Pi Slurp und eine Routine benötigt.
99_readCSVUtils.pm
##################### Routine zum Einlesen einer CSV-Datei
#Module Install Instructions
#
#To install Text::CSV::Slurp, copy and paste the appropriate command in to your #terminal.
#
#cpanm
###########################
#cpanm Text::CSV::Slurp #
###########################
#
#CPAN shell
###########################
#perl -MCPAN -e shell #
#install Text::CSV::Slurp #
###########################
#For more information on module installation, please visit the detailed CPAN #module installation guide.
#!/usr/bin/perlpackage main;
use strict;
use warnings;
use POSIX;
use strict;
use warnings;
use Text::CSV::Slurp;
sub readCSVUtils_Initialize($$)
{
my ($hash) = @_;
}
####################################################################
sub
readCSV ($$){
my ($csvDatei, $Spalte) = @_;
my $slurp = Text::CSV::Slurp->new();
my $Wert;my $Datum;
# CSV Options - see Text::CSV
my %csv_options = (
sep_char => ';',
binary => '1',
);
# Reference to an array of hashes
my $data = $slurp->load( file => $csvDatei, %csv_options );
foreach my $row (@$data) {
$Wert = $row->{$Spalte};}
return $Wert
}
1;
Das DOIF zum manipulieren des Helligkeitswertes
defmod di_Kue2 DOIF ([Twilight:azimuth] and [TempDiff:Sonne] eq "on" and [$SELF:shad_ele] < [Twilight:elevation])\
(set du_SSW Kue2br 36000)\
DOELSEIF\
([Twilight:azimuth] and [LaCrosse_16:temperature] > [du_SSW:ShadTemp] and [$SELF:shad_ele] < [Twilight:elevation])\
(set du_SSW Kue2br 36000)\
DOELSE\
(set du_SSW Kue2br [SonnenSensor:Lux_av])
attr di_Kue2 checkall event
attr di_Kue2 comment Rollladen soll, wenn Temperatur über [du_SSW:ShadTemp] auch ohne Sonne on beschatten.
attr di_Kue2 disable 0
attr di_Kue2 do always
attr di_Kue2 room Rollläden
attr di_Kue2 userReadings shad_ele {readCSV("/opt/fhem/Kue2.csv",int(ReadingsVal("Twilight","azimuth",0)+.5))}
Dummy mit den manipulierten Helligkeitswerten
defmod du_SSW dummy
attr du_SSW readingList Wnz3br Kue1br Kue2br Kue3br Kue4br Slz3br ShadTemp
attr du_SSW room Rollläden
attr du_SSW setList Wnz3br Kue1br Kue2br Kue3br Kue4br Slz3br ShadTemp
attr du_SSW stateFormat <a> Küche_1 Kue1br lx</a>\
<br>\
<a> Küche_2 Kue2br lx</a>\
<br>\
<a> Küche_3 Kue3br lx</a>\
<br>\
<a> Küche_4 Kue4br lx</a>\
<br>\
<a> WnZim_3 Wnz3br lx</a>\
<br>\
<a> SchlZim_3 Slz3br lx</a>
attr du_SSW userReadings Wnz2br Wnz3br Kue1br Kue2br Kue3br Kue4br Slz3br ShadTemp
Hier die wichtigsten Attribute im Rolladen-Device dazu
attr RolKue2 ASC_BrightnessSensor du_SSW:Kue2br 600:100
attr RolKue2 ASC_Shading_InOutAzimuth 94:222
attr RolKue2 ASC_Shading_MinMax_Elevation 01.0:100.0
ttr RolKue2 ASC_Shading_Pos 50
attr RolKue2 ASC_Shading_StateChange_SunnyCloudy 35000:20000 1
attr RolKue2 ASC_TempSensor LaCrosse_16:temperature
In den Anhängen als Beispel unser Fenster2 der Küche, das viel Schatten vom Nachbarhaus bekommt.