simo 2.5.5__py3-none-any.whl → 2.5.6__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/models.py CHANGED
@@ -119,7 +119,8 @@ class Instance(DirtyFieldsMixin, models.Model, SimoAdminMixin):
119
119
 
120
120
  class Zone(DirtyFieldsMixin, models.Model, SimoAdminMixin):
121
121
  instance = models.ForeignKey(
122
- Instance, on_delete=models.CASCADE, related_name='zones'
122
+ Instance, on_delete=models.CASCADE, related_name='zones',
123
+ limit_choices_to={'is_active': True}
123
124
  )
124
125
  name = models.CharField(_('name'), max_length=40)
125
126
  order = models.PositiveIntegerField(
@@ -139,7 +140,9 @@ class Zone(DirtyFieldsMixin, models.Model, SimoAdminMixin):
139
140
 
140
141
 
141
142
  class Category(DirtyFieldsMixin, models.Model, SimoAdminMixin):
142
- instance = models.ForeignKey(Instance, on_delete=models.CASCADE)
143
+ instance = models.ForeignKey(
144
+ Instance, on_delete=models.CASCADE, limit_choices_to={'is_active': True}
145
+ )
143
146
  name = models.CharField(_('name'), max_length=40)
144
147
  icon = models.ForeignKey(Icon, on_delete=models.SET_NULL, null=True)
145
148
  header_image = models.ImageField(
@@ -29,8 +29,11 @@ class Automation:
29
29
  # at least one user's phone is not yet on charge
30
30
  return
31
31
  self.night_is_on = True
32
+ print("Night!")
32
33
  return 'night'
33
34
  else:
35
+ if datetime.hour >= 22 or datetime.hour < 6:
36
+ return
34
37
  # return new_state diena only if there are still users
35
38
  # at home, none of them have their phones on charge
36
39
  # and current state is still night
@@ -41,9 +44,10 @@ class Automation:
41
44
  if iuser.phone_on_charge:
42
45
  # at least one user's phone is still on charge
43
46
  return
44
- else:
45
- self.night_is_on = False
47
+
48
+ self.night_is_on = False
46
49
  if not self.night_is_on and state.value == 'night':
50
+ print("Day has come!")
47
51
  return 'day'
48
52
 
49
53
  def run(self):
simo/fleet/models.py CHANGED
@@ -33,7 +33,8 @@ def get_new_secret():
33
33
 
34
34
  class InstanceOptions(models.Model):
35
35
  instance = models.OneToOneField(
36
- Instance, on_delete=models.CASCADE, related_name='fleet_options'
36
+ Instance, on_delete=models.CASCADE, related_name='fleet_options',
37
+ limit_choices_to={'is_active': True}
37
38
  )
38
39
  secret_key = models.CharField(max_length=20, default=get_new_secret)
39
40
 
@@ -46,7 +47,7 @@ def create_instance_options(sender, instance, *args, **kwargs):
46
47
  class Colonel(DirtyFieldsMixin, models.Model):
47
48
  instance = models.ForeignKey(
48
49
  'core.Instance', on_delete=models.CASCADE, related_name='colonels',
49
- null=True,
50
+ limit_choices_to={'is_active': True}
50
51
  )
51
52
  uid = models.CharField(
52
53
  max_length=100, db_index=True, editable=False, unique=True,
@@ -1,66 +0,0 @@
1
- import time
2
- import random
3
- from django.utils import timezone
4
- from simo.core.middleware import get_current_instance
5
- from simo.core.models import Component
6
- from simo.users.models import InstanceUser
7
- from simo.generic.scripting.helpers import LocalSun
8
-
9
-
10
- class Automation:
11
- REZIMAS_COMPONENT_ID = 130
12
-
13
- def __init__(self):
14
- self.instance = get_current_instance()
15
- self.rezimas = Component.objects.get(id=self.REZIMAS_COMPONENT_ID)
16
- self.sun = LocalSun(self.instance.location)
17
- self.night_is_on = False
18
-
19
- def check_owner_phones(self, rezimas, instance_users, datetime):
20
- if not self.night_is_on:
21
- if not (datetime.hour >= 22 or datetime.hour < 6):
22
- return
23
-
24
- for iuser in instance_users:
25
- # skipping users that are not at home
26
- if not iuser.at_home:
27
- continue
28
- if not iuser.phone_on_charge:
29
- # at least one user's phone is not yet on charge
30
- return
31
- self.night_is_on = True
32
- return 'night'
33
- else:
34
- # return new_rezimas diena only if there are still users
35
- # at home, none of them have their phones on charge
36
- # and current rezimas is still night
37
- for iuser in instance_users:
38
- # skipping users that are not at home
39
- if not iuser.at_home:
40
- continue
41
- if iuser.phone_on_charge:
42
- # at least one user's phone is still on charge
43
- return
44
- else:
45
- self.night_is_on = False
46
- if not self.night_is_on and rezimas.value == 'night':
47
- return 'day'
48
-
49
- def run(self):
50
- while True:
51
- instance_users = InstanceUser.objects.filter(
52
- is_active=True, role__is_owner=True
53
- )
54
- self.rezimas.refresh_from_db()
55
- new_rezimas = self.check_owner_phones(
56
- self.rezimas, instance_users, timezone.localtime()
57
- )
58
- if new_rezimas:
59
- self.rezimas.send(new_rezimas)
60
-
61
- # randomize script load
62
- time.sleep(random.randint(20, 40))
63
-
64
-
65
- def test(self):
66
- pass
@@ -15,6 +15,13 @@ class NotificationAdmin(admin.ModelAdmin):
15
15
  inlines = UserNotificationInline,
16
16
  actions = 'dispatch',
17
17
 
18
+ readonly_fields = 'instance',
19
+
20
+ def save_model(self, request, obj, form, change):
21
+ if not obj.id:
22
+ obj.instance = get_current_instance()
23
+ return super().save_model(request, obj, form, change)
24
+
18
25
  def get_queryset(self, request):
19
26
  qs = super().get_queryset(request)
20
27
  instance = get_current_instance()
@@ -14,7 +14,9 @@ class Notification(models.Model):
14
14
  Notification get's sent to_users as soon as it's created.
15
15
  If new users are added, notification gets sent to those users as well.
16
16
  '''
17
- instance = models.ForeignKey(Instance, on_delete=models.CASCADE)
17
+ instance = models.ForeignKey(
18
+ Instance, on_delete=models.CASCADE, limit_choices_to={'is_active': True}
19
+ )
18
20
  datetime = models.DateTimeField(auto_now_add=True)
19
21
  to_users = models.ManyToManyField(
20
22
  User, through='notifications.UserNotification'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simo
3
- Version: 2.5.5
3
+ Version: 2.5.6
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
@@ -52,7 +52,7 @@ simo/core/gateways.py,sha256=m0eS3XjVe34Dge6xtoCq16kFWCKJcdQrT0JW0REqoq8,3715
52
52
  simo/core/loggers.py,sha256=EBdq23gTQScVfQVH-xeP90-wII2DQFDjoROAW6ggUP4,1645
53
53
  simo/core/managers.py,sha256=n-b3I4uXzfHKTeB1VMjSaMsDUxp8FegFJwnbV1IsWQ4,3019
54
54
  simo/core/middleware.py,sha256=hExD7Vmw7eitk0vAjOwKzkwrtuw8YxpflF92j_CA2YY,3193
55
- simo/core/models.py,sha256=OSvBVfl5rmkx_h6cfQ3k_2gxoV9Nk1f8rvdoQtALquw,22496
55
+ simo/core/models.py,sha256=dqwnGUc-BKefkWx4SfGDhiytP7vxAGFcKOlEXz2VhHA,22594
56
56
  simo/core/permissions.py,sha256=v0iJM4LOeYoEfMiw3OLPYio272G1aUEAg_z9Wd1q5m0,2993
57
57
  simo/core/routing.py,sha256=X1_IHxyA-_Q7hw1udDoviVP4_FSBDl8GYETTC2zWTbY,499
58
58
  simo/core/serializers.py,sha256=Pa2lhJ6VgNalbH4awbKdGJCYAPNsu5WQWfo6Tz6LbOQ,20782
@@ -85,7 +85,7 @@ simo/core/__pycache__/gateways.cpython-38.pyc,sha256=D1ooHL-iSpQrxnD8uAl4xWFJmm-
85
85
  simo/core/__pycache__/loggers.cpython-38.pyc,sha256=Z-cdQnC6XlIonPV4Sl4E52tP4NMEdPAiHK0cFaIL7I8,1623
86
86
  simo/core/__pycache__/managers.cpython-38.pyc,sha256=6RTIxyjOgpQGtAqcUyE2vFPS09w1V5Wmd_vOV7rHRRI,3370
87
87
  simo/core/__pycache__/middleware.cpython-38.pyc,sha256=iOSTXSQl3sEsa-9kx_6w5zbEByRtfzJHT6XkUIYMGdE,2469
88
- simo/core/__pycache__/models.cpython-38.pyc,sha256=4lNUqjILHQyssviRXrr82-03Bc5LxgUrdQ_OmWozahE,18459
88
+ simo/core/__pycache__/models.cpython-38.pyc,sha256=lNpWQXIobV40Pxnq3p5PO8vSE6vX-nFrKARsWlk-76E,18508
89
89
  simo/core/__pycache__/permissions.cpython-38.pyc,sha256=fH4iyqd9DdzRLEu2b621-FeM-napR0M7hzBUTHo9Q3g,2972
90
90
  simo/core/__pycache__/routing.cpython-38.pyc,sha256=3T3FPJ8Cn99xZCGvMyg2xjl7al-Shm9CelbSpkJtNP8,599
91
91
  simo/core/__pycache__/serializers.cpython-38.pyc,sha256=qIHxrurPk555mHc9P8Udg9eGv-ODw1FTmBS_jXrPuws,19220
@@ -10166,7 +10166,7 @@ simo/core/templates/admin/users/qr_code.html,sha256=kE4WNSVsPUvNUFnSUAY8jiD9JCvc
10166
10166
  simo/core/templates/admin/wizard/discovery.html,sha256=xpAiXgKneT0d53c7h1MyAjoOFdXc_lDaH9TdelrggVU,6608
10167
10167
  simo/core/templates/admin/wizard/field.html,sha256=ZbgzAUMs6RdJDH44yQ3-rmAkPmBdsIvBTk1RAQaENAs,413
10168
10168
  simo/core/templates/admin/wizard/wizard_add.html,sha256=RPkwKXctu_yxJxjJqcvVEzG4YtK9-CJK801RPxleWRE,4127
10169
- simo/core/templates/core/auto_night_day_script.py,sha256=IJ-akeGG-aSWY1loJHArCH2PhQj_IzsukH5O62f9JLw,2231
10169
+ simo/core/templates/core/auto_night_day_script.py,sha256=6dnoU4UsjgdiEaD3hIPMovBRhI4p1aCAKL8ca_D-3zQ,2349
10170
10170
  simo/core/templates/core/auto_state_script.py,sha256=_UhSTpeCnv1oOzRzdOI9EXGdaSYevBolWChCKfPPZ6w,2666
10171
10171
  simo/core/templates/core/icon_acutocomplete_select_item.html,sha256=D7aWefAJjrDqyMcwt4vtuwkruklJ1aSjCTi99HLrQUY,768
10172
10172
  simo/core/templates/core/object_acutocomplete_select_item.html,sha256=pS8APlv1IdhfttONh3npzQNfrOhj63YC7837tnOfSHk,465
@@ -10225,7 +10225,7 @@ simo/fleet/controllers.py,sha256=fjri1GtCnflkkDpNqhTwy6i9CK6RDEB0Q_BtADzcG8E,291
10225
10225
  simo/fleet/forms.py,sha256=XTkQUxce-6VPr7-HRONJnIzWZizeIUeA6DGqqTACInQ,62980
10226
10226
  simo/fleet/gateways.py,sha256=lKEJW0MgaOEiNnijH50DNSVChvaUT3TA3UurcI57P8k,5677
10227
10227
  simo/fleet/managers.py,sha256=XOpDOA9L-f_550TNSyXnJbun2EmtGz1TenVTMlUSb8E,807
10228
- simo/fleet/models.py,sha256=eaXuUdiK9LnBFHARcR9sC049It1s6OrPTWVmysfQyYg,16812
10228
+ simo/fleet/models.py,sha256=4ZHiT2yoUv3xnDzsMbPi0Z3DOvYzEfwYZw-jxFlqG30,16884
10229
10229
  simo/fleet/routing.py,sha256=cofGsVWXMfPDwsJ6HM88xxtRxHwERhJ48Xyxc8mxg5o,149
10230
10230
  simo/fleet/serializers.py,sha256=-16BjY_bp9VbDOYuD0V54h7r_RHpuLNkJX0SydWL9aU,2247
10231
10231
  simo/fleet/socket_consumers.py,sha256=8RLEmKQ0Q7nVgJJ6IrU4ioocsWBJrgBVH_AUpVas1no,18095
@@ -10242,7 +10242,7 @@ simo/fleet/__pycache__/controllers.cpython-38.pyc,sha256=jtFHr_uyjCCeuidL-o-hGaf
10242
10242
  simo/fleet/__pycache__/forms.cpython-38.pyc,sha256=8ARAilbCnSUjwluL0mmknFcNvBRn8oZ7b2-z8Yer6ns,42498
10243
10243
  simo/fleet/__pycache__/gateways.cpython-38.pyc,sha256=0RKVn0ndreVKhsrukqeLPSdMnRrsQ_W7yeVeBkRLfIk,5058
10244
10244
  simo/fleet/__pycache__/managers.cpython-38.pyc,sha256=8uz-xpUiqbGDgXIZ_XRZtFb-Tju6NGxflGg-Ee4Yo6k,1310
10245
- simo/fleet/__pycache__/models.cpython-38.pyc,sha256=am7ceraEUIJPD5qO3y-_X1riXIYsZGYZOlZmGjqhy7g,13906
10245
+ simo/fleet/__pycache__/models.cpython-38.pyc,sha256=ePD11IHU9AoiufsuwcgaXukCGkNE0dco-JPajXB96c0,13935
10246
10246
  simo/fleet/__pycache__/routing.cpython-38.pyc,sha256=aPrCmxFKVyB8R8ZbJDwdPdFfvT7CvobovvZeq_mqRgY,314
10247
10247
  simo/fleet/__pycache__/serializers.cpython-38.pyc,sha256=9ljhwoHkolcVrJwOVbYCbGPAUKgALRwor_M3W_K0adE,3173
10248
10248
  simo/fleet/__pycache__/socket_consumers.cpython-38.pyc,sha256=cNLhA0PTF2BgXXcw4b4va1zIw-gBrghoRrSr8iZluE0,13893
@@ -10352,7 +10352,7 @@ simo/generic/__pycache__/models.cpython-38.pyc,sha256=MZpum7syAFxuulf47K7gtUlJJ7
10352
10352
  simo/generic/__pycache__/routing.cpython-38.pyc,sha256=xtxTUTBTdivzFyA5Wh7k-hUj1WDO_FiRq6HYXdbr9Ks,382
10353
10353
  simo/generic/__pycache__/socket_consumers.cpython-38.pyc,sha256=qJO5kvQLWhsQDOr1AtAtsAybuRWioxSkQei3Pc7rdP0,1737
10354
10354
  simo/generic/scripting/__init__.py,sha256=aZZvNBae7unnux_zGHCIWCV2z47hVJc-DIL72Hqfkeo,600
10355
- simo/generic/scripting/example.py,sha256=zj1puyzc9v4HNR0MTha2_1h7tkBvmVyu_drR4e-3qC0,2277
10355
+ simo/generic/scripting/example.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10356
10356
  simo/generic/scripting/helpers.py,sha256=Zt8Mx5AXIggzYk0e7jn-xQNR_NOqzolAReLkrmDJzVQ,3042
10357
10357
  simo/generic/scripting/serializers.py,sha256=PjyFrjdPK1mBsgbNhyqMi9SWzcymqTa742ipy0LhAN4,1996
10358
10358
  simo/generic/scripting/__pycache__/__init__.cpython-38.pyc,sha256=eHncoNpv5dy35IO1_htWd8CK0sHFBnU_WJ0hl5TKOHQ,794
@@ -10414,15 +10414,15 @@ simo/multimedia/migrations/__pycache__/0003_alter_sound_length.cpython-38.pyc,sh
10414
10414
  simo/multimedia/migrations/__pycache__/0004_auto_20231023_1055.cpython-38.pyc,sha256=tX6x1gNeVcUHcCFvisP9Z2jPBE029TJG632fvtvUjV8,892
10415
10415
  simo/multimedia/migrations/__pycache__/__init__.cpython-38.pyc,sha256=mCgSiQBphL85imdWyTi9-4zBDYF6HfXbhB0ycSPVVuA,175
10416
10416
  simo/notifications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10417
- simo/notifications/admin.py,sha256=hB9M_gIHx6RFB693mbOENRQR0kZhiUCrPFrakn78Y1s,949
10417
+ simo/notifications/admin.py,sha256=WQbN_bd2KRxVjbOajeworNrV9QlDNSadQT58La0Nn2M,1174
10418
10418
  simo/notifications/api.py,sha256=GXQpq68ULBaJpU8w3SJKaCKuxYGWYehKnGeocGB1RVc,1783
10419
- simo/notifications/models.py,sha256=VZcvweii59j89nPKlWeUSJ44Qz3ZLjJ6mXN6uB9F1Sw,2506
10419
+ simo/notifications/models.py,sha256=gJW0ahHvSyFrb7BzrJXa3Nk2FFDvX361ZgLcf1k7ff8,2558
10420
10420
  simo/notifications/serializers.py,sha256=altDEAPWwOhxRcEzE9-34jL8EFpyf3vPoEdAPoVLfGc,523
10421
10421
  simo/notifications/utils.py,sha256=uBl-Y7WGu00iaGM5rrdogcq0OMRVtyVfJF39-mdB3_k,1853
10422
10422
  simo/notifications/__pycache__/__init__.cpython-38.pyc,sha256=YvucUfu98XFvEEg1LYFMlOZJpo_jSGxTVrM-ylAFLOg,167
10423
- simo/notifications/__pycache__/admin.cpython-38.pyc,sha256=cMa2NAu5NZUE5IOL5w2--SHdlCyAeboUu4RrZk26UJc,1704
10423
+ simo/notifications/__pycache__/admin.cpython-38.pyc,sha256=MScNrtVM1wavefsPfxy0A7LVyXKcbvEkLH9GJkgNOl8,1945
10424
10424
  simo/notifications/__pycache__/api.cpython-38.pyc,sha256=ys6E4AFghX6bq-rQ0gtA9s0Y2Hh-ypsWH8-Yz4edMrc,2073
10425
- simo/notifications/__pycache__/models.cpython-38.pyc,sha256=rrYjYOEzDZ3Eos2O7aof5wuIo0VUgGt6LLzhXwORDuc,2559
10425
+ simo/notifications/__pycache__/models.cpython-38.pyc,sha256=iOBlXejQrYV-M_SaPIGt6WbIV2YF5y5a3eXgnG5ZaJg,2604
10426
10426
  simo/notifications/__pycache__/serializers.cpython-38.pyc,sha256=7-eRGKYuQ4g1SpKOMpz17SIiu1HmaMoYv-cJbaO9QGA,1028
10427
10427
  simo/notifications/__pycache__/utils.cpython-38.pyc,sha256=6Tq7VkW-pZLzWzcxPtBU9MDFZLO7iLY8-ygyefoJ5OQ,1529
10428
10428
  simo/notifications/migrations/0001_initial.py,sha256=Zh69AQ-EKlQKfqfnMDVRcxvo1MxRY-TFLCdnNcgqi6g,2003
@@ -10551,9 +10551,9 @@ simo/users/templates/invitations/expired_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCe
10551
10551
  simo/users/templates/invitations/expired_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10552
10552
  simo/users/templates/invitations/taken_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10553
10553
  simo/users/templates/invitations/taken_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10554
- simo-2.5.5.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10555
- simo-2.5.5.dist-info/METADATA,sha256=DQfobm2LHYKsXxNe8CJcy_auAd59Ox-Uym_vPMW-MCc,1923
10556
- simo-2.5.5.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
10557
- simo-2.5.5.dist-info/entry_points.txt,sha256=S9PwnUYmTSW7681GKDCxUbL0leRJIaRk6fDQIKgbZBA,135
10558
- simo-2.5.5.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10559
- simo-2.5.5.dist-info/RECORD,,
10554
+ simo-2.5.6.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10555
+ simo-2.5.6.dist-info/METADATA,sha256=Q8JlXRCVfWvw15jO8jXZp65dGIWYlLNfz4u8gNIA5NI,1923
10556
+ simo-2.5.6.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
10557
+ simo-2.5.6.dist-info/entry_points.txt,sha256=S9PwnUYmTSW7681GKDCxUbL0leRJIaRk6fDQIKgbZBA,135
10558
+ simo-2.5.6.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10559
+ simo-2.5.6.dist-info/RECORD,,
File without changes