UVR / CMI / BLNet - Read Data also from within Logic-Blocks with Auto-Discovery

Hello,

with a little help of the TA-Support, I have developed a way to read also Variables from within Logic Blocks and transfer them to HA.
As an example, for a PID Block, these Values are available:
image

The only thing you need to do is to create a Schema with TA-Designer. We need the resulting xml (and it must be uploaded to CMI/BLNet).

The other prerequisite is an MQTT Broker and the MQTT Integration in HA.

All of this runs in a python script with little dependencies.
Then, the only configuration is this:

mqtt_config = {
    "broker": "192.168.177.3",
    "port": 1883,
    "user": "user",
    "password": "pass" 
}

uvr_config = {
    "xml_filename": "Neu.xml",
    "ip": "192.168.177.5",
    "user": "user", 
    "password": "pass"  
}

In HA, the result is an MQTT Device that has the different Sensors as Entities. As soon as the XML is updated (and the script restarted) the new Entities are created automatically. No configuration in HA needed (auto-discovery)

If there is any Interest, I am happy to share the code (until then, I will keep improving it :slight_smile: ).

Greetings,
Hendrik

1 Like

Hey Hendrik,
after struggeling yesterday, hanging around in the linked post… I’ld be super greatful if you coud share your little python code!
Best regards,
Pete

Sure.

Let me know how it goes and don’t hesitate to ask if you need help.

Greetings,
Hendrik

1 Like

Hello Hendrik,
I’m new to Homeassistant and stumbled across your post. Unfortunately I can’t get any further when executing the script. HA returns this error.

Fehler beim Aufrufen des Diensts python_script.send_uvr_mqtt.py. Service python_script.send_uvr_mqtt.py does not match format . for dictionary value @ data[‘sequence’][0][‘service’]. Got ‘python_script.send_uvr_mqtt.py’

I can not do anything with that. Can you help me with something?
greeting
Janusz

Hello,
did you run the script in Home-Assistant, or as standalone?
Please try standalone, that is what it is designed for.

Greetings,
Hendrik

Hi,
so I got back to the project… but it seems I have some issue running the code, too.
So far:
MQTT is running, CMI has a scheme and can be accessed by IP…/schema.html

When running the code in python I get the following error:

Logger: homeassistant.components.python_script.send_uvr_mqtt.py
Source: components/python_script/__init__.py:224
Integration: Python Scripts (documentation, issues)
First occurred: 22:00:29 (1 occurrences)
Last logged: 22:00:29

Error executing script: __import__ not found
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 224, in execute
    exec(compiled.code, restricted_globals)  # noqa: S102
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "send_uvr_mqtt.py", line 1, in <module>
ImportError: __import__ not found

Can you explain your set up more detailed, please. What do you mean by stand alone?

Hello,

the code does not run within HomeAssistant, but outside.

python3 send_uvr_mqtt.py

Please also note, that I have updated the code.

Greetings,
Hendrik

Very good job. Good alternative to the Technische Alternative integration from which I can only get the predefined loggers. With your tool, I can get all the data defined in TA designer.

I run it inside Home Assistant OS. I am using a node-red flow that creates/checks for a virtual environment, installs the required libraries and then executes the code.

Running it using any other options for running python code within HA was too complicated. This is something I don’t understand. Why is it so difficult to run python code via an automation or a plugin on a python based framework…

Regards,
Arnold

Thanks for your feedback, Arnold.

Please check the github from time to time. I will certainly find improvement potential.

Greetings,
Hendrik

please explain
What do you mean by stand alone.
I use pyscript in home assistant and get te following error

Actie python_script.send_uvr_mqtt kon niet worden uitgevoerd. Error executing script (ImportError): import not found

Hello,

I have not tested it with pyscript as I have no experience with it.
Please run it outside Homeassistant. The Sensors will appear in the mqtt-integration.

Greetings,
Hendrik

Can i use your script without an CMI?

Hendrik, great! Your solution finally seems to be something that works more reliably than the query via web frontend or ModBus.
I am currently using the ModBus integration in HA and neither the input nodes are correct for me (5 is actually outside temperature, but is displayed under input 11) nor do the values fit properly.
It is frustrating. It worked better with ioBroker.

Could you please explain to me how this works with the Pyton script? I’ve never done anything with Pyton before and I’m not very confident with Home Assistant either.

Thank you very much
Henri

Hello,

you can Run that Script in any machine. It does Not need to be the Homeassistent machine.

And it does Not Run within Homeassistent, but outside of it.
The entities are Auto detected by the mqtt Integration.

So, depending on the way you have installed HA, geht a shell somehow and Run

python3 script.py 

Thank you Hendrik for your answer.
Let me summarize again so that I have understood everything correctly:

  1. I download your code from GitHub
  2. then I adapt the file “send_uvr_mqtt.py” as follows:
mqtt_config = {
    “broker": ‘192.168.177.3’, ## <-- This ist the IP Adress from my Home Assistant Environment 
    “port": 1883,
    “user": ‘user’,
    “password": ”pass” 
}

uvr_config = {
    “xml_filename": ‘New.xml’, ## <-- this is the file name of my configuration file, which I used to program the UVR
    “ip": ‘192.168.177.5’, ## <-- this ist the IP Adress of my CMI Device
    “user": ‘user’, 
    “password": ”pass”  
}
  1. I copy the TA-Designer project saved as XML, from which I created and uploaded the UVR1611 configuration, into the same folder as your code.

  2. Since I have a NAS on which Pyton is already running, I log in there via terminal and copy your files and my xml File into a folder there

  3. finally, I execute your script once on the command line:

Is that correct?

yes.
caveats:

  1. you need python3, I think
  2. only values in your Schema (Visualization) will appears in HA
1 Like

Good Morning Hendrik,

thank you, the test script uvr.py is working.
But when I execute the script send_uvr_mqtt.py, I get the following error:

Ok, i have installed pip on my NAS, now the script is running :slight_smile:
Edit says: pip and paho.mqtt installed

Sorry Hendrik, there is still a problem to solve:

I executed the script in my Python runtime environment (on the Synology NAS). As a result, the new MQTT device became visible in Home Assistant with the entities in it.

But I can’t get the values to be updated. In my opinion, the script is still running:

but the values do not fit my scheme:

(Außentemperatur Schema 15°C)

Wert im Home Assistant 8,9°C

Try stopping the Script and Run it without nohup so that you see the Output of the Script

1 Like