Hi All,
I decided to get specific device to alert me when is time to refill an oil tank. Device posts data to cloud, something similar to NEST.
I wrote py3 client that will pull data in chunks or bulk from cloud and process columnar data something like this:
reportedDate,tankLevel,inches,gallons
1/1/2016 0:00,65,31.2,358
…
Device is not supporting any protocol like zwave like, just pushes data to cloud in raw format. This might be at the end json or columnar format that client will be able to pull on intervals or in bulk…
I am processing this with Pandas and plotting w matlab.
I will be able to setup filters, cleansed data and send alerts.
My question is can someone point me to dev documentation on how to integrate this sensor into HA fronted.
I will obviously provide code back to community for this type of sensor.
Many tanks to all
Can you share what device you use?
I don’t know about a tutorial, but you’ll want the following:
- create a python module that provides an API to fetch the data. Add that module to Pypi so it is accessible to everyone
- create a new sensor in home-assistant to query the data. Pick a similar sensor as the base for the code (something like tank_utility.py may be a good starting point.
The sensor has an Entity which provides the state and relevant properties, and a setup routine which queries/validates any properties from the configuration file and delivers an instance of the sensor to home-assistant. Read over the developers documentation to get an overview of the overall architecture of home-asisstant:
Hi,
ok, thanks for the pointer on tank_utility.py.
I am not using anything at this point, but looking to give the code to community and company that makes a product.
Right now I am just mimicking behavior of the device via CSV supplied RAW data.
All what I want to do at this point is to create a sensor, and push data to front end.
After that I will when available get rest service and the whole module done and everyone can have it …
check device:
https://www.poemtechnology.com/oscommerce-2.3.4/catalog/product_info.php?products_id=38&osCsid=45ob182lsso3lleiuakro68de6
Regards,
That is cool. When I investigated this topic earlier this year, I did not come up with any suitable sensors for purchase, and determined that it may be hard to design my own that would be accurate enough. I also had the issue that there is no power availability near my tank, and the existing 2" risers are all in use so mounting anything would be annoying.
I ended up taking a completely different tact. I now have a sensor on my furnace that keeps track of how long it runs. I know the flow-rate of my oil nozzle, and so I just calculate the usage from the on-time. Not ideal, but it meets my needs.
That is also cool, good job,
I am very generous, but in this case I emailed company offered to code stuff for hass and they agreed when code done and released to give me device for free…
I have all the hookups in the world, and I also wanted to create hardware by myself, but it is pain and I am not sure that would be as accurate as this one.
On the plus side, company wants me to cleanse and plot some other stuff so I might get paid eventually.
I like HA, it is very nice OS project.
I use my ha and kafka to parse and do some ML on the house!!
Regards,
@catchmonster1 I have multiple modbus devices in my configuration. I was never able to configure HA to poll multiple modbus IPs so I ended up writing python scripts that polled the data I wanted via pymodbus and then push the data into HA via the API. Might this work for you?
I have an automation that fires every 5 seconds that executes the python script.
Not a perfect solution, but it might work…
Python snipit:
sensorname = 'binarysensor.Sump_Pump'
if result2.bits[0]:
data = {"state": "On"}
else:
data = {"state": "Off"}
url = 'http://localhost:8123/api/states/' + sensorname
data_json = json.dumps(data)
headers = {'Content-type': 'application/json'}
response = requests.post(url, data=data_json)
print response
Automation YAML:
- alias: Update Binary Sensors
trigger:
platform: time
seconds: '/5'
action:
service: shell_command.getmodbusbinary
Thanks much,
I will look at these scripts and give it a try…
Let you know …