Setup The Things Network
First we collect the credentials to access the data from a third-party tool.
Start the Console and choose your application from Applications. The Application ID is used to identify the source of your data and is needed for the configuration of Home Assistant later.
You need an access key to be able to read the data from your application. It's recommended to limit the scope of the key to messages.
To use the application and the attached devices with Home Assistant you need to create a Storage integration for your application. For further details about the Storage integration check this video.
Go to Integrations and click "add integration" .
Choose Data Storage from the selection.
Confirm your selection by clicking on "Add integration".
When done, the status of the integration should be Running.
You could check the output after clicking on "go to platform". The web interface let you check the available data.
Depending on your device configuration you may need to decode the payload. If needed, visit Payload Formats and adjust the code in decoder. To get an impression about how it could look like, check the code below.
function Decoder(bytes, port) {
var decoded = {};
var voltage_raw = (bytes[0] << 8) + (bytes[1]);
decoded.voltage = voltage_raw * 2 * 3.3 / 1024;
var temperature_raw = (bytes[2] << 8) + (bytes[3]);
decoded.temperature = temperature_raw / 128;
return decoded;
}
temperature and voltage will be available from the device and the values we are going to monitor in Home Assistant.
At this point you should be able to get data with a tool like curl or httpie.
$ curl -X GET --header 'Accept: application/json' \
--header 'Authorization: key ttn-account-v2.GSsadSxbzqE0VVASdASDADU' \
'https://sensor-123.data.thethingsnetwork.org/api/v2/query'