Commit Graph

20 Commits

Author SHA1 Message Date
Fabio Manganiello abaeabea22
Implemented recursive merges of parent/child relationships in entities 2022-11-30 00:50:53 +01:00
Fabio Manganiello 0edd73690b
Modelling of parent/children relationships on entity level 2022-11-28 21:36:00 +01:00
Fabio Manganiello 69e097707d
Don't lock read session from the main database 2022-11-12 16:10:57 +01:00
Fabio Manganiello 86edd70d93
Fixed session/concurrency management on the main SQLite db
- The `declarative_base` instance should be shared
- Database `session_locks` should be stored at module, not instance
  level
- Better isolation of scoped sessions
- Enclapsulated `get_session` method in `UserManager`
2022-11-12 15:36:17 +01:00
Fabio Manganiello bfeb0a08c4
Encapsulate `_get_session` in `EntityManager` 2022-11-12 15:14:10 +01:00
Fabio Manganiello 6b7933cd33
Using a different SQLite database for entities
This prevents multiprocessing/concurrency issues when modifying the same
database file both from the main process and from the web server process
2022-11-12 02:00:55 +01:00
Fabio Manganiello 691d109fb7
Expunge entities after session commit to ensure that the ORM objects can be reused 2022-10-30 11:00:09 +01:00
Fabio Manganiello d7278857e5
Ensure that no records with duplicate key exist within an SQLAlchemy session before flushing 2022-10-23 00:28:42 +02:00
Fabio Manganiello 1df71cb54a
Proper support for light entities on smartthings 2022-05-30 09:23:05 +02:00
Fabio Manganiello f45df5d4d3
Explictly cast entity IDs to strings when coalescing entity updates
Some plugins may represent entity IDs as integers, while the database
maps external IDs to strings. This may result in entities being
incorrectly mapped during merging. Casting to string prevents these
type-related ambiguities.
2022-04-29 23:24:28 +02:00
Fabio Manganiello ef6b57df31
Added entity info modal and (partial) support for renaming entities 2022-04-23 01:01:14 +02:00
Fabio Manganiello e6bfa1c50f
Better dynamic entities discovery 2022-04-13 11:25:14 +02:00
Fabio Manganiello 2aa8778078
Do not process EntityUpdateEvents only in case of payload changes
The UI relies on these events upon refresh to detect if a device is
still reacheable. Therefore, we shouldn't mask them if we don't detect
any changes with the current entity configuration/state.
2022-04-12 00:41:20 +02:00
Fabio Manganiello f17245e8c7
Send an EntityUpdateEvent only if an entity has already been persisted
If an event comes from an entity that hasn't been persisted yet on the
internal storage then we wait for the entity record to be committed
before firing an event. It's better to wait a couple of seconds for the
database to synchronize rather than dealing with entity events with
incomplete objects.
2022-04-11 00:38:11 +02:00
Fabio Manganiello 67ff585f6c
Entities engine improvements
- Added cache support to prevent duplicate EntityUpdateEvents
- The cache is smartly pre-populated and kept up-to-date, so it's
  possible to trigger events as soon as the entities are published by
  the plugin (not only when the records are flushed to the internal db)
2022-04-11 00:01:21 +02:00
Fabio Manganiello 28026b0428
Trigger an EntityUpdateEvent when an entity state changes 2022-04-07 01:46:37 +02:00
Fabio Manganiello 91ff47167b
Don't terminate the entities engine thread if a batch of entity records fails 2022-04-05 23:04:57 +02:00
Fabio Manganiello fe0f3202fe
columns should be a property of the Entity object 2022-04-05 23:04:19 +02:00
Fabio Manganiello 4b7eeaa4ed
Smarter merging of entities with the same key before they are committed 2022-04-05 21:17:58 +02:00
Fabio Manganiello 4ee7e4db29
Basic support for entities on the local db and implemented support for switch entities on the tplink plugin 2022-04-04 16:50:17 +02:00