@@ -43,6 +43,14 @@ Before being able to use the module you will need :
43
43
* Create a couple access_token/refresh_token at the same time with your required scope (depending of your intents on library use)
44
44
45
45
46
+ In the netatmo philosophy, both the application itself and the user have to be registered thus have authentication credentials to be able to access any station. Registration is free for both.
47
+
48
+ Possible NETATMO_SCOPES ;
49
+ read_station read_smarther write_smarther read_thermostat write_thermostat read_camera write_camera read_doorbell
50
+ read_presence write_precense read_homecoach read_carbonmonoxidedetector read_smokedetector read_magellen write_magellan
51
+ read_bubendorff write_bubendorff read_mx write_mx read_mhs1 write_mhs1
52
+
53
+
46
54
47
55
### 2 Setup your authentication information ###
48
56
@@ -361,7 +369,6 @@ Requires : an authorization object (ClientAuth instance)
361
369
362
370
Return : a homeData object. This object contains most administration properties of home security products and notably Welcome & Presence cameras.
363
371
364
- Raise a lnetatmo.NoDevice exception if no camera is available for the given account.
365
372
366
373
Note : the is_local property of camera is most of the time unusable if your IP changes, use cameraUrls to try to get a local IP as a replacement.
367
374
@@ -437,20 +444,46 @@ Methods :
437
444
* ** getLiveSnapshot** (camera=None, home=None, cid=None) : Get a jpeg of current live view of the camera
438
445
* Input : camera name and optional home name or cameraID to lookup (str)
439
446
* Output : jpeg binary content
447
+
448
+ ```
449
+ homedata = lnetatmo.HomeData(authorization)
450
+ for k, v in homedata.homes.items():
451
+ homeid = k
452
+ S = v.get('smokedetectors')
453
+ C = v.get('cameras')
454
+ P = v.get('persons')
455
+ E = v.get('events')
456
+ if S or C or P or E:
457
+ print ('devices in HomeData')
458
+ for smokedetector in homedata.homes[homeid].get('smokedetectors'):
459
+ print (smokedetector['name'])
460
+ for camera in homedata.homes[homeid].get('cameras'):
461
+ print (camera['name'])
462
+ for persons in homedata.homes[homeid].get('persons'):
463
+ print (persons['name'])
464
+ for events in homedata.homes[homeid].get('events'):
465
+ print (events['name'])
466
+ return homeid
467
+ else:
468
+ homeid = k
469
+ return homeid
470
+
471
+ ```
440
472
441
473
442
474
#### 4-6 HomeStatus class ####
443
475
444
476
445
477
Constructor
446
478
447
- ``` python
479
+ ```
448
480
homeStatus = lnetatmo.HomeStatus( authorization, home_id )
481
+
449
482
```
450
483
451
484
Requires :
452
485
- an authorization object (ClientAuth instance)
453
- - home_id which can be found in https://dev.netatmo.com/apidocumentation/control by using "GET homesdata "
486
+ - home_id which can be found in https://dev.netatmo.com/apidocumentation/control by using "class homedata "
454
487
455
488
Return : a homeStatus object. This object contains most administration properties of Home+ Control devices such as Smarther thermostat, Socket, Cable Output, Centralized fan, Micromodules, ...
456
489
@@ -478,8 +511,188 @@ Methods :
478
511
* Input : module ID and parameter
479
512
* Output : value
480
513
514
+ ```
515
+ homestatus = lnetatmo.HomeStatus(authorization, homeid)
516
+ print ('Rooms in Homestatus')
517
+ for r in homestatus.rooms:
518
+ print (r)
519
+ print ('Persons in Homestatus')
520
+ if 'persons' in homestatus.rawData.keys():
521
+ for pp in homestatus.rawData['persons']:
522
+ print (pp)
523
+ print ('Modules in Homestatus')
524
+ for m in homestatus.modules:
525
+ for kt, vt in m.items():
526
+ if kt == 'type':
527
+ print (m['type'])
528
+ print (m['id'])
529
+ print (lnetatmo.TYPES[vt])
530
+ print (m.keys())
531
+
532
+
533
+ ```
534
+
535
+
536
+ #### 4-7 ThermostatData class ####
537
+
538
+
539
+ Constructor
540
+
541
+ ```
542
+ device = lnetatmo.ThermostatData ( authorization, home_id )
543
+
544
+ ```
545
+
546
+ Requires :
547
+ - an authorization object (ClientAuth instance)
548
+ - home_id which can be found in https://dev.netatmo.com/apidocumentation/control by using "class homedata"
549
+
550
+ Return : a device object. This object contains the Relay_Plug with Thermostat and temperature modules.
551
+
552
+ Methods :
553
+
554
+ * ** rawData** : Full dictionary of the returned JSON DEVICELIST Netatmo API service
555
+ * Output : list of IDs of every relay_plug
556
+
557
+ * ** Relay_Plug** :
558
+ * Output : Dictionairy of First Relay object
559
+
560
+ * ** Thermostat_Data** :
561
+ * Output : Dictionairy of Thermostat object in First Relay[ Modules] .
562
+
563
+ Example :
564
+
565
+ ```
566
+ device = lnetatmo.ThermostatData(authorization, homeid)
567
+ for i in device.rawData:
568
+ print ('rawData')
569
+ print (i['_id'])
570
+ print (i['station_name'])
571
+ print (dir(i))
572
+ print ('modules in rawData')
573
+ print (i['modules'][0]['_id'])
574
+ print (i['modules'][0]['module_name'])
575
+ print (' ')
576
+ print ('Relay Data')
577
+ Relay = device.Relay_Plug()
578
+ print (Relay.keys())
579
+ print ('Thermostat Data')
580
+ TH = device.Thermostat_Data()
581
+ print (TH.keys())
582
+
583
+ ```
584
+
585
+ #### 4-8 HomesData class ####
586
+
587
+
588
+ Constructor
589
+
590
+ ``` python
591
+ homesData = lnetatmo.HomesData ( authorization, home_id )
592
+ ```
593
+
594
+ Requires :
595
+ - an authorization object (ClientAuth instance)
596
+ - home_id which can be found in https://dev.netatmo.com/apidocumentation/control by using "class homedata"
597
+
598
+ Return : a homesdata object. This object contains the Netatmo actual topology and static information of
599
+ all devices present into a user account. It is also possible to specify a home_id to focus on one home.
600
+
601
+ Methods :
602
+
603
+ * ** rawData** : Full dictionary of the returned JSON DEVICELIST Netatmo API service
604
+ * Output : list of IDs of every devices
605
+
606
+ Example :
607
+
608
+ ```
609
+ homesData = lnetatmo.HomesData ( authorization, home_id )
610
+ print (homesdata.Homes_Data['name'])
611
+ print (homesdata.Homes_Data['altitude'])
612
+ print (homesdata.Homes_Data['coordinates'])
613
+ print (homesdata.Homes_Data['country'])
614
+ print (homesdata.Homes_Data['timezone'])
615
+ print ('rooms in HomesData')
616
+ for r in homesdata.Homes_Data.get('rooms'):
617
+ print (r)
618
+ print ('Devices in HomesData')
619
+ for m in homesdata.Homes_Data.get('modules'):
620
+ print (m)
621
+ print ('Persons in HomesData')
622
+ if 'persons' in homesdata.Homes_Data.keys():
623
+ for P in homesdata.Homes_Data.get('persons'):
624
+ print (P)
625
+ print ('Schedules in HomesData')
626
+ print (homesdata.Homes_Data['schedules'][0].keys())
627
+
628
+ ```
629
+
630
+ #### 4-9 Homecoach class ####
631
+
632
+
633
+ Constructor
634
+
635
+ ``` python
636
+ homecoach = lnetatmo.HomeCoach(authorization, home_id )
637
+ ```
638
+
639
+ Requires :
640
+ - an authorization object (ClientAuth instance)
641
+ - home_id which can be found in https://dev.netatmo.com/apidocumentation/control by using "class homedata"
642
+
643
+ Return : a homecoach object. This object contains all Homecoach Data.
644
+
645
+ Methods :
646
+
647
+ * ** rawData** : Full dictionary of the returned JSON DEVICELIST Netatmo API service
648
+ * Output : list of all Homecoach in user account
649
+
650
+ * ** checkNotUpdated** :
651
+ * Output : list of modules name for which last data update is older than specified delay (default 1 hour).
652
+
653
+
654
+ * ** checkUpdated** :
655
+ * Output : list of modules name for which last data update is newer than specified delay (default 1 hour).
656
+
657
+ Example :
658
+
659
+
660
+ ```
661
+ homecoach = lnetatmo.HomeCoach(authorization, homeid)
662
+ #
663
+ Not_updated = []
664
+ updated = []
665
+ d = {}
666
+ for device in homecoach.rawData:
667
+ _id = device['_id']
668
+ d.update({'When': device['dashboard_data']['time_utc']})
669
+ a = homecoach.checkNotUpdated(d, _id)
670
+ b = homecoach.checkUpdated(d, _id)
671
+ print (device['station_name'])
672
+ print (device['date_setup'])
673
+ print (device['last_setup'])
674
+ print (device['type'])
675
+ print (device['last_status_store'])
676
+ print (device['firmware'])
677
+ print (device['last_upgrade'])
678
+ print (device['wifi_status'])
679
+ print (device['reachable'])
680
+ print (device['co2_calibrating'])
681
+ print (device['data_type'])
682
+ print (device['place'])
683
+ print (device['dashboard_data'])
684
+ Not_updated.append(a)
685
+ updated.append(b)
686
+ D = homecoach.HomecoachDevice['dashboard_data']
687
+ print (D.keys())
688
+ # dict_keys(['time_utc', 'Temperature', 'CO2', 'Humidity', 'Noise', 'Pressure', 'AbsolutePressure', 'health_idx', 'min_temp', 'max_temp', 'date_max_temp', 'date_min_temp'])
689
+ print (Not_updated)
690
+ print (updated)
691
+
692
+ ```
693
+
481
694
482
- #### 4-7 Utilities functions ####
695
+ #### 4-10 Utilities functions ####
483
696
484
697
485
698
* ** rawAPI** (authentication, APIkeyword, parameters) : Direct call an APIkeyword from Netatmo and return a dictionary with the raw response the APIkeywork is the path without the / before as specified in the documentation (eg. "gethomesdata" or "homestatus")
@@ -488,7 +701,7 @@ Methods :
488
701
* ** todayStamps** () : Return a couple of epoch time (start, end) for the current day
489
702
490
703
491
- #### 4-8 All-in-One function ####
704
+ #### 4-11 All-in-One function ####
492
705
493
706
494
707
If you just need the current temperature and humidity reported by a sensor with associated min and max values on the last 24 hours, you can get it all with only one call that handle all required steps including authentication :
0 commit comments