Commit graph

76 commits

Author SHA1 Message Date
c9a5c29a4a
🐛 A proper cross-version solution for the utcnow() issue.
No need to maintain two different pieces of logic - a `utcnow()` for
Python < 3.11 and `now(datetime.UTC)` for Python >= 3.11.

`datetime.timezone.utc` existed long before datetime.UTC and that's what
the `utcnow` facade should use.

This means that all the `utcnow()` will always have `tzinfo=UTC`
regardless of the Python version.

There's still a problem with the `utcnow()`-generated timestamps that
have been generated by previous versions of Python and stored on the db.

Therefore, when the code performs comparisons with timestamps fetched
from the db, it should always explicitly do a `.replace(tzinfo=utc)` to
ensure that we always compare offset-aware datetime representations.

See blog post for technical details:
https://manganiello.blog/wheres-my-time-again
2024-06-01 01:34:47 +02:00
4e82dd17bb
🐛 Partial revert of c18768e61f
`datetime.utcnow` may be deprecated on Python >= 3.12, but
`datetime.UTC` isn't present on older Python versions.

Added a `platypush.utils.utcnow()` method as a workaround compatible
with both.
2024-05-31 19:52:32 +02:00
fa318882a5
Replaced deprecated usages of datetime.utcnow() with datetime.now(UTC). 2024-05-31 02:30:48 +02:00
59c693d6a0
[#394] All manifest.yaml converted to manifest.json.
YAML isn't part of the Python standard library, while JSON is.

If we want `setup.py` to dynamically parse the available integration
manifest files in order to populate the extra dependencies, then it's
better to rely on a JSON format for manifest files - the parser is part
of the standard library and it doesn't require the user to install
`pyyaml` before `platypush`.
2024-05-17 02:21:57 +02:00
905d6632e0
Misc documentation improvements. 2023-09-29 18:09:15 +02:00
9298f52443
Moved BluetoothPlugin to __init__.py.
This is for consistency with other plugins, that all have their main
plugin class definition inside of `__init__.py`.
2023-09-24 19:21:53 +02:00
c3337ccc6c
[#311] Docs deps autogen sphinx plugin.
Added an `add_dependencies` plugin to the Sphinx build process that
parses the manifest files of the scanned backends and plugins and
automatically generates the documentation for the required dependencies
and triggered events.

This means that those dependencies are no longer required to be listed
in the docstring of the class itself.

Also in this commit:

- Black/LINT for some integrations that hadn't been touched in a long
  time.

- Deleted some leftovers from previous refactors (deprecated
  `backend.mqtt`, `backend.zwave.mqtt`, `backend.http.request.rss`).

- Deleted deprecated `inotify` backend - replaced by `file.monitor` (see
  #289).
2023-09-24 17:00:08 +02:00
761f2768cb
[#316] Added RPM dependencies. 2023-09-21 23:20:06 +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
2c46b6fe14
Added git a required manifest dependency when needed.
It is needed for packages that install pip packages via git.
2023-08-20 21:19:15 +02:00
98e9abde18
Extended manifest files with Python system packages (if available).
- If a Python optional dependency is available as a system package on
  the target system, try and install it that route rather than pip. It's
  usually faster and it decreases the risk of breaking system packages.

- Added support for apk dependencies in manifest files. This brings the
  number of distros officially supported by all the extensions to four:

  - Alpine
  - Arch
  - Debian
  - Ubuntu
2023-08-16 22:43:51 +02:00
3febfabdd7
Bluetooth LE blacklisted device notices moved info -> debug. 2023-05-01 22:10:06 +02:00
9d82ce6ea9
Noisy beacons notice back to debug level.
There's just too many of them and it ends up polluting the logs.
2023-05-01 21:25:42 +02:00
6b28d16ccf
Exclude more noisy Bluetooth beacons.
Exclude any beacons from devices with no name, no children other than
services, and with none of those services being public/known.
2023-04-29 23:34:24 +02:00
f764d1b4fb
Noisy Bluetooth beacons notices should be logged on info level. 2023-04-29 23:18:12 +02:00
87db5ca5f3 Exclude all iBeacon devices by default (it's not only Apple, it's everyone) 2023-04-26 14:17:59 +02:00
cb288deb71
Exclude more noisy BLE beacons.
Excluding Apple iBeacons and devices with no name and no services.
2023-04-25 16:19:11 +02:00
0cd28f1040
libbluetooth-dev is a required dependency to build pybluez on Debian-derived distros 2023-04-23 18:59:37 +02:00
d964167631
s/TimeDurationSensor/TimeDuration/g 2023-04-02 00:57:48 +02:00
3c355352c5
Using the new StoppableThread API. 2023-03-24 16:39:30 +01:00
998793e94f
Added OBEX_FILE_TRANSFER constant to directory stub. 2023-03-24 15:41:20 +01:00
2f49ddf33a
Fallback logic that uses DBus to disconnect from a BT device.
This logic will be used if the connection wasn't opened by the current
process and therefore a call to DBus is required to terminate it.
2023-03-24 01:57:05 +01:00
913ef6f8cd
Refresh BluetoothDevice.reachable when a device is found/lost. 2023-03-24 01:56:19 +01:00
d46d4e2300
Added support for Bluetooth devices blacklist.
Based on device address, name or manufacturer.
2023-03-24 01:52:39 +01:00
0cebcf4f9b
switchbot.bluetooth integration migrated to a bluetooth plugin. 2023-03-23 17:46:54 +01:00
4fac110bb8
Added bluetooth.set method, whose execution is delegated to the plugins. 2023-03-23 17:45:02 +01:00
cd219f44c4
Pass the list of plugins when creating Bluetooth managers. 2023-03-23 17:42:16 +01:00
43289a3b55
Scan always at least for 10 seconds before failing on get_device. 2023-03-23 17:41:37 +01:00
6267943786
Wrap BleakError exceptions into AssertionError. 2023-03-23 17:40:30 +01:00
d6805a8b18
Added support for custom Bluetooth device plugins. 2023-03-23 17:10:37 +01:00
af125347d6
If no matching services are found when connecting to a device, default to BLEManager.
GATT characteristics are not necessarily exposed as services.
2023-03-23 13:00:26 +01:00
a2a5fce6cb
Added Apple Continuity to the list of blacklisted manufacturers/models 2023-03-22 22:55:19 +01:00
5c23d3aa87
metadata and rssi fields on BLEDevice have been deprecated.
Changed the BLE beacon parsing logic to read those fields from
`AdvertisementData` instead of `BLEDevice`.
2023-03-22 22:39:01 +01:00
65bc3ae06d
Noisy beacons device configuration should look both at manufacturer and model. 2023-03-22 22:37:46 +01:00
e10bec88c0
Noisy beacons logging trace moved from info to debug. 2023-03-22 16:31:57 +01:00
99cfd247a5
A more effective logic to exclude noisy BLE beacons.
This includes BLE beacons sent from all Google/Apple/Microsoft/Samsung
beacon networks in all of their variants.
2023-03-22 15:35:02 +01:00
01d323fad0
Passing a boolean exclude_known_noisy_beacons to bluetooth plugin.
The logic to exclude BLE beacons from randomized devices needs to be a
bit more granular and not limited only to the reported device
manufacturer.
2023-03-22 15:29:19 +01:00
f6e09d34e4
A more clever logic of parsing the manufacturer for BLE devices.
1. Check the manufacturer parsed via Bleak/Theengs
2. Check the MAC address prefix in the oui numbers table
3. Check from the reported `manufacturer_data`
2023-03-22 14:16:00 +01:00
f7e8cfe5a7
Don't include unit in BLE sensors when they are matched against the native type.
It's likely to just include the native type name anyway.
2023-03-22 14:14:59 +01:00
c750d83188
Prevent name collisions on bluetooth.ServiceClass. 2023-03-22 03:27:25 +01:00
174b1ee6a9
Use a default list of excluded Bluetooth manufacturers. 2023-03-21 16:03:01 +01:00
b1cb7ef847
Added a list of excluded_manufacturers to BluetoothPlugin. 2023-03-21 14:32:45 +01:00
3743ee4f00
s/TheengsGateway/TheengsDecoder/g now that the pip package has been published. 2023-03-20 01:41:21 +01:00
12096f2dbe
Don't fail hard when device disconnection fails. 2023-03-19 12:56:53 +01:00
40f81b105f
Set the connected flag when connecting/disconnecting from a service. 2023-03-19 12:56:31 +01:00
9d66b63266
BluetoothService attributes fixes.
BluetoothService IDs should always be in the format `address::uuid` and
the name should always be in title format.
2023-03-19 12:55:14 +01:00
6e9263c4e4
A more elegant logic to infer the manufacturer name. 2023-03-19 12:54:52 +01:00
b568876474
Use a service's UUID as a name instead of Unknown if the service is unknown. 2023-03-19 12:54:09 +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
72c55c03f2
[WIP] Refactoring/extending models and parsers for Bluetooth entities. 2023-03-03 02:10:11 +01:00