Ive basically got a python script that initiates a serial connection to the Victron Solar controller, then prints the info to file. Then I’ve a second script that parses the last line from that file and prints it to a parsed file.
Home Assistant reads it every 30 sec then extracts the section I need via regex.
So, I suppose the way I’ll have to go forward is to create a script that does the extraction from the file, then publishes to MQQT…
This may take a long long long time!
I’ve got HA and OH2 running on the same machine while I get OH ready…
I’d like to read from serial. Much cleaner way to do it. There’s a lot of learning between me and that tho! And from my understanding print doesn’t come in CSV format either. That’s why we used regex in HA.
Think I can manage the print to MQTT in the meantime…
Wow… I have a team! Where are they hiding? Tell 'em to stay out of my code!
You can use your scripts natively in Jython, but you may need to do some conversion to Python 2.7. You could also run your scripts using executeCommandLine. If you are just starting up with OH, I suggest not using the rules DSL and going straight to the new rule engine, scripted automation, Jython , and the helper libraries. If you provide your script, I will make up a rule for you. Everything you are asking for can absolutely be done in OH… in several different ways.
It was an example, you see, not a drop-in tailored solution. For the purposes of fetching data from serial, it doesn’t matter if it comes in CSV or JSON or XML or some unspecified proprietary format, all of that gets dealt with easily after you have the data.
It’d be best at this stage to reveal what you are trying to do, rather than how you are trying to do it.
Your target device is unknown, but a hint in your script that it is a BMV-700, a meter?
This has a serial port, running proprietary protocol “VE-Direct”?
Is your openHAB host going to connect to that? Or there is some other gateway inbetween that openHAB must deal with instead?
I understand trying to exploit existing scripts, but this is looking really unwieldy … you’ve a script that prints to a file, another script that interprets into another file, now you’re looking to transmit as MQTT to a broker, have openHAB subscribe to the broker, and finally reinterpret dat to OH Items.
Unlike the home Assistant forum, we help YOU configure and understand your system.
The volunteers do not and cannot supply complete solutions for you. The system is so flexible that there are many ways to accomplish something. since you alone can troubleshoot any issue, you need some understanding of its operation.
Victron BMV-700 indeed is a meter!
It reads conditions of a 12V battery system and solar array.
I then (in HA with a file sensor component) read the file and create a sensor reading in HA GUI to display for use in automation’s etc.
Ive just managed (with help from someone smarter than I) to convert the parsed file to JSON then publish to the MQTT server.
Its pretty useful that way and I’ve now just added an MQTT thing for each reading from the meter.
Thanks for all the homework guys. Think this will be a steep learing curve for me, but I really do like the interface on this, customizable, no reboot every time you make a sensor change, plenty of paperwork online.
Will definitely look into going direct to serial once I’ve got the bulk of the OH system configured.
The next one for me is ingratiating a Hall pulse flow meter and counter to tally water use (in OpenHab2)!