mirror of
https://github.com/fhem/fhem-mirror.git
synced 2024-11-22 02:59:49 +00:00
73_GardenaSmartBridge: add support for Irrigation Control
git-svn-id: https://svn.fhem.de/fhem/trunk@16984 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
d1b7e2df13
commit
97a34aa4bd
@ -1,5 +1,7 @@
|
||||
# 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.
|
||||
- feature: 73_GardenaSmartBridge: 74_GeardenaSmartDevice: add support for
|
||||
Irrigation Control
|
||||
- change: 98_feels_like.pm: Improved algorithms, fix reDEFINE
|
||||
- new: 42_AptToDate: Modul to retrieves apt information about Debian
|
||||
update state
|
||||
|
@ -8,6 +8,8 @@
|
||||
# Special thanks goes to comitters:
|
||||
# - Michael (mbrak) Thanks for Commandref
|
||||
# - Matthias (Kenneth) Thanks for Wiki entry
|
||||
# - BioS Thanks for predefined start points Code
|
||||
# - fettgu Thanks for Debugging Irrigation Control data flow
|
||||
#
|
||||
#
|
||||
# This script is free software; you can redistribute it and/or modify
|
||||
@ -68,7 +70,7 @@ eval "use JSON;1" or $missingModul .= "JSON ";
|
||||
eval "use IO::Socket::SSL;1" or $missingModul .= "IO::Socket::SSL ";
|
||||
|
||||
|
||||
my $version = "1.0.4";
|
||||
my $version = "1.2.0";
|
||||
|
||||
|
||||
|
||||
@ -83,8 +85,8 @@ sub GardenaSmartBridge_Undef($$);
|
||||
sub GardenaSmartBridge_Delete($$);
|
||||
sub GardenaSmartBridge_ResponseProcessing($$);
|
||||
sub GardenaSmartBridge_ErrorHandling($$$);
|
||||
sub GardenaSmartBridge_encrypt($);
|
||||
sub GardenaSmartBridge_decrypt($);
|
||||
#sub GardenaSmartBridge_encrypt($);
|
||||
#sub GardenaSmartBridge_decrypt($);
|
||||
sub GardenaSmartBridge_WriteReadings($$);
|
||||
sub GardenaSmartBridge_ParseJSON($$);
|
||||
sub GardenaSmartBridge_getDevices($);
|
||||
@ -755,7 +757,7 @@ sub GardenaSmartBridge_ParseJSON($$) {
|
||||
}
|
||||
}
|
||||
|
||||
Log3 $name, 4, "GardenaSmartBridge ($name) - return msg: $msg and tail: $tail";
|
||||
Log3 $name, 5, "GardenaSmartBridge ($name) - return msg: $msg and tail: $tail";
|
||||
return ($msg,$tail);
|
||||
}
|
||||
|
||||
@ -782,17 +784,26 @@ sub GardenaSmartBridge_createHttpValueStrings($@) {
|
||||
$uri .= '/sessions' if( not defined($hash->{helper}{session_id}));
|
||||
|
||||
if( defined($hash->{helper}{locations_id}) ) {
|
||||
#$uri .= '/devices/' . $deviceId . '/abilities/' . $abilities . '/command' if( defined($abilities) and defined($payload) );
|
||||
if ( defined($abilities) and $abilities eq 'mower_settings') {
|
||||
|
||||
$method = 'PUT';
|
||||
my $dhash = $modules{GardenaSmartDevice}{defptr}{$deviceId};
|
||||
$uri .= '/devices/' . $deviceId . '/settings/' . $dhash->{helper}{STARTINGPOINTID} if( defined($abilities) and defined($payload) and $abilities eq 'mower_settings');
|
||||
$uri .= '/devices/' . $deviceId . '/settings/' . $dhash->{helper}{STARTINGPOINTID} if( defined($abilities) and defined($payload) and $abilities eq 'mower_settings');
|
||||
|
||||
} elsif( defined($abilities) and defined($payload) and $abilities eq 'watering') {
|
||||
my $valve_id;
|
||||
$method = 'PUT';
|
||||
|
||||
if( $payload =~ m#watering_timer_(\d)# ) {
|
||||
$valve_id = $1;
|
||||
}
|
||||
$uri .= '/devices/' . $deviceId . '/abilities/' . $abilities . '/properties/watering_timer_' . $valve_id;
|
||||
|
||||
} else {
|
||||
$uri .= '/devices/' . $deviceId . '/abilities/' . $abilities . '/command' if( defined($abilities) and defined($payload) and $abilities ne 'mower_settings');
|
||||
$uri .= '/devices/' . $deviceId . '/abilities/' . $abilities . '/command' if( defined($abilities) and defined($payload) );
|
||||
}
|
||||
|
||||
$uri .= '?locationId=' . $hash->{helper}{locations_id};
|
||||
$uri .= '?locationId=' . $hash->{helper}{locations_id};
|
||||
}
|
||||
|
||||
return ($payload,$session_id,$header,$uri,$method,$deviceId,$abilities);
|
||||
|
@ -9,6 +9,7 @@
|
||||
# - Michael (mbrak) Thanks for Commandref
|
||||
# - Matthias (Kenneth) Thanks for Wiki entry
|
||||
# - BioS Thanks for predefined start points Code
|
||||
# - fettgu Thanks for Debugging Irrigation Control data flow
|
||||
#
|
||||
#
|
||||
# This script is free software; you can redistribute it and/or modify
|
||||
@ -66,7 +67,7 @@ use Time::Local;
|
||||
eval "use JSON;1" or $missingModul .= "JSON ";
|
||||
|
||||
|
||||
my $version = "1.0.2";
|
||||
my $version = "1.2.0";
|
||||
|
||||
|
||||
|
||||
@ -100,7 +101,7 @@ sub GardenaSmartDevice_Initialize($) {
|
||||
|
||||
$hash->{AttrFn} = "GardenaSmartDevice_Attr";
|
||||
$hash->{AttrList} = "readingValueLanguage:de,en ".
|
||||
"model:watering_computer,sensor,mower ".
|
||||
"model:watering_computer,sensor,mower,ic24 ".
|
||||
"IODev ".
|
||||
$readingFnAttributes;
|
||||
|
||||
@ -190,26 +191,26 @@ sub GardenaSmartDevice_Set($@) {
|
||||
#my ($arg, @params) = @args;
|
||||
|
||||
my $payload;
|
||||
my $abilities = '';
|
||||
my $abilities = '';
|
||||
|
||||
|
||||
### mower
|
||||
if( lc $cmd eq 'parkuntilfurthernotice' ) {
|
||||
|
||||
$payload = '"name":"park_until_further_notice"';
|
||||
$payload = '"name":"park_until_further_notice"';
|
||||
|
||||
} elsif( lc $cmd eq 'parkuntilnexttimer' ) {
|
||||
|
||||
$payload = '"name":"park_until_next_timer"';
|
||||
$payload = '"name":"park_until_next_timer"';
|
||||
|
||||
} elsif( lc $cmd eq 'startresumeschedule' ) {
|
||||
|
||||
$payload = '"name":"start_resume_schedule"';
|
||||
$payload = '"name":"start_resume_schedule"';
|
||||
|
||||
} elsif( lc $cmd eq 'startoverridetimer' ) {
|
||||
|
||||
my $duration = join( " ", @args );
|
||||
$payload = '"name":"start_override_timer","parameters":{"duration":' . $duration . '}';
|
||||
$payload = '"name":"start_override_timer","parameters":{"duration":' . $duration . '}';
|
||||
|
||||
} elsif( lc $cmd eq 'startpoint' ) {
|
||||
my $err;
|
||||
@ -220,17 +221,29 @@ sub GardenaSmartDevice_Set($@) {
|
||||
### watering_computer
|
||||
} elsif( lc $cmd eq 'manualoverride' ) {
|
||||
|
||||
my $duration = join( " ", @args );
|
||||
$payload = '"name":"manual_override","parameters":{"duration":' . $duration . '}';
|
||||
my $duration = join( " ", @args );
|
||||
$payload = '"name":"manual_override","parameters":{"duration":' . $duration . '}';
|
||||
|
||||
} elsif( lc $cmd eq 'canceloverride' ) {
|
||||
|
||||
$payload = '"name":"cancel_override"';
|
||||
$payload = '"name":"cancel_override"';
|
||||
|
||||
### Watering ic24
|
||||
} elsif( $cmd =~ /manualDurationValve/ ) {
|
||||
|
||||
my $valve_id;
|
||||
my $duration = join( " ", @args );
|
||||
|
||||
if( $cmd =~ m#(\d)$# ) {
|
||||
$valve_id = $1;
|
||||
}
|
||||
|
||||
$payload = '"properties":{"name":"watering_timer_' . $valve_id . '","value":{"state":"manual","duration":' . $duration . ',"valve_id":' . $valve_id . '}}';
|
||||
|
||||
### Sensors
|
||||
} elsif( lc $cmd eq 'refresh' ) {
|
||||
|
||||
my $sensname = join( " ", @args );
|
||||
my $sensname = join( " ", @args );
|
||||
if( lc $sensname eq 'temperature' ) {
|
||||
$payload = '"name":"measure_ambient_temperature"';
|
||||
$abilities = 'ambient_temperature';
|
||||
@ -249,13 +262,15 @@ sub GardenaSmartDevice_Set($@) {
|
||||
my $list = '';
|
||||
$list .= 'parkUntilFurtherNotice:noArg parkUntilNextTimer:noArg startResumeSchedule:noArg startOverrideTimer:slider,0,60,1440 startpoint' if( AttrVal($name,'model','unknown') eq 'mower' );
|
||||
$list .= 'manualOverride:slider,0,1,59 cancelOverride:noArg' if( AttrVal($name,'model','unknown') eq 'watering_computer' );
|
||||
$list .= 'refresh:temperature,light' if( AttrVal($name,'model','unknown') eq 'sensor' );
|
||||
$list .= 'manualDurationValve1:slider,1,1,59 manualDurationValve2:slider,1,1,59 manualDurationValve3:slider,1,1,59 manualDurationValve4:slider,1,1,59 manualDurationValve5:slider,1,1,59 manualDurationValve6:slider,1,1,59' if( AttrVal($name,'model','unknown') eq 'ic24' );
|
||||
$list .= 'refresh:temperature,light,humidity' if( AttrVal($name,'model','unknown') eq 'sensor' );
|
||||
|
||||
return "Unknown argument $cmd, choose one of $list";
|
||||
}
|
||||
|
||||
$abilities = 'mower' if( AttrVal($name,'model','unknown') eq 'mower' ) and $abilities ne 'mower_settings';
|
||||
$abilities = 'outlet' if( AttrVal($name,'model','unknown') eq 'watering_computer' );
|
||||
$abilities = 'watering' if( AttrVal($name,'model','unknown') eq 'ic24' );
|
||||
|
||||
|
||||
$hash->{helper}{deviceAction} = $payload;
|
||||
@ -281,7 +296,7 @@ sub GardenaSmartDevice_Parse($$) {
|
||||
}
|
||||
|
||||
Log3 $name, 4, "GardenaSmartDevice ($name) - ParseFn was called";
|
||||
Log3 $name, 5, "GardenaSmartDevice ($name) - JSON: $json";
|
||||
Log3 $name, 4, "GardenaSmartDevice ($name) - JSON: $json";
|
||||
|
||||
|
||||
if( defined($decode_json->{id}) ) {
|
||||
@ -326,7 +341,8 @@ sub GardenaSmartDevice_WriteReadings($$) {
|
||||
and $decode_json->{abilities}[$abilities]{name}.'-'.$propertie->{name} ne 'ambient_temperature-temperature'
|
||||
and $decode_json->{abilities}[$abilities]{name}.'-'.$propertie->{name} ne 'soil_temperature-temperature'
|
||||
and $decode_json->{abilities}[$abilities]{name}.'-'.$propertie->{name} ne 'humidity-humidity'
|
||||
and $decode_json->{abilities}[$abilities]{name}.'-'.$propertie->{name} ne 'light-light' );
|
||||
and $decode_json->{abilities}[$abilities]{name}.'-'.$propertie->{name} ne 'light-light'
|
||||
and ref($propertie->{value}) ne "HASH" );
|
||||
|
||||
readingsBulkUpdate($hash,$decode_json->{abilities}[$abilities]{name}.'-'.$propertie->{name},GardenaSmartDevice_RigRadingsValue($hash,$propertie->{value})) if( defined($propertie->{value})
|
||||
and ($decode_json->{abilities}[$abilities]{name}.'-'.$propertie->{name} eq 'radio-quality'
|
||||
@ -336,6 +352,16 @@ sub GardenaSmartDevice_WriteReadings($$) {
|
||||
or $decode_json->{abilities}[$abilities]{name}.'-'.$propertie->{name} eq 'soil_temperature-temperature'
|
||||
or $decode_json->{abilities}[$abilities]{name}.'-'.$propertie->{name} eq 'humidity-humidity'
|
||||
or $decode_json->{abilities}[$abilities]{name}.'-'.$propertie->{name} eq 'light-light') );
|
||||
|
||||
readingsBulkUpdateIfChanged($hash,$decode_json->{abilities}[$abilities]{name}.'-'.$propertie->{name},join(',',@{$propertie->{value}})) if( defined($propertie->{value}) and $decode_json->{abilities}[$abilities]{name}.'-'.$propertie->{name} eq 'ic24-valves_connected' );
|
||||
|
||||
readingsBulkUpdateIfChanged($hash,$decode_json->{abilities}[$abilities]{name}.'-'.$propertie->{name},join(',',@{$propertie->{value}})) if( defined($propertie->{value}) and $decode_json->{abilities}[$abilities]{name}.'-'.$propertie->{name} eq 'ic24-valves_master_config' );
|
||||
|
||||
if( ref($propertie->{value}) eq "HASH" ) {
|
||||
while( my ($r,$v) = each %{$propertie->{value}} ) {
|
||||
readingsBulkUpdate($hash,$decode_json->{abilities}[$abilities]{name}.'-'.$propertie->{name}.'_'.$r,GardenaSmartDevice_RigRadingsValue($hash,$v));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -368,6 +394,8 @@ sub GardenaSmartDevice_WriteReadings($$) {
|
||||
readingsBulkUpdate($hash,'state',(ReadingsVal($name,'outlet-valve_open','readingsValError') == 1 ? GardenaSmartDevice_RigRadingsValue($hash,'open') : GardenaSmartDevice_RigRadingsValue($hash,'closed'))) if( AttrVal($name,'model','unknown') eq 'watering_computer' );
|
||||
|
||||
readingsBulkUpdate($hash,'state','T: ' . ReadingsVal($name,'ambient_temperature-temperature','readingsValError') . '°C, H: ' . ReadingsVal($name,'humidity-humidity','readingsValError') . '%, L: ' . ReadingsVal($name,'light-light','readingsValError') . 'lux') if( AttrVal($name,'model','unknown') eq 'sensor' );
|
||||
|
||||
readingsBulkUpdate($hash,'state','scheduled watering next start: ' . (ReadingsVal($name,'scheduling-scheduled_watering_next_start','readingsValError'))) if( AttrVal($name,'model','unknown') eq 'ic24' );
|
||||
|
||||
readingsEndUpdate( $hash, 1 );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user