Commit graph

2514 commits

Author SHA1 Message Date
7e92d5f244
Added recursive .copy() method to Entity. 2023-03-09 22:35:31 +01:00
9f9ee575f1
Added _import_error_ignored_modules.
ImportErrors on these entity modules will be ignored when dynamically
loading them, since they have optional external dependencies and we
shouldn't throw an error if we can't import them.
2023-03-09 01:40:35 +01:00
c4efec6832
Several fixes and improvements on the entities engine.
- Support for an optional callback on `publish_entities` to get notified
  when the published object are flushed to the db.

- Use `lazy='selectin'` for the entity parent -> children relationship -
  it is more efficient and it ensures that all the data the application
  needs is loaded upfront.

- `Entity.entity_key` rolled back to `<external_id, plugin>`. The
  fallback logic on `<id, plugin>` created more problems than those it
  as supposed to solve.

- Added `expire_on_commit=False` to the entities engine session to make
  sure that we don't get errors on detached/expired instances.
2023-03-09 01:16:04 +01:00
1781a19a79
s/Entity.to_json/Entity.to_dict/g
stuff
2023-03-06 23:46:33 +01:00
b9efa9fa30
entity_key should coalesce (entity.external_id or entity.id) 2023-03-06 16:54:02 +01:00
72c55c03f2
[WIP] Refactoring/extending models and parsers for Bluetooth entities. 2023-03-03 02:10:11 +01:00
a688e7102e
Changed default poll_interval for RunnablePlugin.
30 -> 15 seconds.
2023-03-03 02:00:48 +01:00
ead4513915
Added optional unit column to RawSensor entity. 2023-03-03 01:59:27 +01:00
7be55e446f
Convert UUID objects to strings when serializing to JSON. 2023-03-02 21:58:26 +01:00
15fadb93bb
Added stand-alone connect and disconnect actions to bluetooth. 2023-02-25 01:59:35 +01:00
70d1bb893c
A cleaner way of calculating the success response attribute. 2023-02-25 01:58:09 +01:00
2dfb389630
Added remaining bluetooth entity types in _mappers.py. 2023-02-23 21:20:41 +01:00
a0556d3a42
Added PresenceSensor entities. 2023-02-23 01:42:26 +01:00
886b930e2f
Support for bluetooth devices with multiple temperature sensors. 2023-02-23 01:27:31 +01:00
56d693032a
Added DewPointSensor entities. 2023-02-23 01:23:04 +01:00
d212276247
Added PressureSensor entities. 2023-02-23 01:12:27 +01:00
dd3f683006
Added unit to bluetooth mappers whenever available. 2023-02-23 01:04:33 +01:00
d961e2a997
Added TimeDurationSensor entity. 2023-02-23 01:02:13 +01:00
c3e16f9f9d
Added support for heart rate sensor entities. 2023-02-23 00:55:55 +01:00
3dab94c346
Added StepsSensor detection to bluetooth. 2023-02-23 00:50:06 +01:00
e1b3d52706
Added StepsSensor entity. 2023-02-23 00:45:58 +01:00
dcab766cef
Only scan for the configured Bluetooth service UUIDs. 2023-02-22 03:36:16 +01:00
d8c429f4a8
Major improvements on the entities engine.
- Better logic to recursively link parent/children entities, so partial
  updates won't get lost.

- Removed `EntitiesCache` - it was too much to maintain while keeping
  consistent with the ORM, and it was a perennial fight against
  SQLAlchemy's own cache.

- Removed `EntityNotifier` - with no need to merge cached entities, the
  `notify` method has become much simpler and it's simply been merged
  in the `EntitiesRepository`.
2023-02-22 02:53:45 +01:00
9776921836
Better way of handling with RawSensor in bluetooth integration. 2023-02-22 02:26:51 +01:00
a5a923a752
Added BluetoothDeviceNewDataEvent.
These events handle the case where a Bluetooth device only publishes new
service data without advertising any additional updated properties.
2023-02-22 02:23:11 +01:00
dc7cbe743d
Refactored/improved RawSensor entity.
It will now automatically deal with most of the native types and convert
them to strings on the db.
2023-02-22 02:19:19 +01:00
b2ffc08c89
s/MultiValueSensor/CompositeSensor/g on smartthings 2023-02-22 02:18:12 +01:00
340fd08064
Removed some old type: ignore comments. 2023-02-22 01:29:51 +01:00
cf219d5a48
Added some more docstrings to entities. 2023-02-22 01:02:26 +01:00
7fa545d7f8
Merge branch 'master' into 29-generic-entities-support 2023-02-22 00:46:33 +01:00
c645ce6bb8
Bump version: 0.24.4 → 0.24.5 2023-02-22 00:32:57 +01:00
bbc9647cb0
s/MultiValueSensor/CompositeSensor/g 2023-02-21 23:14:10 +01:00
2fa45fc5a3
Documentation and LINT fixes for sensor entities. 2023-02-21 23:10:05 +01:00
b4627ecd04 Removed deprecated use_unicode parameter from MPDClient 2023-02-20 20:35:33 +01:00
aa0b909fff
Use the TheengsDecoder to parse Bluetooth packets and map services to native entities. 2023-02-20 20:27:17 +01:00
73bf2446bd
Wrap bluetooth.connect in a per-device locked section. 2023-02-19 23:11:19 +01:00
9112239ac3
Better exception management in AsyncRunnablePlugin.
Exceptions that cause the termination of the plugin's loop should always
be logged as such, unless the plugin is supposed to stop and various
exceptions may occur upon teardown.
2023-02-19 23:03:27 +01:00
a6c36fa1c1
Added brand, model and model_id columns to BluetoothDevice. 2023-02-19 23:02:04 +01:00
68e6b271c1
Updated dist files 2023-02-19 22:58:20 +01:00
cb9b01c89f
Added raw_sensor metadata 2023-02-19 22:57:50 +01:00
72a9a9dfcf
LINT/type fixes 2023-02-19 22:56:45 +01:00
8aedc3c233
Recursively normalize child entities in EntityManager._normalize_entities 2023-02-18 17:51:57 +01:00
613e32e7c1
Extended number of supported events and data fields in Bluetooth integration. 2023-02-18 01:15:10 +01:00
7adae272a4
Merge branch 'master' into 29-generic-entities-support 2023-02-15 22:24:41 +01:00
08553f84b9
Added timeout parameter to websocket.send. 2023-02-15 22:23:15 +01:00
45664be44b
Removed deprecated backend.bluetooth.scanner.
Scan capabilities are now implemented on the `bluetooth` plugin itself.
2023-02-13 23:13:51 +01:00
471bc1fd3d
Updated dist files 2023-02-13 23:13:32 +01:00
a3aa186ddf
- Added support for scan_pause/scan_resume on bluetooth integration.
- Added `BluetoothDevice` as its own entity type.
2023-02-13 23:12:25 +01:00
1d0be5c929
- Simplified prototype for EntityManager.set
- Added small documentation/annotations notes to the `Plugin` module.

- Small LINT fixes
2023-02-11 21:35:00 +01:00
575635fd6b
Defined set as a base method for all plugins that implement writeable entities 2023-02-11 04:04:21 +01:00
4365352331
[WIP] s/set_value/set/g for entities 2023-02-11 03:57:23 +01:00
b0cc80ceb0
Rewriting bluetooth.ble plugin to use bleak instead of gattlib. 2023-02-10 17:40:20 +01:00
f30e077a5a
Support for custom Bluetooth adapter on switchbot.bluetooth. 2023-02-08 23:01:05 +01:00
8469a1027f
Migrated/refactored switchbot.bluetooth integration.
- Out `gattlib` + `pybluez`, in `bleak`. It's not platform-dependent, it doesn't
  require libboost and other heavy build dependencies, and it doesn't require the
  user that runs the service from having special privileges to access raw
  Bluetooth sockets.

- Better integration with Platypush native entities. The devices are now mapped
  to write-only `EnumSwitch` entities, and the status returns the serialized
  representation of those entities instead of the previous intermediate
  representation.
2023-02-08 22:42:00 +01:00
35719b0da9
Let publish_entities return the list of transformed_entities 2023-02-08 02:09:34 +01:00
e04870209e
More LINT fixes 2023-02-08 01:50:54 +01:00
a98a5f0980
typo fix 2023-02-08 01:09:25 +01:00
e49a0aec4d
Various improvements.
- Better synchronization logic on stop for `AsyncRunnablePlugin`.
- Fixed several thread names by dropping `prctl.set_name` in favour of
  specifying the name directly on thread creation.
- Several LINT fixes.
2023-02-08 00:46:50 +01:00
9d028af524
Removed last reference of SwitchPlugin 2023-02-05 23:10:35 +01:00
419a0cec61
More LINTing
Better prototype for `MultiLevelSwitchEntityManager.set_value`
2023-02-05 23:07:43 +01:00
fde834c1b1
More LINT fixes + refactors 2023-02-05 22:00:50 +01:00
4849e14414
LINT fixes for the utils module + additional documentation 2023-02-05 18:05:41 +01:00
b8fca97891
Default poll_interval for RunnablePlugin set to 30 seconds 2023-02-05 17:31:43 +01:00
06dfd1a152
Added support for more entities in switchbot 2023-02-05 15:34:50 +01:00
64e9bf17cf
Updated dist files 2023-02-05 14:53:36 +01:00
2047b9b76c
[WIP] Refactoring switchbot plugin as a runnable plugin + entity manager 2023-02-04 22:22:51 +01:00
65827aa0cd
Updated dist files 2023-02-04 17:36:46 +01:00
b96838a856
Major LINT fixes/refactor for the Config class 2023-02-04 17:35:48 +01:00
db5846d296
Add the unit to the Dimmer display value if it's available 2023-02-04 17:28:54 +01:00
0311d87bc3
The switch.wemo integration now extends SwitchEntityManager 2023-02-04 00:58:28 +01:00
de2849546a
LINT fixes 2023-02-04 00:26:48 +01:00
a160d3217e
Removed legacy get_sensor_plugins and get_switch_plugins actions 2023-02-03 22:54:42 +01:00
b6814b4f16
Removed legacy Switches integration [frontend] 2023-02-03 22:49:09 +01:00
6ef2feea71
LINT fixes for utils plugin 2023-02-03 18:08:19 +01:00
3db9c58d31
[WIP] Converted switch.tplink plugin.
`switch.tplink` converted to a `RunnablePlugin` that implements
`SwitchEntityManager`.
2023-02-03 02:20:20 +01:00
be3b99326f
[WIP] Refactoring @manages annotation into a proper EntityManager hierarchy 2023-02-02 23:21:12 +01:00
63d6920716
Updated dist files 2023-02-02 18:07:44 +01:00
59eb0742a1
s/warnings/logger.debug/ if publish_entities is called with no engine registered 2023-01-29 21:52:12 +01:00
8aff181956
Merged zwave.mqtt backend into the zwave.mqtt plugin 2023-01-29 02:34:48 +01:00
0e56d0fff6
Double-check if self._thread != None on stop on the ntfy thread
Race conditions may occur here
2023-01-27 22:12:34 +01:00
341e749d23
Merged the zigbee.mqtt backend into the plugin.
- Deprecated the old `zigbee.mqtt` backend
- Black style for the `mqtt` backend
2023-01-27 01:59:57 +01:00
afdeb91f66
Implemented remaining supported entities for the smartthings integration 2023-01-26 22:10:02 +01:00
334ccc35a2
Don't serialize I/O wrappers
This removes warnings on `config.get`, where the `logging` configuration
key may also contain the current logging stream and we end up with a
JSONDecodeError when trying to serialize it.
2023-01-25 00:52:37 +01:00
ba31dff06a
Major refactor + fixes for smartthings 2023-01-24 23:56:28 +01:00
147f36c86c
All Sensor instances should have is_read_only=True by default 2023-01-22 21:05:14 +01:00
fd76642082
Added Volume and Muted entities 2023-01-22 21:04:46 +01:00
bb637a1411
Defined a unique stop_timeout (default=5) for RunnablePlugin 2023-01-22 14:28:16 +01:00
6d4cf64253
More work on smartthings.
- Added support for `Battery` entities
- Fixed saturation range for `Light` entities
- Parsing `min`/`max`/`unit` from the status attributes, if available
2023-01-22 01:01:47 +01:00
ddd516a677
Added polling/RunnablePlugin logic to smartthings 2023-01-22 00:09:10 +01:00
dabbe031ab
Don't show the entity modal unless the user clicks on the name or icon 2023-01-21 23:46:38 +01:00
32e4e60579
A more robust handling of events in the zwave.mqtt backend 2023-01-21 23:44:51 +01:00
3940288396
Use the new bus notification helpers 2023-01-21 16:59:18 +01:00
241670c9d0
Handle parent/child update events through broadcast bus events 2023-01-21 16:58:28 +01:00
3923a09831
- Expose methods on the bus module to publish/subscribe to notifications and entity updates
- Removed some redundant `pass` statements in Z-Wave derived event classes
2023-01-21 16:56:27 +01:00
fb562bb415
Propagate the @update event to the parent entities 2023-01-21 14:55:06 +01:00
4d762b81dc
EntityUpdateEvent traces can now be logged on INFO level
The EntityUpdateEvents generated by light.hue are now less noisy.
2023-01-21 14:50:05 +01:00
247912799f
Refactored light.hue integration so EntityUpdateEvents won't be triggered on every call to _get_lights 2023-01-21 14:48:33 +01:00
dfb13127ee
Added MotionSensor entities 2023-01-21 14:47:18 +01:00
a892bad34c
Refactoring smartthings plugin to support more entity types 2023-01-21 14:09:26 +01:00
22b8b03cb2
Refactored EntityIcon component 2023-01-15 20:02:50 +01:00