simo 2.5.18__py3-none-any.whl → 2.5.19__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of simo might be problematic. Click here for more details.
- simo/core/__pycache__/tasks.cpython-38.pyc +0 -0
- simo/core/tasks.py +6 -4
- simo/generic/__pycache__/controllers.cpython-38.pyc +0 -0
- simo/generic/controllers.py +56 -27
- simo/users/__pycache__/api.cpython-38.pyc +0 -0
- simo/users/__pycache__/models.cpython-38.pyc +0 -0
- simo/users/api.py +4 -1
- simo/users/models.py +1 -0
- {simo-2.5.18.dist-info → simo-2.5.19.dist-info}/METADATA +1 -1
- {simo-2.5.18.dist-info → simo-2.5.19.dist-info}/RECORD +14 -14
- {simo-2.5.18.dist-info → simo-2.5.19.dist-info}/LICENSE.md +0 -0
- {simo-2.5.18.dist-info → simo-2.5.19.dist-info}/WHEEL +0 -0
- {simo-2.5.18.dist-info → simo-2.5.19.dist-info}/entry_points.txt +0 -0
- {simo-2.5.18.dist-info → simo-2.5.19.dist-info}/top_level.txt +0 -0
|
Binary file
|
simo/core/tasks.py
CHANGED
|
@@ -214,13 +214,15 @@ def sync_with_remote():
|
|
|
214
214
|
weather_component.controller.set(weather)
|
|
215
215
|
weather_component.save()
|
|
216
216
|
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
if new_instance:
|
|
218
|
+
print(f"NEW INSTANCE: {instance}")
|
|
219
|
+
print(f"Users data: {users_data}")
|
|
219
220
|
|
|
220
221
|
|
|
221
222
|
for email, options in users_data.items():
|
|
222
|
-
|
|
223
|
-
|
|
223
|
+
if new_instance:
|
|
224
|
+
print(f"EMAIL: {email}")
|
|
225
|
+
print(f"OPTIONS: {options}")
|
|
224
226
|
if new_instance or not instance.instance_users.count():
|
|
225
227
|
# Create user for new instance!
|
|
226
228
|
user, new_user = User.objects.get_or_create(
|
|
Binary file
|
simo/generic/controllers.py
CHANGED
|
@@ -153,64 +153,86 @@ class PresenceLighting(Script):
|
|
|
153
153
|
|
|
154
154
|
# script specific variables
|
|
155
155
|
sensors = {}
|
|
156
|
+
condition_comps = {}
|
|
156
157
|
light_org_values = {}
|
|
157
158
|
is_on = False
|
|
158
159
|
turn_off_task = None
|
|
159
160
|
last_presence = 0
|
|
161
|
+
hold_time = 60
|
|
162
|
+
conditions = []
|
|
160
163
|
|
|
161
164
|
def _run(self):
|
|
165
|
+
self.hold_time = self.component.config.get('hold_time', 0) * 10
|
|
166
|
+
for id in self.component.config['presence_sensors']:
|
|
167
|
+
sensor = Component.objects.filter(id=id).first()
|
|
168
|
+
if sensor:
|
|
169
|
+
sensor.on_change(self._on_sensor)
|
|
170
|
+
self.sensors[id] = sensor
|
|
171
|
+
|
|
172
|
+
for condition in self.component.config.get('conditions', []):
|
|
173
|
+
comp = Component.objects.filter(
|
|
174
|
+
id=condition.get('component', 0)
|
|
175
|
+
).first()
|
|
176
|
+
if comp:
|
|
177
|
+
condition['component'] = comp
|
|
178
|
+
self.conditions.append(condition)
|
|
179
|
+
comp.on_change(self._on_condition)
|
|
180
|
+
self.condition_comps[comp.id] = comp
|
|
181
|
+
|
|
162
182
|
while True:
|
|
163
|
-
self.
|
|
164
|
-
hold_time = self.component.config.get('hold_time', 0) * 10
|
|
165
|
-
if self.last_presence and hold_time and (
|
|
166
|
-
time.time() - hold_time > self.last_presence
|
|
167
|
-
):
|
|
168
|
-
self._turn_it_off()
|
|
183
|
+
self._regulate(on_val_change=False)
|
|
169
184
|
time.sleep(random.randint(5, 15))
|
|
170
185
|
|
|
171
186
|
def _on_sensor(self, sensor=None):
|
|
172
|
-
|
|
173
|
-
self.component.refresh_from_db()
|
|
174
|
-
for id in self.component.config['presence_sensors']:
|
|
175
|
-
if id not in self.sensors:
|
|
176
|
-
sensor = Component.objects.filter(id=id).first()
|
|
177
|
-
if sensor:
|
|
178
|
-
sensor.on_change(self._on_sensor)
|
|
179
|
-
self.sensors[id] = sensor
|
|
180
|
-
|
|
181
187
|
if sensor:
|
|
182
188
|
self.sensors[sensor.id] = sensor
|
|
189
|
+
self._regulate()
|
|
190
|
+
|
|
191
|
+
def _on_condition(self, condition_comp=None):
|
|
192
|
+
if condition_comp:
|
|
193
|
+
for condition in self.conditions:
|
|
194
|
+
if condition['component'].id == condition_comp.id:
|
|
195
|
+
condition['component'] = condition_comp
|
|
196
|
+
self._regulate()
|
|
183
197
|
|
|
198
|
+
|
|
199
|
+
def _regulate(self, on_val_change=True):
|
|
184
200
|
presence_values = [s.value for id, s in self.sensors.items()]
|
|
185
201
|
if self.component.config.get('act_on', 0) == 0:
|
|
186
202
|
must_on = any(presence_values)
|
|
187
203
|
else:
|
|
188
204
|
must_on = all(presence_values)
|
|
189
205
|
|
|
190
|
-
if
|
|
206
|
+
if must_on and on_val_change:
|
|
191
207
|
print("Presence detected!")
|
|
192
208
|
|
|
193
209
|
additional_conditions_met = True
|
|
194
|
-
for condition in self.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
id=condition.get('component', 0)
|
|
199
|
-
).first()
|
|
200
|
-
if not comp:
|
|
201
|
-
continue
|
|
210
|
+
for condition in self.conditions:
|
|
211
|
+
|
|
212
|
+
comp = condition['component']
|
|
213
|
+
|
|
202
214
|
op = OPERATIONS.get(condition.get('op'))
|
|
203
215
|
if not op:
|
|
204
216
|
continue
|
|
217
|
+
|
|
205
218
|
if condition['op'] == 'in':
|
|
206
219
|
if comp.value not in self._string_to_vals(condition['value']):
|
|
220
|
+
if must_on and on_val_change:
|
|
221
|
+
print(
|
|
222
|
+
f"Condition not met: [{comp} value:{comp.value} "
|
|
223
|
+
f"{condition['op']} {condition['value']}]"
|
|
224
|
+
)
|
|
207
225
|
additional_conditions_met = False
|
|
208
|
-
|
|
226
|
+
break
|
|
209
227
|
|
|
210
228
|
if not op(comp.value, condition['value']):
|
|
211
|
-
if
|
|
212
|
-
print(
|
|
229
|
+
if must_on and on_val_change:
|
|
230
|
+
print(
|
|
231
|
+
f"Condition not met: [{comp} value:{comp.value} "
|
|
232
|
+
f"{condition['op']} {condition['value']}]"
|
|
233
|
+
)
|
|
213
234
|
additional_conditions_met = False
|
|
235
|
+
break
|
|
214
236
|
|
|
215
237
|
if must_on and additional_conditions_met and not self.is_on:
|
|
216
238
|
print("Turn the lights ON!")
|
|
@@ -230,9 +252,16 @@ class PresenceLighting(Script):
|
|
|
230
252
|
if not any(presence_values):
|
|
231
253
|
if not self.component.config.get('hold_time', 0):
|
|
232
254
|
return self._turn_it_off()
|
|
255
|
+
|
|
233
256
|
if not self.last_presence:
|
|
234
257
|
self.last_presence = time.time()
|
|
235
258
|
|
|
259
|
+
if self.hold_time and (
|
|
260
|
+
time.time() - self.hold_time > self.last_presence
|
|
261
|
+
):
|
|
262
|
+
self._turn_it_off()
|
|
263
|
+
|
|
264
|
+
|
|
236
265
|
def _turn_it_off(self):
|
|
237
266
|
print("Turn the lights OFF!")
|
|
238
267
|
self.is_on = False
|
|
Binary file
|
|
Binary file
|
simo/users/api.py
CHANGED
|
@@ -234,12 +234,15 @@ class UserDeviceReport(InstanceMixin, viewsets.GenericViewSet):
|
|
|
234
234
|
iu.phone_on_charge = request.data.get('is_charging', False)
|
|
235
235
|
iu.save()
|
|
236
236
|
|
|
237
|
+
phone_on_charge = False
|
|
238
|
+
if request.data.get('is_charging'):
|
|
239
|
+
phone_on_charge = True
|
|
237
240
|
UserDeviceReportLog.objects.create(
|
|
238
241
|
user_device=user_device, instance=self.instance,
|
|
239
242
|
app_open=request.data.get('app_open', False),
|
|
240
243
|
location=','.join([str(i) for i in location]) if location else None,
|
|
241
244
|
relay=relay, speed_kmh=speed_kmh,
|
|
242
|
-
phone_on_charge=
|
|
245
|
+
phone_on_charge=phone_on_charge
|
|
243
246
|
)
|
|
244
247
|
|
|
245
248
|
return RESTResponse({'status': 'success'})
|
simo/users/models.py
CHANGED
|
@@ -257,6 +257,7 @@ class User(AbstractBaseUser, SimoAdminMixin):
|
|
|
257
257
|
cache_key = f'user-{self.id}_instance-{instance.id}-role-id'
|
|
258
258
|
cached_val = cache.get(cache_key, 'expired')
|
|
259
259
|
if cached_val == 'expired':
|
|
260
|
+
cached_val = None
|
|
260
261
|
for role in self.roles.all().select_related('instance'):
|
|
261
262
|
if role.instance == instance:
|
|
262
263
|
cached_val = role.id
|
|
@@ -59,7 +59,7 @@ simo/core/serializers.py,sha256=WgksN1Ombv240nfQR_UtmKslTWM9vz9Y0yTdN5usiHU,2189
|
|
|
59
59
|
simo/core/signal_receivers.py,sha256=YZZVg0MHIqfJ4RxG_KH5G5pkVz97SLXsMkMxpo-ec2I,8842
|
|
60
60
|
simo/core/socket_consumers.py,sha256=trRZvBGTJ7xIbfdmVvn7zoiWp_qssSkMZykDrI5YQyE,9783
|
|
61
61
|
simo/core/storage.py,sha256=_5igjaoWZAiExGWFEJMElxUw55DzJG1jqFty33xe8BE,342
|
|
62
|
-
simo/core/tasks.py,sha256=
|
|
62
|
+
simo/core/tasks.py,sha256=M0GHGZvRSik_CDWufcDRwbDQju_88q-yHK_Nnp0N4IA,15923
|
|
63
63
|
simo/core/todos.py,sha256=eYVXfLGiapkxKK57XuviSNe3WsUYyIWZ0hgQJk7ThKo,665
|
|
64
64
|
simo/core/types.py,sha256=WJEq48mIbFi_5Alt4wxWMGXxNxUTXqfQU5koH7wqHHI,1108
|
|
65
65
|
simo/core/views.py,sha256=3SRZr00fyLQf8ja3U-9eekKt-ld5TvU1WQqUWprXfQ4,2390
|
|
@@ -92,7 +92,7 @@ simo/core/__pycache__/serializers.cpython-38.pyc,sha256=d4wpUjFuo8GxaNWbin9GdHKi
|
|
|
92
92
|
simo/core/__pycache__/signal_receivers.cpython-38.pyc,sha256=bBnV6L69VVH46nrWDHi4VGBEMcxusfEsXN7aZoQRzDI,6729
|
|
93
93
|
simo/core/__pycache__/socket_consumers.cpython-38.pyc,sha256=KqbO1cOewodVPcy0-htVefyUjCuELKV0o7fOfYqfgPc,8490
|
|
94
94
|
simo/core/__pycache__/storage.cpython-38.pyc,sha256=9R1Xu0FJDflfRXUPsqEgt0SpwiP7FGk7HaR8s8XRyI8,721
|
|
95
|
-
simo/core/__pycache__/tasks.cpython-38.pyc,sha256=
|
|
95
|
+
simo/core/__pycache__/tasks.cpython-38.pyc,sha256=mLvFf_G9SCINI2aQYV7rIuGkMj5qe6orc2L359Mz6CY,10766
|
|
96
96
|
simo/core/__pycache__/todos.cpython-38.pyc,sha256=lOqGZ58siHM3isoJV4r7sg8igrfE9fFd-jSfeBa0AQI,253
|
|
97
97
|
simo/core/__pycache__/views.cpython-38.pyc,sha256=K_QM967bIJeU02DJu0Dm7j8RiFDKn_TLzX77YzNkA7c,2495
|
|
98
98
|
simo/core/__pycache__/widgets.cpython-38.pyc,sha256=sR0ZeHCHrhnNDBJuRrxp3zUsfBp0xrtF0xrK2TkQv1o,3520
|
|
@@ -10340,7 +10340,7 @@ simo/fleet/templates/fleet/controllers_info/ENS160AirQualitySensor.md,sha256=3LS
|
|
|
10340
10340
|
simo/generic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10341
10341
|
simo/generic/app_widgets.py,sha256=TPRLj4hri2hBuY6mrdwBiv-01z2hDxZmsup-GDD9LrM,953
|
|
10342
10342
|
simo/generic/base_types.py,sha256=u3SlfpNYaCwkVBwomWgso4ODzL71ay9MhiAW-bxgnDU,341
|
|
10343
|
-
simo/generic/controllers.py,sha256=
|
|
10343
|
+
simo/generic/controllers.py,sha256=i-xKQ5PrNKwCuO0dFaHHUaD5rF9lDnq18ziVSNBENao,50134
|
|
10344
10344
|
simo/generic/forms.py,sha256=H841-wbWltnZ2-RXQEM1G8H4kfOcl88Qhg7bxE4VCiQ,28993
|
|
10345
10345
|
simo/generic/gateways.py,sha256=sMedpxIfpxqTx746DdhsIu-pzTrqduOSIb7i7XDX9GU,15339
|
|
10346
10346
|
simo/generic/models.py,sha256=Adq7ipWK-renxJlNW-SZnAq2oGEOwKx8EdUWaKnfcVQ,7597
|
|
@@ -10349,7 +10349,7 @@ simo/generic/socket_consumers.py,sha256=K2OjphIhKJH48BvfFfoCOyCQZ1NmXb_phs6y1IP-
|
|
|
10349
10349
|
simo/generic/__pycache__/__init__.cpython-38.pyc,sha256=mLu54WS9KIl-pHwVCBKpsDFIlOqml--JsOVzAUHg6cU,161
|
|
10350
10350
|
simo/generic/__pycache__/app_widgets.cpython-38.pyc,sha256=YZ5db6-FPynBi6ooPW5crK9lZ6ymRh2DlGN6FwxfX4M,1820
|
|
10351
10351
|
simo/generic/__pycache__/base_types.cpython-38.pyc,sha256=aV5NdIuvXR-ItKpI__MwcyPZHD6Z882TFdgYkPCkr1I,493
|
|
10352
|
-
simo/generic/__pycache__/controllers.cpython-38.pyc,sha256
|
|
10352
|
+
simo/generic/__pycache__/controllers.cpython-38.pyc,sha256=-Y3fV0gbkye9WgWpdNY7qG9VvMWpFUT7Spl1eukztgQ,33352
|
|
10353
10353
|
simo/generic/__pycache__/forms.cpython-38.pyc,sha256=w7p-dFYvxtNMlrKVnM2zWa1Jp0zXygP6Lbo6kKg-Ox4,21228
|
|
10354
10354
|
simo/generic/__pycache__/gateways.cpython-38.pyc,sha256=QGj0mIWyqrVpn9AeGeYzdu6PxcF5SdQOHNzEqcHCy_E,11648
|
|
10355
10355
|
simo/generic/__pycache__/models.cpython-38.pyc,sha256=MZpum7syAFxuulf47K7gtUlJJ7xRD-IBUBAwUM1ZRnw,5825
|
|
@@ -10443,14 +10443,14 @@ simo/notifications/migrations/__pycache__/0003_alter_notification_instance.cpyth
|
|
|
10443
10443
|
simo/notifications/migrations/__pycache__/__init__.cpython-38.pyc,sha256=YMBRHVon2nWDtIUbghckjnC12sIg_ykPWhV5aM0tto4,178
|
|
10444
10444
|
simo/users/__init__.py,sha256=6a7uBpCWB_DR7p54rbHusc0xvi1qfT1ZCCQGb6TiBh8,52
|
|
10445
10445
|
simo/users/admin.py,sha256=WDRJJtEkbYBQFtLg_5VOIlBV0eeJhgmrsFL51ttme0w,6760
|
|
10446
|
-
simo/users/api.py,sha256=
|
|
10446
|
+
simo/users/api.py,sha256=WSFUqBf6PMZNjZeqyppXfALs-la0rV-TVZUjuqDbeHA,12154
|
|
10447
10447
|
simo/users/apps.py,sha256=cq0A8-U1HALEwev0TicgFhr4CAu7Icz8rwq0HfOaL4E,207
|
|
10448
10448
|
simo/users/auth_backends.py,sha256=bBSNXQJ88TRXaQxyh1aETfmOIfiDr08Jnj8rSY9sHDk,4074
|
|
10449
10449
|
simo/users/auto_urls.py,sha256=lcJvteBsbHQMJieZpDz-63tDYejLApqsW3CUnDakd7k,272
|
|
10450
10450
|
simo/users/dynamic_settings.py,sha256=sEIsi4yJw3kH46Jq_aOkSuK7QTfQACGUE-lkyBogCaM,570
|
|
10451
10451
|
simo/users/managers.py,sha256=Dm21Avmu38-h8MsZ5ljtpgKihMGUBU4hHGpiPvp4NtM,323
|
|
10452
10452
|
simo/users/middleware.py,sha256=GMCrnWSc_2qCleyQIkfQGdL-pU-UTEcSg1wPvIKZ9uk,1210
|
|
10453
|
-
simo/users/models.py,sha256=
|
|
10453
|
+
simo/users/models.py,sha256=8P-nldx9cm17GxRM9p0Vkfc-MSzOK0jXpkuOD3Y46yI,19281
|
|
10454
10454
|
simo/users/permissions.py,sha256=IwtYS8yQdupWbYKR9VimSRDV3qCJ2jXP57Lyjpb2EQM,242
|
|
10455
10455
|
simo/users/serializers.py,sha256=zzw1KONTnaTNBaU0r4rNVxJ827KzD6Z5LuQt27ZsQ98,2516
|
|
10456
10456
|
simo/users/sso_urls.py,sha256=gQOaPvGMYFD0NCVSwyoWO-mTEHe5j9sbzV_RK7kdvp0,251
|
|
@@ -10460,14 +10460,14 @@ simo/users/utils.py,sha256=1HGSZyHRqQvdJ4RtAiZDg1juvgG8aOlrGXR7CcvsyQc,1886
|
|
|
10460
10460
|
simo/users/views.py,sha256=dOQVvmlHG7ihWKJLFUBcqKOA0UDctlMKR0pTc36JZqg,3487
|
|
10461
10461
|
simo/users/__pycache__/__init__.cpython-38.pyc,sha256=VFoDJE_SKKaPqqYaaBYd1Ndb1hjakkTo_u0EG_XJ1GM,211
|
|
10462
10462
|
simo/users/__pycache__/admin.cpython-38.pyc,sha256=5LEDivt0AydPmqk9PCKvlKRRtc3QBxA6hZgcy_8bEQU,7680
|
|
10463
|
-
simo/users/__pycache__/api.cpython-38.pyc,sha256=
|
|
10463
|
+
simo/users/__pycache__/api.cpython-38.pyc,sha256=BCee2Qk_VJLtXGb13VyHasDo2HmGW1ZVE6WiuTi2ijA,10223
|
|
10464
10464
|
simo/users/__pycache__/apps.cpython-38.pyc,sha256=dgbWL8CxzzISJQTmq_4IztPJ2UzykNVdqA2Ae1PmeGk,605
|
|
10465
10465
|
simo/users/__pycache__/auth_backends.cpython-38.pyc,sha256=n5nx2QSXNj2idzRcGE6bAagMN-8qxoCs580H1EFZXls,3105
|
|
10466
10466
|
simo/users/__pycache__/auto_urls.cpython-38.pyc,sha256=K-3sz2h-cEitoflSmZk1t0eUg5mQMMGLNZFREVwG7_o,430
|
|
10467
10467
|
simo/users/__pycache__/dynamic_settings.cpython-38.pyc,sha256=6F8JBjZkHykySnmZjNEzjS0ijbmPdcp9yUAZ5kqq_Fo,864
|
|
10468
10468
|
simo/users/__pycache__/managers.cpython-38.pyc,sha256=oAy5mRBI-FQWgx9xgQsHmCiknKqojuVY363mfEVK0i8,697
|
|
10469
10469
|
simo/users/__pycache__/middleware.cpython-38.pyc,sha256=Tj4nVEAvxEW3xA63fBRiJWRJpz_M848ZOqbHioc_IPE,1149
|
|
10470
|
-
simo/users/__pycache__/models.cpython-38.pyc,sha256=
|
|
10470
|
+
simo/users/__pycache__/models.cpython-38.pyc,sha256=gETn4dAfZAkIpclgbmegAxWzFeq6KjZ0GPeEIP0Un54,17879
|
|
10471
10471
|
simo/users/__pycache__/permissions.cpython-38.pyc,sha256=ez5NxoL_JUeeH6GsKhvFreuA3FCBgGf9floSypdXUtM,633
|
|
10472
10472
|
simo/users/__pycache__/serializers.cpython-38.pyc,sha256=Dy8RAcwNkNSXoJHvLp8fozURyHCtucqpSPyqZtbnMZc,3732
|
|
10473
10473
|
simo/users/__pycache__/sso_urls.cpython-38.pyc,sha256=uAwDozpOmrhUald-8tOHANILXkH7-TI8fNYXOtPkSY8,402
|
|
@@ -10561,9 +10561,9 @@ simo/users/templates/invitations/expired_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCe
|
|
|
10561
10561
|
simo/users/templates/invitations/expired_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10562
10562
|
simo/users/templates/invitations/taken_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10563
10563
|
simo/users/templates/invitations/taken_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10564
|
-
simo-2.5.
|
|
10565
|
-
simo-2.5.
|
|
10566
|
-
simo-2.5.
|
|
10567
|
-
simo-2.5.
|
|
10568
|
-
simo-2.5.
|
|
10569
|
-
simo-2.5.
|
|
10564
|
+
simo-2.5.19.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
|
|
10565
|
+
simo-2.5.19.dist-info/METADATA,sha256=NsP9qv6SZr9uYMDMweh18wvAxLc5WRGqCiu0-apto0U,1924
|
|
10566
|
+
simo-2.5.19.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
10567
|
+
simo-2.5.19.dist-info/entry_points.txt,sha256=S9PwnUYmTSW7681GKDCxUbL0leRJIaRk6fDQIKgbZBA,135
|
|
10568
|
+
simo-2.5.19.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
|
|
10569
|
+
simo-2.5.19.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|