simo 2.0.12__py3-none-any.whl → 2.0.13__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
Binary file
simo/core/admin.py CHANGED
@@ -336,9 +336,9 @@ class ComponentAdmin(admin.ModelAdmin):
336
336
  'alarm_category', 'arm_status'
337
337
  ):
338
338
  if field_neme in form.fields:
339
- form.fields.pop(field_neme)
339
+ form.fields.pop(field_neme, None)
340
340
  if 'slaves' not in form.declared_fields:
341
- form.fields.pop('slaves')
341
+ form.fields.pop('slaves', None)
342
342
 
343
343
  ctx['is_last'] = True
344
344
  ctx['current_step'] = 3
simo/core/forms.py CHANGED
@@ -287,8 +287,8 @@ class ComponentAdminForm(forms.ModelForm):
287
287
  model = Component
288
288
  fields = '__all__'
289
289
  exclude = (
290
- 'gateway', 'controller_uid', 'base_type', 'instance_methods'
291
- 'alive', 'value_type', 'value', 'arm_status',
290
+ 'gateway', 'controller_uid', 'base_type', 'instance_methods',
291
+ 'alive', 'value_type', 'value', 'arm_status', 'slaves',
292
292
  )
293
293
  widgets = {
294
294
  'icon': autocomplete.ModelSelect2(
@@ -331,7 +331,8 @@ class ComponentAdminForm(forms.ModelForm):
331
331
  main_fields = (
332
332
  'name', 'icon', 'zone', 'category',
333
333
  'show_in_app', 'battery_level',
334
- 'instance_methods', 'value_units',
334
+ #'instance_methods',
335
+ 'value_units',
335
336
  'alarm_category', 'arm_status',
336
337
  )
337
338
  base_fields = ['id', 'gateway', 'base_type', 'name']
@@ -347,7 +348,7 @@ class ComponentAdminForm(forms.ModelForm):
347
348
 
348
349
  base_fields.append('show_in_app')
349
350
  base_fields.append('control')
350
- base_fields.append('instance_methods')
351
+ #base_fields.append('instance_methods')
351
352
 
352
353
  fieldsets = [
353
354
  (_("Base settings"), {'fields': base_fields}),
simo/core/serializers.py CHANGED
@@ -8,6 +8,8 @@ from collections.abc import Iterable
8
8
  from easy_thumbnails.files import get_thumbnailer
9
9
  from simo.core.middleware import get_current_request
10
10
  from rest_framework import serializers
11
+ from rest_framework.fields import SkipField
12
+ from rest_framework.relations import Hyperlink, PKOnlyObject
11
13
  from simo.core.forms import HiddenField, FormsetField
12
14
  from rest_framework.relations import PrimaryKeyRelatedField, ManyRelatedField
13
15
  from .drf_braces.serializers.form_serializer import (
@@ -158,7 +160,30 @@ class ComponentFormsetField(FormSerializer):
158
160
  return kwargs
159
161
 
160
162
  def to_representation(self, instance):
161
- return super(FormSerializerBase, self).to_representation(instance)
163
+ """
164
+ Object instance -> Dict of primitive datatypes.
165
+ """
166
+ ret = OrderedDict()
167
+ fields = self._readable_fields
168
+
169
+ for field in fields:
170
+ try:
171
+ attribute = field.get_attribute(instance)
172
+ except SkipField:
173
+ continue
174
+ except:
175
+ ret[field.field_name] = None
176
+ continue
177
+
178
+ check_for_none = attribute.pk if isinstance(
179
+ attribute, PKOnlyObject
180
+ ) else attribute
181
+ if check_for_none is None:
182
+ ret[field.field_name] = None
183
+ else:
184
+ ret[field.field_name] = field.to_representation(attribute)
185
+
186
+ return ret
162
187
 
163
188
  def get_form(self, data=None, **kwargs):
164
189
  form = super().get_form(data=data, **kwargs)
@@ -188,7 +213,7 @@ class ComponentManyToManyRelatedField(serializers.Field):
188
213
  super().__init__(*args, **kwargs)
189
214
 
190
215
  def to_representation(self, value):
191
- return [obj.pk for obj in value]
216
+ return [obj.pk for obj in value.all()]
192
217
 
193
218
  def to_internal_value(self, data):
194
219
  if data == [] and self.allow_blank:
@@ -198,7 +223,6 @@ class ComponentManyToManyRelatedField(serializers.Field):
198
223
 
199
224
  class ComponentSerializer(FormSerializer):
200
225
  id = ObjectSerializerMethodField()
201
- controller_methods = serializers.SerializerMethodField()
202
226
  last_change = TimestampField(read_only=True)
203
227
  read_only = serializers.SerializerMethodField()
204
228
  app_widget = serializers.SerializerMethodField()
@@ -214,7 +238,6 @@ class ComponentSerializer(FormSerializer):
214
238
 
215
239
  class Meta:
216
240
  form = ComponentAdminForm
217
- exclude = ('instance_methods', )
218
241
  field_mapping = {
219
242
  HiddenField: HiddenSerializerField,
220
243
  forms.TypedChoiceField: serializers.ChoiceField,
@@ -228,7 +251,7 @@ class ComponentSerializer(FormSerializer):
228
251
  def get_fields(self):
229
252
  self.set_form_cls()
230
253
 
231
- ret = super(FormSerializerBase, self).get_fields()
254
+ ret = OrderedDict()
232
255
 
233
256
  field_mapping = reduce_attr_dict_from_instance(
234
257
  self,
@@ -245,11 +268,11 @@ class ComponentSerializer(FormSerializer):
245
268
  if field_name in getattr(self.Meta, 'exclude', []):
246
269
  continue
247
270
 
248
- # if field is already defined via declared fields
249
- # skip mapping it from forms which then honors
250
- # the custom validation defined on the DRF declared field
251
- if field_name in ret:
252
- continue
271
+ # # if field is already defined via declared fields
272
+ # # skip mapping it from forms which then honors
273
+ # # the custom validation defined on the DRF declared field
274
+ # if field_name in ret:
275
+ # continue
253
276
 
254
277
  form_field = form[field_name]
255
278
 
@@ -277,7 +300,10 @@ class ComponentSerializer(FormSerializer):
277
300
  ret[field_name].initial = form_field.initial
278
301
  ret[field_name].default = form_field.initial
279
302
 
280
- print("Fields: ", ret)
303
+ for name, field in super(FormSerializerBase, self).get_fields().items():
304
+ if name in ret:
305
+ continue
306
+ ret[name] = field
281
307
  return ret
282
308
 
283
309
  def _get_field_kwargs(self, form_field, serializer_field_class):
simo/fleet/controllers.py CHANGED
@@ -112,7 +112,6 @@ class DS18B20Sensor(FleeDeviceMixin, BasicSensorMixin, BaseNumericSensor):
112
112
 
113
113
 
114
114
  class BaseClimateSensor(FleeDeviceMixin, BasicSensorMixin, BaseMultiSensor):
115
- manual_add = False
116
115
  app_widget = NumericSensorWidget
117
116
 
118
117
  def __init__(self, *args, **kwargs):
@@ -195,6 +194,29 @@ class BasicOutputMixin:
195
194
  class Switch(FleeDeviceMixin, BasicOutputMixin, BaseSwitch):
196
195
  config_form = ColonelSwitchConfigForm
197
196
 
197
+ def signal(self, pulses):
198
+ '''
199
+ Expecting list of tuples where each item represents component value
200
+ followed by duration in miliseconds.
201
+ Maximum of 20 pulses is accepted, each pulse might not be longer than 3000ms
202
+ If you need anything longer than this, use on(), off() methods instead.
203
+ :param pulses: [(True, 200), (False, 600), (True, 200)]
204
+ :return: None
205
+ '''
206
+ assert len(pulses) > 0, "At least on pulse is expected"
207
+ assert len(pulses) <= 20, "No more than 20 pulses is accepted"
208
+ for i, pulse in enumerate(pulses):
209
+ assert isinstance(pulse[0], bool), f"{i+1}-th pulse is not boolean!"
210
+ assert pulse[1] <= 3000, "Pulses must not exceed 3000ms"
211
+
212
+ GatewayObjectCommand(
213
+ self.component.gateway,
214
+ Colonel(id=self.component.config['colonel']),
215
+ command='call', method='signal', args=[pulses],
216
+ id=self.component.id,
217
+ ).publish()
218
+
219
+
198
220
 
199
221
  class PWMOutput(FleeDeviceMixin, BasicOutputMixin, BaseDimmer):
200
222
  name = "Dimmer"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simo
3
- Version: 2.0.12
3
+ Version: 2.0.13
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
@@ -25,7 +25,7 @@ simo/_hub_template/hub/settings.py,sha256=4QhvhbtLRxHvAntwqG_qeAAtpDUqKvN4jzw9u3
25
25
  simo/_hub_template/hub/supervisor.conf,sha256=IY3fdK0fDD2eAothB0n54xhjQj8LYoXIR96-Adda5Z8,1353
26
26
  simo/_hub_template/hub/urls.py,sha256=Ydm-1BkYAzWeEF-MKSDIFf-7aE4qNLPm48-SA51XgJQ,25
27
27
  simo/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
- simo/core/admin.py,sha256=MoYz7B5YaTkF2JeacaqsR177N2IagKXc-rG0FTXjJ1w,17622
28
+ simo/core/admin.py,sha256=5QFmf7ZOqkSEba2Fo-UfJp5dVe-vhKUtOUlAnfQGhno,17634
29
29
  simo/core/api.py,sha256=OVvv3a7KYJGbuUgSOfWzPg8hoCCRhdDejQ2kVs0H2p8,23803
30
30
  simo/core/api_auth.py,sha256=_3hG4e1eLKrcRnSAOB_xTL6cwtOJ2_7JS7GZU_iqTgA,1251
31
31
  simo/core/api_meta.py,sha256=dZkz7z-7GaMPVAsfQxOYCvpYaMPx_v2zynbY6JM8oD8,3477
@@ -38,7 +38,7 @@ simo/core/controllers.py,sha256=2D7YCLktx7a-4tn80DenQP2CdY0dc2bWg6IRU69YTZ8,2724
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=QSBxiVD-mHG6b5M9ALvSw4mKTzZb3e0TY_m7bqD152A,21686
41
+ simo/core/forms.py,sha256=H66FJCX_OJ8ADTfFHRLLl6xEg5AsaFH59rbd2rCE2c8,21711
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
@@ -46,7 +46,7 @@ simo/core/middleware.py,sha256=64PYjnyRnYf4sgMvPfR0oQqf9UEtxUwnhJe3RV6z_HI,2040
46
46
  simo/core/models.py,sha256=j5AymbJFt5HOIOYsHJ8UUKhb1TvIoqgH0T1y3BeGJuM,19408
47
47
  simo/core/permissions.py,sha256=UmFjGPDWtAUbaWxJsWORb2q6BREHqndv9mkSIpnmdLk,1379
48
48
  simo/core/routing.py,sha256=X1_IHxyA-_Q7hw1udDoviVP4_FSBDl8GYETTC2zWTbY,499
49
- simo/core/serializers.py,sha256=aiFddwjss4Zwf05S1bMcDIePNUeBDPyTtJabNrZB26c,16351
49
+ simo/core/serializers.py,sha256=dY2R9KPvmmwMP4Up_6AHM6lf0MY3BoON8Dn8ixFubAI,17118
50
50
  simo/core/signal_receivers.py,sha256=EZ8NSYZxUgSaLS16YZdK7T__l8dl0joMRllOxx5PUt4,2809
51
51
  simo/core/socket_consumers.py,sha256=n7VE2Fvqt4iEAYLTRbTPOcI-7tszMAADu7gimBxB-Fg,9635
52
52
  simo/core/storage.py,sha256=YlxmdRs-zhShWtFKgpJ0qp2NDBuIkJGYC1OJzqkbttQ,572
@@ -56,7 +56,7 @@ simo/core/types.py,sha256=WJEq48mIbFi_5Alt4wxWMGXxNxUTXqfQU5koH7wqHHI,1108
56
56
  simo/core/views.py,sha256=hlAKpAbCbqI3a-uL5tDp532T2oLFiF0MBzKUJ_SNzo0,5833
57
57
  simo/core/widgets.py,sha256=J9e06C6I22F6xKic3VMgG7WeX07glAcl-4bF2Mg180A,2827
58
58
  simo/core/__pycache__/__init__.cpython-38.pyc,sha256=y0IW37wBUIGa3Eh_ZG28pRqHKoLiPyTgUX2OnbkEPlc,158
59
- simo/core/__pycache__/admin.cpython-38.pyc,sha256=GP3lRW8djW3w_k5jgzs_fuW7j8wnmeysZcDtm5RFnD0,13442
59
+ simo/core/__pycache__/admin.cpython-38.pyc,sha256=D9Hu5xMkclP6xFjEOLB-mBOe0ZMuCF10uilsROKkvmM,13446
60
60
  simo/core/__pycache__/api.cpython-38.pyc,sha256=W-CdACWTu_ebqH52riswadzT7z2mNRZJU8HngqbYXzw,18874
61
61
  simo/core/__pycache__/api_auth.cpython-38.pyc,sha256=5UTBr3rDMERAfc0OuOVDwGeQkt6Q7GLBtZJAMBse1sg,1712
62
62
  simo/core/__pycache__/api_meta.cpython-38.pyc,sha256=7dDi_Aay7T4eSNYmEItMlb7yU91-5_pzEVg8GXXf4Qc,2783
@@ -69,7 +69,7 @@ simo/core/__pycache__/controllers.cpython-38.pyc,sha256=-NjuX7iGheE_ZMqkZ6g4ZnnV
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=Wn5ZNCT5nqYUQUghSbdppYa1v4Fd8tuEcZAYDbae8wo,18215
72
+ simo/core/__pycache__/forms.cpython-38.pyc,sha256=ikU7wTC6vxzsCJJul0VD5qFJlpXHvvksSkwGun8tYVM,18187
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
@@ -77,7 +77,7 @@ simo/core/__pycache__/middleware.cpython-38.pyc,sha256=bGOFJNEhJeLbpsZp8LYn1VA3p
77
77
  simo/core/__pycache__/models.cpython-38.pyc,sha256=Gm36LWRxswvWiB3Wz0F7g32ZVXugh7chSSBz1lgBPZs,16995
78
78
  simo/core/__pycache__/permissions.cpython-38.pyc,sha256=uygjPbfRQiEzyo5-McCxsuMDJLbDYO_TLu55U7bJbR0,1809
79
79
  simo/core/__pycache__/routing.cpython-38.pyc,sha256=3T3FPJ8Cn99xZCGvMyg2xjl7al-Shm9CelbSpkJtNP8,599
80
- simo/core/__pycache__/serializers.cpython-38.pyc,sha256=8N_iZ3V8E5E-el3OQQRAMANJvNrYLGWb7hy91IHVtGc,16136
80
+ simo/core/__pycache__/serializers.cpython-38.pyc,sha256=07FzXZGZBEHlx1vboZThhU98WpmJDSbcQP3uYWNKMDw,16551
81
81
  simo/core/__pycache__/signal_receivers.cpython-38.pyc,sha256=sgjH_wv-1U99auH5uHb3or0qettPeHAlsz8P7B03ajY,2430
82
82
  simo/core/__pycache__/socket_consumers.cpython-38.pyc,sha256=NJUr7nRyHFvmAumxxWpsod5wzVVZM99rCEuJs1utHA4,8432
83
83
  simo/core/__pycache__/storage.cpython-38.pyc,sha256=BTkYH8QQyjqI0WOtJC8fHNtgu0YA1vjqZclXjC2vCVI,1116
@@ -10168,7 +10168,7 @@ simo/fleet/api.py,sha256=Hxn84xI-Q77HxjINgRbjSJQOv9jii4OL20LxK0VSrS8,2499
10168
10168
  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
- simo/fleet/controllers.py,sha256=SypK2i_-0iNNVDr9CWtjFVUmFjC81mtwpAwRUI_xH-A,19561
10171
+ simo/fleet/controllers.py,sha256=rTxRFf-LKWAZxzixrsLZHHm51BmMx9a1PLdgf6inlNM,20533
10172
10172
  simo/fleet/forms.py,sha256=rLymJ2ovNgmwdKYJtxTfjuIm5Q4p3GLkIb7-Yo2DmS4,36375
10173
10173
  simo/fleet/gateways.py,sha256=KV5i5fxXIrlK-k6zyEkk83x11GJt-ELQ0npb4Ac83cM,3693
10174
10174
  simo/fleet/managers.py,sha256=XOpDOA9L-f_550TNSyXnJbun2EmtGz1TenVTMlUSb8E,807
@@ -10184,7 +10184,7 @@ simo/fleet/__pycache__/api.cpython-38.pyc,sha256=rL9fb7cCQatyFvXyKmlNOKmxVo8vHYe
10184
10184
  simo/fleet/__pycache__/auto_urls.cpython-38.pyc,sha256=SqyTuaz_kEBvx-bL46SclsZEEP5RFh6U6TGKyXDdiOE,565
10185
10185
  simo/fleet/__pycache__/base_types.cpython-38.pyc,sha256=deyPwjpT6xZiFxBGFnj5b7R-lbdOTh2krgpJhrcGVhc,274
10186
10186
  simo/fleet/__pycache__/ble.cpython-38.pyc,sha256=Nrof9w7cm4OlpFWHeVnmvvanh2_oF9oQ3TknJiV93-0,1267
10187
- simo/fleet/__pycache__/controllers.cpython-38.pyc,sha256=H7RNRVGyT8ZNW3Z32sCePbALxq1huzwOroLPak2kLck,17163
10187
+ simo/fleet/__pycache__/controllers.cpython-38.pyc,sha256=l9bz18Qp33C12TJOKPSn9vIXnlBKnBusODNk7Fg64qA,18103
10188
10188
  simo/fleet/__pycache__/forms.cpython-38.pyc,sha256=-Sbb1kBxb246hV8A2ESlR4LVEISJNedVFiOK1IzRt6c,25954
10189
10189
  simo/fleet/__pycache__/gateways.cpython-38.pyc,sha256=YAcgTOqJbtjGI03lvEcU6keFfrwAHkObVmErYzfRvjk,3569
10190
10190
  simo/fleet/__pycache__/managers.cpython-38.pyc,sha256=8uz-xpUiqbGDgXIZ_XRZtFb-Tju6NGxflGg-Ee4Yo6k,1310
@@ -10444,8 +10444,8 @@ simo/users/templates/invitations/expired_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCe
10444
10444
  simo/users/templates/invitations/expired_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10445
10445
  simo/users/templates/invitations/taken_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10446
10446
  simo/users/templates/invitations/taken_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10447
- simo-2.0.12.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10448
- simo-2.0.12.dist-info/METADATA,sha256=WO2Mt2Kexp6wdYCPQ_aw7e4ebWdaCi8ZET12OdoZIs4,1700
10449
- simo-2.0.12.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
10450
- simo-2.0.12.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10451
- simo-2.0.12.dist-info/RECORD,,
10447
+ simo-2.0.13.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10448
+ simo-2.0.13.dist-info/METADATA,sha256=rwjjG5hKGMgEGunNKlhYByM46Kepk1OFgrYTcoQ5bcg,1700
10449
+ simo-2.0.13.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
10450
+ simo-2.0.13.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10451
+ simo-2.0.13.dist-info/RECORD,,
File without changes