4 Commits

Author SHA1 Message Date
Gilles MOREL
72e1c94a80 Traduction du README en français
Cette bibliothèque ne sert que pour un service français fourni en France.
2020-09-27 15:22:55 +02:00
Gilles MOREL
8fb1eac749 Correction du style 2020-09-26 07:55:57 +02:00
Gilles MOREL
b338230b37 Récupération des paramètres de la caméra
J'ai aussi enlevé la classe Camera pour intégrer les méthodes dans la classe Sensor.
2020-09-26 07:51:52 +02:00
Gilles MOREL
f5e8e4bdf0 Mise à jour de l'authentification 2020-09-20 12:00:45 +02:00
2 changed files with 41 additions and 34 deletions

View File

@@ -1,13 +1,13 @@
# What's this? # Qu'est-ce que c'est ?
This is a set of libraries to control your Home by SFR account. Il s'agit d'une bibliothèque qui permet d'accéder au système Home by SFR.
They all work around the website. Le code s'appuie sur les appels fait sur le [site](https://home.sfr.fr). De fait, sa conception a été faite par rétro-ingénérie et peut cesser de fonctionner sans préavis.
# What's Home by SFR? # Qu'est-ce que Home by SFR ?
Home by SFR is a security and automation service provided by the French Internet provider SFR. Home by SFR est un service de sécurité et de domotique fourni par SFR.
The library was only tested for the French version because I don't know if it exists elsewhere Cette bibliothèque ne peut utiliser que le service fourni par SFR en France.
# Licence # Licence
These libraries are under GNU GPL v3. Voir la [licence](LICENSE) pour plus de détails.

View File

@@ -21,7 +21,7 @@ authors = (
'Gilles "Almtesh" Émilien MOREL', 'Gilles "Almtesh" Émilien MOREL',
) )
name = 'homesfr for Python 3' name = 'homesfr for Python 3'
version = '1.1' version = '1.2'
# Settable modes # Settable modes
MODE_OFF = 0 MODE_OFF = 0
@@ -51,12 +51,12 @@ class Common ():
# path to login test # path to login test
self.auth_path = '/mysensors' self.auth_path = '/mysensors'
self.auth_ok = '/accueil' # if logged self.auth_ok_url = 'https://home.sfr.fr/logged' # if logged
self.auth_post_url = 'https://cas.home.sfr.fr/authentification' self.auth_post_url = 'https://boutique.home.sfr.fr/authentification'
self.auth_referer = 'https://cas.home.sfr.fr/authentification' self.auth_referer = 'https://boutique.home.sfr.fr/authentification?back=service'
self.auth_user_field = 'username' self.auth_user_field = 'email'
self.auth_pass_field = 'password' self.auth_pass_field = 'passwd'
self.auth_extra_fields = {} self.auth_extra_fields = {'back': 'service', 'token_sso': '', 'error_sso': '', 'SubmitLogin': 'OK'}
self.auth_logout_path = '/deconnexion' self.auth_logout_path = '/deconnexion'
# Path to sensors and mode # Path to sensors and mode
@@ -89,14 +89,15 @@ class Common ():
self.camera_get_config_mac = 'mac' self.camera_get_config_mac = 'mac'
self.camera_get_config_flip = 'FLIP' self.camera_get_config_flip = 'FLIP'
self.camera_get_config_leds = 'LEDMODE' # set to 0 to turn the leds on self.camera_get_config_leds = 'LEDMODE' # set to 0 to turn the leds on
self.camera_get_config_detectionsensibility = 'DP' # from 1 to 4 self.camera_get_config_petmode = 'pet_mode'
self.camera_get_config_recording = 'REC24' self.camera_get_config_recording = 'rec24'
self.camera_get_config_privacy = 'privacy'
self.camera_get_config_name = 'NAME' self.camera_get_config_name = 'NAME'
self.camera_set_config_path = '/homescope/camsettings' self.camera_set_config_path = '/homescope/camsettings'
self.camera_set_config_mac = 'mac' self.camera_set_config_mac = 'mac'
self.camera_set_config_flip = 'flip' self.camera_set_config_flip = 'flip'
self.camera_set_config_leds = 'led_mode' # set to 0 to turn the leds on self.camera_set_config_leds = 'led_mode' # set to 0 to turn the leds on
self.camera_set_config_detectionsensibility = 'dp' # from 1 to 4 self.camera_set_config_petmode = 'pet_mode'
self.camera_set_config_recording = 'rec24' self.camera_set_config_recording = 'rec24'
self.camera_set_config_name = 'name' self.camera_set_config_name = 'name'
@@ -251,7 +252,7 @@ class HomeSFR (Common):
a = self.opener.open (self.auth_post_url, data = data) a = self.opener.open (self.auth_post_url, data = data)
if self.DEBUG: if self.DEBUG:
print ('Auth redirected to ' + a.geturl ()) print ('Auth redirected to ' + a.geturl ())
return (a.geturl () == self.base_url + self.auth_ok) return (a.geturl () == self.auth_ok_url)
else: else:
return (False) return (False)
@@ -259,7 +260,7 @@ class HomeSFR (Common):
''' '''
Trigger the autologin Trigger the autologin
''' '''
if (self.autologin and not self.test_login ()): while (self.autologin and not self.test_login ()):
self.login () self.login ()
def logout (self): def logout (self):
@@ -364,8 +365,6 @@ class HomeSFR (Common):
Get a Camera object from the sensor's id Get a Camera object from the sensor's id
''' '''
self.do_autologin () self.do_autologin ()
if (self.autologin and not self.test_login ()):
self.login ()
r = Camera (id, self.opener) r = Camera (id, self.opener)
r.refresh () r.refresh ()
return (r) return (r)
@@ -484,18 +483,7 @@ class Sensor (Common):
''' '''
return (self.sensor_dict [self.sensors_status_field] == self.sensors_status_value_ok) return (self.sensor_dict [self.sensors_status_field] == self.sensors_status_value_ok)
def get_camera_snapshot (self):
class Camera (Sensor):
'''
Class used to manipulate easily cameras
'''
def __init__ (self, sensor_dict, opener):
'''
Initialize the class with the dict producted by HomeSFR.get_camera ()
'''
Sensor.__init__ (self, sensor_dict, opener)
def get_snapshot (self):
''' '''
Get a snapshot from the camera Get a snapshot from the camera
Return a PIL.Image object Return a PIL.Image object
@@ -503,3 +491,22 @@ class Camera (Sensor):
r = self.base_url + self.camera_snapshot + '?' + self.camera_snapshot_mac + '=' + self.get_mac () r = self.base_url + self.camera_snapshot + '?' + self.camera_snapshot_mac + '=' + self.get_mac ()
a = self.bytes2image (self.opener.open (r).read ()) a = self.bytes2image (self.opener.open (r).read ())
return (a) return (a)
def get_camera_petmode (self):
'''
Gets the pet mode value
Pet mode is a setting on movement sensibility, to avoid trigger on pet movements
'''
return (self.sensor_dict [self.camera_get_config_petmode] == '1')
def get_camera_recording (self):
'''
Gets if the camera records or not
'''
return (self.sensor_dict [self.camera_get_config_recording] == '1')
def get_camera_privacy (self):
'''
Gets if the camera records or not
'''
return (self.sensor_dict [self.camera_get_config_privacy] == '1')