Recently purchased a Tank Mate - the fact that there was a basic integration in place (Thanks Simon!) swung the decision in favour of their device.
I’ve made a few tweaks to Simon’s excellent starting point and include them here in case of use to anyone else.
# Mofified version of the Tankmate "Farm Tank" sensor by SimonPth
# Modifications by hughhalf:
# * Set scan interval to 5m instead of default 30s Data changes no more often than
# 15m and reduces load the TankMate backend
# * Used 'tankName' as the Value_template and shifted currentLevel into template section
# this seemed to improve handling of the 'currentLevel' value in HA cards etc
# * Unit of measure fot outlet height is millimetres rather than metres
# * Changed name to "Water Tank" from "Farm Tank"
#
# ToDo One Day Maybe...
# * Abstract out UID, API Key and DeviceID to be set once at top of file
# * Re-write as a full integration with multi tank support etc.
#
# This version 2024-08-12a
sensor: # May not need this line depending on how you include this into your HA install
- platform: rest
name: Water Tank
resource: https://api.tankmate.app/status/?uid=Your-UID-Goes-Here
scan_interval: 300
method: GET
headers:
accept: application/json
api-key: Your-API-Key-Goes-Here
value_template: "{{ value_json['Your-DeviceID-Goes-Here']['tankName'] }}"
json_attributes:
- 'Your-DeviceID-Goes-Here'
- platform: template
sensors:
water_tank_device_id:
friendly_name: "Water Tank Device ID"
value_template: "{{ state_attr('sensor.water_tank', 'Your-DeviceID-Goes-Here').deviceId }}"
water_tank_max_volume:
friendly_name: "Water Tank Max Volume"
value_template: "{{ state_attr('sensor.water_tank', 'Your-DeviceID-Goes-Here').maxVolume }}"
unit_of_measurement: "L"
device_class: volume_storage
water_tank_maximum_height:
friendly_name: "Water Tank Maximum Height"
value_template: "{{ state_attr('sensor.water_tank', 'Your-DeviceID-Goes-Here').maximumHeight }}"
unit_of_measurement: "m"
device_class: distance
water_tank_outlet_height:
friendly_name: "Water Tank Outlet Height"
value_template: "{{ state_attr('sensor.water_tank', 'Your-DeviceID-Goes-Here').outletHeight }}"
unit_of_measurement: "mm"
device_class: distance
water_tank_overflow_height:
friendly_name: "Water Tank Overflow Height"
value_template: "{{ state_attr('sensor.water_tank', 'Your-DeviceID-Goes-Here').overflowHeight }}"
unit_of_measurement: "m"
device_class: distance
water_tank_tank_area:
friendly_name: "Water Tank tank Area"
value_template: "{{ state_attr('sensor.water_tank', 'Your-DeviceID-Goes-Here').tankArea }}"
unit_of_measurement: "m2"
water_tank_bat_voltage:
friendly_name: "Water Tank Battery Voltage"
value_template: "{{ state_attr('sensor.water_tank', 'Your-DeviceID-Goes-Here').batVoltage | float / 1000|round(2) }}"
unit_of_measurement: "V"
device_class: battery
water_tank_current_volume:
friendly_name: "Water tank Current Volume"
value_template: "{{ state_attr('sensor.water_tank', 'Your-DeviceID-Goes-Here').currentVolume }}"
unit_of_measurement: "L"
device_class: volume_storage
water_tank_current_percent:
friendly_name: "Water Tank Current Percent"
value_template: "{{ state_attr('sensor.water_tank', 'Your-DeviceID-Goes-Here').currentPercent }}"
unit_of_measurement: "%"
device_class: volume_storage
water_tank_current_level:
friendly_name: "Water Tank Current Level"
value_template: "{{ state_attr('sensor.water_tank', 'Your-DeviceID-Goes-Here').currentLevel }}"
unit_of_measurement: "m"
device_class: distance
water_tank_last_reading:
friendly_name: "Water Tank Last Reading"
value_template: "{{ state_attr('sensor.water_tank', 'Your-DeviceID-Goes-Here').lastReading }}"
device_class: timestamp
water_tank_network:
friendly_name: "Water Tank Network"
value_template: "{{ state_attr('sensor.water_tank', 'Your-DeviceID-Goes-Here').network }}"
Thanks for the YAML Hugh & Simon. I added it to my HA and have got it calling the TankMate API for my sensor, which incidentally I need to re-calibrate as I have made some guesses on the tank dimensions, so some of the readings are out.
I’ve “recalibrated” the sensor by tweaking the tank dimensions in the app, so the reported parameters are now more realistic. Also I think a scan_interval of 2000 or longer is better given the sensor only sends updates to TankMate twice a day. The app also displays the battery % but the YAML code doesn’t calculate this. Not sure how to add this - perhaps some local calculation/formula is required?
The water tank area could do with having only 2 decimal places Again, so local formula is needed to do this.
I’ve added the following YAML to get a battery percentage. Based on my particular model of TankMate and battery type, with the app reporting 4.8V as 64%, the formula needed a divisor of 7.59, then round off to a whole number:
Ah, no sorry, I was looking at your post and I realised it’s just a screenshot of the app on your phone
All good, I have something drawn up anyway, I’ll share it later.
Hi Simon i came across you post, i have 3 x Tankmate sensors id like to intergrate into HA also, do you know how to grab hold of the api for these, im using chatgpt to help out as i dont have any coding experience, any help much appreciate. Alan