andyboeh / mediola2mqtt

Mediola MQTT Gateway
11 stars 13 forks source link

Move config file to config tab inside addon page #1

Closed lukanc closed 2 years ago

andyboeh commented 3 years ago

Thanks for the PR. Unfortunately, that breaks running mediola2mqtt as a systemd service which is what I need it for. Hence, we can't port mediola2mqtt.py to bashio - but we can create wrappers and other stuff.

There are probably several ways to solve this:

  1. Create a simple wrapper script that creates the mediola2mqtt.yaml file on demand, based on bashio from the configuration inside the addon.
  2. Pass all parameters as command line arguments to the python script.
  3. Split mediola2mqtt.py into a python backend and two frontends - one based on bashio and the other based on the configuration file.
andyboeh commented 3 years ago

@lukanc I just implemented configuration option parsing inside mediola2mqtt.py. However, I can't test it since I don't run in add-on mode. Could you check whether it works? And if not, please report back the content of the variable 'config' after loading it from /data/options.json. Thanks.

lukanc commented 3 years ago

@andyboeh I tried your code today. It does start up, but the config variable is empty. Addon config tab doesn't have configuration tab https://imgur.com/a/OSjYzHK. To enable this, you have to add "options" and "schema" keys inside "config.json" file. I don't know whether those changes impact on docker image in a way you use it. Thanks for your effort :)

andyboeh commented 3 years ago

Ah OK, I missed options and schema - no, that doesn't impact my usage in any way, I'll add that and let you know when I have something.

andyboeh commented 3 years ago

@lukanc This might be finally fixed with the latest commit. Would you mind testing it again?

CAVE: I also made some changes to how the relationship between blinds and devices is. Be prepared that this might lead to some of your blinds being visible twice. The latest release only adds one device that represents your "Mediola" and then attaches all configured blinds/buttons to this device. This seemed more logical to me, plus, in the near future, I will add support for multiple Mediola gateways since I ordered a second one.

lukanc commented 3 years ago

@andyboeh

I tested your updated code today. My system consist of 22 blinds. Blinds with address names 0A, 0B, ..., 0F doesn't work. In attached logs, you can see successful moving of blind with address 01, and failed attempt for addr 0E.

Msg: mediola/blinds/ER_01/set 0 b'close' Msg: mediola/blinds/ER_01/set 0 b'open' Msg: mediola/blinds/ER_01/set 0 b'stop' Msg: mediola/blinds/ER_01/set 0 b'close' Msg: mediola/blinds/ER_0E/set 0 b'close' Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/usr/lib/python3.8/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/usr/lib/python3.8/site-packages/paho/mqtt/client.py", line 3452, in _thread_main self.loop_forever(retry_first_connection=True) File "/usr/lib/python3.8/site-packages/paho/mqtt/client.py", line 1779, in loop_forever rc = self.loop(timeout, max_packets) File "/usr/lib/python3.8/site-packages/paho/mqtt/client.py", line 1181, in loop rc = self.loop_read(max_packets) File "/usr/lib/python3.8/site-packages/paho/mqtt/client.py", line 1572, in loop_read rc = self._packet_read() File "/usr/lib/python3.8/site-packages/paho/mqtt/client.py", line 2310, in _packet_read rc = self._packet_handle() File "/usr/lib/python3.8/site-packages/paho/mqtt/client.py", line 2936, in _packet_handle return self._handle_publish() File "/usr/lib/python3.8/site-packages/paho/mqtt/client.py", line 3216, in _handle_publish self._handle_on_message(message) File "/usr/lib/python3.8/site-packages/paho/mqtt/client.py", line 3444, in _handle_on_message self.on_message(self, self._userdata, message) File "./mediola2mqtt.py", line 73, in on_message data = format(int(adr), "02x") + "00" ValueError: invalid literal for int() with base 10: '0E'

Other wise, it works great =)

andyboeh commented 3 years ago

A blind with a hex ID should not exist. That was a bug in an older version, they should have decimal numbering now. Could you check if you have the same blind twice with a different ID?