Difference between revisions of "Home Assistant: Configuring "Salt Sentry" using MQTT protocol"
From falz.net
(Created page with "Category:Dev Category:Unix ===Background=== About a week ago I had never heard of Home Assistant, Salt Sentry, nor MQTT. Just before that, I replaced a water softene...") |
|||
Line 3: | Line 3: | ||
===Background=== | ===Background=== | ||
− | About a week ago I had never heard of Home Assistant, Salt Sentry, nor MQTT. | + | About a week ago I had never heard of Home Assistant, Salt Sentry, nor MQTT. If you're hear, maybe this is fully or partially true for you too. |
+ | |||
+ | |||
+ | Just before that, I replaced a water softener. This reminded me that you also have to add salt to said water softener. I never remember to do this and thought it would be keen if something could tell me when to do so by measuring the physical salt level. | ||
− | |||
A bit of googling revealed a few home dev style solutions (buy some parts, solder some things) but the most complete of these appeared to be a product called "[https://www.tindie.com/products/ErikLemcke/salt-sentry-water-softener-monitor/ Salt Sentry]" | A bit of googling revealed a few home dev style solutions (buy some parts, solder some things) but the most complete of these appeared to be a product called "[https://www.tindie.com/products/ErikLemcke/salt-sentry-water-softener-monitor/ Salt Sentry]" | ||
+ | |||
It works by using a small software development board which contains a [https://www.st.com/en/imaging-and-photonics-solutions/vl53l0x.html VL53L0X] sensor which is some magical device that can measure distance with accuracy of 2mm when just pointing it into the ether. 🤷 cool. | It works by using a small software development board which contains a [https://www.st.com/en/imaging-and-photonics-solutions/vl53l0x.html VL53L0X] sensor which is some magical device that can measure distance with accuracy of 2mm when just pointing it into the ether. 🤷 cool. | ||
+ | |||
To use this, you need to integrate it with something else, there are a few options, but the most popular one seemed to be called "Home Assistant". While I was waiting for the Salt Sentry to arrive, i thought I'd get ahead of things and install Home Assistant. | To use this, you need to integrate it with something else, there are a few options, but the most popular one seemed to be called "Home Assistant". While I was waiting for the Salt Sentry to arrive, i thought I'd get ahead of things and install Home Assistant. | ||
Line 16: | Line 20: | ||
=== Home Assistant === | === Home Assistant === | ||
[https://www.home-assistant.io/ Home Assistant] ([https://en.wikipedia.org/wiki/Home_Assistant wikipedia]) is something one can run on a Raspberry Pi or other similar hardware. I happened to have a few Pi's laying around unused so i thought I'd give it a shot: | [https://www.home-assistant.io/ Home Assistant] ([https://en.wikipedia.org/wiki/Home_Assistant wikipedia]) is something one can run on a Raspberry Pi or other similar hardware. I happened to have a few Pi's laying around unused so i thought I'd give it a shot: | ||
+ | |||
{{Quote|"Home Assistant is free and open-source software for home automation designed to be a central control system for smart home devices with a focus on local control and privacy."}} | {{Quote|"Home Assistant is free and open-source software for home automation designed to be a central control system for smart home devices with a focus on local control and privacy."}} | ||
Line 26: | Line 31: | ||
Plug it in, boot it up, and i highly recommend creating a local DNS record for 'homeassistant.local' as most of the docs use that and may even link to it. [https://www.home-assistant.io/getting-started/ Configuring it] is outside of the scope of this page but it's pretty simple. | Plug it in, boot it up, and i highly recommend creating a local DNS record for 'homeassistant.local' as most of the docs use that and may even link to it. [https://www.home-assistant.io/getting-started/ Configuring it] is outside of the scope of this page but it's pretty simple. | ||
+ | |||
On its own with no config it auto discovered some Devices, which it calls "Integrations" on its own: | On its own with no config it auto discovered some Devices, which it calls "Integrations" on its own: | ||
− | |||
* Ecobee thermostat + remote sensor | * Ecobee thermostat + remote sensor | ||
− | * | + | * Roku |
* Onkyo A/V receiver | * Onkyo A/V receiver | ||
+ | * Mobile phone (once app installed) | ||
* Outdoor Weather | * Outdoor Weather | ||
− | * | + | * The literal Sun |
Line 42: | Line 48: | ||
===MQTT=== | ===MQTT=== | ||
[https://www.home-assistant.io/docs/mqtt/ MQTT] ([https://en.wikipedia.org/wiki/MQTT wikipedia] stands for "MQ Telemetry Transport". What does MQ stand for? Apparently it came from IBM thing called "MQSeries" where it stood for Message Queing, wikipedia says it stands for nothing. We're off to a great start. | [https://www.home-assistant.io/docs/mqtt/ MQTT] ([https://en.wikipedia.org/wiki/MQTT wikipedia] stands for "MQ Telemetry Transport". What does MQ stand for? Apparently it came from IBM thing called "MQSeries" where it stood for Message Queing, wikipedia says it stands for nothing. We're off to a great start. | ||
+ | |||
If you go to Settings -> Devices and Services -> [http://homeassistant.local:8123/config/integrations Integrations] and choose to add MQTT, it just asks for your broker and you're just kinda stuck. | If you go to Settings -> Devices and Services -> [http://homeassistant.local:8123/config/integrations Integrations] and choose to add MQTT, it just asks for your broker and you're just kinda stuck. | ||
+ | |||
To use MQTT with Home Assitant, you must use something called "[https://github.com/home-assistant/addons/tree/master/mosquitto Mosquitto Broker]". Why? I don't know, but you need it. Install it from Settings -> [http://homeassistant.local:8123/hassio/dashboard Add-Ons] -> Add-on store. It will take several minutes to install. I would recommend rebooting after as well. | To use MQTT with Home Assitant, you must use something called "[https://github.com/home-assistant/addons/tree/master/mosquitto Mosquitto Broker]". Why? I don't know, but you need it. Install it from Settings -> [http://homeassistant.local:8123/hassio/dashboard Add-Ons] -> Add-on store. It will take several minutes to install. I would recommend rebooting after as well. | ||
+ | |||
+ | [[Image:Mosquito-settings.png|border|300px|right]] | ||
Once it's installed.. this is where you hit question marks. What's next? [https://github.com/home-assistant/addons/blob/master/mosquitto/DOCS.md The docs] just say that it should show up as a discovered integraiton, but it didn't for me. So I rebooted Home Assistant, and then MQTT appeared as discovered after a bit. | Once it's installed.. this is where you hit question marks. What's next? [https://github.com/home-assistant/addons/blob/master/mosquitto/DOCS.md The docs] just say that it should show up as a discovered integraiton, but it didn't for me. So I rebooted Home Assistant, and then MQTT appeared as discovered after a bit. | ||
+ | Before going further, go and add a new user to Home assistant itsself, and configure Mosquitto to use it. This made it a lot easier to get the device to talk to it. I used "mosquitto" as username, use what you want. Record the password | ||
+ | |||
+ | * Settings -> People -> [http://homeassistant.local:8123/config/users Users] -> Add user | ||
+ | ** Display name / Username: mosquitto | ||
+ | ** Password: <redacted> | ||
+ | ** Create | ||
+ | |||
+ | |||
+ | Now go in to the MQTT settings and tell it | ||
+ | * Settings -> [http://homeassistant.local:8123/config/integrations Devices and Services] -> MQTT Configure | ||
+ | ** Re-Configure MQTT | ||
+ | ** Username: mosquitto | ||
+ | ** Password: <redacted> | ||
+ | ** Next (until finished). | ||
+ | ** It may ask you to reboot | ||
+ | |||
+ | |||
+ | [[Image:Saltsentry-connected.png|border|300px|right]] | ||
===Salt Sentry=== | ===Salt Sentry=== | ||
+ | Configure the [https://github.com/Lemcke-solutions/SaltSentryManuals device per the manual]. On its settings page set: | ||
+ | |||
+ | * mqtt server: <ip of your home assistant server> | ||
+ | * mqtt username: mosquitto | ||
+ | * mqtt password: <redacted, same as MQTT> | ||
+ | * mqtt topic: saltsentry | ||
+ | |||
+ | |||
+ | Once you have this in, the Salt Sentry should finally show as connected. | ||
+ | |||
+ | |||
+ | [[Image:Mqtt-homeassistant.png|border|300px|right]] | ||
+ | Do a sanity check. | ||
+ | * Settings -> [http://homeassistant.local:8123/config/integrations Devices and Services] -> MQTT Configure | ||
+ | ** Listen to a topic: saltsentry | ||
+ | ** Start Listening | ||
+ | |||
+ | You should see a message received at the current timestamp. |
Revision as of 16:24, 28 January 2023
Contents
[hide]Background
About a week ago I had never heard of Home Assistant, Salt Sentry, nor MQTT. If you're hear, maybe this is fully or partially true for you too.
Just before that, I replaced a water softener. This reminded me that you also have to add salt to said water softener. I never remember to do this and thought it would be keen if something could tell me when to do so by measuring the physical salt level.
A bit of googling revealed a few home dev style solutions (buy some parts, solder some things) but the most complete of these appeared to be a product called "Salt Sentry"
It works by using a small software development board which contains a VL53L0X sensor which is some magical device that can measure distance with accuracy of 2mm when just pointing it into the ether. 🤷 cool.
To use this, you need to integrate it with something else, there are a few options, but the most popular one seemed to be called "Home Assistant". While I was waiting for the Salt Sentry to arrive, i thought I'd get ahead of things and install Home Assistant.
Home Assistant
Home Assistant (wikipedia) is something one can run on a Raspberry Pi or other similar hardware. I happened to have a few Pi's laying around unused so i thought I'd give it a shot:
"Home Assistant is free and open-source software for home automation designed to be a central control system for smart home devices with a focus on local control and privacy."
I ended up installing this by downloading and using `dd` to image it to an SD card.
dd if=haos_rpi3-64-9.4.img of=/dev/sdb bs=4M && sync
Plug it in, boot it up, and i highly recommend creating a local DNS record for 'homeassistant.local' as most of the docs use that and may even link to it. Configuring it is outside of the scope of this page but it's pretty simple.
On its own with no config it auto discovered some Devices, which it calls "Integrations" on its own:
- Ecobee thermostat + remote sensor
- Roku
- Onkyo A/V receiver
- Mobile phone (once app installed)
- Outdoor Weather
- The literal Sun
All of this was super easy, didn't require any CLI changes, it just was clicky clicky from a quick web UI. Cool, that'll be the same with MQTT too? no.
MQTT
MQTT (wikipedia stands for "MQ Telemetry Transport". What does MQ stand for? Apparently it came from IBM thing called "MQSeries" where it stood for Message Queing, wikipedia says it stands for nothing. We're off to a great start.
If you go to Settings -> Devices and Services -> Integrations and choose to add MQTT, it just asks for your broker and you're just kinda stuck.
To use MQTT with Home Assitant, you must use something called "Mosquitto Broker". Why? I don't know, but you need it. Install it from Settings -> Add-Ons -> Add-on store. It will take several minutes to install. I would recommend rebooting after as well.
Once it's installed.. this is where you hit question marks. What's next? The docs just say that it should show up as a discovered integraiton, but it didn't for me. So I rebooted Home Assistant, and then MQTT appeared as discovered after a bit.
Before going further, go and add a new user to Home assistant itsself, and configure Mosquitto to use it. This made it a lot easier to get the device to talk to it. I used "mosquitto" as username, use what you want. Record the password
- Settings -> People -> Users -> Add user
- Display name / Username: mosquitto
- Password: <redacted>
- Create
Now go in to the MQTT settings and tell it
- Settings -> Devices and Services -> MQTT Configure
- Re-Configure MQTT
- Username: mosquitto
- Password: <redacted>
- Next (until finished).
- It may ask you to reboot
Salt Sentry
Configure the device per the manual. On its settings page set:
- mqtt server: <ip of your home assistant server>
- mqtt username: mosquitto
- mqtt password: <redacted, same as MQTT>
- mqtt topic: saltsentry
Once you have this in, the Salt Sentry should finally show as connected.
Do a sanity check.
- Settings -> Devices and Services -> MQTT Configure
- Listen to a topic: saltsentry
- Start Listening
You should see a message received at the current timestamp.