@ErikNL Do you have some home assistant screenshots and/or the yaml to make this work?
Unfortunately, the sensor doesn’t work that well on water, if you can however put something floating in the water, it would work.
I configured the topic hal/saltsentry in the saltsentry I use myself, and added these two configurations to configuration.yaml
- platform: mqtt
name: "Salt sentry percentage"
state_topic: "hal/saltsentry"
qos: 0
unit_of_measurement: "%"
- platform: mqtt
name: "Salt sentry cm"
state_topic: "hal/saltsentry_distance"
qos: 0
unit_of_measurement: "cm"
In the UI, it looks like this:
Mine arrived a few days ago. Set it up yesterday, it’s working like a charm! Nice work!
One small thing, at the bottom of page 7 of the English manual the second sensor setup should be state_topic: "hallway/saltsentry_distance"
Thanks for the comment, I’ve updated the manual.
I also recently (after a question from a user) tried to see if the module would wok with ESPHome, I got it working with the following code:
esphome:
name: salt-sentry
esp8266:
board: esp_wroom_02
i2c:
sda: 2
scl: 14
scan: true
id: bus_a
sensor:
- platform: vl53l0x
name: "VL53L0x Distance"
address: 0x29
update_interval: 60s
long_range: false
unit_of_measurement: cm
The Salt sentry will now send the measured distance in cm to Home assistant. To get a full/empty percentage, you can configure a template senor.
Did some more fiddling around and came up with a better ESPHome config that will also calculate the percentage:
esphome:
name: salt-sentry
esp8266:
board: esp_wroom_02
i2c:
sda: 2
scl: 14
scan: true
globals:
- id: full_cm
type: float
initial_value: '5'
- id: empty_cm
type: float
initial_value: '35'
sensor:
- platform: vl53l0x
id: distance_m
address: 0x29
update_interval: 60s
long_range: false
internal: true
- platform: template
unit_of_measurement: cm
icon: mdi:arrow-expand-down
name: distance
id: distance
update_interval: 60s
lambda: |-
return id(distance_m).state * 100;
- platform: template
name: "percentage"
unit_of_measurement: '%'
icon: mdi:percent
lambda: |-
if (id(distance).state < id(full_cm)) {
return 100;
}
if (id(distance).state > id(empty_cm)) {
return 0;
}
return 100 - (id(distance).state - id(full_cm)) / ((id(empty_cm) - id(full_cm)) / 100);
update_interval: 60s
The values in the “globals” section should be changed to reflect the number of cm when the water softener should be seen as full or empty.
Just ordered mine, bit of a price increase since i last checked, but that’s fine. Looking forward to this.
My Salt Sentry just arrived. Immediately I added it to ESPHome with your above code. I did a few things like:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "0142casdfasdcca51"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Add a default domain name
domain: .temp.nl
# Enable Web server.
web_server:
port: 80
# Sync time with Home Assistant.
time:
- platform: homeassistant
id: homeassistant_time
But for some reason the sensors present ‘unknown’.
If I check the logs I’m seeing the following:
[D][api.connection:917]: Home Assistant 2022.10.5 (192.168.21.92): Connected successfully
[D][time:041]: Synchronized time: 2022-10-26 16:28:14
[D][sensor:126]: 'distance': Sending state nan cm with 1 decimals of accuracy
[D][sensor:126]: 'percentage': Sending state -nan % with 1 decimals of accuracy
[D][sensor:126]: 'distance': Sending state nan cm with 1 decimals of accuracy
Any thoughts?
Hi Martijn,
Sorry to hear you have some trouble with it. If you’re looking in the logs, do you see lines like these?
[19:51:18][I][i2c.arduino:054]: Results from i2c bus scan:
[19:51:18][I][i2c.arduino:060]: Found i2c device at address 0x29
Did you also fill in proper values for your water softener in the globals
section?
After a while, you should also see lines like:
[19:52:38][D][sensor:124]: 'percentage': Sending state 0.00000 % with 1 decimals of accuracy
[19:52:39][D][vl53l0x:308]: 'distance_m' - Got distance 1.111 m
[19:52:39][D][sensor:124]: 'distance_m': Sending state 1.11100 m with 2 decimals of accuracy
[19:52:44][D][sensor:124]: 'distance': Sending state 111.09999 cm with 1 decimals of accuracy
Can you maybe also try the code I postend in: Salt sentry: Water softener monitoring device - #17 by ErikNL It’s basically the same code, but without the calculations.
I test every Salt sentry before it goes out the door, so I wouldn’t expect the sensor itself to be a problem.
So with only the:
sensor:
- platform: vl53l0x
name: "VL53L0x Distance"
address: 0x29
update_interval: 60s
long_range: false
unit_of_measurement: cm
Section; it works. It creates a new sensor according to the provided name, and it shows the distance.
Going to try with the other sensors again.
mmmm… I think it is a human error / OSI-Layer-8 or PEBCAK, or anything similar. I didn’t have it build in yet (into the Aquacell) and apparently that is needed.
So my sincere apologies, but works now. Great!
Glad to hear it’s working now
What possibly happened is that the distance from the salt sentry to the nearest surface was above the maximum distance the sensor can measure, and that would then make the calculation return “nan”
@erikNL - the MQTT message being received by Home Assistant is completely inaccurate right now. I see no way to troubleshoot this further, as I have checked distance to other objects and it still just reports the same thing. Is there a way to test this outside of Home Assistant, to see if this is an MQTT broker issue? I have a connection issue I just had to change the config to correct. This all popped up a couple days ago and I’m wondering if anyone else is having issues with Home Assistant as well since the last updates.
Try MQTT Explorer to look at all MQTT messages on the broker
EDIT - Spoke too soon, it’s reporting wrong to MQTT Explorer as well. It was working again for a second by modifying case sensitivity, but then went back to an incorrect value.
@ErikNL - Is this project abandoned? I loved it when it was working, but I’m wondering if I need to to look for an alternative now, as this is essentially useless to me right now…
No, it is not, I was just on holiday
I don’t totally understand the issue you are facing yet. Did you add these line to your configuration.yaml?
if so, you should have device called “salt sentry” and “salt sentry distance” in home assistant, they should look something like this and they should update once a minute:
Please note that the hole in the salt sentry should be facing the salt, so it should be mounted upside down.
I’m using Homer assistant core 2022.12.6, but will soon update to see if any issues arrize
Thanks for the reply. I noticed the problems started in mid January, so I do believe it’s related to the updates. I am on 2023.01.1
No matter what I do, it reports the distance as 4 and the percentage as 100. I have even reset the device and changed the thresholds to see if that would help.
I’ve now also updated to a newer version of HA, I’m now on 2023.2.2. I do not experience any problems, so it must be something else.
I’ll contact you via DM to see if we can figure it out, if the device is faulty, I’ll make sure you get a replacement.