simo 2.0.15__py3-none-any.whl → 2.0.16__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/core/forms.py CHANGED
@@ -507,11 +507,22 @@ class SwitchForm(BaseComponentForm):
507
507
  )
508
508
  )
509
509
 
510
+ def __init__(self, *args, **kwargs):
511
+ super().__init__(*args, **kwargs)
512
+ if self.instance.pk:
513
+ self.fields['slaves'].initial = self.instance.slaves.all()
514
+
510
515
  def clean_slaves(self):
511
516
  if not self.cleaned_data['slaves'] or not self.instance:
512
517
  return self.cleaned_data['slaves']
513
518
  return validate_slaves(self.cleaned_data['slaves'], self.instance)
514
519
 
520
+ def save(self, commit=True):
521
+ obj = super().save(commit=commit)
522
+ if commit:
523
+ obj.slaves.set(self.cleaned_data['slaves'])
524
+ return obj
525
+
515
526
 
516
527
  class DoubleSwitchConfigForm(BaseComponentForm):
517
528
  icon_1 = forms.ModelChoiceField(
@@ -634,11 +645,23 @@ class DimmerConfigForm(BaseComponentForm):
634
645
  )
635
646
  )
636
647
 
648
+ def __init__(self, *args, **kwargs):
649
+ super().__init__(*args, **kwargs)
650
+ if self.instance.pk:
651
+ self.fields['slaves'].initial = self.instance.slaves.all()
652
+
637
653
  def clean_slaves(self):
638
654
  if not self.cleaned_data['slaves'] or not self.instance:
639
655
  return self.cleaned_data['slaves']
640
656
  return validate_slaves(self.cleaned_data['slaves'], self.instance)
641
657
 
658
+ def save(self, commit=True):
659
+ self.instance.config['output_pin_no'] = self.cleaned_data['output_pin'].no
660
+ obj = super().save(commit=commit)
661
+ if commit:
662
+ obj.slaves.set(self.cleaned_data['slaves'])
663
+ return obj
664
+
642
665
 
643
666
  class DimmerPlusConfigForm(BaseComponentForm):
644
667
  main_min = forms.FloatField(
Binary file
simo/fleet/forms.py CHANGED
@@ -526,12 +526,16 @@ class ColonelSwitchConfigForm(ColonelComponentForm):
526
526
  )
527
527
  )
528
528
 
529
+ def __init__(self, *args, **kwargs):
530
+ super().__init__(*args, **kwargs)
531
+ if self.instance.pk:
532
+ self.fields['slaves'].initial = self.instance.slaves.all()
533
+
529
534
  def clean_slaves(self):
530
535
  if not self.cleaned_data['slaves'] or not self.instance:
531
536
  return self.cleaned_data['slaves']
532
537
  return validate_slaves(self.cleaned_data['slaves'], self.instance)
533
538
 
534
-
535
539
  def clean(self):
536
540
  super().clean()
537
541
  if not self.cleaned_data.get('colonel'):
@@ -551,7 +555,10 @@ class ColonelSwitchConfigForm(ColonelComponentForm):
551
555
 
552
556
  def save(self, commit=True):
553
557
  self.instance.config['output_pin_no'] = self.cleaned_data['output_pin'].no
554
- return super().save(commit=commit)
558
+ obj = super().save(commit=commit)
559
+ if commit:
560
+ obj.slaves.set(self.cleaned_data['slaves'])
561
+ return obj
555
562
 
556
563
 
557
564
  class ColonelPWMOutputConfigForm(ColonelComponentForm):
@@ -625,6 +632,11 @@ class ColonelPWMOutputConfigForm(ColonelComponentForm):
625
632
  )
626
633
  )
627
634
 
635
+ def __init__(self, *args, **kwargs):
636
+ super().__init__(*args, **kwargs)
637
+ if self.instance.pk:
638
+ self.fields['slaves'].initial = self.instance.slaves.all()
639
+
628
640
  def clean_slaves(self):
629
641
  if not self.cleaned_data['slaves'] or not self.instance:
630
642
  return self.cleaned_data['slaves']
@@ -649,7 +661,10 @@ class ColonelPWMOutputConfigForm(ColonelComponentForm):
649
661
 
650
662
  def save(self, commit=True):
651
663
  self.instance.config['output_pin_no'] = self.cleaned_data['output_pin'].no
652
- return super().save(commit=commit)
664
+ obj = super().save(commit=commit)
665
+ if commit:
666
+ obj.slaves.set(self.cleaned_data['slaves'])
667
+ return obj
653
668
 
654
669
 
655
670
  class ColonelRGBLightConfigForm(ColonelComponentForm):
simo/fleet/models.py CHANGED
@@ -101,9 +101,9 @@ class Colonel(DirtyFieldsMixin, models.Model):
101
101
  return self.name if self.name else self.uid
102
102
 
103
103
  def save(self, *args, **kwargs):
104
- if 'socket_connected' in self.get_dirty_fields() and self.pk:
104
+ if 'socket_connected' in self.get_dirty_fields() and self.socket_connected:
105
105
  for comp in self.components.all():
106
- comp.alive = self.is_connected
106
+ comp.alive = True
107
107
  comp.save()
108
108
 
109
109
  if self.minor_upgrade_available and self.firmware_version == self.minor_upgrade_available:
simo/fleet/tasks.py ADDED
@@ -0,0 +1,25 @@
1
+ import datetime
2
+ from django.db.models import Prefetch
3
+ from django.utils import timezone
4
+ from celeryc import celery_app
5
+
6
+
7
+ @celery_app.task
8
+ def check_colonel_components_alive():
9
+ from simo.core.models import Component
10
+ from .models import Colonel
11
+ for lost_colonel in Colonel.objects.filter(
12
+ last_seen__lt=timezone.now() - datetime.timedelta(seconds=60)
13
+ ).prefetch_related(Prefetch(
14
+ 'components', queryset=Component.objects.filter(alive=True),
15
+ to_attr='alive_components'
16
+ )):
17
+ for comp in lost_colonel.alive_components:
18
+ print(f"{comp} is no longer alive!")
19
+ comp.alive = False
20
+ comp.save()
21
+
22
+
23
+ @celery_app.on_after_finalize.connect
24
+ def setup_periodic_tasks(sender, **kwargs):
25
+ sender.add_periodic_task(20, check_colonel_components_alive.s())
simo/users/models.py CHANGED
@@ -113,7 +113,7 @@ def post_instance_user_save(sender, instance, created, **kwargs):
113
113
  if 'at_home' in dirty_fields:
114
114
  def post_update():
115
115
  ObjectChangeEvent(
116
- instance, dirty_fields=dirty_fields
116
+ instance.instance, instance, dirty_fields=dirty_fields
117
117
  ).publish()
118
118
  transaction.on_commit(post_update)
119
119
  if 'role' or 'is_active' in instance.dirty_fields:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simo
3
- Version: 2.0.15
3
+ Version: 2.0.16
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
@@ -38,7 +38,7 @@ simo/core/controllers.py,sha256=2NH1xZFA4_YWNjJWjHqEvCB6SerebiQ5eHZix_xYvx8,2696
38
38
  simo/core/dynamic_settings.py,sha256=U2WNL96JzVXdZh0EqMPWrxqO6BaRR2Eo5KTDqz7MC4o,1943
39
39
  simo/core/events.py,sha256=LvtonJGNyCb6HLozs4EG0WZItnDwNdtnGQ4vTcnKvUs,4438
40
40
  simo/core/filters.py,sha256=ghtOZcrwNAkIyF5_G9Sn73NkiI71mXv0NhwCk4IyMIM,411
41
- simo/core/forms.py,sha256=H66FJCX_OJ8ADTfFHRLLl6xEg5AsaFH59rbd2rCE2c8,21711
41
+ simo/core/forms.py,sha256=iI3tiHMbjSrjldH8W8OYh8qJyT8QTVtfYczTPINY1ds,22502
42
42
  simo/core/gateways.py,sha256=s_c2W0v2_te89i6LS4Nj7F2wn9UwjZXPT7pfy6SToVo,3714
43
43
  simo/core/loggers.py,sha256=EBdq23gTQScVfQVH-xeP90-wII2DQFDjoROAW6ggUP4,1645
44
44
  simo/core/managers.py,sha256=WoQ4OX3akIvoroSYji-nLVqXBSJzCiC1u_IiWkKbKmA,2413
@@ -69,7 +69,7 @@ simo/core/__pycache__/controllers.cpython-38.pyc,sha256=WmItOZU7CPqyYhxxB1F9I7QA
69
69
  simo/core/__pycache__/dynamic_settings.cpython-38.pyc,sha256=ELu06Hub4DOidja71ybvD3ZM4HdXiyZjNJrZfnXZXNA,2476
70
70
  simo/core/__pycache__/events.cpython-38.pyc,sha256=A1Axx-qftd1r7st7wkO3DkvTdt9-RkcJe5KJhpzJVk8,5109
71
71
  simo/core/__pycache__/filters.cpython-38.pyc,sha256=VIMADCBiYhziIyRmxAyUDJluZvuZmiC4bNYWTRsGSao,721
72
- simo/core/__pycache__/forms.cpython-38.pyc,sha256=ikU7wTC6vxzsCJJul0VD5qFJlpXHvvksSkwGun8tYVM,18187
72
+ simo/core/__pycache__/forms.cpython-38.pyc,sha256=iuxu0J6KHGL2TJl2nPIrVEkSFurM9N95kHFI-OAfT34,19047
73
73
  simo/core/__pycache__/gateways.cpython-38.pyc,sha256=XBiwMfBkjoQ2re6jvADJOwK0_0Aav-crzie9qtfqT9U,4599
74
74
  simo/core/__pycache__/loggers.cpython-38.pyc,sha256=Z-cdQnC6XlIonPV4Sl4E52tP4NMEdPAiHK0cFaIL7I8,1623
75
75
  simo/core/__pycache__/managers.cpython-38.pyc,sha256=5vstOMfm997CZBBkaSiaS7EojhLTWZlbeA_EQ8u-yfg,2554
@@ -10169,13 +10169,14 @@ simo/fleet/auto_urls.py,sha256=X04oKJWA48wFW5iXg3PPROY2KDdHn_a99orQSE28QC4,518
10169
10169
  simo/fleet/base_types.py,sha256=wL9RVkHr0gA7HI1wZq0pruGEIgvQqpfnCL4cC3ywsvw,102
10170
10170
  simo/fleet/ble.py,sha256=eHA_9ABjbmH1vUVCv9hiPXQL2GZZSEVwfO0xyI1S0nI,1081
10171
10171
  simo/fleet/controllers.py,sha256=rTxRFf-LKWAZxzixrsLZHHm51BmMx9a1PLdgf6inlNM,20533
10172
- simo/fleet/forms.py,sha256=Ree_e3V0rBkVk1bVPr4aV8bsdo0pfCS8i5UV2OBtMJQ,37684
10172
+ simo/fleet/forms.py,sha256=ucH9mkwHDA8iUaxVP5W9O8tyoKUb7N2V0KCVSD-oCWI,38237
10173
10173
  simo/fleet/gateways.py,sha256=KV5i5fxXIrlK-k6zyEkk83x11GJt-ELQ0npb4Ac83cM,3693
10174
10174
  simo/fleet/managers.py,sha256=XOpDOA9L-f_550TNSyXnJbun2EmtGz1TenVTMlUSb8E,807
10175
- simo/fleet/models.py,sha256=J-rnn7Ew-7s3646NNRVY947Sbz21mUD_nBHtuHAKXds,14160
10175
+ simo/fleet/models.py,sha256=1Wb9xPc61OtoiYu9aS4KezchPGZTC4CDxa2dqVhltqM,14161
10176
10176
  simo/fleet/routing.py,sha256=cofGsVWXMfPDwsJ6HM88xxtRxHwERhJ48Xyxc8mxg5o,149
10177
10177
  simo/fleet/serializers.py,sha256=zEpXAXxjk4Rf1JhlNnLTrs20qJggqjvIySbeHVo4Tt4,1505
10178
10178
  simo/fleet/socket_consumers.py,sha256=Z-MooNN2HQccdhkynADJks5slbK9mGsnEpMLuA51H3I,18534
10179
+ simo/fleet/tasks.py,sha256=AGq9BXFNAqkhOANsPvId8yjEbDtVCB3MRsi_AKDpgIM,821
10179
10180
  simo/fleet/utils.py,sha256=2gcjbwQawsGw2edr_wm9q6XacGpYqO-gd4BF1t0Hg6U,3511
10180
10181
  simo/fleet/views.py,sha256=YKkcf8KcLgiPjr-brIHvu5yr1zZUIs8aytAgwdo49Pg,1694
10181
10182
  simo/fleet/__pycache__/__init__.cpython-38.pyc,sha256=pIZE7EL6-cuJ3pQtaSwjKLrKLsTYelp1k9sRhXKLh6s,159
@@ -10185,13 +10186,14 @@ simo/fleet/__pycache__/auto_urls.cpython-38.pyc,sha256=SqyTuaz_kEBvx-bL46SclsZEE
10185
10186
  simo/fleet/__pycache__/base_types.cpython-38.pyc,sha256=deyPwjpT6xZiFxBGFnj5b7R-lbdOTh2krgpJhrcGVhc,274
10186
10187
  simo/fleet/__pycache__/ble.cpython-38.pyc,sha256=Nrof9w7cm4OlpFWHeVnmvvanh2_oF9oQ3TknJiV93-0,1267
10187
10188
  simo/fleet/__pycache__/controllers.cpython-38.pyc,sha256=l9bz18Qp33C12TJOKPSn9vIXnlBKnBusODNk7Fg64qA,18103
10188
- simo/fleet/__pycache__/forms.cpython-38.pyc,sha256=IvK-njOrKBAlvzSGsvPrKnsHwB1gcRrmWL8Nlkg_fF0,27050
10189
+ simo/fleet/__pycache__/forms.cpython-38.pyc,sha256=vFMihKqwLKQRO9GoErkNZwGmDPQd6OYywh9iiZ8rf84,27566
10189
10190
  simo/fleet/__pycache__/gateways.cpython-38.pyc,sha256=YAcgTOqJbtjGI03lvEcU6keFfrwAHkObVmErYzfRvjk,3569
10190
10191
  simo/fleet/__pycache__/managers.cpython-38.pyc,sha256=8uz-xpUiqbGDgXIZ_XRZtFb-Tju6NGxflGg-Ee4Yo6k,1310
10191
- simo/fleet/__pycache__/models.cpython-38.pyc,sha256=S9pPqRjIxASXahoIOkkjQX7cBwjkdu4d2nXMju0-Cf8,12283
10192
+ simo/fleet/__pycache__/models.cpython-38.pyc,sha256=DQtRR6kI9bt3atgJ0pArCVfSyuutqb6SpxYrsBg10cM,12277
10192
10193
  simo/fleet/__pycache__/routing.cpython-38.pyc,sha256=aPrCmxFKVyB8R8ZbJDwdPdFfvT7CvobovvZeq_mqRgY,314
10193
10194
  simo/fleet/__pycache__/serializers.cpython-38.pyc,sha256=yuY2H7jcboQGZdjb5WIsgNHXFhI9IPMUrEu9NgSiXNo,2452
10194
10195
  simo/fleet/__pycache__/socket_consumers.cpython-38.pyc,sha256=RjzPD580096fby0HYLzZorm61zdZNOq5AHXmNAC4Yd8,13764
10196
+ simo/fleet/__pycache__/tasks.cpython-38.pyc,sha256=RoNxL2WUiW67s9O9DjaYVVjCBSZu2nje0Qn9FJkWVS0,1116
10195
10197
  simo/fleet/__pycache__/utils.cpython-38.pyc,sha256=dTuvW9MnhUycwdCc6eHYfHsMlvZw-CmEWXWYu18X8Uw,1955
10196
10198
  simo/fleet/__pycache__/views.cpython-38.pyc,sha256=7hhRBlf6Vczg0TTdwTE5Hc5B-F7VcvFg1iS6mfs-fgo,1790
10197
10199
  simo/fleet/migrations/0001_initial.py,sha256=lce8nkD8Sz6pYr-XJSpDm4CMDuB6TA__WtnHpIp-eA4,1326
@@ -10359,7 +10361,7 @@ simo/users/auth_backends.py,sha256=I5pnaTa20-Lxfw_dFG8471xDITb0_fQl1PVhJalp5vU,3
10359
10361
  simo/users/auto_urls.py,sha256=lcJvteBsbHQMJieZpDz-63tDYejLApqsW3CUnDakd7k,272
10360
10362
  simo/users/dynamic_settings.py,sha256=sEIsi4yJw3kH46Jq_aOkSuK7QTfQACGUE-lkyBogCaM,570
10361
10363
  simo/users/middleware.py,sha256=GMCrnWSc_2qCleyQIkfQGdL-pU-UTEcSg1wPvIKZ9uk,1210
10362
- simo/users/models.py,sha256=e4Abz8Px4f9QUGmiqhNKduBeUjJMPlnf0tDdqRCSM1A,18565
10364
+ simo/users/models.py,sha256=Sr2T0GaN8l4iXIRR_ZXdaJO088nn5REyhwQju1S3X2g,18585
10363
10365
  simo/users/permissions.py,sha256=IwtYS8yQdupWbYKR9VimSRDV3qCJ2jXP57Lyjpb2EQM,242
10364
10366
  simo/users/serializers.py,sha256=Gay16bdHinjhbn1Ly2KBwnomwK2d4jclO-OqAVeWbZI,2491
10365
10367
  simo/users/sso_urls.py,sha256=gQOaPvGMYFD0NCVSwyoWO-mTEHe5j9sbzV_RK7kdvp0,251
@@ -10374,7 +10376,7 @@ simo/users/__pycache__/auth_backends.cpython-38.pyc,sha256=MuOieBIXt6lrDx83-UQtd
10374
10376
  simo/users/__pycache__/auto_urls.cpython-38.pyc,sha256=K-3sz2h-cEitoflSmZk1t0eUg5mQMMGLNZFREVwG7_o,430
10375
10377
  simo/users/__pycache__/dynamic_settings.cpython-38.pyc,sha256=6F8JBjZkHykySnmZjNEzjS0ijbmPdcp9yUAZ5kqq_Fo,864
10376
10378
  simo/users/__pycache__/middleware.cpython-38.pyc,sha256=Tj4nVEAvxEW3xA63fBRiJWRJpz_M848ZOqbHioc_IPE,1149
10377
- simo/users/__pycache__/models.cpython-38.pyc,sha256=qSDZPjbMd5t7qDWGQSX6zE1IwrSsqzzNFYGanlAMMDw,17515
10379
+ simo/users/__pycache__/models.cpython-38.pyc,sha256=xgieyXEO74tyeN2rTUaPb0ciRgqx6XNGerGre4BYj9E,17526
10378
10380
  simo/users/__pycache__/permissions.cpython-38.pyc,sha256=ez5NxoL_JUeeH6GsKhvFreuA3FCBgGf9floSypdXUtM,633
10379
10381
  simo/users/__pycache__/serializers.cpython-38.pyc,sha256=RfyHFuPrIhPJ62h5RHy3h17S-5DX41hL5cLhmcDIaXo,3435
10380
10382
  simo/users/__pycache__/sso_urls.cpython-38.pyc,sha256=uAwDozpOmrhUald-8tOHANILXkH7-TI8fNYXOtPkSY8,402
@@ -10444,8 +10446,8 @@ simo/users/templates/invitations/expired_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCe
10444
10446
  simo/users/templates/invitations/expired_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10445
10447
  simo/users/templates/invitations/taken_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10446
10448
  simo/users/templates/invitations/taken_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10447
- simo-2.0.15.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10448
- simo-2.0.15.dist-info/METADATA,sha256=UqCCt7aUFVM4KSRZgpdaBDqE7HmzyUYAa8BKE01kwz8,1700
10449
- simo-2.0.15.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
10450
- simo-2.0.15.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10451
- simo-2.0.15.dist-info/RECORD,,
10449
+ simo-2.0.16.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10450
+ simo-2.0.16.dist-info/METADATA,sha256=toSBqhmwLzLJ7BNGd9_e0-YJpXhry91efsl9xGJn01M,1700
10451
+ simo-2.0.16.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
10452
+ simo-2.0.16.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10453
+ simo-2.0.16.dist-info/RECORD,,
File without changes