├── CHANGED ├── FHEM ├── 48_HomeConnect.pm └── 48_HomeConnectConnection.pm ├── LICENSE ├── README.md └── controls_homeconnect.txt /CHANGED: -------------------------------------------------------------------------------- 1 | Aug 22, 2018 2 | Support new client secret API feature 3 | Support stateFormat attribute for appliance devices 4 | 5 | May 5, 2018 6 | Bug fixes from Schlimbo 7 | -add a "disabled" attribute 8 | -FHEM no longer stops responding in certain Home Connect scenarios 9 | -Fix changing settings when values are non numeric 10 | 11 | Mar 21, 2018 Version 1.0 12 | fixed simulator mode (API URL had changed) 13 | longer timeouts for synchronous API requests to improve work with slow simulator 14 | quicker processing of appliance status changes (important for ovens and coffee makers) 15 | fixed setting of non-numeric program options 16 | changed model of starting programs, first select program, then check options and start 17 | 18 | Jan 25, 2018 19 | fix handling of refresh token 20 | 21 | Jan 21, 2018 22 | Added error handling for invalid JSON strings 23 | 24 | Aug 2, 2017 25 | Fixed a Perl warning, thanks to n8falke.de 26 | Fixed handling of event stream http errors 27 | Write less log messages in default levels 28 | Fixed exception handling when logging in 29 | 30 | Jun 19, 2017 31 | More debug logging and improved event stream connection retry handling 32 | 33 | Jun 12, 2017 34 | Add state reading and more documentation to HomeConnectConnection 35 | 36 | Jun 07, 2017 37 | Added a increasing delay when trying to reconnect to the Home Connect event stream 38 | Removed the "found nothing to read, channel closed" message hoping that the keep-alive works better detecting a missing connection 39 | 40 | Nov 29, 2016 41 | Added reading and updating of appliance settings 42 | Improved event stream reading 43 | 44 | Nov 28, 2016 45 | Added this CHANGED file 46 | 47 | Nov 21, 2016 48 | Added timeout feature to check for missing keep alive messages 49 | 50 | Nov 20, 2016 51 | Improved logging, fixed some warnings 52 | 53 | Nov 18, 2016 54 | Added controls file for FHEM update 55 | 56 | Nov 15, 2016 57 | Fix crash when event channel does not open 58 | Show error messages when program start does not work 59 | 60 | Nov 3, 2016 61 | Added new attribute accessScope to setup access rights 62 | Display error messages after failed Home Connect logon 63 | 64 | Nov 1, 2016 65 | Documentation update 66 | 67 | Oct 31, 2016 68 | First commit 69 | -------------------------------------------------------------------------------- /FHEM/48_HomeConnect.pm: -------------------------------------------------------------------------------- 1 | =head1 2 | 48_HomeConnect.pm 3 | 4 | Version 1.1 5 | 6 | =head1 SYNOPSIS 7 | Bosch Siemens Home Connect Modul for FHEM 8 | contributed by Stefan Willmeroth 09/2016 9 | 10 | =head1 DESCRIPTION 11 | 98_HomeConnect handle individual Home Connect devices via the 12 | 96_HomeConnectConnection 13 | 14 | =head1 AUTHOR - Stefan Willmeroth 15 | swi@willmeroth.com (forum.fhem.de) 16 | =cut 17 | 18 | package main; 19 | 20 | use strict; 21 | use warnings; 22 | use JSON; 23 | use Switch; 24 | use Scalar::Util qw(looks_like_number); 25 | 26 | use vars qw(%defs); 27 | require 'HttpUtils.pm'; 28 | 29 | ############################################## 30 | my %HomeConnect_Iconmap = ( 31 | "Dishwasher" => "scene_dishwasher", 32 | "Oven" => "scene_baking_oven", 33 | "FridgeFreezer" => "scene_wine_cellar", #fixme 34 | "Washer" => "scene_washing_machine", 35 | "Dryer" => "scene_clothes_dryer", 36 | "CoffeeMaker" => "max_heizungsthermostat" #fixme 37 | ); 38 | 39 | my @HomeConnect_SettablePgmOptions = ( 40 | "BSH.Common.Option.StartInRelative", 41 | "Cooking.Oven.Option.SetpointTemperature", 42 | "ConsumerProducts.CoffeeMaker.Option.FillQuantity", 43 | "ConsumerProducts.CoffeeMaker.Option.BeanAmount", 44 | "ConsumerProducts.CoffeeMaker.Option.CoffeeTemperature" 45 | ); 46 | 47 | ############################################## 48 | sub HomeConnect_Initialize($) 49 | { 50 | my ($hash) = @_; 51 | 52 | $hash->{SetFn} = "HomeConnect_Set"; 53 | $hash->{DefFn} = "HomeConnect_Define"; 54 | $hash->{GetFn} = "HomeConnect_Get"; 55 | $hash->{AttrList} = "disable:0,1 " . 56 | "updateTimer " . 57 | "stateFormat " . 58 | $readingFnAttributes; 59 | return; 60 | } 61 | 62 | ################################### 63 | sub HomeConnect_Set($@) 64 | { 65 | my ($hash, @a) = @_; 66 | my $reDOUBLE = '^(\\d+\\.?\\d{0,2})$'; 67 | my $JSON = JSON->new->utf8(0)->allow_nonref; 68 | 69 | my $haId = $hash->{haId}; 70 | my $cmdPrefix = $hash->{commandPrefix}; 71 | my $programs = $hash->{programs}; 72 | 73 | if (!defined($programs)) {$programs="";} 74 | 75 | my $remoteStartAllowed = ReadingsVal($hash->{NAME}, "BSH.Common.Status.RemoteControlStartAllowed","0"); 76 | my $operationState = ReadingsVal($hash->{NAME}, "BSH.Common.Status.OperationState","0"); 77 | 78 | my $pgmRunning =($operationState eq "BSH.Common.EnumType.OperationState.Active" || 79 | $operationState eq "BSH.Common.EnumType.OperationState.DelayedStart" || 80 | $operationState eq "BSH.Common.EnumType.OperationState.Run"); 81 | 82 | my $availableCmds; 83 | my $availableOpts=""; 84 | my $availableSets=""; 85 | 86 | if (defined($hash->{READINGS})) { 87 | foreach my $reading (keys %{$hash->{READINGS}}) { 88 | if (index ($reading,".Option.")>0 && grep( /^$reading$/, @HomeConnect_SettablePgmOptions )) { 89 | $availableOpts .= " ".$reading; 90 | } 91 | if (index ($reading,".Setting.")>0) { 92 | $availableSets .= " ".$reading; 93 | } 94 | } 95 | } 96 | 97 | if (!defined $hash->{type}) { 98 | if (Value($hash->{hcconn}) ne "Logged in") { 99 | $availableCmds = "init"; 100 | } 101 | } else { 102 | if ($pgmRunning) { 103 | $availableCmds = "stopProgram"; 104 | } elsif ($remoteStartAllowed) { 105 | $availableCmds = "startProgram"; 106 | } 107 | $availableCmds.=" requestSettings BSH.Common.Root.SelectedProgram:$programs requestProgramOptions:$programs"; 108 | $availableCmds.=$availableOpts if (length($availableOpts)>0); 109 | $availableCmds.=$availableSets if (length($availableSets)>0); 110 | } 111 | 112 | return "no set value specified" if(int(@a) < 2); 113 | return $availableCmds if($a[1] eq "?"); 114 | 115 | shift @a; 116 | my $command = shift @a; 117 | 118 | Log3 $hash->{NAME}, 3, "$hash->{NAME}: set command: $command"; 119 | 120 | ## Start a program 121 | if($command eq "startProgram") { 122 | return "A program is already running" if ($pgmRunning); 123 | 124 | return "Please enable remote start on your appliance to start a program" if (!$remoteStartAllowed); 125 | 126 | my $pgm = shift @a; 127 | if (!defined $pgm) { 128 | $pgm = ReadingsVal($hash->{NAME},"BSH.Common.Root.SelectedProgram",undef); 129 | } 130 | if (!defined $pgm || index($programs,$pgm) == -1) { 131 | return "Unknown program - choose one of $programs"; 132 | } 133 | 134 | my $options=""; 135 | foreach my $key ( @HomeConnect_SettablePgmOptions ) { 136 | my $optval = ReadingsVal($hash->{NAME},$key,undef); 137 | if (defined $optval) { 138 | my @a = split("[ \t][ \t]*", $optval); 139 | $options .= "," if (length($options)>0); 140 | if (looks_like_number($a[0])) { 141 | $options .= "{\"key\":\"$key\",\"value\":$a[0]"; 142 | } else { 143 | $options .= "{\"key\":\"$key\",\"value\":\"$a[0]\""; 144 | } 145 | $options .= ",\"unit\":\"$a[1]\"" if defined $a[1]; 146 | $options .= "}"; 147 | } 148 | } 149 | # start a program 150 | my $data = { 151 | callback => \&HomeConnect_Response, 152 | uri => "/api/homeappliances/$haId/programs/active", 153 | data => "{\"data\":{\"key\":\"$cmdPrefix$pgm\",\"options\":[$options]}}" 154 | }; 155 | HomeConnectConnection_request($hash, $data); 156 | } 157 | ## Stop current program 158 | if($command eq "stopProgram") { 159 | return "No program is running" if (!$pgmRunning); 160 | my $data = { 161 | callback => \&HomeConnect_Response, 162 | uri => "/api/homeappliances/$haId/programs/active" 163 | }; 164 | HomeConnectConnection_delrequest($hash, $data); 165 | } 166 | ## Set options, update current program if needed 167 | if(index($availableOpts,$command)>-1) { 168 | my $optval = shift @a; 169 | my $optunit = shift @a; 170 | if (!defined $optval) { 171 | return "Please enter a new option value"; 172 | } 173 | my $newreading = $optval; 174 | $newreading .= " ".$optunit if (defined $optunit); 175 | readingsBeginUpdate($hash); 176 | readingsBulkUpdate($hash, $command, $newreading); 177 | readingsEndUpdate($hash, 1); 178 | 179 | if ($pgmRunning) { 180 | my $json = "{\"data\":{\"key\":\"$command\",\"value\":$optval"; 181 | $json .= ",\"unit\":\"$optunit\"" if (defined $optunit); 182 | $json .= "}}"; 183 | # set option 184 | my $data = { 185 | callback => \&HomeConnect_Response, 186 | uri => "/api/homeappliances/$haId/programs/active/options/$command", 187 | data => $json 188 | }; 189 | HomeConnectConnection_request($hash, $data); 190 | } 191 | 192 | } 193 | ## Change settings 194 | if(index($availableSets,$command)>-1) { 195 | my $setval = shift @a; 196 | my $setunit = shift @a; 197 | if (!defined $setval) { 198 | return "Please enter a new setting value"; 199 | } 200 | $setval = "\"$setval\"" if (!looks_like_number($setval)); 201 | # workaround: fix booleans 202 | $setval = "1" eq $setval ? "true":"false" if (!defined $setunit && ("0" eq $setval || "1" eq $setval)); 203 | 204 | # send the update 205 | my $json = "{\"data\":{\"key\":\"$command\",\"value\":$setval"; 206 | $json .= ",\"unit\":\"$setunit\"" if (defined $setunit); 207 | $json .= "}}"; 208 | my $data = { 209 | callback => \&HomeConnect_Response, 210 | uri => "/api/homeappliances/$haId/settings/$command", 211 | data => $json 212 | }; 213 | HomeConnectConnection_request($hash,$data); 214 | } 215 | ## Connect to Home Connect server, update status 216 | if($command eq "init") { 217 | return HomeConnect_Init($hash); 218 | } 219 | ## Select a program 220 | if($command eq "BSH.Common.Root.SelectedProgram") { 221 | my $pgm = shift @a; 222 | if (!defined $pgm || index($programs,$pgm) == -1) { 223 | return "Unknown program $pgm, choose one of $programs"; 224 | } 225 | 226 | my $cmdPrefix = $hash->{commandPrefix}; 227 | my $data = { 228 | callback => \&HomeConnect_Response, 229 | uri => "/api/homeappliances/$haId/programs/selected", 230 | data => "{\"data\":{\"key\":\"$cmdPrefix$pgm\"}}" 231 | }; 232 | HomeConnectConnection_request($hash,$data); 233 | } 234 | ## Request options for selected program 235 | if($command eq "requestProgramOptions") { 236 | my $pgm = shift @a; 237 | if (!defined $pgm || index($programs,$pgm) == -1) { 238 | return "Unknown program - choose one of $programs"; 239 | } 240 | HomeConnect_GetProgramOptions($hash,$pgm); 241 | } 242 | ## Request appliance settings 243 | if($command eq "requestSettings") { 244 | HomeConnect_GetSettings($hash); 245 | HomeConnect_GetPrograms($hash); 246 | } 247 | } 248 | 249 | ##################################### 250 | sub HomeConnect_Response() 251 | { 252 | my ($hash, $data) = @_; 253 | if (defined $data && length ($data) >0) { 254 | Log3 $hash->{NAME}, 4, "$hash->{NAME}: response $data"; 255 | 256 | my $JSON = JSON->new->utf8(0)->allow_nonref; 257 | my $parsed = eval {$JSON->decode($data)}; 258 | if($@){ 259 | Log3 $hash->{NAME}, 2, "$hash->{NAME}: JSON error: $@"; 260 | return; 261 | } 262 | } 263 | } 264 | 265 | ##################################### 266 | sub HomeConnect_Define($$) 267 | { 268 | my ($hash, $def) = @_; 269 | my @a = split("[ \t][ \t]*", $def); 270 | 271 | my $u = "wrong syntax: define HomeConnect to add appliances"; 272 | 273 | return $u if(int(@a) < 4); 274 | 275 | $hash->{hcconn} = $a[2]; 276 | $hash->{haId} = $a[3]; 277 | 278 | #### Delay init if not yet connected 279 | return undef if(Value($hash->{hcconn}) ne "Logged in"); 280 | 281 | return HomeConnect_Init($hash); 282 | } 283 | 284 | ##################################### 285 | sub HomeConnect_Init($) 286 | { 287 | #### Read list of appliances, find my haId 288 | my ($hash) = @_; 289 | my $data = { 290 | callback => \&HomeConnect_ResponseInit, 291 | uri => "/api/homeappliances" 292 | }; 293 | HomeConnectConnection_request($hash,$data); 294 | } 295 | 296 | ##################################### 297 | sub HomeConnect_ResponseInit 298 | { 299 | my ($hash, $data) = @_; 300 | my $JSON = JSON->new->utf8(0)->allow_nonref; 301 | 302 | if (!defined $data) { 303 | return "Failed to connect to HomeConnect API, see log for details"; 304 | } 305 | 306 | Log3 $hash->{NAME}, 4, "$hash->{NAME}: init response $data"; 307 | 308 | my $appliances = eval {$JSON->decode ($data)}; 309 | if($@){ 310 | Log3 $hash->{NAME}, 2, "$hash->{NAME}: JSON error requesting appliances: $@"; 311 | return; 312 | } 313 | 314 | for (my $i = 0; 1; $i++) { 315 | my $appliance = $appliances->{data}->{homeappliances}[$i]; 316 | if (!defined $appliance) { last }; 317 | if ($hash->{haId} eq $appliance->{haId}) { 318 | $hash->{aliasname} = $appliance->{name}; 319 | $hash->{type} = $appliance->{type}; 320 | $hash->{brand} = $appliance->{brand}; 321 | $hash->{vib} = $appliance->{vib}; 322 | $hash->{connected} = $appliance->{connected}; 323 | Log3 $hash->{NAME}, 3, "$hash->{NAME}: defined as HomeConnect $hash->{type} $hash->{brand} $hash->{vib}"; 324 | 325 | my $icon = $HomeConnect_Iconmap{$appliance->{type}}; 326 | 327 | $attr{$hash->{NAME}}{icon} = $icon if (!defined $attr{$hash->{NAME}}{icon} && defined $icon); 328 | $attr{$hash->{NAME}}{alias} = $hash->{aliasname} if (!defined $attr{$hash->{NAME}}{alias} && defined $hash->{aliasname}); 329 | $attr{$hash->{NAME}}{webCmd} = "BSH.Common.Root.SelectedProgram:startProgram:stopProgram" 330 | if (!defined $attr{$hash->{NAME}}{webCmd} && "FridgeFreezer" ne $hash->{type}); 331 | 332 | HomeConnect_GetPrograms($hash); 333 | HomeConnect_UpdateStatus($hash); 334 | RemoveInternalTimer($hash); 335 | HomeConnect_CloseEventChannel($hash); 336 | HomeConnect_Timer($hash); 337 | return; 338 | } 339 | } 340 | Log3 $hash->{NAME}, 3, "$hash->{NAME}: Specified appliance with haId $hash->{haId} not found"; 341 | } 342 | 343 | ##################################### 344 | sub HomeConnect_Undef($$) 345 | { 346 | my ( $hash, $arg ) = @_; 347 | 348 | RemoveInternalTimer($hash); 349 | HomeConnect_CloseEventChannel($hash); 350 | Log3 $hash->{NAME}, 3, "$hash->{NAME}: --- removed ---"; 351 | return undef; 352 | } 353 | 354 | ##################################### 355 | sub HomeConnect_Get($@) 356 | { 357 | my ($hash, @args) = @_; 358 | 359 | return 'HomeConnect_Get needs two arguments' if (@args != 2); 360 | 361 | my $get = $args[1]; 362 | my $val = $hash->{Invalid}; 363 | 364 | return "HomeConnect_Get: not supported"; 365 | } 366 | 367 | ##################################### 368 | sub HomeConnect_Timer 369 | { 370 | my ($hash) = @_; 371 | my $name = $hash->{NAME}; 372 | 373 | my $updateTimer = AttrVal($name, "updateTimer", 5); 374 | 375 | if (defined $hash->{conn} and AttrVal($name, "disable", 0) == 0) { 376 | HomeConnect_ReadEventChannel($hash); 377 | } 378 | # check if still connected 379 | if (!defined $hash->{conn} and AttrVal($name, "disable", 0) == 0) { 380 | # a new connection attempt is needed 381 | my $retryCounter = defined($hash->{retrycounter}) ? $hash->{retrycounter} : 0; 382 | if ($retryCounter == 0) { 383 | # first try 384 | HomeConnect_ConnectEventChannel($hash); 385 | InternalTimer( gettimeofday() + $updateTimer, "HomeConnect_Timer", $hash, 0); 386 | } else { 387 | # add an extra wait time 388 | InternalTimer( gettimeofday() + (($retryCounter) * 300), "HomeConnect_WaitTimer", $hash, 0); 389 | } 390 | $retryCounter++; 391 | $hash->{retrycounter} = $retryCounter; 392 | } else { 393 | # all good 394 | InternalTimer( gettimeofday() + $updateTimer, "HomeConnect_Timer", $hash, 0); 395 | } 396 | } 397 | 398 | ##################################### 399 | sub HomeConnect_WaitTimer 400 | { 401 | my ($hash) = @_; 402 | my $name = $hash->{NAME}; 403 | 404 | my $updateTimer = AttrVal($name, "updateTimer", 10); 405 | 406 | if (!defined $hash->{conn}) { 407 | # a new connection attempt is needed 408 | HomeConnect_ConnectEventChannel($hash); 409 | } 410 | InternalTimer( gettimeofday() + $updateTimer, "HomeConnect_Timer", $hash, 0); 411 | } 412 | 413 | ##################################### 414 | sub HomeConnect_GetProgramOptions 415 | { 416 | my ($hash, $program) = @_; 417 | 418 | my $haId = $hash->{haId}; 419 | my $cmdPrefix = $hash->{commandPrefix}; 420 | 421 | my $data = { 422 | callback => \&HomeConnect_ResponseGetProgramOptions, 423 | uri => "/api/homeappliances/$haId/programs/available/$cmdPrefix$program" 424 | }; 425 | HomeConnectConnection_request($hash, $data); 426 | } 427 | 428 | ##################################### 429 | sub HomeConnect_ResponseGetProgramOptions 430 | { 431 | my ($hash, $json) = @_; 432 | 433 | if (defined $json) { 434 | Log3 $hash->{NAME}, 4, "$hash->{NAME}: program options response $json"; 435 | 436 | my $JSON = JSON->new->utf8(0)->allow_nonref; 437 | my $parsed = eval {$JSON->decode ($json)}; 438 | if($@){ 439 | Log3 $hash->{NAME}, 2, "$hash->{NAME}: JSON error requesting options: $@"; 440 | } else { 441 | my %readings = (); 442 | HomeConnect_parseOptionsToHash2(\%readings,$parsed); 443 | 444 | readingsBeginUpdate($hash); 445 | for my $get (keys %readings) { 446 | readingsBulkUpdate($hash, $get, $readings{$get}); 447 | } 448 | readingsEndUpdate($hash, 1); 449 | } 450 | } 451 | } 452 | 453 | ##################################### 454 | sub HomeConnect_GetSettings 455 | { 456 | my ($hash, $program) = @_; 457 | my $data = { 458 | callback => \&HomeConnect_ResponseGetSettings, 459 | uri => "/api/homeappliances/$hash->{haId}/settings" 460 | }; 461 | HomeConnectConnection_request($hash,$data); 462 | } 463 | 464 | ##################################### 465 | sub HomeConnect_ResponseGetSettings 466 | { 467 | my ($hash, $json) = @_; 468 | 469 | if (defined $json) { 470 | Log3 $hash->{NAME}, 4, "$hash->{NAME}: get settings response $json"; 471 | my $JSON = JSON->new->utf8(0)->allow_nonref; 472 | my $parsed = eval {$JSON->decode ($json)}; 473 | if($@){ 474 | Log3 $hash->{NAME}, 2, "$hash->{NAME}: JSON error requesting settings: $@"; 475 | } else { 476 | my %readings = (); 477 | HomeConnect_parseSettingsToHash(\%readings,$parsed); 478 | 479 | readingsBeginUpdate($hash); 480 | for my $get (keys %readings) { 481 | readingsBulkUpdate($hash, $get, $readings{$get}); 482 | } 483 | readingsEndUpdate($hash, 1); 484 | }; 485 | } 486 | } 487 | 488 | ##################################### 489 | sub HomeConnect_GetPrograms 490 | { 491 | my ($hash) = @_; 492 | 493 | my $operationState = ReadingsVal($hash->{NAME},"BSH.Common.Status.OperationState",""); 494 | my $activeProgram = ReadingsVal($hash->{NAME},"BSH.Common.Root.ActiveProgram",undef); 495 | 496 | if ($operationState eq "BSH.Common.EnumType.OperationState.Active" || 497 | $operationState eq "BSH.Common.EnumType.OperationState.DelayedStart" || 498 | $operationState eq "BSH.Common.EnumType.OperationState.Run") { 499 | if (defined $activeProgram) { 500 | #### Currently we dont get a list of programs if a program is active, so we just use the active program name 501 | my $prefix = HomeConnect_checkPrefix(undef, $activeProgram); 502 | my $prefixLen = length $prefix; 503 | $hash->{commandPrefix} = $prefix; 504 | $hash->{programs} = substr($activeProgram, $prefixLen); 505 | } 506 | return; 507 | } 508 | 509 | #### Request available programs 510 | my $data = { 511 | callback => \&HomeConnect_ResponseGetPrograms, 512 | uri => "/api/homeappliances/$hash->{haId}/programs/available" 513 | }; 514 | HomeConnectConnection_request($hash,$data); 515 | } 516 | 517 | ##################################### 518 | sub HomeConnect_ResponseGetPrograms 519 | { 520 | my ($hash, $json) = @_; 521 | 522 | if (defined $json) { 523 | Log3 $hash->{NAME}, 4, "$hash->{NAME}: get programs response $json"; 524 | 525 | my $JSON = JSON->new->utf8(0)->allow_nonref; 526 | my $parsed = eval {$JSON->decode ($json)}; 527 | if($@){ 528 | Log3 $hash->{NAME}, 2, "$hash->{NAME}: JSON error requesting programs: $@"; 529 | } else { 530 | my %readings = (); 531 | my @pgms = (); 532 | my $prefix; 533 | for (my $i = 0; 1; $i++) { 534 | my $programline = $parsed->{data}->{programs}[$i]; 535 | if (!defined $programline) { last }; 536 | push (@pgms, $programline->{key}); 537 | $prefix = HomeConnect_checkPrefix($prefix, $programline->{key}); 538 | } 539 | #### command beautyfication: remove a common prefix 540 | my $prefixLen = length $prefix; 541 | my $programs = ""; 542 | foreach my $program (@pgms) { 543 | if ($programs ne "") { 544 | $programs .= ","; 545 | } 546 | $programs .= substr($program, $prefixLen); 547 | } 548 | $hash->{commandPrefix} = $prefix; 549 | $hash->{programs} = $programs; 550 | }; 551 | } 552 | } 553 | 554 | ##################################### 555 | sub HomeConnect_checkPrefix 556 | { 557 | my ($prefix, $value) = @_; 558 | 559 | if (!defined $prefix) { 560 | $value =~ /(.*)\..*$/; 561 | return $1."."; 562 | } else { 563 | for (my $i=0; $i < length $value; $i++) { 564 | if (substr($prefix, $i, 1) ne substr($value, $i, 1)) { 565 | return substr($prefix, 0, $i); 566 | } 567 | } 568 | return $value; 569 | } 570 | } 571 | 572 | ##################################### 573 | sub HomeConnect_parseOptionsToHash 574 | { 575 | my ($hash, $parsed) = @_; 576 | my %options = (); 577 | 578 | for (my $i = 0; 1; $i++) { 579 | my $optionsline = $parsed->{data}->{options}[$i]; 580 | if (!defined $optionsline) { last }; 581 | my $key = $optionsline->{key}; 582 | # $key =~ tr/\\./_/; 583 | $options{ $key } = "$optionsline->{value} $optionsline->{unit}"; 584 | Log3 $hash->{NAME}, 4, "$hash->{NAME}: $key = $optionsline->{value} $optionsline->{unit}"; 585 | } 586 | return \%options; 587 | } 588 | 589 | ##################################### 590 | sub HomeConnect_parseOptionsToHash2 591 | { 592 | my ($hash,$parsed) = @_; 593 | 594 | for (my $i = 0; 1; $i++) { 595 | my $optionsline = $parsed->{data}->{options}[$i]; 596 | if (!defined $optionsline) { last }; 597 | my $key = $optionsline->{key}; 598 | # $key =~ tr/\\./_/; 599 | $hash->{$key} = "$optionsline->{value}" if (defined $optionsline->{value}); 600 | $hash->{$key} .= " $optionsline->{unit}" if (defined $optionsline->{unit}); 601 | # Log3 $hash->{NAME}, 4, "$hash->{NAME}: $key = $optionsline->{value} $optionsline->{unit}"; 602 | } 603 | } 604 | 605 | ##################################### 606 | sub HomeConnect_parseSettingsToHash 607 | { 608 | my ($hash,$parsed) = @_; 609 | 610 | for (my $i = 0; 1; $i++) { 611 | my $optionsline = $parsed->{data}->{settings}[$i]; 612 | if (!defined $optionsline) { last }; 613 | my $key = $optionsline->{key}; 614 | $hash->{$key} = "$optionsline->{value}" if (defined $optionsline->{value}); 615 | $hash->{$key} .= " $optionsline->{unit}" if (defined $optionsline->{unit}); 616 | } 617 | } 618 | 619 | ##################################### 620 | sub HomeConnect_ShortenKey 621 | { 622 | my ($key) = @_; 623 | my ($b,$c) = $a =~ m|^(.*[\.])([^\.]+?)$|; 624 | return $c; 625 | } 626 | 627 | ##################################### 628 | sub HomeConnect_UpdateStatus 629 | { 630 | my ($hash) = @_; 631 | 632 | #### Get status variables 633 | my $data = { 634 | callback => \&HomeConnect_ResponseUpdateStatus, 635 | uri => "/api/homeappliances/$hash->{haId}/status" 636 | }; 637 | my $json = HomeConnectConnection_request($hash,$data); 638 | } 639 | 640 | ##################################### 641 | sub HomeConnect_ResponseUpdateStatus 642 | { 643 | my ($hash, $json) = @_; 644 | if (!defined $json) { 645 | # no status available 646 | return; 647 | } 648 | 649 | Log3 $hash->{NAME}, 4, "$hash->{NAME}: status response $json"; 650 | 651 | my $JSON = JSON->new->utf8(0)->allow_nonref; 652 | my $parsed = eval{$JSON->decode ($json)}; 653 | if($@){ 654 | Log3 $hash->{NAME}, 2, "$hash->{NAME}: JSON error requesting status: $@"; 655 | return; 656 | } 657 | 658 | my %readings = (); 659 | for (my $i = 0; 1; $i++) { 660 | my $statusline = $parsed->{data}->{status}[$i]; 661 | if (!defined $statusline) { last }; 662 | $readings{$statusline->{key}} = $statusline->{value}; 663 | $readings{$statusline->{key}}.=" ".$statusline->{unit} if defined $statusline->{unit}; 664 | } 665 | 666 | if ($parsed->{error}) { 667 | if (defined $parsed->{error}->{description}) { 668 | if ($parsed->{error}->{description} =~ m/.*offline.*/) { 669 | $readings{"state"} = "Offline" if ($hash->{STATE} ne "Offline"); 670 | $hash->{STATE} = "Offline"; 671 | } 672 | } 673 | } 674 | 675 | my $operationState = $readings{"BSH.Common.Status.OperationState"}; 676 | my $pgmRunning = defined $operationState && 677 | ($operationState eq "BSH.Common.EnumType.OperationState.Active" || 678 | $operationState eq "BSH.Common.EnumType.OperationState.DelayedStart" || 679 | $operationState eq "BSH.Common.EnumType.OperationState.Run" 680 | ); 681 | 682 | #### Update Readings 683 | readingsBeginUpdate($hash); 684 | for my $get (keys %readings) { 685 | readingsBulkUpdate($hash, $get, $readings{$get}); 686 | } 687 | readingsEndUpdate($hash, 1); 688 | 689 | if ($pgmRunning) { 690 | #### Check for a running program 691 | HomeConnect_CheckProgram($hash); 692 | } 693 | } 694 | 695 | ##################################### 696 | sub HomeConnect_CheckProgram 697 | { 698 | my ($hash) = @_; 699 | 700 | #### Get status variables 701 | my $data = { 702 | callback => \&HomeConnect_ResponseCheckProgram, 703 | uri => "/api/homeappliances/$hash->{haId}/programs/active" 704 | }; 705 | HomeConnectConnection_request($hash,$data); 706 | } 707 | 708 | ##################################### 709 | sub HomeConnect_ResponseCheckProgram 710 | { 711 | my ($hash, $json) = @_; 712 | my %readings = (); 713 | 714 | if (!defined $json) { 715 | # no program running 716 | $readings{state} = "Idle"; 717 | $readings{"BSH.Common.Root.ActiveProgram"} = "None"; 718 | $readings{"BSH.Common.Option.RemainingProgramTime"} = "0 seconds"; 719 | $readings{"BSH.Common.Option.ProgramProgress"} = "0 %"; 720 | } else { 721 | Log3 $hash->{NAME}, 4, "$hash->{NAME}: program response $json"; 722 | 723 | my $JSON = JSON->new->utf8(0)->allow_nonref; 724 | my $parsed = eval {$JSON->decode ($json)}; 725 | if($@){ 726 | Log3 $hash->{NAME}, 2, "$hash->{NAME}: JSON error requesting status: $@"; 727 | } else { 728 | $readings{"BSH.Common.Root.ActiveProgram"} = $parsed->{data}->{key}; 729 | HomeConnect_parseOptionsToHash2(\%readings,$parsed); 730 | 731 | $readings{state} = "Program active"; 732 | 733 | $readings{state} .= " (".$readings{"BSH.Common.Option.ProgramProgress"} .")" if defined $readings{"BSH.Common.Option.ProgramProgress"}; 734 | }; 735 | } 736 | 737 | #### Update Readings 738 | readingsBeginUpdate($hash); 739 | for my $get (keys %readings) { 740 | readingsBulkUpdate($hash, $get, $readings{$get}); 741 | } 742 | readingsEndUpdate($hash, 1); 743 | } 744 | 745 | ##################################### 746 | sub HomeConnect_ConnectEventChannel 747 | { 748 | my ($hash) = @_; 749 | my $haId = $hash->{haId}; 750 | my $api_uri = $defs{$hash->{hcconn}}->{api_uri}; 751 | 752 | my $param = { 753 | url => "$api_uri/api/homeappliances/$haId/events", 754 | hash => $hash, 755 | timeout => 10, 756 | noshutdown => 1, 757 | noConn2 => 1, 758 | httpversion=> "1.1", 759 | keepalive => 1, 760 | callback => \&HomeConnect_HttpConnected 761 | }; 762 | 763 | Log3 $hash->{NAME}, 5, "$hash->{NAME}: connecting to event channel"; 764 | 765 | HttpUtils_NonblockingGet($param); 766 | 767 | } 768 | 769 | ##################################### 770 | sub HomeConnect_HttpConnected 771 | { 772 | my ($param, $err, $data) = @_; 773 | my $hash = $param->{hash}; 774 | my $name = $hash->{NAME}; 775 | 776 | # this is a callback used by HttpUtils_NonblockingGet 777 | # it will be called after the http socket connection has been opened 778 | # and handles the http protocol part. 779 | 780 | # make sure we're really connected 781 | if (!defined $param->{conn}) { 782 | HomeConnect_CloseEventChannel($hash); 783 | return; 784 | } 785 | 786 | my ($gterror, $token) = getKeyValue($hash->{hcconn}."_accessToken"); 787 | my $method = $param->{method}; 788 | $method = ($data ? "POST" : "GET") if( !$method ); 789 | 790 | my $httpVersion = $param->{httpversion} ? $param->{httpversion} : "1.0"; 791 | my $hdr = "$method $param->{path} HTTP/$httpVersion\r\n"; 792 | $hdr .= "Host: $param->{host}\r\n"; 793 | $hdr .= "User-Agent: fhem\r\n" if(!$param->{header} || $param->{header} !~ "User-Agent:"); 794 | $hdr .= "Accept: text/event-stream\r\n"; 795 | $hdr .= "Accept-Encoding: gzip,deflate\r\n" if($param->{compress}); 796 | $hdr .= "Connection: keep-alive\r\n" if($param->{keepalive}); 797 | $hdr .= "Connection: Close\r\n" if($httpVersion ne "1.0" && !$param->{keepalive}); 798 | $hdr .= "Authorization: Bearer $token\r\n"; 799 | if(defined($data)) { 800 | $hdr .= "Content-Length: ".length($data)."\r\n"; 801 | $hdr .= "Content-Type: application/x-www-form-urlencoded\r\n" if ($hdr !~ "Content-Type:"); 802 | } 803 | $hdr .= "\r\n"; 804 | 805 | Log3 $hash->{NAME}, 5, "$hash->{NAME}: sending headers to event channel: $hdr"; 806 | 807 | syswrite $param->{conn}, $hdr; 808 | $hash->{conn} = $param->{conn}; 809 | $hash->{eventChannelTimeout} = time(); 810 | 811 | Log3 $hash->{NAME}, 5, "$hash->{NAME}: connected to event channel"; 812 | 813 | # the server connection is left open to receive new events 814 | } 815 | 816 | ##################################### 817 | sub HomeConnect_CloseEventChannel($) 818 | { 819 | my ( $hash ) = @_; 820 | 821 | if (defined $hash->{conn}) { 822 | $hash->{conn}->close(); 823 | delete($hash->{conn}); 824 | Log3 $hash->{NAME}, 5, "$hash->{NAME}: disconnected from event channel"; 825 | } 826 | } 827 | 828 | ##################################### 829 | sub HomeConnect_ReadEventChannel($) 830 | { 831 | my ($hash) = @_; 832 | my $inputbuf; 833 | my $JSON = JSON->new->utf8(0)->allow_nonref; 834 | 835 | if (defined $hash->{conn}) { 836 | my ($rout, $rin) = ('', ''); 837 | vec($rin, $hash->{conn}->fileno(), 1) = 1; 838 | 839 | # check for timeout 840 | if (defined $hash->{eventChannelTimeout} && 841 | (time() - $hash->{eventChannelTimeout}) > 140) { 842 | Log3 $hash->{NAME}, 2, "$hash->{NAME}: event channel timeout, two keep alive messages missing"; 843 | HomeConnect_CloseEventChannel($hash); 844 | return undef; 845 | } 846 | 847 | my $count = 0; 848 | 849 | # read data 850 | while($hash->{conn}->fileno()) { 851 | # loop monitoring 852 | $count = $count + 1; 853 | if ($count > 100){ 854 | Log3 $hash->{NAME}, 2, "$hash->{NAME}: event channel fatal error: infinite loop"; 855 | last; 856 | } 857 | # check channel data availability 858 | my $tmp = $hash->{conn}->fileno(); 859 | my $nfound = select($rout=$rin, undef, undef, 0); 860 | Log3 $hash->{NAME}, 5, "$hash->{NAME}: event channel searching for data, fileno:\"$tmp\", nfound:\"$nfound\", loopCounter:\"$count\""; 861 | 862 | if($nfound < 0) { 863 | Log3 $hash->{NAME}, 2, "$hash->{NAME}: event channel timeout/error: $!"; 864 | HomeConnect_CloseEventChannel($hash); 865 | return undef; 866 | } 867 | if($nfound == 0) { 868 | last; 869 | } 870 | 871 | my $len = sysread($hash->{conn},$inputbuf,32768); 872 | Log3 $hash->{NAME}, 5, "$hash->{NAME}: event channel len:\"$len\", received:\"$inputbuf\""; 873 | 874 | # check if something was actually read 875 | if (defined($len) && $len > 0 && defined($inputbuf) && length($inputbuf) > 0) { 876 | 877 | # process data 878 | Log3 $hash->{NAME}, 5, "$hash->{NAME}: event channel received $inputbuf"; 879 | 880 | # reset timeout 881 | $hash->{eventChannelTimeout} = time(); 882 | 883 | readingsBeginUpdate($hash); 884 | 885 | # split data into lines, 886 | for (split /^/, $inputbuf) { 887 | # check for http result line 888 | if (length($_) == 0) { 889 | next 890 | } 891 | if (index($_,"HTTP/1.1") == 0) { 892 | if (substr($_,9,3) ne "200") { 893 | Log3 $hash->{NAME}, 2, "$hash->{NAME}: event channel received an http error: $_"; 894 | HomeConnect_CloseEventChannel($hash); 895 | return undef; 896 | } else { 897 | # successful connection, reset counter 898 | $hash->{retrycounter} = 0; 899 | } 900 | } elsif (index($_,"data:") == 0) { # extract data json elements 901 | if (length ($_) < 10) { next }; 902 | my $json = substr($_,5); 903 | Log3 $hash->{NAME}, 5, "$hash->{NAME}: event channel data: $json"; 904 | 905 | my $parsed = eval {$JSON->decode ($json)}; 906 | if($@){ 907 | Log3 $hash->{NAME}, 2, "$hash->{NAME}: JSON error reading from event channel"; 908 | } else { 909 | # update readings from json elements 910 | my %readings = (); 911 | for (my $i = 0; 1; $i++) { 912 | my $item = $parsed->{items}[$i]; 913 | if (!defined $item) { last }; 914 | my $key = $item->{key}; 915 | $readings{$key}=(defined $item->{value})?$item->{value}:"-"; 916 | $readings{$key}.=" ".$item->{unit} if defined $item->{unit}; 917 | 918 | if ($key eq "BSH.Common.Root.SelectedProgram" && 919 | defined($hash->{commandPrefix}) && length($readings{$key}) > length($hash->{commandPrefix}) ) { 920 | my $prefixLen = length $hash->{commandPrefix}; 921 | $readings{$key} = substr($readings{$key}, $prefixLen); 922 | } 923 | 924 | readingsBulkUpdate($hash, $key, $readings{$key}); 925 | Log3 $hash->{NAME}, 4, "$hash->{NAME}: $key = $readings{$key}"; 926 | } 927 | } 928 | # define new device state 929 | my $state; 930 | my $operationState = ReadingsVal($hash->{NAME},"BSH.Common.Status.OperationState",""); 931 | my $program = ReadingsVal($hash->{NAME},"BSH.Common.Root.ActiveProgram",""); 932 | if (defined($program) && defined($hash->{commandPrefix}) && length($program) > length($hash->{commandPrefix}) ) { 933 | my $prefixLen = length $hash->{commandPrefix}; 934 | $program = substr($program, $prefixLen); 935 | } 936 | if ($operationState eq "BSH.Common.EnumType.OperationState.Active" || 937 | $operationState eq "BSH.Common.EnumType.OperationState.Run") { 938 | 939 | $state = "Program $program active"; 940 | my $pct = ReadingsVal($hash->{NAME},"BSH.Common.Option.ProgramProgress",undef); 941 | $state .= " ($pct)" if (defined $pct); 942 | } elsif ($operationState eq "BSH.Common.EnumType.OperationState.DelayedStart") { 943 | $state = "Delayed start of program $program"; 944 | } else { 945 | $state = "Idle"; 946 | } 947 | readingsBulkUpdate($hash, "state", $state) if ($hash->{STATE} ne $state); 948 | } elsif (index($_,"event:DISCONNECTED") == 0) { # disconnected event Morluktom 10.05.2020 949 | my $state = "Offline"; 950 | readingsBulkUpdate($hash, "state", $state) if ($hash->{STATE} ne $state); 951 | } elsif (index($_,"event:CONNECTED") == 0) { # connected event Morluktom 10.05.2020 952 | HomeConnect_UpdateStatus($hash); 953 | } else { 954 | #Log3 $hash->{NAME}, 5, "$hash->{NAME}: event channel unknown: $_"; 955 | } 956 | } 957 | readingsEndUpdate($hash, 1); 958 | } else { 959 | Log3 $hash->{NAME}, 5, "$hash->{NAME}: event channel read failed, len:\"$len\", received:\"$inputbuf\""; 960 | HomeConnect_CloseEventChannel($hash); 961 | return undef; 962 | } 963 | } 964 | Log3 $hash->{NAME}, 5, "$hash->{NAME}: event channel received no more data"; 965 | } else { 966 | Log3 $hash->{NAME}, 5, "$hash->{NAME}: event channel is not connected"; 967 | } 968 | } 969 | 970 | 971 | 972 | 1; 973 | 974 | =pod 975 | =begin html 976 | 977 | 978 |

HomeConnect

979 |
    980 | 981 |

    Define

    982 |
      983 | define <name> HomeConnect <connection> <haId> 984 |
      985 |
      986 | Defines a single Home Connect household appliance. See Home Connect.

      987 | Example: 988 | 989 | define Dishwasher HomeConnect hcconn SIEMENS-HCS02DWH1-83D908F0471F71
      990 | 991 |
      992 | Typically the Home Connect devices are created automatically by the scanDevices action in HomeConnectConnection. 993 |
      994 |
    995 | 996 | 997 | Set 998 |
      999 |
    • BSH.Common.Root.SelectedProgram
      1000 | Select a program on the appliance. A program name must be given as first parameter. 1001 | This prepares the appliance for a program start and presets the program options with sensible defaults. 1002 |
    • startProgram
      1003 | Start a program on the appliance. The program currently selected on the appliance will be started by default. 1004 | A program name can be given as first parameter. The program will be started with specific options. 1005 |
    • 1006 |
    • stopProgram
      1007 | Stop the running program on the appliance. 1008 |
    • 1009 |
    • requestProgramOptions
      1010 | Read options for a specific appliance program and add them to Readings for later editing. 1011 |
    • 1012 |
    • requestSettings
      1013 | Read all settings available for the appliance and add them to Readings for later editing. 1014 |
    • 1015 |
    1016 |
    1017 | 1018 | 1019 |

    Attributes

    1020 | 1024 |
1025 | 1026 | =end html 1027 | =cut 1028 | -------------------------------------------------------------------------------- /FHEM/48_HomeConnectConnection.pm: -------------------------------------------------------------------------------- 1 | =head1 2 | 48_HomeConnectConnection.pm 3 | 4 | # $Id: $ 5 | 6 | Version 1.1 7 | 8 | =head1 SYNOPSIS 9 | Bosch Siemens Home Connect Modul for FHEM 10 | contributed by Stefan Willmeroth 09/2016 11 | 12 | =head1 DESCRIPTION 13 | 48_HomeConnectConnection keeps the OAuth token needed by devices defined by 14 | 48_HomeConnect 15 | 16 | =head1 AUTHOR - Stefan Willmeroth 17 | swi@willmeroth.com (forum.fhem.de) 18 | =cut 19 | 20 | package main; 21 | 22 | use strict; 23 | use warnings; 24 | use JSON; 25 | use URI::Escape; 26 | use Switch; 27 | use Data::Dumper; #debugging 28 | 29 | use vars qw($readingFnAttributes); 30 | use vars qw(%defs); 31 | use vars qw(%FW_webArgs); 32 | 33 | require HttpUtils; 34 | 35 | ############################################## 36 | sub HomeConnectConnection_Initialize($) 37 | { 38 | my ($hash) = @_; 39 | 40 | $hash->{SetFn} = "HomeConnectConnection_Set"; 41 | $hash->{DefFn} = "HomeConnectConnection_Define"; 42 | $hash->{GetFn} = "HomeConnectConnection_Get"; 43 | $hash->{FW_summaryFn} = "HomeConnectConnection_FwFn"; 44 | $hash->{FW_detailFn} = "HomeConnectConnection_FwFn"; 45 | $hash->{AttrList} = "disable:0,1 " . 46 | "accessScope " . 47 | $readingFnAttributes; 48 | } 49 | 50 | ################################### 51 | sub HomeConnectConnection_Set($@) 52 | { 53 | my ($hash, @a) = @_; 54 | my $rc = undef; 55 | my $reDOUBLE = '^(\\d+\\.?\\d{0,2})$'; 56 | 57 | my ($gterror, $gotToken) = getKeyValue($hash->{NAME}."_accessToken"); 58 | 59 | return "no set value specified" if(int(@a) < 2); 60 | return "LoginNecessary" if($a[1] eq "?" && !defined($gotToken)); 61 | return "scanDevices refreshToken logout" if($a[1] eq "?"); 62 | if ($a[1] eq "auth") { 63 | return HomeConnectConnection_GetAuthToken($hash,$a[2]); 64 | } 65 | if ($a[1] eq "scanDevices") { 66 | HomeConnectConnection_AutocreateDevices($hash); 67 | } 68 | if ($a[1] eq "refreshToken") { 69 | undef $hash->{expires_at}; 70 | HomeConnectConnection_RefreshToken($hash); 71 | } 72 | if ($a[1] eq "logout") { 73 | setKeyValue($hash->{NAME}."_accessToken",undef); 74 | setKeyValue($hash->{NAME}."_refreshToken",undef); 75 | undef $hash->{expires_at}; 76 | $hash->{STATE} = "Login necessary"; 77 | readingsBeginUpdate($hash); 78 | readingsBulkUpdate($hash, "state", $hash->{STATE}); 79 | readingsEndUpdate($hash, 1); 80 | } 81 | } 82 | 83 | ##################################### 84 | sub HomeConnectConnection_Define($$) 85 | { 86 | my ($hash, $def) = @_; 87 | my @a = split("[ \t][ \t]*", $def); 88 | 89 | my $u = "wrong syntax: define HomeConnectConnection [client_id] [redirect_uri] [simulator]"; 90 | 91 | return $u if(int(@a) < 4); 92 | 93 | $hash->{api_uri} = "https://api.home-connect.com"; 94 | 95 | if(int(@a) >= 4) { 96 | $hash->{client_id} = $a[2]; 97 | $hash->{redirect_uri} = $a[3]; 98 | if (int(@a) > 4) { 99 | if ("simulator" eq $a[4]) { 100 | $hash->{simulator} = "1"; 101 | $hash->{api_uri} = "https://simulator.home-connect.com"; 102 | } else { 103 | $hash->{client_secret} = $a[4]; 104 | } 105 | } 106 | if (int(@a) > 5) { 107 | $hash->{client_secret} = $a[5]; 108 | } 109 | } 110 | $hash->{STATE} = "Login necessary"; 111 | readingsBeginUpdate($hash); 112 | readingsBulkUpdate($hash, "state", $hash->{STATE}); 113 | readingsEndUpdate($hash, 1); 114 | 115 | # start with a delayed token refresh 116 | setKeyValue($hash->{NAME}."_accessToken",undef); 117 | undef $hash->{expires_at}; 118 | InternalTimer(gettimeofday()+10, "HomeConnectConnection_RefreshTokenTimer", $hash, 0); 119 | 120 | return; 121 | } 122 | 123 | ##################################### 124 | sub 125 | HomeConnectConnection_FwFn($$$$) 126 | { 127 | my ($FW_wname, $d, $room, $pageHash) = @_; # pageHash is set for summaryFn. 128 | my $hash = $defs{$d}; 129 | 130 | my ($gterror, $authToken) = getKeyValue($hash->{NAME}."_accessToken"); 131 | 132 | my $fmtOutput; 133 | 134 | if (!defined $authToken) { 135 | 136 | my $scope = AttrVal($hash->{NAME}, "accessScope", 137 | "IdentifyAppliance Monitor Settings Dishwasher-Control Washer-Control Dryer-Control CoffeeMaker-Control"); 138 | 139 | my $csrfToken = InternalVal("WEB", "CSRFTOKEN", "HomeConnectConnection_auth"); 140 | 141 | $fmtOutput = "{api_uri}/security/oauth/authorize?response_type=code" . 142 | "&redirect_uri=". uri_escape($hash->{redirect_uri}) . "&realm=fhem.de" . 143 | "&client_id=$hash->{client_id}&scope=" . uri_escape($scope) . 144 | "&state=" .$csrfToken. "\">Home Connect Login"; 145 | 146 | } 147 | 148 | return $fmtOutput; 149 | } 150 | 151 | ##################################### 152 | sub HomeConnectConnection_GetAuthToken 153 | { 154 | my ($hash,$tokens) = @_; 155 | my $name = $hash->{NAME}; 156 | my $JSON = JSON->new->utf8(0)->allow_nonref; 157 | 158 | my $error = $FW_webArgs{"error"}; 159 | if (defined $error) { 160 | my $err_desc = $FW_webArgs{"error_description"}; 161 | my $msg = "Login to Home Connect failed with error $error"; 162 | $msg .= ": $err_desc" if defined($err_desc); 163 | return $msg; 164 | } 165 | 166 | my $code = $FW_webArgs{"code"}; 167 | if (!defined $code) { 168 | Log3 $name, 4, "Searching auth tokens in: $tokens"; 169 | $tokens =~ m/code=([^&]*)/; 170 | $code = $1; 171 | } 172 | 173 | Log3 $name, 4, "Got oauth code: $code"; 174 | 175 | HttpUtils_NonblockingGet({ 176 | callback => \&HomeConnectConnection_CallbackGetAuthToken, 177 | hash => $hash, 178 | url => "$hash->{api_uri}/security/oauth/token", 179 | timeout => 10, 180 | noshutdown => 1, 181 | data => {grant_type => 'authorization_code', 182 | client_id => $hash->{client_id}, 183 | client_secret => $hash->{client_secret}, 184 | code => $code, 185 | redirect_uri => $hash->{redirect_uri} 186 | } 187 | }); 188 | } 189 | 190 | ##################################### 191 | sub HomeConnectConnection_RefreshToken($;$) 192 | { 193 | my ($hash, $nextcall) = @_; 194 | my $name = $hash->{NAME}; 195 | my $refresh = undef; 196 | 197 | my $conn = $hash->{hcconn}; 198 | if (!defined $conn) { 199 | $conn = $hash; 200 | } else { 201 | $conn = $defs{$conn}; 202 | } 203 | 204 | my ($gkerror, $refreshToken) = getKeyValue($conn->{NAME}."_refreshToken"); 205 | if (!defined $refreshToken) { 206 | $refresh = "no token to be refreshed"; 207 | } 208 | 209 | if( defined($conn->{expires_at}) ) { 210 | my ($seconds) = gettimeofday(); 211 | if( $seconds < $conn->{expires_at} - 300 ) { 212 | $refresh = "no token refresh needed"; 213 | } 214 | } 215 | 216 | if (defined($refresh)) { 217 | Log3 $name, 4, "$name: $refresh"; 218 | if (defined($nextcall)) { 219 | $nextcall->{callback}($hash, $nextcall->{data}); 220 | } 221 | } else { 222 | Log3 $name, 4, "$name: refreshing token"; 223 | HttpUtils_NonblockingGet({ 224 | callback => \&HomeConnectConnection_CallbackRefreshToken, 225 | hash => $hash, 226 | nextcall => $nextcall, 227 | url => "$hash->{api_uri}/security/oauth/token", 228 | timeout => 10, 229 | noshutdown => 1, 230 | data => {grant_type => 'refresh_token', 231 | client_id => $conn->{client_id}, 232 | client_secret => $conn->{client_secret}, 233 | refresh_token => $refreshToken 234 | } 235 | }); 236 | } 237 | return undef; 238 | } 239 | 240 | ##################################### 241 | sub HomeConnectConnection_AutocreateDevices 242 | { 243 | my ($hash) = @_; 244 | 245 | #### Read list of appliances 246 | my $URL = "/api/homeappliances"; 247 | 248 | my $data = {callback => \&HomeConnectConnection_ResponseAutocreateDevices, uri => $URL}; 249 | HomeConnectConnection_request($hash, $data); 250 | } 251 | 252 | ##################################### 253 | sub HomeConnectConnection_Undef($$) 254 | { 255 | my ( $hash, $arg ) = @_; 256 | 257 | RemoveInternalTimer($hash); 258 | Log3 $hash->{NAME}, 3, "--- removed ---"; 259 | return undef; 260 | } 261 | 262 | ##################################### 263 | sub HomeConnectConnection_Get($@) 264 | { 265 | my ($hash, @args) = @_; 266 | 267 | return 'HomeConnectConnection_Get needs two arguments' if (@args != 2); 268 | 269 | my $get = $args[1]; 270 | my $val = $hash->{Invalid}; 271 | 272 | return "HomeConnectConnection_Get: no such reading: $get"; 273 | 274 | } 275 | 276 | ##################################### 277 | sub HomeConnectConnection_RefreshTokenTimer($) 278 | { 279 | my ($hash) = @_; 280 | my $name = $hash->{NAME}; 281 | 282 | return if (AttrVal($name, "disable", 0) == 1); 283 | 284 | undef $hash->{expires_at}; 285 | HomeConnectConnection_RefreshToken($hash); 286 | } 287 | 288 | ##################################### 289 | sub HomeConnectConnection_request 290 | { 291 | my ($hash, $data) = @_; 292 | my $name = $hash->{NAME}; 293 | 294 | Log3 $name, 4, "$name: request $data->{uri}"; 295 | 296 | my $api_uri = (defined $hash->{hcconn}) ? $defs{$hash->{hcconn}}->{api_uri} : $hash->{api_uri}; 297 | 298 | my $URL = $api_uri . $data->{uri}; 299 | my $nextcall = { 300 | callback => \&HomeConnectConnection_requestAfterToken, 301 | data => { 302 | uri => $URL, 303 | data=>$data->{data}, 304 | nextcall => { 305 | callback => $data->{callback} 306 | } 307 | } 308 | }; 309 | HomeConnectConnection_RefreshToken($hash, $nextcall); 310 | } 311 | 312 | ##################################### 313 | sub HomeConnectConnection_requestAfterToken 314 | { 315 | my ($hash, $data) = @_; 316 | my $name = $hash->{NAME}; 317 | 318 | my $conn = $hash->{hcconn}; 319 | if (!defined $conn) { 320 | $conn = $name; 321 | } 322 | 323 | my ($gkerror, $token) = getKeyValue($conn."_accessToken"); 324 | 325 | if (!defined($data)) { 326 | Log3 $name, 1, "$name: requestAfterToken no data"; 327 | return; 328 | } 329 | 330 | my $uri = $data->{uri}; 331 | if (!defined($uri)) { 332 | Log3 $name, 1, "$name: requestAfterToken no uri"; 333 | return; 334 | } 335 | 336 | Log3 $name, 4, "$name: requestAfterToken $uri"; 337 | 338 | my $param; 339 | if (defined($data->{data})) { 340 | 341 | if ($data->{data} eq "DELETE") { 342 | $param = { 343 | url => $uri, 344 | hash => $hash, 345 | nextcall => $data->{nextcall}, 346 | callback => \&HomeConnectConnection_CallbackRequest, 347 | timeout => 5, 348 | noshutdown => 1, 349 | method => "DELETE", 350 | header => { "Accept" => "application/vnd.bsh.sdk.v1+json", "Authorization" => "Bearer $token" } 351 | }; 352 | } else { 353 | $param = { 354 | url => $uri, 355 | hash => $hash, 356 | nextcall => $data->{nextcall}, 357 | callback => \&HomeConnectConnection_CallbackRequest, 358 | timeout => 5, 359 | noshutdown => 1, 360 | method => "PUT", 361 | header => { "Accept" => "application/vnd.bsh.sdk.v1+json", 362 | "Authorization" => "Bearer $token", 363 | "Content-Type" => "application/vnd.bsh.sdk.v1+json" 364 | }, 365 | data => $data->{data} 366 | }; 367 | } 368 | } else { 369 | $param = { 370 | url => $uri, 371 | hash => $hash, 372 | nextcall => $data->{nextcall}, 373 | callback => \&HomeConnectConnection_CallbackRequest, 374 | timeout => 5, 375 | noshutdown => 1, 376 | header => { "Accept" => "application/vnd.bsh.sdk.v1+json", "Authorization" => "Bearer $token" } 377 | }; 378 | } 379 | HttpUtils_NonblockingGet($param); 380 | } 381 | 382 | ##################################### 383 | sub HomeConnectConnection_delrequest 384 | { 385 | my ($hash, $data) = @_; 386 | $data->{data} = "DELETE"; 387 | HomeConnectConnection_request($hash, $data); 388 | } 389 | 390 | ##################################### 391 | sub HomeConnectConnection_CallbackRefreshToken 392 | { 393 | my ($param, $err, $data) = @_; 394 | my $hash = $param->{hash}; 395 | my $name = $hash->{NAME}; 396 | 397 | my $conn = $hash->{hcconn}; 398 | if (!defined $conn) { 399 | $conn = $hash; 400 | } else { 401 | $conn = $defs{$conn}; 402 | } 403 | 404 | if( $err ) { 405 | Log3 $name, 2, "$name: http request failed: $err"; 406 | $hash->{lastError} = $err; 407 | } elsif( $data ) { 408 | Log3 $name, 4, "$name: RefreshTokenResponse $data"; 409 | 410 | $data =~ s/\n//g; 411 | if( $data !~ m/^\{.*}$/m ) { 412 | 413 | Log3 $name, 2, "$name: invalid json detected: >>$data<<"; 414 | 415 | } else { 416 | my $json = eval {decode_json($data)}; 417 | if($@){ 418 | Log3 $name, 2, "$name JSON error while reading refreshed token"; 419 | } else { 420 | 421 | if( $json->{error} ) { 422 | $hash->{lastError} = $json->{error}; 423 | } 424 | 425 | my ($gterror, $gotToken) = getKeyValue($conn->{NAME}."_accessToken"); #old token 426 | 427 | setKeyValue($conn->{NAME}."_accessToken", $json->{access_token}); 428 | setKeyValue($conn->{NAME}."_refreshToken", $json->{refresh_token}); 429 | 430 | if( $json->{access_token} ) { 431 | $conn->{STATE} = "Connected"; 432 | $conn->{expires_at} = gettimeofday(); 433 | $conn->{expires_at} += $json->{expires_in}; 434 | undef $conn->{refreshFailCount}; 435 | readingsBeginUpdate($conn); 436 | readingsBulkUpdate($conn, "tokenExpiry", scalar localtime $conn->{expires_at}); 437 | readingsBulkUpdate($conn, "state", $conn->{STATE}); 438 | readingsEndUpdate($conn, 1); 439 | RemoveInternalTimer($conn); 440 | InternalTimer(gettimeofday()+$json->{expires_in}*3/4, 441 | "HomeConnectConnection_RefreshTokenTimer", $conn, 0); 442 | 443 | # no old token - init HomeConnect devices 444 | if (!$gotToken) { 445 | foreach my $key ( keys %defs ) { 446 | if ($defs{$key}->{TYPE} eq "HomeConnect") { 447 | fhem "set $key init"; 448 | } 449 | } 450 | } 451 | 452 | if (defined($param->{nextcall})) { 453 | my $nextcall = $param->{nextcall}; 454 | $nextcall->{callback}($hash, $nextcall->{data}); 455 | } 456 | return; 457 | } 458 | } 459 | } 460 | } 461 | 462 | $conn->{STATE} = "Refresh Error" ; 463 | 464 | if (defined $conn->{refreshFailCount}) { 465 | $conn->{refreshFailCount} += 1; 466 | } else { 467 | $conn->{refreshFailCount} = 1; 468 | } 469 | 470 | if ($conn->{refreshFailCount}==10) { 471 | Log3 $conn->{NAME}, 2, "$conn->{NAME}: Refreshing token failed too many times, stopping"; 472 | $conn->{STATE} = "Login necessary"; 473 | setKeyValue($hash->{NAME}."_refreshToken", undef); 474 | } else { 475 | RemoveInternalTimer($conn); 476 | InternalTimer(gettimeofday()+60, "HomeConnectConnection_RefreshTokenTimer", $conn, 0); 477 | } 478 | 479 | readingsBeginUpdate($hash); 480 | readingsBulkUpdate($hash, "state", $hash->{STATE}); 481 | readingsEndUpdate($hash, 1); 482 | } 483 | 484 | ##################################### 485 | sub HomeConnectConnection_CallbackGetAuthToken 486 | { 487 | my ($param, $err, $data) = @_; 488 | my $hash = $param->{hash}; 489 | my $name = $hash->{NAME}; 490 | 491 | if( $err ) { 492 | Log3 $name, 2, "$name http request failed: $err"; 493 | $hash->{lastError} = $err; 494 | return; 495 | } elsif( $data ) { 496 | Log3 $name, 2, "$name AuthTokenResponse $data"; 497 | 498 | $data =~ s/\n//g; 499 | if( $data !~ m/^\{.*}$/m ) { 500 | Log3 $name, 2, "$name invalid json detected: >>$data<<"; 501 | return; 502 | } 503 | } 504 | 505 | my $JSON = JSON->new->utf8(0)->allow_nonref; 506 | my $json = eval {$JSON->decode($data)}; 507 | if($@){ 508 | Log3 $name, 2, "($name) - JSON error requesting tokens: $@"; 509 | return; 510 | } 511 | 512 | if( $json->{error} ) { 513 | $hash->{lastError} = $json->{error}; 514 | } 515 | 516 | setKeyValue($hash->{NAME}."_accessToken",$json->{access_token}); 517 | setKeyValue($hash->{NAME}."_refreshToken", $json->{refresh_token}); 518 | 519 | if( $json->{access_token} ) { 520 | $hash->{STATE} = "Connected"; 521 | readingsBeginUpdate($hash); 522 | readingsBulkUpdate($hash, "state", $hash->{STATE}); 523 | 524 | ($hash->{expires_at}) = gettimeofday(); 525 | $hash->{expires_at} += $json->{expires_in}; 526 | 527 | readingsBulkUpdate($hash, "tokenExpiry", scalar localtime $hash->{expires_at}); 528 | readingsEndUpdate($hash, 1); 529 | 530 | foreach my $key ( keys %defs ) { 531 | if (($defs{$key}->{TYPE} eq "HomeConnect") && ($defs{$key}->{hcconn} eq $hash->{NAME})) { 532 | fhem "set $key init"; 533 | } 534 | } 535 | 536 | RemoveInternalTimer($hash); 537 | InternalTimer(gettimeofday()+$json->{expires_in}*3/4, 538 | "HomeConnectConnection_RefreshTokenTimer", $hash, 0); 539 | } else { 540 | $hash->{STATE} = "Error"; 541 | readingsBeginUpdate($hash); 542 | readingsBulkUpdate($hash, "state", $hash->{STATE}); 543 | readingsEndUpdate($hash, 1); 544 | } 545 | } 546 | 547 | ##################################### 548 | sub HomeConnectConnection_CallbackRequest 549 | { 550 | my ($param, $err, $data) = @_; 551 | my $hash = $param->{hash}; 552 | my $name = $hash->{NAME}; 553 | if ($err) { 554 | Log3 $name, 2, "$name: error in request" . $err; 555 | } else { 556 | Log3 $name, 4 , "$name: response " . $data; 557 | } 558 | 559 | if (defined($param->{nextcall})) { 560 | my $nextcall = $param->{nextcall}; 561 | $nextcall->{callback}($hash, $data); 562 | } 563 | else { 564 | Log3 $name, 2 , "$name: no callback for request registered"; 565 | } 566 | } 567 | 568 | ##################################### 569 | sub HomeConnectConnection_ResponseAutocreateDevices 570 | { 571 | my ($hash, $data) = @_; 572 | 573 | if (!defined $data) { 574 | return "Failed to connect to HomeConnectConnection API, see log for details"; 575 | } 576 | 577 | my $appliances = eval {decode_json ($data)}; 578 | if($@){ 579 | Log3 $hash->{NAME}, 2, "$hash->{NAME} JSON error while reading appliances"; 580 | } else { 581 | for (my $i = 0; 1; $i++) { 582 | my $appliance = $appliances->{data}->{homeappliances}[$i]; 583 | if (!defined $appliance) { last }; 584 | if (!defined $defs{$appliance->{vib}}) { 585 | fhem ("define $appliance->{vib} HomeConnect $hash->{NAME} $appliance->{haId}"); 586 | } 587 | } 588 | }; 589 | } 590 | 591 | 592 | 1; 593 | 594 | =pod 595 | =begin html 596 | 597 | 598 |

HomeConnectConnection

599 |
    600 | 601 |

    Define

    602 |
      603 | define <name> HomeConnectConnection <api_key> <redirect_url> [simulator] 604 |
      605 |
      606 | Defines a connection and login to Home Connect Household appliances. See Home Connect for details.
      607 |
      608 | The following steps are needed to link FHEM to Home Connect:
      609 |
        610 |
      • Define a static CSRF Token in FHEM using a command like attr WEB.* csrfToken myToken123 611 |
      • Create a developer account at Home Connect for Developers
      • 612 |
      • Update your account to an Advanced Account
      • 613 |
      • Create your Application under "My Applications", the REDIRECT-URL must be pointing to your local FHEM installation, e.g.
        614 | http://localhost:8083/fhem?cmd.Test=set%20hcconn%20auth%20&fwcsrf=myToken123
      • 615 |
      • Make sure to include the rest of the URL as shown above. 616 |
      • Note the Client ID and Client Secret after creating the Application 617 |
      • Now define the FHEM HomeConnectConnection device with your API Key, Secret and URL:
        618 | define hcconn HomeConnectConnection API-KEY REDIRECT-URL [simulator] CLIENT_SECRET
      • 619 |
      • Click on the link "Home Connect Login" in the device and log in to your account. The simulator will not ask for any credentials.
      • 620 |
      • Execute the set scanDevices action to create FHEM devices for your appliances.
      • 621 |
      622 |
      623 | Currently, Home Connect API only supports the Simulator instead of your real Appliances unless you are a Home Connect beta tester. 624 | So the keyword simulator needs to be added to the definition. 625 |
      626 | If your FHEM server does not run on localhost, please change the REDIRECT-URL accordingly 627 |
      628 | If you would like to name your HomeConnectConnection differently or if you need to connect to more than one account, the name hcconn may be changed. 629 | Make sure to update the new name into your REDIRECT-URL (both in FHEM and Home Connect). If you want to use more than one connection, you can list 630 | both redirect-URLs in your Home Connect Application. 631 |
      632 | Troubleshooting tips: If you see errors when logging in, you should check the following points:
        633 |
      • Do you have an advanced Home Connect Developer account? If not, set the AccessScope attribute to IdentifyAppliance Monitor or update your account.
      • 634 |
      • Did you define a static csrf token and add it to your redirect URL?
      • 635 |
      • Does the redirect URL point to you FHEM and is it according to the specifications above?
      • 636 |
      • Is the name of your HomeConnectConnection device hcconn? If not, you need to update the URL accordingly.
      • 637 |
      • Is the redirect URL identically defined in your Home Connect Developer application and in you FHEM device definition?
      • 638 |
      639 |
    640 |
    641 | 642 | Set 643 |
      644 |
    • scanDevices
      645 | Start a device scan of the Home Connect account. The registered Home Connect devices are then created automatically 646 | in FHEM. The device scan can be started several times and will not duplicate devices as long as they have not been 647 | renamed in FHEM. You should change the alias attribute instead. 648 |
    • 649 |
    • refreshToken
      650 | Manually refresh the access token. This should be necessary only after internet connection problems. 651 |
    • 652 |
    • logout
      653 | Delete the access token and refresh tokens, and show the login link again. 654 |
    • 655 |
    656 |
    657 | 658 |

    Attributes

    659 |
      660 |
    • AccessScope
      661 | Change this attribute to limit the access rights given to FHEM. The default is: 662 | IdentifyAppliance Monitor Settings Dishwasher-Control Washer-Control Dryer-Control CoffeeMaker-Control 663 | Minimum setting would be IdentifyAppliance Monitor. This minimum setting will also work for non-advanced Home Connect Developer Accounts. 664 |
    • 665 |
    666 |
    667 | 668 |
669 | 670 | =end html 671 | =cut 672 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FHEM-HomeConnect 2 | FHEM Module to integrate your Home Connect household appliances 3 | 4 | Enter this command in your FHEM command line to install the Home Connect plugin: 5 | 6 | update all https://raw.githubusercontent.com/sw-home/FHEM-HomeConnect/master/controls_homeconnect.txt 7 | 8 | Then check the HomeConnectConnection device description in your FHEM Commandref. 9 | -------------------------------------------------------------------------------- /controls_homeconnect.txt: -------------------------------------------------------------------------------- 1 | UPD 2021-12-07_00:00:00 31752 FHEM/48_HomeConnect.pm 2 | UPD 2021-12-07_00:00:00 20411 FHEM/48_HomeConnectConnection.pm 3 | --------------------------------------------------------------------------------