simo 2.6.2__py3-none-any.whl → 2.6.4__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.

Binary file
simo/automation/forms.py CHANGED
@@ -112,14 +112,7 @@ class ScriptConfigForm(BaseComponentForm):
112
112
  self.cleaned_data['code'] = self._ai_resp['result']
113
113
  if 'notes' in self.cleaned_data:
114
114
  self.cleaned_data['notes'] = self._ai_resp['description']
115
- obj = super().save(commit)
116
- if commit:
117
- obj.controller.stop()
118
- if self.cleaned_data.get('keep_alive') \
119
- or self.cleaned_data.get('autostart'):
120
- time.sleep(2)
121
- obj.controller.start()
122
- return obj
115
+ return super().save(commit)
123
116
 
124
117
 
125
118
  class ConditionForm(forms.Form):
@@ -156,7 +149,7 @@ class ConditionForm(forms.Form):
156
149
  controller_val_type = type(component.controller.default_value)
157
150
  for val in values:
158
151
  val = val.strip()
159
- if controller_val_type == 'bool':
152
+ if controller_val_type == bool:
160
153
  if val.lower() in ('0', 'false', 'none', 'null'):
161
154
  final_val = False
162
155
  else:
@@ -277,14 +270,4 @@ class PresenceLightingConfigForm(BaseComponentForm):
277
270
  ContentType.objects.get_for_model(Component).id,
278
271
  self.instance.id
279
272
  )
280
- )
281
-
282
- def save(self, commit=True):
283
- obj = super().save(commit)
284
- if commit:
285
- obj.controller.stop()
286
- if self.cleaned_data.get('keep_alive') \
287
- or self.cleaned_data.get('autostart'):
288
- time.sleep(2)
289
- obj.controller.start()
290
- return obj
273
+ )
@@ -1,3 +1,4 @@
1
+ import os
1
2
  import sys
2
3
  import logging
3
4
  import pytz
@@ -45,6 +46,7 @@ class ScriptRunHandler(multiprocessing.Process):
45
46
  self.logger = get_component_logger(self.component)
46
47
  sys.stdout = StreamToLogger(self.logger, logging.INFO)
47
48
  sys.stderr = StreamToLogger(self.logger, logging.ERROR)
49
+ self.component.meta['pid'] = os.getpid()
48
50
  self.component.set('running')
49
51
 
50
52
  if hasattr(self.component.controller, '_run'):
@@ -0,0 +1,31 @@
1
+ import time
2
+ from django.db import transaction
3
+ from django.db.models.signals import post_save, post_delete
4
+ from django.dispatch import receiver
5
+ from simo.core.models import Component
6
+
7
+
8
+ @receiver(post_save, sender=Component)
9
+ def post_script_change(sender, instance, created, **kwargs):
10
+ from .controllers import Script
11
+ if not isinstance(instance.controller, Script):
12
+ return
13
+
14
+ if 'config' not in instance.get_dirty_fields():
15
+ return
16
+
17
+ def post_update():
18
+ instance.controller.stop()
19
+ if instance.config.get('keep_alive') or instance.config.get('autostart'):
20
+ time.sleep(2)
21
+ instance.controller.start()
22
+
23
+ transaction.on_commit(post_update)
24
+
25
+
26
+ @receiver(post_delete, sender=Component)
27
+ def gateway_post_delete(sender, instance, *args, **kwargs):
28
+ from .controllers import Script
29
+ if not isinstance(instance.controller, Script):
30
+ return
31
+ instance.stop()
@@ -1,4 +1,5 @@
1
1
  import time
2
+ import random
2
3
  from django.utils import timezone
3
4
  from simo.core.middleware import get_current_instance
4
5
  from simo.core.models import Component
@@ -52,4 +53,6 @@ class Automation:
52
53
  new_state = get_day_evening_night_morning(
53
54
  self.sun, timezone.localtime()
54
55
  )
55
- print(f"{new_state.upper()}!")
56
+ print(f"{new_state.upper()}!")
57
+ self.state.send(new_state)
58
+ time.sleep(random.randint(60, 120))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simo
3
- Version: 2.6.2
3
+ Version: 2.6.4
4
4
  Summary: Smart Home on Steroids!
5
5
  Author-email: Simanas Venčkauskas <simanas@simo.io>
6
6
  Project-URL: Homepage, https://simo.io
@@ -8,23 +8,25 @@ simo/__pycache__/__init__.cpython-38.pyc,sha256=j81de0BqHMr6bs0C7cuYrXl7HwtK_vv8
8
8
  simo/__pycache__/asgi.cpython-38.pyc,sha256=5W_YSKOIrRd6NQQuJDuA3Yuj688GzirXVVOyLe8wJIQ,845
9
9
  simo/__pycache__/celeryc.cpython-38.pyc,sha256=eSRoaKwfYlxVaxAiwqpQ2ndEcx7W-VpZtbxRFSV8UYg,1653
10
10
  simo/__pycache__/conf.cpython-38.pyc,sha256=MYP2yk3ULxiYwZsZR6tCLjKnU-z03A3avzQzIn66y3k,273
11
- simo/__pycache__/settings.cpython-38.pyc,sha256=Grz4Vv3nIjPYHWL7mzOBC3KMVB5Cf73cRVmjNBdTCAk,6149
11
+ simo/__pycache__/settings.cpython-38.pyc,sha256=D6M7v6npEvxE6t4ks0xTW-9b6KeK6SzdCtiIM4mfJuE,6149
12
12
  simo/__pycache__/urls.cpython-38.pyc,sha256=u0x6EqT8S1YfDOSPgbI8Kf-RDlveY9OV-EDXMYKAQ7w,2125
13
13
  simo/__pycache__/wsgi.cpython-38.pyc,sha256=TpRxO7VM_ql31hbKphVdanydC5RI1nHB4l0QA2pdWxo,322
14
14
  simo/automation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  simo/automation/app_widgets.py,sha256=gaqImMZjuMHm7nIb9a4D-Y3qipz_WhSPAHXcwGx4Uzs,199
16
16
  simo/automation/controllers.py,sha256=gIkEOqq7IJ3BoDF40mN2aTGE8_yVwhQrO0RZlJYiYfg,9451
17
- simo/automation/forms.py,sha256=tom_z2CRRsjro2aq3ypjybYWfzPa-uVIJxxS5fRP8n0,10650
18
- simo/automation/gateways.py,sha256=1ByxQZPDARU006b30ua6unSbp25bcbyw1ETzQXWhrbU,9349
17
+ simo/automation/forms.py,sha256=wJMaXE5ngO_o60jqxnf4Om09q48yXpWwRna0FkQCZYs,10081
18
+ simo/automation/gateways.py,sha256=7r33NOAiRd_RGMMm44i0KYzuAuweQnEF4HxLo-Rpexs,9408
19
19
  simo/automation/helpers.py,sha256=iP-fxxB8HsFQy3k2CjFubu86aMqvWgmh-p24DiyOrek,4330
20
+ simo/automation/models.py,sha256=l45FHgeKGsfpLtd1X1PVFpIjB5JI4BlvKkodpcxm6aE,927
20
21
  simo/automation/serializers.py,sha256=PjyFrjdPK1mBsgbNhyqMi9SWzcymqTa742ipy0LhAN4,1996
21
22
  simo/automation/state.py,sha256=aZZvNBae7unnux_zGHCIWCV2z47hVJc-DIL72Hqfkeo,600
22
23
  simo/automation/__pycache__/__init__.cpython-38.pyc,sha256=YmP0xAD-mxpQHgdTZeC64sXChA8TriMZD1jckNYi3xg,164
23
24
  simo/automation/__pycache__/app_widgets.cpython-38.pyc,sha256=7DfUA9V_1MiwrOe_ta-ts8dYY8xXb9UMg2_9A3XoRcs,523
24
25
  simo/automation/__pycache__/controllers.cpython-38.pyc,sha256=JUQ105NN-9Si1pyCkqn4P_4yQ9NG7OnQfSRBzBaeth4,7535
25
- simo/automation/__pycache__/forms.cpython-38.pyc,sha256=zdNJhSZp4PXaQQgvbwO_10CaolhW5WxQOCVfQkH2N04,8131
26
- simo/automation/__pycache__/gateways.cpython-38.pyc,sha256=UhLcKI2kasoVnGCoe0M0-giBIVkWWuySMjKTgX2FdOs,7502
26
+ simo/automation/__pycache__/forms.cpython-38.pyc,sha256=qxQZeTafJOT_lrXOKY6134XjIrx5OzABAZdncNnRV4E,7720
27
+ simo/automation/__pycache__/gateways.cpython-38.pyc,sha256=W6OrugOLOGaYbibEWSs-zBZc8jQpNlO_NmJU-rmd6fU,7558
27
28
  simo/automation/__pycache__/helpers.cpython-38.pyc,sha256=4VSSarOFnUk_KExWwvDlx5dEhv8aHUCHMZDtGG--pUY,3627
29
+ simo/automation/__pycache__/models.cpython-38.pyc,sha256=6gXdIMcrWaGACal2omj-b2if5JW8QvLIrtRfYVpDRQU,1230
28
30
  simo/automation/__pycache__/serializers.cpython-38.pyc,sha256=gWgcuPE8aY-TmuRLXCuSR74mvtKerpZ04m0MfPfw0AI,3405
29
31
  simo/automation/__pycache__/state.cpython-38.pyc,sha256=TO2IM6h2hbGVlOUcoMwHkDUF4V-54d_KVhcebMgNtCk,784
30
32
  simo/automation/migrations/0001_initial.py,sha256=VB6WIK1RlUdtqlWYCEhtnVE24odp2dfUvOVcxUZPpQ4,990
@@ -34,7 +36,7 @@ simo/automation/migrations/__pycache__/0001_initial.cpython-38.pyc,sha256=yg99vG
34
36
  simo/automation/migrations/__pycache__/0002_update_helpers_in_scripts.cpython-38.pyc,sha256=O-e7CnihMInCHHBBBE6L28LeryhTECLAKQaeu2cFO5g,1039
35
37
  simo/automation/migrations/__pycache__/__init__.cpython-38.pyc,sha256=L2WU6Wk1EXhqcOKUNA9o--Z4G0aTQqwvRhKYxuUooAM,175
36
38
  simo/automation/templates/admin/controller_widgets/script.html,sha256=biUEMo5V35wqSrM97d5WqNDi47GNaDpi53I3YBfDLOs,1484
37
- simo/automation/templates/automations/auto_away.py,sha256=Vd8zixKvF4-ESn02X3fmK0FJIAQUoKEIl9ECdmxof3w,1802
39
+ simo/automation/templates/automations/auto_away.py,sha256=asz9AJ8eLHkxkpvm5phZhUqCNpghd54TKgllmvYkBoM,1911
38
40
  simo/automation/templates/automations/auto_state_script.py,sha256=pEaeKNss7L-PnhlMUpEfNRqCjquq6FAGrjTZ92CMxUY,1001
39
41
  simo/automation/templates/automations/phones_sleep_script.py,sha256=b6JZkfXdhDd3FwDJWq93kxBsm80kNzMGPWAF5jcWTHo,2894
40
42
  simo/backups/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -125,7 +127,7 @@ simo/core/__pycache__/widgets.cpython-38.pyc,sha256=sR0ZeHCHrhnNDBJuRrxp3zUsfBp0
125
127
  simo/core/db_backend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
126
128
  simo/core/db_backend/base.py,sha256=wY5jsZ8hQpwot3o-7JNtDe33xy-vlfMLXa011htDojI,601
127
129
  simo/core/db_backend/__pycache__/__init__.cpython-38.pyc,sha256=sxC6PmFqnwe6RRKzSR7QtUFzRc_aRRR1fffsR3TPLRc,169
128
- simo/core/db_backend/__pycache__/base.cpython-38.pyc,sha256=pmAGMpazhXHIsPL5dXdJICmTzyRiiMIWDzHTGhLGoRQ,977
130
+ simo/core/db_backend/__pycache__/base.cpython-38.pyc,sha256=mJMgw02ZMTB10eepCKgJhEWILAKdRFEX35Dt_1GOWhQ,977
129
131
  simo/core/drf_braces/README,sha256=sYqsYB38WGwrU_zg1ttz7Gv69wElhY9aP8VhCsb9AsU,126
130
132
  simo/core/drf_braces/__init__.py,sha256=YW_TchAczdYPAsb4DIJcKXU7qSUHF3T--Q6OW4YDybc,194
131
133
  simo/core/drf_braces/mixins.py,sha256=yIquEvCDuji1vf76hkzz3Q_DBuldXe64k4Sq2DD-dYI,1624
@@ -187,7 +189,7 @@ simo/core/management/commands/gateways_manager.py,sha256=oHzgC-eV4w_KHkiz6eCAlt3
187
189
  simo/core/management/commands/on_http_start.py,sha256=A2V40pyGY7AfONhtnxiGATOkqd0i9FUvRRxkwyAJF9k,2252
188
190
  simo/core/management/commands/run_gateway.py,sha256=bp0FQQoBeOSoxjHCCMicDL1fxPZZGyLgnq2QKht3bJo,645
189
191
  simo/core/management/commands/__pycache__/__init__.cpython-38.pyc,sha256=WKpfZZpAB9D7U4X6oWQIrU_H-6rUmq8Gl9fj9XaY2fw,178
190
- simo/core/management/commands/__pycache__/gateways_manager.cpython-38.pyc,sha256=g5xhLz6AgU7cGZ5EmoiBZIZuZbs9AN01ZRZEOCEFqeE,6031
192
+ simo/core/management/commands/__pycache__/gateways_manager.cpython-38.pyc,sha256=ijlkNjiMXKNI_81RZJLLGG4dWvLQglOrOYt5zC5WbrQ,6031
191
193
  simo/core/management/commands/__pycache__/on_http_start.cpython-38.pyc,sha256=LQeFW3oYYRrEPEcGghyeahFE114-4VbnKH4XaVGcQcg,3235
192
194
  simo/core/migrations/0001_initial.py,sha256=0Uy7IqJxQQYlurs8Mw_RJy7NaWS7BU0VFmZBBz8YkQI,9220
193
195
  simo/core/migrations/0002_load_icons.py,sha256=s9TtGo5NWEyWV3BspfbDNAlWqmQWxmDj7GjEaJXruFk,2044
@@ -10597,9 +10599,9 @@ simo/users/templates/invitations/expired_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCe
10597
10599
  simo/users/templates/invitations/expired_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10598
10600
  simo/users/templates/invitations/taken_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10599
10601
  simo/users/templates/invitations/taken_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10600
- simo-2.6.2.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10601
- simo-2.6.2.dist-info/METADATA,sha256=cAbQa5xBzOrd28hMtHVGC9zYeYZEyEQD9c0_zIoqrJI,1952
10602
- simo-2.6.2.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
10603
- simo-2.6.2.dist-info/entry_points.txt,sha256=S9PwnUYmTSW7681GKDCxUbL0leRJIaRk6fDQIKgbZBA,135
10604
- simo-2.6.2.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10605
- simo-2.6.2.dist-info/RECORD,,
10602
+ simo-2.6.4.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10603
+ simo-2.6.4.dist-info/METADATA,sha256=NoyEMezGXQEMN7GPtCpiLjVhl1WvSZrArBjsdJc8h0U,1952
10604
+ simo-2.6.4.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
10605
+ simo-2.6.4.dist-info/entry_points.txt,sha256=S9PwnUYmTSW7681GKDCxUbL0leRJIaRk6fDQIKgbZBA,135
10606
+ simo-2.6.4.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10607
+ simo-2.6.4.dist-info/RECORD,,
File without changes