Mastodon user e_mobil2014 found a broken link along with the fact that I didn't have my MQTT sensors being imported to HA! Updated the content.

This commit is contained in:
Norm Rasmussen
2023-10-11 12:26:08 -04:00
parent 3d92eec619
commit b8b09f41e8
7 changed files with 240 additions and 31 deletions

View File

@ -27,7 +27,9 @@ cover:
hidden: true # only hide on current single page
---
_This is Part One of a Two Part Series. You can find Part Two, here._
This is Part One of a Two Part Series. You can find Part Two, [here.]({{<ref "birdnet_homeassistant_part2.md" >}})
**Update: 10/11/2023. A huge thanks to Mastodon User [e_mobile2014](https://mastodon.social/@e_mobil2014) who found a broken link in this guide and pointed out that I never explained how to get the mqtt sensors into HomeAssistant!**
## What you will need
@ -166,9 +168,9 @@ adding `print()` statements at various points, you'll notice that the payload is
```json
{
"payload": {
"data": "data"
}
"payload": {
"data": "data"
}
}
```
@ -180,8 +182,7 @@ grab the string by their index. If you remember what [we did above]({{<ref "bird
This next section is shooting all the variables we just defined back via MQTT. The reason why we do it this way is because we
need HomeAssistant to grab each of these variables as individual sensors. BirdNET doesn't give us that capability - it's a
single message with all the information in one. [Here is the documentation from AppDaemon](## BirdNET-PI Notification Setup - MQTT
) on `mqtt_publish`. Later on, I'll show you how to ensure that HomeAssistant takes those topic payloads and adds them as
single message with all the information in one. [Here is the documentation from AppDaemon](https://appdaemon.readthedocs.io/en/latest/MQTT_API_REFERENCE.html) on `mqtt_publish`. Later on, I'll show you how to ensure that HomeAssistant takes those topic payloads and adds them as
entities in your HA setup.
#### Part 3: Wikipedia Sensor
@ -230,9 +231,11 @@ response contains multiple photos in a single response. We're passing `per_page=
Left out of that response, though, is a one-stop-shop for a URL to that photo. Thankfully, Flickr can help us put together a
URL from the data in the response.
{{< box info >}}
_Note: Full Transparency that I only learned about this after reading through BirdNET-Pi's code base. Full credit goes to
[mcguirepr89](https://github.com/mcguirepr89). For additional reference, here is Flickr's [official page on construction
photo image URLS](https://www.flickr.com/services/api/misc.urls.html)_
{{< /box >}}
With this response, we now have the variables we need to construct the URL to actually render the image. Those variables are:
Farm ID, Server ID, ID and Secret. I haven't yet looked into why we need "farm" when the official documentation doesn't state
@ -255,8 +258,54 @@ from Flickr.
attributes={"image": image_url})
```
In Part 2 of this article, we'll take a look at Home Assistant, see what these sensors look like, and create a rudimentary
dashboard.
## Importing MQTT Sensors into HomeAssistant
Now that we have all the sensors defined and communicating via MQTT, we have one more step to import them into HomeAssistant.
[This MQTT documentation](https://www.home-assistant.io/integrations/mqtt/) by HomeAssistant is good to read about if you
need a broker setup. I will not be going over the broker in this tutorial, but may add one in the future. I tend to like the
yaml configuration for HomeAssistant, so for the sake of this guide, I'll be referencing the [manual configuration of MQTT
items and sensors](https://www.home-assistant.io/integrations/mqtt/#manual-configured-mqtt-items).
To add the sensors from above, open up your `configuration.yaml` file in your favorite editor. You'll then want to add the
mqtt platform and domain:
```yaml
mqtt:
- { domain }:
```
For the BirdNet sensors, we will be using a single domain: `sensor`. Feel free to copy and paste my config from below, but
make sure the names of each entity align with your needs, syntax, and nomenclature/system.
**Full MQTT Sensors in Configuration.yml**
```yaml
mqtt:
sensor:
- name: "Bird Common Name"
state_topic: "birdnet/sensors/common_name"
- name: "Bird Science Name"
state_topic: "birdnet/sensors/science_name"
- name: "Bird Time Seen"
state_topic: "birdnet/sensors/time_seen"
- name: "Bird Date Seen"
state_topic: "birdnet/sensors/date_seen"
- name: "Bird Confidence"
state_topic: "birdnet/sensors/confidence"
value_template: '{{ (value|float(0) *100) | round(1) }}'
unit_of_measurement: '%'
```
You might be looking at the list above and wondering where the Flickr and Wikipedia Description entities are. They were
already created by the AppDaemon script! Specifically, `self.hassapi.set_state()` function will either update the state for
an exisiting entity or, if the entity doesn't exist, it will create a new one.
For the rest of the mqtt payloads, we need HomeAssistant to create them as they come in, which is why we add the above
code block to our HomeAssistant configuration file. To be clear, you _do not_ need to add the Wikipedia and Flickr sensors to
HA's configuration file!
By this point, you should have successfully created 7 new sensors in HomeAssistant. In Part 2 of this article, we'll take a
look at Home Assistant, see what these sensors look like, and create a rudimentary dashboard.
## Birdnet AppDaemon Script
@ -313,3 +362,13 @@ class birdnet(adbase.ADBase):
attributes={"image": image_url})
```
<style>
.box-shortcode {
color: #e8e8e8;
border: none;
}
.post-content img {
margin: auto
}
</style>

View File

@ -166,9 +166,10 @@ The best way to do this is by just type e from any screen in the HomeAssistant U
</header>
<div class="entry-content">
<p>This is Part One of a Two Part Series. You can find Part Two, here.
What you will need BirdNET-Pi HomeAssistant AppDaemon MQTT Broker (I use Mosquitto) Background In early 2023, at the height of the Raspberry Pi shortage I felt like a king with an extra Rpi laying around, not being used. Im a big fan of any sort of passive intake of information and had been looking around for various citizen science-style projects that can capture information from the world around me....</p>
Update: 10/11/2023. A huge thanks to Mastodon User e_mobile2014 who found a broken link in this guide and pointed out that I never explained how to get the mqtt sensors into HomeAssistant!
What you will need BirdNET-Pi HomeAssistant AppDaemon MQTT Broker (I use Mosquitto) Background In early 2023, at the height of the Raspberry Pi shortage I felt like a king with an extra Rpi laying around, not being used....</p>
</div>
<footer class="entry-footer"><span title='2023-09-30 11:21:55 -0400 EDT'>September 30, 2023</span>&nbsp;·&nbsp;10 min&nbsp;·&nbsp;1953 words&nbsp;·&nbsp;Me</footer>
<footer class="entry-footer"><span title='2023-09-30 11:21:55 -0400 EDT'>September 30, 2023</span>&nbsp;·&nbsp;11 min&nbsp;·&nbsp;2296 words&nbsp;·&nbsp;Me</footer>
<a class="entry-link" aria-label="post link to Creating a BirdNetPi Dashboard in HomeAssistant - Part 1" href="./posts/birdnet_homeassistant.html"></a>
</article>

View File

@ -140,9 +140,10 @@ The best way to do this is by just type e from any screen in the HomeAssistant U
</header>
<div class="entry-content">
<p>This is Part One of a Two Part Series. You can find Part Two, here.
What you will need BirdNET-Pi HomeAssistant AppDaemon MQTT Broker (I use Mosquitto) Background In early 2023, at the height of the Raspberry Pi shortage I felt like a king with an extra Rpi laying around, not being used. Im a big fan of any sort of passive intake of information and had been looking around for various citizen science-style projects that can capture information from the world around me....</p>
Update: 10/11/2023. A huge thanks to Mastodon User e_mobile2014 who found a broken link in this guide and pointed out that I never explained how to get the mqtt sensors into HomeAssistant!
What you will need BirdNET-Pi HomeAssistant AppDaemon MQTT Broker (I use Mosquitto) Background In early 2023, at the height of the Raspberry Pi shortage I felt like a king with an extra Rpi laying around, not being used....</p>
</div>
<footer class="entry-footer"><span title='2023-09-30 11:21:55 -0400 EDT'>September 30, 2023</span>&nbsp;·&nbsp;10 min&nbsp;·&nbsp;1953 words&nbsp;·&nbsp;Me</footer>
<footer class="entry-footer"><span title='2023-09-30 11:21:55 -0400 EDT'>September 30, 2023</span>&nbsp;·&nbsp;11 min&nbsp;·&nbsp;2296 words&nbsp;·&nbsp;Me</footer>
<a class="entry-link" aria-label="post link to Creating a BirdNetPi Dashboard in HomeAssistant - Part 1" href="./posts/birdnet_homeassistant.html"></a>
</article>

File diff suppressed because one or more lines are too long

View File

@ -125,9 +125,10 @@ The best way to do this is by just type e from any screen in the HomeAssistant U
</header>
<div class="entry-content">
<p>This is Part One of a Two Part Series. You can find Part Two, here.
What you will need BirdNET-Pi HomeAssistant AppDaemon MQTT Broker (I use Mosquitto) Background In early 2023, at the height of the Raspberry Pi shortage I felt like a king with an extra Rpi laying around, not being used. Im a big fan of any sort of passive intake of information and had been looking around for various citizen science-style projects that can capture information from the world around me....</p>
Update: 10/11/2023. A huge thanks to Mastodon User e_mobile2014 who found a broken link in this guide and pointed out that I never explained how to get the mqtt sensors into HomeAssistant!
What you will need BirdNET-Pi HomeAssistant AppDaemon MQTT Broker (I use Mosquitto) Background In early 2023, at the height of the Raspberry Pi shortage I felt like a king with an extra Rpi laying around, not being used....</p>
</div>
<footer class="entry-footer"><span title='2023-09-30 11:21:55 -0400 EDT'>September 30, 2023</span>&nbsp;·&nbsp;10 min&nbsp;·&nbsp;1953 words&nbsp;·&nbsp;Me</footer>
<footer class="entry-footer"><span title='2023-09-30 11:21:55 -0400 EDT'>September 30, 2023</span>&nbsp;·&nbsp;11 min&nbsp;·&nbsp;2296 words&nbsp;·&nbsp;Me</footer>
<a class="entry-link" aria-label="post link to Creating a BirdNetPi Dashboard in HomeAssistant - Part 1" href="../posts/birdnet_homeassistant.html"></a>
</article>

View File

@ -125,9 +125,10 @@ The best way to do this is by just type e from any screen in the HomeAssistant U
</header>
<div class="entry-content">
<p>This is Part One of a Two Part Series. You can find Part Two, here.
What you will need BirdNET-Pi HomeAssistant AppDaemon MQTT Broker (I use Mosquitto) Background In early 2023, at the height of the Raspberry Pi shortage I felt like a king with an extra Rpi laying around, not being used. Im a big fan of any sort of passive intake of information and had been looking around for various citizen science-style projects that can capture information from the world around me....</p>
Update: 10/11/2023. A huge thanks to Mastodon User e_mobile2014 who found a broken link in this guide and pointed out that I never explained how to get the mqtt sensors into HomeAssistant!
What you will need BirdNET-Pi HomeAssistant AppDaemon MQTT Broker (I use Mosquitto) Background In early 2023, at the height of the Raspberry Pi shortage I felt like a king with an extra Rpi laying around, not being used....</p>
</div>
<footer class="entry-footer"><span title='2023-09-30 11:21:55 -0400 EDT'>September 30, 2023</span>&nbsp;·&nbsp;10 min&nbsp;·&nbsp;1953 words&nbsp;·&nbsp;Me</footer>
<footer class="entry-footer"><span title='2023-09-30 11:21:55 -0400 EDT'>September 30, 2023</span>&nbsp;·&nbsp;11 min&nbsp;·&nbsp;2296 words&nbsp;·&nbsp;Me</footer>
<a class="entry-link" aria-label="post link to Creating a BirdNetPi Dashboard in HomeAssistant - Part 1" href="../posts/birdnet_homeassistant.html"></a>
</article>
</main>

View File

@ -110,9 +110,10 @@ if (!doNotTrack) {
</header>
<div class="entry-content">
<p>This is Part One of a Two Part Series. You can find Part Two, here.
What you will need BirdNET-Pi HomeAssistant AppDaemon MQTT Broker (I use Mosquitto) Background In early 2023, at the height of the Raspberry Pi shortage I felt like a king with an extra Rpi laying around, not being used. Im a big fan of any sort of passive intake of information and had been looking around for various citizen science-style projects that can capture information from the world around me....</p>
Update: 10/11/2023. A huge thanks to Mastodon User e_mobile2014 who found a broken link in this guide and pointed out that I never explained how to get the mqtt sensors into HomeAssistant!
What you will need BirdNET-Pi HomeAssistant AppDaemon MQTT Broker (I use Mosquitto) Background In early 2023, at the height of the Raspberry Pi shortage I felt like a king with an extra Rpi laying around, not being used....</p>
</div>
<footer class="entry-footer"><span title='2023-09-30 11:21:55 -0400 EDT'>September 30, 2023</span>&nbsp;·&nbsp;10 min&nbsp;·&nbsp;1953 words&nbsp;·&nbsp;Me</footer>
<footer class="entry-footer"><span title='2023-09-30 11:21:55 -0400 EDT'>September 30, 2023</span>&nbsp;·&nbsp;11 min&nbsp;·&nbsp;2296 words&nbsp;·&nbsp;Me</footer>
<a class="entry-link" aria-label="post link to Creating a BirdNetPi Dashboard in HomeAssistant - Part 1" href="../posts/birdnet_homeassistant.html"></a>
</article>
</main>