Open Crash123Crash123 opened 2 years ago
I've never seen that (I do not have 433MHz sockets), is this was the Mediola sends via UDP? Did you get the from mediola2mqtt's log file? We can come up with a solution if that's the case.
This is what I get from Mediola via ip (http://192.168.18x.xxx/command?XC_FNC=GetStates). I wasn´t able to start your script on ubuntu. So I just installed HASS on a PI. But I have to learn and install MQTT first on HASS.
If I want to start in Ubuntu I get this:
root@Mediola:~/addon# python3 -u ./mediola2mqtt.py Running in local mode Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python3.9/threading.py", line 973, in _bootstrap_inner self.run() File "/usr/lib/python3.9/threading.py", line 910, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 3591, in _thread_main self.loop_forever(retry_first_connection=True) File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 1756, in loop_forever rc = self._loop(timeout) File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 1164, in _loop rc = self.loop_read() File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 1556, in loop_read rc = self._packet_read() File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 2439, in _packet_read rc = self._packet_handle() File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 3039, in _packet_handle return self._handle_connack() File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 3138, in _handle_connack on_connect( File "/root/addon/./mediola2mqtt.py", line 46, in on_connect setup_discovery() File "/root/addon/./mediola2mqtt.py", line 130, in setup_discovery mediolaid = config['buttons'][ii]['mediola'] KeyError: 'mediola'
I first had to install paho-mqtt and request because this was missing in ubuntu.
Then we don't know yet if we need to change something in the script. If you manage to run it, we need the UDP packet that's sent from the Mediola. You can find it in mediola2mqtt's log file if it can't be handled as-is - you might have to set debug
to true
in the configuration file.
The error that you're getting is a configuration problem and actually a problem with the provided example file. I just pushed an updated example file, changes are only in section buttons
(the key mediola
was missing for both buttons).
Never run scripts as root unless absolutely necessary! For system-wide installations, the Arch package script creates a user mediola2mqtt
and a group mediola2mqtt
, the systemd init script switches to this account during launch.
I changed the yaml and now get this:
root@Mediola:~/addon# python3 -u ./mediola2mqtt.py Running in local mode Traceback (most recent call last): File "/root/addon/./mediola2mqtt.py", line 27, in <module> config = yaml.safe_load(fp) File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 162, in safe_load return load(stream, SafeLoader) File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 114, in load return loader.get_single_data() File "/usr/lib/python3/dist-packages/yaml/constructor.py", line 49, in get_single_data node = self.get_single_node() File "/usr/lib/python3/dist-packages/yaml/composer.py", line 36, in get_single_node document = self.compose_document() File "/usr/lib/python3/dist-packages/yaml/composer.py", line 55, in compose_document node = self.compose_node(None, None) File "/usr/lib/python3/dist-packages/yaml/composer.py", line 84, in compose_node node = self.compose_mapping_node(anchor) File "/usr/lib/python3/dist-packages/yaml/composer.py", line 133, in compose_mapping_node item_value = self.compose_node(node, item_key) File "/usr/lib/python3/dist-packages/yaml/composer.py", line 82, in compose_node node = self.compose_sequence_node(anchor) File "/usr/lib/python3/dist-packages/yaml/composer.py", line 111, in compose_sequence_node node.value.append(self.compose_node(node, index)) File "/usr/lib/python3/dist-packages/yaml/composer.py", line 84, in compose_node node = self.compose_mapping_node(anchor) File "/usr/lib/python3/dist-packages/yaml/composer.py", line 127, in compose_mapping_node while not self.check_event(MappingEndEvent): File "/usr/lib/python3/dist-packages/yaml/parser.py", line 98, in check_event self.current_event = self.state() File "/usr/lib/python3/dist-packages/yaml/parser.py", line 428, in parse_block_mapping_key if self.check_token(KeyToken): File "/usr/lib/python3/dist-packages/yaml/scanner.py", line 116, in check_token self.fetch_more_tokens() File "/usr/lib/python3/dist-packages/yaml/scanner.py", line 258, in fetch_more_tokens raise ScannerError("while scanning for the next token", None, yaml.scanner.ScannerError: while scanning for the next token found character '\t' that cannot start any token in "mediola2mqtt.yaml", line 18, column 22
This is just a test installation. When it runs of course I don´t use root and destroy this container.
Did you change your file? If yes, you used tab instead of spaces!
So I changed the yaml to sniff only (no buttons and blinds) and it starts. When i push the button i got this:
root@Mediola:~/addon# python3 -u ./mediola2mqtt.py Running in local mode Debugging messages enabled Sending CONNECT (u0, p0, wr0, wq0, wf0, c1, k60) client_id=b'' Received CONNACK (1, 0) Received message: b'{XC_EVT}{"type":"EL","data":"141151"}' Sending PUBLISH (d0, q0, r0, m1), 'b'mediola'', ... (37 bytes) Traceback (most recent call last): File "/root/addon/./mediola2mqtt.py", line 351, in <module> if not handle_packet_v4(data, addr): File "/root/addon/./mediola2mqtt.py", line 269, in handle_packet_v4 topic, payload, retain = handle_button(packet_type, File "/root/addon/./mediola2mqtt.py", line 210, in handle_button for ii in range(0, len(config['buttons'])): KeyError: 'buttons'
If I insert your button topic and change Type from IT to EL and adr from 3d5e00 to 141151 like above I get this:
root@Mediola:~/addon# python3 -u ./mediola2mqtt.py Running in local mode Debugging messages enabled Sending CONNECT (u0, p0, wr0, wq0, wf0, c1, k60) client_id=b'' Received CONNACK (1, 0) Caught exception in on_connect: can only concatenate str (not "int") to str Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python3.9/threading.py", line 973, in _bootstrap_inner self.run() File "/usr/lib/python3.9/threading.py", line 910, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 3591, in _thread_main self.loop_forever(retry_first_connection=True) File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 1756, in loop_forever rc = self._loop(timeout) File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 1164, in _loop rc = self.loop_read() File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 1556, in loop_read rc = self._packet_read() File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 2439, in _packet_read rc = self._packet_handle() File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 3039, in _packet_handle return self._handle_connack() File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 3138, in _handle_connack on_connect( File "/root/addon/./mediola2mqtt.py", line 46, in on_connect setup_discovery() File "/root/addon/./mediola2mqtt.py", line 126, in setup_discovery identifier = config['buttons'][ii]['type'] + '_' + config['buttons'][ii]['adr'] TypeError: can only concatenate str (not "int") to str
Try setting adr
to "141151"
(in quotes) so that it is forced to String - that's a limitation of the YAML parser.
I had a look at the code again: The data packet that I receive for IT buttons is two bytes longer and contains the state. Yours is only 6 bytes, so it might work if you set adr
to "1411"
Thank you very much. It is solved. With adr "1411" I get the status 51 for on and 54 for off. Now I am trying to publish.
Perfect, that's exactly how it's supposed to be! If you configure the button, the button gets its own topic. For Home Assistant, it then triggers automatically an event without any configuration on the Home Assistant side.
So I tried to switch to HASS but I struggle within the button. If i use an ubuntu container I get it working, but don´t get the button entity: but how can I use the button? There is no entity to use:
When I include the same in HASS OS I can´t save the yaml:
Buttons do not create entities in HA. You can use the evens in automations and that should work, since your screenshot shows the reception of a "button_short_press" event. Please have a look at the HA documentation on how to configure it.
Seems like the add-on configuration does not support buttons. Since I do not use the add-on, I rarely test in add-on mode.
OK. Thank you a lot for your help.
Hi, is it possible to include type EVENT:
{XC_SUC}[{"type":"EVENT","adr":"FF","state":"0"}]
It is a Wireless socket with 433mhz