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