ParemTech - PTLevel Wireless Water Level Monitors - Wi-Fi only or Wi-Fi and LoRa

I have been following the ESPHome water level sensor thread on this forum now for some time. That thread is more of a hands on build it yourself thread.

In looking for a water level monitor for a future rainwater catchment tank project, I came across the PTLevel water level monitors by ParemTech. This might be a solution for those that do not want to build their own hardware but are able to program, as currently there is no Home Assistant integration for the PTLevel products.

They have two models. One is Wi-Fi only and you need Wi-Fi signal at your water tank that you are monitoring. The other is hybrid LoRa (915Mhz) that sends the data to a Wi-Fi unit. The unit uses a weighted tube connected to a pressure sensor in the transmitting unit. For best accuracy the tube should be empty of air once a year, which by the way is also the life expectancy of the 4 AA batteries in the LoRa transmitter unit. The Wi-Fi needs power at the tank, but ParemTech says this can be done over a network cable with POE and splitters, but these are not included.

They have a cloud monitoring solution and app, but in going through one of the PDF manuals for the PTLevel products I found the following:

Device Features to Know About
The device WiFi signal is always available. This gives you the opportunity to easily access the device at any time. The other way to access the device at any time is through your own home network if you know the IP address. You can find the IP in the Features of your device online. A few things available to you if you want to access the device:

  • Disconnect the device from the current WiFi.
  • Setup a Static IP should you want to.
  • Retrieve raw sensor values in JSON format by going to xxx.xxx.xxx.xxx/get_sensors

Investigating further I found they have not only an API for their cloud service but also direct to the local device and documentation. The Wi-Fi unit seems to only return the water level data. The LoRa unit return many more data values, signal strength, network information, number of connection failures and battery level to name a few.

Here is the sample API JSON output from the units. See the API documentation for more details.

PTLevel Long Range Wireless (with LoRa and four AA batteries)

{
  "free_space": "667648",
  "rx_id": "210",
  "tx_id": "110",
  "tx_rssi": "-101",
  "rx_rssi": "-42",
  "firmware_version": "210",
  "hardware_version": "4",
  "id": "CC50E36CF496",
  "ip": "192.168.0.202",
  "subnet": "255.255.255.0",
  "gateway": "192.168.0.1",
  "dns": "unknown",
  "tx_firmware_version": "7",
  "tx_hardware_version": "5",
  "fails": "0",
  "rx_sensors": "[]",
  "tx_sensors": "[{\"1\":314,\"z\":60},{\"2\":5.83},{\"3\":7.12}]"
}

PTLevel WiFi

{
  "local_s": "[{\"1\":68,\"z\":68}]"
}

These units are built by a small rural Canadian company, ParemTech and have a two year warranty. If you are interested more in how they are made I would recommend visiting the ParemTech’s Instagram page.

The units can be purchased from their website paremtech.com (free shipping in N. America), amazon.com and on the site where I first found them Rain Brothers. They are currently priced around $200 (Wi-Fi) and $300 (Wi-Fi and LoRa).

The LoRa frequency of 915 Mhz used limits the Long Range Wireless PTLevel unit’s use to North and South America.

Just thought I would share this here in case some one is looking for a water level monitoring solution to integrate with Home Assistant. It looks to be a good hardware unit. Now all this unit needs is a Home Assistant integration. :sunglasses:

3 Likes

One warning, you will need a paid subscription to use the ParemTech server API as it says this in the API documentation:

You are required to have our Premium Account to use any of the server API’s.

I’ve recently installed this for my water tank and I’ve added this to my home assistant setup. I am very new to this, and the code might be rough, but it works:

1- install file editor from the addons
2- edit configuration.yaml and add the below

sensor:
  - platform: rest
    name: waterlevel
    resource: http://xxx.xxx.xxx.xxx/get_sensors
    scan_interval: 120
    value_template: '{{ (value_json.local_s | regex_findall_index("1\":(-?\d+\.?\d+)") | float - 65) | multiply(0.6289308176100629) | round(0) }}'
    unit_of_measurement: "%"

You need to replace xxx.xxx.xxx.xxx by the IP address of the unit (better to have a static IP for it). A couple of numbers needs to be changed:

  • 65: this is my number for 0 (the “z” field if you go to xxx.xxx.xxx.xxx/get_sensors)
  • 0.6289308176100629: 100/(“1” number - "z"number) <— the “1” number needs to be your maximum number, you can do the math otherwise.

Finally restart home assistant and add it on your dashboard, create automations, etc…

2 Likes

Michel, thanks for your contribution!

I get an error stating Template variable warning: 'dict object' has no attribute 'local_s' when rendering '{{ (value_json.local_s | regex_findall_index...

Any clues?

TIA!

What do you get if you open http://xxx.xxx.xxx.xxx/get_sensors with your browser? Are you using the lora or wifi version?

Using the LoRa and the wired versions, along with the public API. I’m absolutely ok to share it, so you can see the output. The LoRa public address is: https://www.mypt.in/device/1712, and the wired one https://www.mypt.in/device/4558. You might notice that there are percentLevel fields for both, so most of the work is done. Can you help me just capture its value and insert it into the corresponding sensor? I started yesterday with the whole HA adventure… and thanks again, Michel!

Hey did you ever get this working with the public API? I can’t seem to get any info through the local IP so I’m also using the public API but don’t know how to get the values.

I didn’t try the public API, I am only using it on my local network (and public API requires premium subscription). Are you using the Long range wireless or WIFI version? the non-wifi version will require /config?json=true instead of /get_sensors

My YAML skills are the same as they were before, I am not sure how you can fetch that. I only made it work with what I have. But share it here if you ended up figuring this out

So I ended up paying for the API, here’s my fully working config, should work with the API, just need to replace the device ID in the resource:

sensor:
  - platform: rest
    resource: https://www.mypt.in/device/XXXX.json
    value_template: 1
    json_attributes:
      - percentLevel
      - volumeLevel
      - batteryStatus 

  - platform: template
      waterpercentage:
        friendly_name: "Water Level Percentage"
        unit_of_measurement: "%"
        value_template: "{{state_attr('sensor.rest_sensor', 'percentLevel')}}"
      wateravailable:
        friendly_name: "Available Liters"
        unit_of_measurement: "L"
        value_template: "{{state_attr('sensor.rest_sensor', 'volumeLevel')}} "
      tank_battery:
        friendly_name: "Tank Battery"
        value_template: "{{state_attr('sensor.rest_sensor', 'batteryStatus') | regex_replace(find='<[^>]*>', replace=' ' )}}"

This creates three entities, one for the % and one for the liters available, and one for battery status.

I also ended up finding the /config?json=true instead of get_sensors, but still couldn’t get it to work, just get unavailable, this is my code. Hopefully I could get this working so I don’t have to pay for the API next year.

Code from local json

{
   "free_space":"667648",
   "rx_id":"247",
   "tx_id":"91",
   "tx_rssi":"-95",
   "rx_rssi":"-82",
   "firmware_version":"212",
   "hardware_version":"4",
   "id":"A848FACFEEF3",
   "ip":"192.168.15.211",
   "subnet":"255.255.255.0",
   "gateway":"192.168.15.1",
   "dns":"unknown",
   "tx_firmware_version":"7",
   "tx_hardware_version":"5",
   "fails":"0",
   "rx_sensors":"[]",
   "tx_sensors":"[{"1":384,""z"":62},{"2":6.44},{"3":4.66}]"
}

YAML code

sensor:
  - platform: rest
    name: waterlevel
    resource: http://192.168.15.211/config?json=true
    scan_interval: 120
    value_template: '{{ (value_json.local_s | regex_findall_index("1\":(-?\d+\.?\d+)") | float - 62) | multiply(0.314465408805031) | round(0) }}'
    unit_of_measurement: "%"
2 Likes

Thanks to everyone who contributed above, particularly @micmak who did the heavy lifting. I’ve got a long-range PT Level (wifi/LoRa) and as others noted, struggled getting the wifi device solution to work. I kept getting an error processing the device’s JSON data, and realized the device firmware has a bug resulting in the data missing a comma that trips up the parsing engine. (There’s a missing comma between the subnet and gateway entries .)

To their credit, the good folks at Paremtech support confirmed the problem and indicated that they’d put together a firmware update to resolve the JSON error.

In the meantime, I found an alternative that so far has been working. Instead of using the rest sensor on the JSON formatted stream, I’m using the multiscrape integration and the html “/config” page (install multiscrape through HACS). Here’s the code from my configuration.yaml that (so far) successfully scrapes the “Z” value data every 15 minutes from the html page and converts it into a sensor called watertank that provides the % full.

multiscrape:
  - resource: 'http://192.168.x.xxx/config' 
       #replace with the ip address of your PT Level; /config points to the html page
    scan_interval: 900 
       # rescan every 15 minutes (15*60=900)
    sensor:
      - unique_id: watertank
        name: watertank
        select: 'body > div > div.container > dl:nth-child(5) > dd:nth-child(8)' 
       # CSS path to the sensor value should be same
        value_template: '{{ (value | regex_findall_index("1\":(-?\d+\.?\d+)") | float - 61) | multiply(0.304878) | round(0) }}' 
       # replace 61 with your "Z" value and replace 0.304878 with your calculation 100/("1" value at its maximum minus "Z" value)

A quick graph card and I can finally see the watertank status on the dashboard.

image

I’ll update if I get any update on the firmware fix. The device itself has been spot on. I real comfort when we really depend on that tank staying full.

4 Likes

this is awesome. I am using your code. thank you. I ran my tank dry with sprinklers while wife was in the shower too many times I can now have automation that turns sprinklers off when the tank is getting low…

1 Like

This is awesome, it works in my brand new device

1 Like

Actually, it shows 229%, so I am missing something.

I was able to get this working - thanks to all who contributed!
I used the free api with a rest sensor

sensor:
  - platform: rest
    name: cistern
    resource: http://192.168.0.120/config?json=true
    scan_interval: 120
    value_template: '{{ (value_json.tx_sensors | regex_findall_index("1\":(-?\d+\.?\d+)") | float - 10107) | multiply(0.0075103266992114) | round(0) }}'
    unit_of_measurement: "%"

and a gauge card
image

and an automation to alert me if the level drops below a certain percentage.

Awesomeness!

2 Likes