Skip to content

Instantly share code, notes, and snippets.

@dlizcano
Created May 8, 2023 02:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlizcano/cf0ca8b89bdc36d7cdbb5d5a04441c5e to your computer and use it in GitHub Desktop.
Save dlizcano/cf0ca8b89bdc36d7cdbb5d5a04441c5e to your computer and use it in GitHub Desktop.
Connect to BirdWeather to get detections and species name

Get detections and species names from BirdWeather using the token provided by Tim as the BirdWeather ID

My BirdNET-Pi installation has been running since February 2023 and has picked up a lot of great detections and recordings. The station logs all the data locally, but you can optionally submit your detections to BirdWeather. BirdWeather’s API makes this project possible as it lets you request the data needed for the display.

This flow uses the API to get the detection number of the last 24 hours and the name of the last detected species and transmit it to your MQTTP broker for display later or storage in a database.

[
{
"id": "56f468673944b324",
"type": "tab",
"label": "Flow 3",
"disabled": false,
"info": "",
"env": []
},
{
"id": "8e32e0382db875c3",
"type": "http request",
"z": "56f468673944b324",
"name": "bird detections",
"method": "GET",
"ret": "obj",
"paytoqs": "ignore",
"url": "https://app.birdweather.com/api/v1/stations/[USE YOUR KEY]/stats",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 200,
"y": 260,
"wires": [
[
"281c9adbe5a011d9"
]
]
},
{
"id": "281c9adbe5a011d9",
"type": "change",
"z": "56f468673944b324",
"name": "birds",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.detections",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 350,
"y": 260,
"wires": [
[
"2090b0a782354ac5",
"f951e3003ee751d9"
]
]
},
{
"id": "2090b0a782354ac5",
"type": "mqtt out",
"z": "56f468673944b324",
"name": "",
"topic": "detections",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "5fc6518ec7e47158",
"x": 510,
"y": 260,
"wires": []
},
{
"id": "b238ebdf4f5f3ca0",
"type": "debug",
"z": "56f468673944b324",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 710,
"y": 440,
"wires": []
},
{
"id": "86d444c5e1aef56c",
"type": "mqtt in",
"z": "56f468673944b324",
"name": "",
"topic": "detections",
"qos": "2",
"datatype": "auto-detect",
"broker": "5fc6518ec7e47158",
"nl": false,
"rap": false,
"inputs": 0,
"x": 500,
"y": 400,
"wires": [
[
"b238ebdf4f5f3ca0"
]
]
},
{
"id": "f951e3003ee751d9",
"type": "delay",
"z": "56f468673944b324",
"name": "",
"pauseType": "delay",
"timeout": "15",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 480,
"y": 180,
"wires": [
[
"901a2bc49bfb7009"
]
]
},
{
"id": "854a6c824d711a07",
"type": "inject",
"z": "56f468673944b324",
"name": "start",
"props": [],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 90,
"y": 360,
"wires": [
[
"8e32e0382db875c3"
]
]
},
{
"id": "901a2bc49bfb7009",
"type": "http request",
"z": "56f468673944b324",
"name": "bird species",
"method": "GET",
"ret": "obj",
"paytoqs": "ignore",
"url": "https://app.birdweather.com/api/v1/stations/[USE YOUR KEY]/detections/?limit=1",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 650,
"y": 180,
"wires": [
[
"1852c5d77724f6d1"
]
]
},
{
"id": "1852c5d77724f6d1",
"type": "change",
"z": "56f468673944b324",
"name": "birds",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.detections.species.scientificName",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 830,
"y": 180,
"wires": [
[
"7569e633d8a3d9ea",
"8929c18df3ab77ba"
]
]
},
{
"id": "7569e633d8a3d9ea",
"type": "mqtt out",
"z": "56f468673944b324",
"name": "",
"topic": "species",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "5fc6518ec7e47158",
"x": 840,
"y": 260,
"wires": []
},
{
"id": "ec08e6210645e428",
"type": "mqtt in",
"z": "56f468673944b324",
"name": "",
"topic": "species",
"qos": "2",
"datatype": "auto-detect",
"broker": "5fc6518ec7e47158",
"nl": false,
"rap": false,
"inputs": 0,
"x": 490,
"y": 460,
"wires": [
[
"b238ebdf4f5f3ca0"
]
]
},
{
"id": "8929c18df3ab77ba",
"type": "delay",
"z": "56f468673944b324",
"name": "",
"pauseType": "delay",
"timeout": "45",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 480,
"y": 80,
"wires": [
[
"8e32e0382db875c3"
]
]
},
{
"id": "6c4ccb9982523789",
"type": "comment",
"z": "56f468673944b324",
"name": "",
"info": "Adapted from https://becausebirds.com/project-track-backyard-birds-on-a-digital-counter/",
"x": 300,
"y": 340,
"wires": []
},
{
"id": "5fc6518ec7e47158",
"type": "mqtt-broker",
"name": "raspi_mqttp_bird",
"broker": "192.168.1.59",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment