This script fetches telemetry data from the Kuksa Data Broker, performs anomaly detection using a pre-trained LSTM/GRU TensorFlow model, and publishes the results to a new topic in the data broker. Optionally, it logs telemetry data to a JSON file for further analysis.
- Raspberry Pi or any system capable of running Python.
- Access to a Kuksa Data Broker instance.
- Python 3.7+
- TensorFlow 2.x
kuksa-client
Python library- Standard Python libraries:
numpy
,json
,argparse
Install required Python libraries:
pip install tensorflow numpy
Save the script as data_eval_client.py
and execute it with the following command:
python3 data_eval_client.py -th <host> -tp <port> -m <model_path> [-w <write_to_file>] [-o <output_file>] [-i <interval>] [--verbose]
Argument | Description | Default |
---|---|---|
-th, --host |
Hostname of the Kuksa Data Broker. | localhost |
-tp, --port |
Port of the Kuksa Data Broker. | 55555 |
-w, --write |
Whether to write telemetry data to a JSON file. | False |
-o, --output |
Output JSON file path for telemetry data. | telemetry_data.json |
-m, --model |
Path to the pre-trained TensorFlow model. Required. | |
-i, --interval |
Time interval (in seconds) between data polling. | 0.1 |
--verbose |
Print telemetry data and predictions to the console. | Disabled |
python3 data_eval_client.py -th localhost -tp 55555 -m lstm_model.h5 -w True -o telemetry.json -i 0.5 --verbose
-
Connection Issues:
- Verify that the Kuksa Data Broker is running and accessible at the specified host and port.
- Check the network connectivity between the client and the broker.
-
TensorFlow Model Compatibility:
- Ensure the LSTM/GRU TensorFlow model matches the input shape and features used in the script.
-
Error Handling:
- Enable verbose mode (
--verbose
) to debug issues with telemetry data or predictions.
- Enable verbose mode (
For further questions or support, feel free to reach out!