This script interacts with the DESS Monitor API to authenticate and fetch the latest device data, exporting the results as JSON.
- Securely loads authentication credentials from a separate configuration file.
- Fetches the latest data for a specified device.
- Supports command-line arguments for querying past data.
- Outputs results in JSON format for further processing.
- Implements SHA-1-based authentication as required by the API.
Ensure you have the following installed:
- `` (default on Linux/macOS)
- `` (for making API requests)
- `` (for processing JSON data)
- `` (for hashing operations)
To install missing dependencies:
# Debian/Ubuntu
sudo apt install jq openssl
# macOS (via Homebrew)
brew install jq openssl
git clone https://github.com/yourusername/dessmonitor-export.git
cd dessmonitor-export
-
Copy the example config file and edit it:
cp config.env.example config.env nano config.env
-
Update the following fields in
config.env
:# User credentials DESS_USER="[email protected]" DESS_PASS="YourSecurePassword" DESS_COMPANY_KEY="YourCompanyKey" # Device-specific details DEVICE_PN="YourDevicePN" DEVICE_CODE="YourDeviceCode" DEVICE_ADDR="YourDeviceAddress" DEVICE_SN="YourDeviceSerialNumber"
-
Important: Prevent accidental leaks by adding
config.env
to.gitignore
:echo "config.env" >> .gitignore
-
Ensure secure file permissions to prevent unauthorized access:
chmod 600 config.env
./dessmonitor.sh
./dessmonitor.sh YYYY-MM-DD
Example:
./dessmonitor.sh 2024-03-10
- **Authentication token is retrieved and stored in **``
- **Device data is fetched and saved to **``
- The script logs the results, which can be processed further
This script relies on endpoints from DESS Monitor API, documented at:
- Query Device Last Data
Fetches the latest available data for a specific device.
For Home Assistant integration, check out:
SilverFire/dessmonitor-homeassistant
- DO NOT hardcode secrets in the script. Instead, use
config.env
as demonstrated. - Use environment variables instead of storing credentials in a file if deploying on a server.
- **Ensure **
** is added to **
so it is not accidentally committed. - If working on a shared system, restrict file access using:
chmod 600 config.env
- The script hashes passwords using SHA-1 before transmission.
- Communication with the API uses
HTTPS
for encryption.
This script is provided as-is. Feel free to modify and improve it.
- DESS Monitor API Documentation (https://api.dessmonitor.com/chapter5/queryDeviceLastData.html) for detailed API specifications.
- SilverFire/dessmonitor-homeassistant for inspiration on integrating DESS Monitor with Home Assistant.