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

@@ -121,15 +121,18 @@ class PresenceLighting(Script):
121
121
  name = _("Presence lighting")
122
122
  config_form = PresenceLightingConfigForm
123
123
 
124
- # script specific variables
125
- sensors = {}
126
- condition_comps = {}
127
- light_org_values = {}
128
- is_on = False
129
- turn_off_task = None
130
- last_presence = 0
131
- hold_time = 60
132
- conditions = []
124
+ def __init__(self, *args, **kwargs):
125
+ super().__init__(*args, **kwargs)
126
+ # script specific variables
127
+ self.sensors = {}
128
+ self.condition_comps = {}
129
+ self.light_org_values = {}
130
+ self.light_send_values = {}
131
+ self.is_on = False
132
+ self.turn_off_task = None
133
+ self.last_presence = 0
134
+ self.hold_time = 60
135
+ self.conditions = []
133
136
 
134
137
  def _run(self):
135
138
  self.hold_time = self.component.config.get('hold_time', 0) * 10
@@ -158,33 +161,36 @@ class PresenceLighting(Script):
158
161
  self.condition_comps[comp.id] = comp
159
162
 
160
163
  while True:
161
- self._regulate(on_val_change=False)
164
+ self._regulate()
162
165
  time.sleep(random.randint(5, 15))
163
166
 
164
167
  def _on_sensor(self, sensor=None):
165
168
  if sensor:
166
169
  self.sensors[sensor.id] = sensor
167
- self._regulate()
170
+ self._regulate(on_sensor=True)
168
171
 
169
172
  def _on_condition(self, condition_comp=None):
170
173
  if condition_comp:
171
174
  for condition in self.conditions:
172
175
  if condition['component'].id == condition_comp.id:
173
176
  condition['component'] = condition_comp
174
- self._regulate()
177
+ self._regulate(on_condition_change=True)
175
178
 
176
179
  def _on_light_change(self, light):
177
- if self.is_on:
180
+ # change original value if it has been changed to something different
181
+ # than this script does.
182
+ if self.is_on and light.value != self.light_send_values[light.id]:
183
+ self.light_send_values[light.id] = light.value
178
184
  self.light_org_values[light.id] = light.value
179
185
 
180
- def _regulate(self, on_val_change=True):
186
+ def _regulate(self, on_sensor=False, on_condition_change=False):
181
187
  presence_values = [s.value for id, s in self.sensors.items()]
182
188
  if self.component.config.get('act_on', 0) == 0:
183
189
  must_on = any(presence_values)
184
190
  else:
185
191
  must_on = all(presence_values)
186
192
 
187
- if must_on and on_val_change:
193
+ if must_on and on_sensor:
188
194
  print("Presence detected!")
189
195
 
190
196
  additional_conditions_met = True
@@ -198,7 +204,7 @@ class PresenceLighting(Script):
198
204
 
199
205
  if condition['op'] == 'in':
200
206
  if comp.value not in self._string_to_vals(condition['value']):
201
- if must_on and on_val_change:
207
+ if must_on and on_sensor:
202
208
  print(
203
209
  f"Condition not met: [{comp} value:{comp.value} "
204
210
  f"{condition['op']} {condition['value']}]"
@@ -207,7 +213,7 @@ class PresenceLighting(Script):
207
213
  break
208
214
 
209
215
  if not op(comp.value, condition['value']):
210
- if must_on and on_val_change:
216
+ if must_on and on_sensor:
211
217
  print(
212
218
  f"Condition not met: [{comp} value:{comp.value} "
213
219
  f"{condition['op']} {condition['value']}]"
@@ -215,7 +221,15 @@ class PresenceLighting(Script):
215
221
  additional_conditions_met = False
216
222
  break
217
223
 
218
- if must_on and additional_conditions_met and not self.is_on:
224
+
225
+ if not self.is_on:
226
+ if not must_on:
227
+ return
228
+ if not additional_conditions_met:
229
+ return
230
+ if on_condition_change:
231
+ return
232
+
219
233
  print("Turn the lights ON!")
220
234
  self.is_on = True
221
235
  self.light_org_values = {}
@@ -226,11 +240,15 @@ class PresenceLighting(Script):
226
240
  if not comp or not comp.controller:
227
241
  continue
228
242
  self.light_org_values[comp.id] = comp.value
229
- print(f"Send {light_params['on_value']} to {comp}!")
230
- comp.controller.send(light_params['on_value'])
243
+ on_val = light_params['on_value']
244
+ if type(comp.controller.default_value) == bool:
245
+ on_val = bool(on_val)
246
+ print(f"Send {on_val} to {comp}!")
247
+ self.light_send_values[comp.id] = on_val
248
+ comp.controller.send(on_val)
231
249
  return
232
250
 
233
- if self.is_on:
251
+ else:
234
252
  if not additional_conditions_met:
235
253
  return self._turn_it_off()
236
254
  if not any(presence_values):
simo/notifications/api.py CHANGED
@@ -34,7 +34,7 @@ class NotificationsViewSet(
34
34
  archived = bool(int(self.request.query_params['archived']))
35
35
  except:
36
36
  archived = False
37
- qs = qs.objects.filter(
37
+ qs = qs.filter(
38
38
  user_notifications__archived__isnull=not archived,
39
39
  user_notifications__user=self.request.user
40
40
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simo
3
- Version: 2.6.4
3
+ Version: 2.6.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
@@ -13,7 +13,7 @@ simo/__pycache__/urls.cpython-38.pyc,sha256=u0x6EqT8S1YfDOSPgbI8Kf-RDlveY9OV-EDX
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
- simo/automation/controllers.py,sha256=gIkEOqq7IJ3BoDF40mN2aTGE8_yVwhQrO0RZlJYiYfg,9451
16
+ simo/automation/controllers.py,sha256=Py62mo8boFsreiGVAnalJt_1SJePxD67aCGma6zGjWg,10206
17
17
  simo/automation/forms.py,sha256=wJMaXE5ngO_o60jqxnf4Om09q48yXpWwRna0FkQCZYs,10081
18
18
  simo/automation/gateways.py,sha256=7r33NOAiRd_RGMMm44i0KYzuAuweQnEF4HxLo-Rpexs,9408
19
19
  simo/automation/helpers.py,sha256=iP-fxxB8HsFQy3k2CjFubu86aMqvWgmh-p24DiyOrek,4330
@@ -22,7 +22,7 @@ simo/automation/serializers.py,sha256=PjyFrjdPK1mBsgbNhyqMi9SWzcymqTa742ipy0LhAN
22
22
  simo/automation/state.py,sha256=aZZvNBae7unnux_zGHCIWCV2z47hVJc-DIL72Hqfkeo,600
23
23
  simo/automation/__pycache__/__init__.cpython-38.pyc,sha256=YmP0xAD-mxpQHgdTZeC64sXChA8TriMZD1jckNYi3xg,164
24
24
  simo/automation/__pycache__/app_widgets.cpython-38.pyc,sha256=7DfUA9V_1MiwrOe_ta-ts8dYY8xXb9UMg2_9A3XoRcs,523
25
- simo/automation/__pycache__/controllers.cpython-38.pyc,sha256=JUQ105NN-9Si1pyCkqn4P_4yQ9NG7OnQfSRBzBaeth4,7535
25
+ simo/automation/__pycache__/controllers.cpython-38.pyc,sha256=s9YqMUTCzjIxNVrk36SrIvGrXWYLc9DR80Sa3orpg1o,7936
26
26
  simo/automation/__pycache__/forms.cpython-38.pyc,sha256=qxQZeTafJOT_lrXOKY6134XjIrx5OzABAZdncNnRV4E,7720
27
27
  simo/automation/__pycache__/gateways.cpython-38.pyc,sha256=W6OrugOLOGaYbibEWSs-zBZc8jQpNlO_NmJU-rmd6fU,7558
28
28
  simo/automation/__pycache__/helpers.cpython-38.pyc,sha256=4VSSarOFnUk_KExWwvDlx5dEhv8aHUCHMZDtGG--pUY,3627
@@ -10449,13 +10449,13 @@ simo/multimedia/migrations/__pycache__/0004_auto_20231023_1055.cpython-38.pyc,sh
10449
10449
  simo/multimedia/migrations/__pycache__/__init__.cpython-38.pyc,sha256=mCgSiQBphL85imdWyTi9-4zBDYF6HfXbhB0ycSPVVuA,175
10450
10450
  simo/notifications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10451
10451
  simo/notifications/admin.py,sha256=WQbN_bd2KRxVjbOajeworNrV9QlDNSadQT58La0Nn2M,1174
10452
- simo/notifications/api.py,sha256=qzM-P3kq_YQ8_wHS8EMIutRbTvtqOXczQbJFb7EgQ08,1773
10452
+ simo/notifications/api.py,sha256=QrfFn5kBU0vlqi8X368w1-0iTmDGu_hmMxLW2R0OTTg,1765
10453
10453
  simo/notifications/models.py,sha256=QGDLGAi5gk8OTcvd7ho5WNdctDymWGmGF1ZqN4-G_ZA,2443
10454
10454
  simo/notifications/serializers.py,sha256=altDEAPWwOhxRcEzE9-34jL8EFpyf3vPoEdAPoVLfGc,523
10455
10455
  simo/notifications/utils.py,sha256=uBl-Y7WGu00iaGM5rrdogcq0OMRVtyVfJF39-mdB3_k,1853
10456
10456
  simo/notifications/__pycache__/__init__.cpython-38.pyc,sha256=YvucUfu98XFvEEg1LYFMlOZJpo_jSGxTVrM-ylAFLOg,167
10457
10457
  simo/notifications/__pycache__/admin.cpython-38.pyc,sha256=MScNrtVM1wavefsPfxy0A7LVyXKcbvEkLH9GJkgNOl8,1945
10458
- simo/notifications/__pycache__/api.cpython-38.pyc,sha256=8dPiIMaFQlBFP01VwXbQ98udaZaqwibZJtz_Y2cXa8U,2073
10458
+ simo/notifications/__pycache__/api.cpython-38.pyc,sha256=eQmCHwTnr4zQ3ZY_SKZVCryiSEnzmyIjHQM13pZ5LT0,2071
10459
10459
  simo/notifications/__pycache__/models.cpython-38.pyc,sha256=PoqLuOnlaAWQQ-20AtqhvAlLSkakPmdn7J7wGvHNW3g,2449
10460
10460
  simo/notifications/__pycache__/serializers.cpython-38.pyc,sha256=7-eRGKYuQ4g1SpKOMpz17SIiu1HmaMoYv-cJbaO9QGA,1028
10461
10461
  simo/notifications/__pycache__/utils.cpython-38.pyc,sha256=6Tq7VkW-pZLzWzcxPtBU9MDFZLO7iLY8-ygyefoJ5OQ,1529
@@ -10599,9 +10599,9 @@ simo/users/templates/invitations/expired_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCe
10599
10599
  simo/users/templates/invitations/expired_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10600
10600
  simo/users/templates/invitations/taken_msg.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10601
10601
  simo/users/templates/invitations/taken_suggestion.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
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,,
10602
+ simo-2.6.6.dist-info/LICENSE.md,sha256=M7wm1EmMGDtwPRdg7kW4d00h1uAXjKOT3HFScYQMeiE,34916
10603
+ simo-2.6.6.dist-info/METADATA,sha256=U_rJSOAn0Y32OcYjYKHpnflh2C1SLDSmOxb5f6rWXXM,1952
10604
+ simo-2.6.6.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
10605
+ simo-2.6.6.dist-info/entry_points.txt,sha256=S9PwnUYmTSW7681GKDCxUbL0leRJIaRk6fDQIKgbZBA,135
10606
+ simo-2.6.6.dist-info/top_level.txt,sha256=GmS1hrAbpVqn9OWZh6UX82eIOdRLgYA82RG9fe8v4Rs,5
10607
+ simo-2.6.6.dist-info/RECORD,,
File without changes