@SabotTX did you get it working.? Once you get everything connected for the first time then everything is a lot easier after that.
So you kind of posted the pictures backwards in order of how everything should be done so lets untangle that first. You set up your broker in HA first which it looks like you did it correct because I see it in the MQTT Explorer. The next step is setting up the Atlas software which it does not look like you did correctly. If it was connected you would see it in the Explorer just like you see the second homeassistant
under the main homeassistant
.
Setting up the MQTT with the Atlas software.
1 - Double check your spelling in the Endpoint URI
. It’s hard to tell in your picture if your spelled homeassistant:local
or if you spelled it homeasslstant:local
with an l
after the ss
or an i
. It’s a little blurry so I just want to make sure.
3 - The next thing that I see missing is your User ID
and Password
. Use the same one you used in HA when you sent up the broker which looks to be myusername
and it’s password. FYI it looks like the password you used is quite long, I personally use something simple that is only 4-6 characters long. It’s just easier. Either way, make sure you correctly enter both into the Atlas MQTT setup.
3 - Next, just to keep it simple, delete the Client ID
and for the Topic
just use one word like Atlas
or something else that will stand out when you’re looking at everything. You could always go back and change these things.
4 - Next, change the Interval (Secs)
to something shorter like 10 seconds or whatever. For now, it just makes it easier to see the data coming in. Again, you could always go back and change this.
5 - Save everything and just for the good measure reboot your RPi and then check to make sure it all saved correctly. (If you go back and change anything I would always reboot the RPi just to make sure everything saved and updated correctly.)
Now go back and open up the MQTT Explorer and check to see what it shows. I used Atlas
as the name for my Topic
which you can see in the picture below.
If you don’t see it at first, give it a second. This is one of the reasons I suggested changing the Interval (Secs)
to something shorter. If you have 60-seconds you might have to wait 60-seconds for it to show. If you see Atlas
or whatever Topic
you used then so far you’re good. If not, go back over the steps and doublecheck everything.
If you see you Topic
keep expanding it until you get to what I have highlighted in yellow below and make sure you click on it so it’s highlighted. When you do that you should see information similar to what I have on the right of the below picture. The data highlighted is my pH value. That as well as everything above and below it could be brought into HA. The data highlighted in the green is your Topic
. If you go back and change your Topic
name in the Atlas software this (as well as the part where you expanded Atlas
) will change to the new name.
Now you can copy the green highlighted data and enter into the part where you tried to Listen to a topic
in HA. After you start listening to it you will have to again wait for the interval time you selected for the first data message to appear. They will continue to appear at the selected interval until you stop listening. If this is working then you’re almost there.
The final part is creating a sensor. Open up your File Editor or Studio Code Server in HA and go to your configuration
file. Here you create a sensor using what previously highlighted in green and blue. (If you don’t know how to do this, click on the below arrow to expand my explanation explaining how.
Explanation
If you’ve never edited any HA files you need to use File Editor or Studio Code Server. If you don’t already have one of them you can find them in the ADD-ON STORE in HA which is the same place you found the Mosquitto broker add-on.
I would personally suggest using the File Editor because it would probably be easier for you. Add it, insIt should appear in the side menu of HA. After you install it click on START
. I have all of the options enabled for it but that’s just my preference. I would definitely choose Start of boot
and Show in sidebar
which makes it easier to find,
Open the UI by either clicking on that option or on the new icon for it on the sidebar. Look for a file name configuration
and open it and go to an empty stop at the bottom and create your sensor.
If you don’t see that file you might have to open another folder such as homeassistant
to find it.
For future knowledge and since you’re new at HA, based on how much you start using HA adding sensors and other things could quickly fill up your configuration
file. So what I do it point the configuration
file to a seperate file for my MQTT sensors. I actually do this for templates
, input_buttons
, and others things because it’s cleaner and I have more control entering in the actual yaml code than using the Lovelace UI and HA Helpers.
My configuration
begins like this and has a couple of other things which I did not include. The hashtag sign at the beginning means everything after it is a comment.
# Configuration yaml.
# Loads default set of integrations. Do not remove.
default_config:
# Text to speech.
tts:
- platform: google_translate
# Separate included files.
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
# group: !include group.yaml
light: !include light.yaml
# zone: !include zone.yaml
sensor: !include sensor.yaml
switch: !include switch.yaml
device_tracker: !include device_tracker.yaml
input_select: !include input_selects.yaml
input_boolean: !include input_booleans.yaml
input_text: !include input_texts.yaml
input_button: !include input_buttons.yaml
input_number: !include input_numbers.yaml
input_datetime: !include input_datetimes.yaml
plant: !include plants.yaml
template: !include templates.yaml
binary_sensor: !include binary_sensor.yaml
timer: !include timers.yaml
mqtt: !include mqtt.yaml # Adding this will point to a separate file for MQTT sensors.
homeassistant:
customize: !include customize.yaml
After you get everything working and if you want to do this then go ahead and try it. All you need to do is add the line of code in the configuration
file that I marked and then create a new file called mqtt.yaml
like below.
After creating the file, cut and paste the MQTT sensor from the configuration
file to the new mqtt
file. Then remove the part that says mqtt
since HA knows that’s what everything in the file is and shift the rest of it over so it looks like below.
# mqtt sensors -------------------------------------------
- sensor:
- name: "Atlas 001 ph value"
state_topic: "atlas/pH/add99"
value_template: "{{ value_json.value }}"
Then you could restart HA and it should work but before you do click on the CHECK CONFIGURATION
button. I always do this when making changes to make sure I didn’t do anything that will lock up HA.
# Below is what you need to create your sensor
mqtt:
sensor:
- name: "ENTER A NAME FOR YOUR SENSOR"
state_topic: "ENTER THE TOPIC HIGHLIGHTED IN GREEN"
value_template: "{{ value_json.ENTER THE BLUE HIGHLIGHTED VALUE }}"
# Below is what mine looks like.
mqtt:
sensor:
- name: "Atlas 001 ph value"
state_topic: "atlas/pH/add99"
value_template: "{{ value_json.value }}"
The value I highlighted in blue is only one of several values that you could make a sensor for. If you go back and look at the values above and below it, you could use any of these: created_at
, VersionInfo
, ModuleType
, etc. if you notice, mine does not have anything for name. In your Atlas software, you can click on your sensor and go to its settings and give it a name. If you choose to do this the name you give it will now be displayed as the Name
value. I don’t think this matters much because you can name your sensor whatever you want and then always edit it in HA.
You can now add your sensor to HA by using whichever card works best for you.
You can expand the arrow to see how I use HA. I just started using the Atlas sensors but plan on using more. I found they’re a lot cheaper and versatile than buying Blue Lab and other environment and water monitoring products from other companies. I have grow tents and use the AC Infinity controller because @dalinicus created an awesome HA integration for it that you can find HERE. I started with no knowledge of HA and only basic coding experience but HA could get a little addictive as you can see from my interface. I also use the HA Cloud by Nabu Casa which allows me to remotely connect with my phone. You could find more info about that HERE.
My Home Assistant
Hopefully this helps.