Copyright (c) David Lomas
This SmartApp logs SmartThings device attributes to an InfluxDB database.
- Changes to device attributes are immediately logged to InfluxDB.
- The Soft-Polling feature forces attribute values to be written to the database periodically, even if values haven't changed.
- Logs Location Mode events.
- Supports an InfluxDB instance on the local LAN, without needing to route traffic via the cloud.
- Supports Basic Authentication to InfluxDB database.
Follow these instructions to install the SmartApp in the SmartThings IDE. However, before publishing the code in the IDE, edit the getGroupName() command (at the bottom of the code) to add the Group IDs for your SmartThings instance. These can be found from the 'My Locations' tab in the SmartThings IDE.
For more information about installing InfluxDB, Grafana, and this SmartApp, see this guide.
- InfluxDB Database: Specify your InfluxDB instance details in this section.
- Polling: Configure the Soft-Polling interval. All device attribute values will be written to the database at least once per interval. This is useful to ensure attribute values are written to the database, even when they have not changed. Set to zero to disable.
- System Monitoring: Configure which location and hub attributes are logged.
- Devices to Monitor: Specify which device attributes to monitor.
- Supports Basic HTTP Authentication.
- logger(): Wrapper for all logging.
- softPoll(): checks that attribute values are != null.
- postToInfluxDB(): Added callback option to the HubAction object.
- handleInfluxResponse(): New callback function. Handles response from posts made in postToInfluxDB() and logs errors.
- updated(): Removed custom attributes for EnergyMeters.
- Fixed typo in postToInfluxDB().
- Added support for more capabilities:
- Shock Sensors (capability.shockSensor)
- Signal Strength Meters (capability.signalStrength)
- Sound Sensors (capability.soundSensor)
- Tamper Alerts (capability.tamperAlert)
- Window Shades (capability.windowShade)
- Added support for Sound Pressure Level Sensors (capability.soundPressureLevel).
- Added support for:
- Buttons (capability.button)
- Carbon Dioxide Detectors (capability.carbonDioxideMeasurement)
- Consumables (capability.consumable)
- pH Meters (capability.pHMeasurement)
- Pressure Sensors (non-standard capability: capability.sensor)
- Touch Sensors (capability.touch)
- UV Meters (capability.ultravioletIndex)
- Voltage Meters (capability.voltageMeasurement)
- Added support for logging SmartThings Mode changes. [Measurement name: _stMode]
- Added support for logging SmartThings Location properties (e.g. mode and timeZone) [Measurement name: _stLocation]
- Added support for logging SmartThings Hub properties (e.g. uptime and firmware version). [Measurement name: _stHub]
- handleEvent(): All device measurements now include groupId, groupName, hubId, hubName, locationId, and locationName as tags.
- handleEvent(): ThreeAxis measurements are split into valueX, valueY, valueZ fields.
- escapeStringForInfluxDB(): Added substitution of apostrophes (uncomment to use).
- Added subscription to 'scheduledSetpoint', 'optimisation', and 'windowFunction' custom attributes for Evohome thermostats.
- Added handling of many new string value events.
- Added a catch-all for any events with string values.
- Added subscription to 'thermostatSetpointMode' custom attribute for Evohome thermostats.
- Device subscriptions now auto-generated from state.deviceAttributes.
- Soft-polling auto-generated from state.deviceAttributes.
- Better escaping of characters.
- softpoll automatically sends values to InfluxDB, to give enough points for Grafana to display.
- switch events now have value and valueBinary fields.
- Expanded range of device types supported.
- Uses a generic event handler for all subscriptions.
- Sends the following tags: device, group, unit.
- Event.name now maps to the 'measurement' name.
- Headers and path are stored as state (to avoid recalculating on every event).
- Initial Version.
Some useful links relevant to the development of this SmartApp:
- SmartThings Capabilities Reference
- InfluxDB Documentation
- Codersaur.com - SmartThings Data Visualisation using InfluxDB and Grafana
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.