Commit graph

150 commits

Author SHA1 Message Date
d872835093
New API to check if a table class exists before defining it.
- Check if it's part of the metadata through a function call rather than
  checking `Base.metadata` in every single module.

- Make it possible to override them (mostly for doc generation logic
  that needs to be able to import those classes).

- Make it possible to extend them.
2023-10-09 01:33:44 +02:00
c311987741
Removed typing.Final from some of the most commonly used modules.
`typing.Final` is not defined on Python < 3.8.
2023-09-26 23:50:10 +02:00
3e8d6bb01e Removed typing-extensions dependency.
The package isn't present on older versions of Debian.
2023-09-18 14:05:39 +02:00
ac72b2f7a8
Fixed management of state on zigbee.mqtt.
Before the merge of the plugin and the listener those components
used to have their own separate state, which led to inconsistencies.
2023-09-14 23:05:27 +02:00
a8255f3621
Pass the configuration file used by the application to the Alembic process.
The database settings could also be overridden in the configuration file
besides the command line.

We should therefore pass the path to the runtime configuration file, so
the Alembic process can initialize its configuration from the same file
and use the same settings.
2023-08-19 13:23:20 +02:00
181da63c89
Pass the database engine to the Alembic process as an extra argument.
If the path of the default database engine is overridden via `--workdir`
option then it won't be visible to the new `python` subprocess spawned
for Alembic.
2023-08-19 13:02:05 +02:00
2cab836bdf
Entity.columns class property replaced by Entity.get_columns method.
Again, Python < 3.9 doesn't like the combination of `@property` +
`@classmethod`.
2023-08-18 17:20:53 +02:00
adfedfa2dd
s/TimeoutError/AssertionError/ if get_entities_engine times out. 2023-08-17 02:36:40 +02:00
04921c759f
Added wait_stop method to the entities engine and cron scheduler. 2023-08-14 23:49:47 +02:00
0dc380fa94
Removed dependency from prctl.
Also, black'd and LINT-fixed some files that hadn't been touched in a
while.
2023-07-23 19:17:30 +02:00
998990aabc
Made Entity.children_ids resilient against deleted objects. 2023-05-01 22:09:16 +02:00
ce248ccfbb
Added children_ids to the entity attributes serialized in to_json. 2023-05-01 19:59:13 +02:00
f40f956507
Migrated variable table to the new entities framework. 2023-04-29 11:36:55 +02:00
78cee5d9b0
Added support for automatic database migrations.
Added Alembic environment and `run_db_migrations` logic to the entities
engine so database schema changes can be processed as soon as the
application is started.
2023-04-29 11:32:31 +02:00
8478245cde
Removed Mapped[Entity] type annotation.
`Mapped` has been introduced only in SQLAlchemy 1.4, while Debian stable
still ships 1.3.

Removing the type annotation doesn't come with a big cost, but it keeps
Platypush compatible with Debian stable.
2023-04-24 21:48:52 +02:00
9c03b028d7 Be a bit more resilient if an upstream integration sent some empty entities 2023-04-24 00:44:16 +02:00
a72c32cb00
Added battery entity support to system plugin. 2023-04-23 00:41:21 +02:00
b3440ab96b
Added support for fan sensors on the system plugin. 2023-04-23 00:08:27 +02:00
45d5f439be
Added support for system temperature sensor entities. 2023-04-22 22:42:11 +02:00
374f936c1f
Merged network_stats into NetworkInterface model. 2023-04-22 17:19:24 +02:00
977b55dea9
Merged network addresses into NetworkInterface model. 2023-04-22 17:19:23 +02:00
d473b5d836 Make the recursive entity merger/column set logic more resilient against ObjectDeletedError 2023-04-22 10:40:30 +02:00
98a300c4b1
Added NetworkInterface entities to system plugin.
Plus, `platypush.schemas.system` has now been split into multiple
submodules to avoid a single-file mega-module with all the system
schemas definitions.
2023-04-21 00:45:15 +02:00
44b8fd4b34
Support for disk entities in the system integration. 2023-04-20 16:26:51 +02:00
153d03d43f
Moved CPU percentage on the level of the CPU entity instead of a child entity. 2023-04-19 01:48:05 +02:00
4ebfbf3851
Added memory stats entities. 2023-04-19 01:31:11 +02:00
a5b0a524f6
Added CpuStats entity to system. 2023-04-18 01:19:06 +02:00
e810025a6d
Added Cpu and CpuTimes entities. 2023-04-17 02:25:03 +02:00
65481dc6b4
Added PercentSensor entity type. 2023-04-17 02:25:02 +02:00
e7f64843a5
Added include_children parameter to _merge_columns.
We need to recursively merge the columns of children entities if a child
entity isn't a leaf node.
2023-04-17 02:25:02 +02:00
3e3c48d779
Defined new entity and schema for CpuInfo. 2023-04-17 02:25:02 +02:00
4c19535612 A more resilient logic on entity copy/serialization to prevent ObjectDeletedError 2023-04-13 17:16:21 +02:00
3cd42c9e45
Entity should use Message.Encoder as a JSON serializer. 2023-04-02 02:44:19 +02:00
31f411868c
Message.Encoder should serialize binary data to 0x-led hex strings. 2023-04-02 02:43:06 +02:00
9e5ad0e0b1
Entity.to_dict now takes into account columns mapped to properties.
No more `_value` in the JSON output instead of the `value` property.

If a column is marked as private, and there's an associated property
mapped to its public name, then we should use and serialize that value.
2023-04-02 02:22:40 +02:00
8d4aa310f4
Support for values passed in dict format to ThreeAxisSensor 2023-04-02 02:02:08 +02:00
5a6f4bcf57
Added 3-axis sensor, accelerometer and magnetometer entities 2023-04-02 01:13:22 +02:00
d964167631
s/TimeDurationSensor/TimeDuration/g 2023-04-02 00:57:48 +02:00
226034946f Added distance_sensor entity 2023-03-31 14:22:28 +02:00
276aff757b
Removed circular dependency.
Workaround for the circular dependency between
`platypush.entities.bluetooth` and `platypush.plugins.bluetooth.model`.

Unentangling the circular dependency would require way too much work,
since the entity model provides several helpers and properties that
depend on the plugin's model.

The workaround in this commit is to simply push those imports down in
the methods that use them, so they won't be imported until those methods
are called, as well as removing some type annotations that depended on
those objects.
2023-03-26 15:30:57 +02:00
bc2730c841
Rewritten linode integration.
- Support for cloud instances as native entities.
- Using Marshmallow dataclasses+schemas instead of custom `Response`
  objects.
- Merge `linode` backend into `linode` plugin.
2023-03-26 11:23:33 +02:00
7bbae55e44
platypush.entities._managers -> platypush.entities.managers.
It's better for entity managers to be stored in their own public
package, instead of cluttering too much the namespace of their parent
package.
2023-03-26 03:46:06 +02:00
e71c312133
Always read an entity's parent through get_parent when climbing up.
This should avoid the risk of `DetachedInstanceError` by retrieving the
object into the session if it's not available.
2023-03-22 22:41:09 +01:00
b1cb7ef847
Added a list of excluded_manufacturers to BluetoothPlugin. 2023-03-21 14:32:45 +01:00
243de15813
Added connected flag to BluetoothService. 2023-03-19 12:49:38 +01:00
256d9adbf2
Removed children from BluetoothDevice.to_json - it makes events too verbose 2023-03-19 12:48:11 +01:00
878fe91155
Big rewrite/refactor of the entities merger 2023-03-19 12:40:48 +01:00
2411b961e8
[WIP] Big, big refactor of the Bluetooth integration.
- Merged together Bluetooth legacy and BLE plugins and scanners.
- Introduced Theengs as a dependency to infer BLE device types and
  create sub-entities appropriately.
- Using `BluetoothDevice` and `BluetoothService` entities as the bread
  and butter for all the Bluetooth plugin's components.
- Using a shared cache of devices and services between the legacy and
  BLE integrations, with merging/coalescing logic included.
- Extended list of discoverable services to include all those officially
  supported by the Bluetooth specs.
- Instantiate a separate pool of workers to discover services.
- Refactor of the Bluetooth events - all of them are now instantiated
  from a single `BluetoothDevice` object.
2023-03-13 02:31:21 +01:00
4bc61133c5
The Entity object should also have a to_json method. 2023-03-12 23:01:51 +01:00
31552963c4
EntitiesDb.upsert should return a deep copy of the upserted entities.
Not the upserted entities themselves, no matter if expunged or made transient.

Reminder to my future self: returning the flushed entities and then using them
outside of the session or in another thread opens a big can of worms when using
SQLAlchemy.
2023-03-10 12:06:36 +01:00