simo 2.0.0__py3-none-any.whl → 2.0.1__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/controllers.py CHANGED
@@ -275,6 +275,10 @@ class ControllerBase(ABC):
275
275
  'val': icon if any(values) else None}
276
276
  ]
277
277
 
278
+ def poke(self):
279
+ '''Use this when component is dead to try and wake it up'''
280
+ pass
281
+
278
282
  def _prepare_for_send(self, value):
279
283
  return value
280
284
 
@@ -435,7 +439,19 @@ class BinarySensor(ControllerBase):
435
439
  return value
436
440
 
437
441
 
438
- class Dimmer(ControllerBase, TimerMixin):
442
+ class OnOffPokerMixin:
443
+ _poke_toggle = False
444
+
445
+ def poke(self):
446
+ if self._poke_toggle:
447
+ self._poke_toggle = False
448
+ self.turn_on()
449
+ else:
450
+ self._poke_toggle = True
451
+ self.turn_off()
452
+
453
+
454
+ class Dimmer(ControllerBase, TimerMixin, OnOffPokerMixin):
439
455
  name = _("Dimmer")
440
456
  base_type = 'dimmer'
441
457
  app_widget = KnobWidget
@@ -444,6 +460,7 @@ class Dimmer(ControllerBase, TimerMixin):
444
460
  default_config = {'min': 0.0, 'max': 100.0, 'inverse': False}
445
461
  default_value = 0
446
462
 
463
+
447
464
  def _prepare_for_send(self, value):
448
465
  if isinstance(value, bool):
449
466
  if value:
@@ -484,7 +501,8 @@ class Dimmer(ControllerBase, TimerMixin):
484
501
  self.turn_on()
485
502
 
486
503
 
487
- class DimmerPlus(ControllerBase, TimerMixin):
504
+
505
+ class DimmerPlus(ControllerBase, TimerMixin, OnOffPokerMixin):
488
506
  name = _("Dimmer Plus")
489
507
  base_type = 'dimmer-plus'
490
508
  app_widget = KnobPlusWidget
@@ -564,7 +582,7 @@ class DimmerPlus(ControllerBase, TimerMixin):
564
582
  self.turn_on()
565
583
 
566
584
 
567
- class RGBWLight(ControllerBase, TimerMixin):
585
+ class RGBWLight(ControllerBase, TimerMixin, OnOffPokerMixin):
568
586
  name = _("RGB(W) Light")
569
587
  base_type = 'rgbw-light'
570
588
  app_widget = RGBWidget
@@ -648,7 +666,7 @@ class MultiSwitchBase(ControllerBase):
648
666
  return value
649
667
 
650
668
 
651
- class Switch(MultiSwitchBase, TimerMixin):
669
+ class Switch(MultiSwitchBase, TimerMixin, OnOffPokerMixin):
652
670
  name = _("Switch")
653
671
  base_type = 'switch'
654
672
  app_widget = SingleSwitchWidget
simo/fleet/admin.py CHANGED
@@ -81,11 +81,6 @@ class ColonelAdmin(admin.ModelAdmin):
81
81
  def has_add_permission(self, request):
82
82
  return False
83
83
 
84
- def save_model(self, request, obj, form, change):
85
- res = super().save_model(request, obj, form, change)
86
- obj.update_config()
87
- return res
88
-
89
84
  def update_firmware(self, request, queryset):
90
85
  count = 0
91
86
  for colonel in queryset:
simo/fleet/models.py CHANGED
@@ -179,6 +179,7 @@ class Colonel(DirtyFieldsMixin, models.Model):
179
179
 
180
180
  @transaction.atomic()
181
181
  def move_to(self, other_colonel):
182
+ # TODO: Need to replace pins on components!
182
183
  other_colonel.refresh_from_db()
183
184
  assert list(other_colonel.components.all()) == [], \
184
185
  "Other colonel must be completely empty!"
@@ -261,22 +262,27 @@ class ColonelPin(models.Model):
261
262
 
262
263
 
263
264
  @receiver(post_save, sender=Colonel)
264
- def create_interfaces(sender, instance, created, *args, **kwargs):
265
+ def after_colonel_save(sender, instance, created, *args, **kwargs):
265
266
  if not created:
266
267
  return
267
- for no, data in GPIO_PINS.get(instance.type).items():
268
- ColonelPin.objects.get_or_create(
269
- colonel=instance, no=no,
270
- input=data.get('input'), output=data.get('output'),
271
- capacitive=data.get('capacitive'), adc=data.get('adc'),
272
- native=data.get('native'), note=data.get('note')
273
- )
274
- if instance.type in ('ample-wall', 'game-changer'):
275
- I2CInterface.objects.create(
276
- colonel=instance, name='Main', no=0,
277
- scl_pin=ColonelPin.objects.get(colonel=instance, no=4),
278
- sda_pin=ColonelPin.objects.get(colonel=instance, no=15),
279
- )
268
+
269
+ def after_update():
270
+ for no, data in GPIO_PINS.get(instance.type).items():
271
+ ColonelPin.objects.get_or_create(
272
+ colonel=instance, no=no,
273
+ input=data.get('input'), output=data.get('output'),
274
+ capacitive=data.get('capacitive'), adc=data.get('adc'),
275
+ native=data.get('native'), note=data.get('note')
276
+ )
277
+ if instance.type in ('ample-wall', 'game-changer'):
278
+ I2CInterface.objects.create(
279
+ colonel=instance, name='Main', no=0,
280
+ scl_pin=ColonelPin.objects.get(colonel=instance, no=4),
281
+ sda_pin=ColonelPin.objects.get(colonel=instance, no=15),
282
+ )
283
+ instance.update_config()
284
+
285
+ transaction.on_commit(after_update)
280
286
 
281
287
 
282
288
  @receiver(pre_delete, sender=Component)
simo/users/serializers.py CHANGED
@@ -81,8 +81,8 @@ class FingerprintSerializer(serializers.ModelSerializer):
81
81
 
82
82
  class Meta:
83
83
  model = Fingerprint
84
- fields = 'type', 'value', 'user'
85
- read_only_fields = ('type', 'value')
84
+ fields = 'id', 'type', 'value', 'user'
85
+ read_only_fields = ('id', 'type', 'value')
86
86
 
87
87
  def get_type(self, obj):
88
88
  return obj.type
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simo
3
- Version: 2.0.0
3
+ Version: 2.0.1
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
@@ -34,7 +34,7 @@ simo/core/auto_urls.py,sha256=0gu-IL7PHobrmKW6ksffiOkAYu-aIorykWdxRNtwGYo,1194
34
34
  simo/core/autocomplete_views.py,sha256=JT5LA2_Wtr60XYSAIqaXFKFYPjrmkEf6yunXD9y2zco,4022
35
35
  simo/core/base_types.py,sha256=yqbIZqBksrAkEuHRbt6iExwPDDy0K5II2NzRCkmOvMU,589
36
36
  simo/core/context.py,sha256=98PXAMie43faRVBFkOG22uNpvGRNprcGhzjBFkrxaRY,1367
37
- simo/core/controllers.py,sha256=vJ4PXlmo8gZ7_Cm16IV9fvgObolkC-0P7dgujavvXnE,26200
37
+ simo/core/controllers.py,sha256=bxJRpmREw8CsgDAiuVvpOl8HxHhZqrRM1qXTF_8afV4,26617
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
@@ -10120,7 +10120,7 @@ simo/core/utils/validators.py,sha256=FRO6_K5HAO1OaC-LosApZjh-W3EA-IJZ53HnwEJgqiI
10120
10120
  simo/core/utils/__pycache__/api.cpython-38.pyc,sha256=CuJq9GKQC8gbeCxmH2wQHZUmkIihVILSEIAoVYCFwH0,1575
10121
10121
  simo/core/utils/__pycache__/serialization.cpython-38.pyc,sha256=zOo2M97bAC0Ed-iiNoVtcHvgdAYR8RwrF2bUwuf8Pus,1145
10122
10122
  simo/fleet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10123
- simo/fleet/admin.py,sha256=9dEA3XcynAhcyeJrGzuPOXSGGPtawVyHUOyrVty5CEc,5480
10123
+ simo/fleet/admin.py,sha256=sN16en2sKYbApCHkitjOq6Fc5xagBTRSQ8tNCiVa1r0,5317
10124
10124
  simo/fleet/api.py,sha256=Hxn84xI-Q77HxjINgRbjSJQOv9jii4OL20LxK0VSrS8,2499
10125
10125
  simo/fleet/auto_urls.py,sha256=gAXTWUvsWkQHRdZGM_W_5iJBEsM4lY063kIx3f5LUqs,578
10126
10126
  simo/fleet/ble.py,sha256=eHA_9ABjbmH1vUVCv9hiPXQL2GZZSEVwfO0xyI1S0nI,1081
@@ -10128,7 +10128,7 @@ simo/fleet/controllers.py,sha256=ELYfj2o1xrceg2tcprv6ofHA4WtYaWrFmgiIAthnCSw,138
10128
10128
  simo/fleet/forms.py,sha256=UGj1mK2Zbl2LRlvLtEDObeGfC2wcuHleRbePo1_Vx6I,34972
10129
10129
  simo/fleet/gateways.py,sha256=xFsmF_SXYXK_kMJOCHkiInPJ_0VcPWz-kJDoMup2lT8,1576
10130
10130
  simo/fleet/managers.py,sha256=kpfvvfdH4LDxddIBDpdAb5gsVk8Gb0-L9biFcj9OFPs,807
10131
- simo/fleet/models.py,sha256=ly_1nU0rzLcplkQe7pBL-7BweRiaKOj0XunyvQSQIno,12216
10131
+ simo/fleet/models.py,sha256=iLIdmcWTr_j8R7wTHph3fAExek8UH4S1HJyJ-asTNgw,12420
10132
10132
  simo/fleet/routing.py,sha256=cofGsVWXMfPDwsJ6HM88xxtRxHwERhJ48Xyxc8mxg5o,149
10133
10133
  simo/fleet/serializers.py,sha256=lVxqb4ldmJ5bUIklqeet5AIQak2Fbp_Tx5uKcP0eqmQ,1339
10134
10134
  simo/fleet/socket_consumers.py,sha256=HbkrV0i1TwBC38otu_2lzN6IlBdyZHVdXIVhU4y-YCM,18872
@@ -10279,7 +10279,7 @@ simo/users/dynamic_settings.py,sha256=sEIsi4yJw3kH46Jq_aOkSuK7QTfQACGUE-lkyBogCa
10279
10279
  simo/users/middleware.py,sha256=9epN8xDcnYAMoEjAeJGg4W9e54szTgh48LKz3rlywFI,1287
10280
10280
  simo/users/models.py,sha256=f59mkQBpq_fFLDUa-44b1qWleB-TvGdC1M0G67huJMg,18498
10281
10281
  simo/users/permissions.py,sha256=IwtYS8yQdupWbYKR9VimSRDV3qCJ2jXP57Lyjpb2EQM,242
10282
- simo/users/serializers.py,sha256=9fDT23WBsOSPnNlmtOp6095IF8wng2eg_iboUCzYIDA,2474
10282
+ simo/users/serializers.py,sha256=yrWghK7ONxfzkjO3LbDLK1WPxsPBMYUegdm29qovjjo,2486
10283
10283
  simo/users/sso_urls.py,sha256=gQOaPvGMYFD0NCVSwyoWO-mTEHe5j9sbzV_RK7kdvp0,251
10284
10284
  simo/users/sso_views.py,sha256=-XI67TvQ7SN3goU4OuAHyn84u_1vtusvpn7Pu0K97zo,4648
10285
10285
  simo/users/tasks.py,sha256=v9J7t4diB0VnqUDVZAQ8H-rlr4ZR14bgEUuEGpODyOI,854
@@ -10343,8 +10343,8 @@ simo/users/templates/invitations/expired_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCe
10343
10343
  simo/users/templates/invitations/expired_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10344
10344
  simo/users/templates/invitations/taken_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10345
10345
  simo/users/templates/invitations/taken_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10346
- simo-2.0.0.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10347
- simo-2.0.0.dist-info/METADATA,sha256=a3T7zOscRzMDFgziDrgeASopaHXZ8XnLBEwdS4OTl08,1669
10348
- simo-2.0.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
10349
- simo-2.0.0.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10350
- simo-2.0.0.dist-info/RECORD,,
10346
+ simo-2.0.1.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10347
+ simo-2.0.1.dist-info/METADATA,sha256=UNG_zOqdwai9Z5jFbVFDrXcVozRzzHrASc4hdMZgKQM,1669
10348
+ simo-2.0.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
10349
+ simo-2.0.1.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10350
+ simo-2.0.1.dist-info/RECORD,,
File without changes