Giter Site home page Giter Site logo

lumimqtt's Introduction

MQTT agent for Xiaomi Lumi gateway

Description

The service allow controlling gateway LEDs, button, and illuminance sensor over MQTT

Default config should be located in /etc/lumimqtt.json or can be overridden with LUMIMQTT_CONFIG environment variable.

Interaction

Default devices

Action Topic Payload Expected values
Read light state lumi/<ID>/light {"state": "ON", "brightness": 255, "color": {"r": 255, "g": 0, "b": 0}}
Switch light lumi/<ID>/light/set {"state": "ON"}
Set light color lumi/<ID>/light/set {"color": {"r": 255, "g": 0, "b": 0}}
Set brightness lumi/<ID>/light/set {"brightness": 255}
Set color or brigthness with 10 seconds transition lumi/<ID>/light/set {"color": {"r": 255, "g": 0, "b": 0}, "brightness": 100, "transition": 10}
Read illuminance lumi/<ID>/illuminance 0-1000
Button lumi/<ID>/btn0/action single, double, triple, quadruple, many,
hold, double_hold, triple_hold, quadruple_hold, many_hold,
release

Binary sensors (soldered to GPIO points)

Action Topic Expected values
Read GPIO sensor lumi/<ID>/<SENSOR_NAME> ON/OFF

Run application

Example run command:

LUMIMQTT_CONFIG=./lumimqtt.json python3 -m lumimqtt

The configuration file is a JSON with the following content:

{
    "mqtt_host": "localhost",
    "mqtt_port": 1883,
    "mqtt_user": "",
    "mqtt_password": "",
    "topic_root": "lumi/{device_id}",
    "auto_discovery": true,
    "sensor_retain": false,
    "sensor_threshold": 50,
    "sensor_debounce_period": 60,
    "light_transition_period": 1.0
}

Every line is optional. By default, LumiMQTT will use the connection to localhost with the anonymous login.

device_id if not provided will be automatically replaced by a hex number representing a MAC address of the first network interface.

auto_discovery set to false to disable creating autodiscovery topics that are user by Home Assistant to discover entities.

sensor_retain is option to enable storing last sensor value on the broker

sensor_threshold is a threshold to avoid sending data to MQTT on small changes

sensor_debounce_period value in seconds to send data despite the threshold

light_transition_period value in seconds to set default transition for light switching or light change. Use 0 to remove the transition.

SSL connection

To use SSL connection, you need to set mqtt_cert and mqtt_key, and optional mqtt_ca with corresponding paths to files.

Custom sensors

You can also use GPIO(s) as binary sensor(s). Add this to configuration:

{
    <your configuration>,
    "binary_sensors": {
        "<sensor name>": {
            "gpio": "<gpio number>",
            "device_class": "<device class>",
            "topic": "<sensor name>"
        }
    }
}

Values in <> must be replaced.

gpio is required, device_class and topic are optional. By default topic is sensor's name.

List of GPIOs. List of device classes.

Custom commands

You can add an extra section with custom commands that are executed with mqtt topics. Every command is exported as a switch entity in Home Assistant. If json is passed to the set topic, the command will be interpolated with the values. Plain text is passed as {text} variable

{
    <your configuration>,
    "custom_commands": {
      "blink": "for i in 0 255 0 255 0 255 0; do echo $i > /sys/class/leds/{color}/brightness; sleep 1; done",
      "tts": "echo \"Test TTS without MPD component for home assistant\" | python3 -c 'from urllib.parse import quote_plus;from sys import stdin;print(\"wget -O /tmp/tts.mp3 -U Mozilla \\\"http://translate.google.com/translate_tts?q=\"+quote_plus(stdin.read()[:100])+\"&ie=UTF-8&tl=en&total=1&idx=0&client=tw-ob&prev=input&ttsspeed=1\\\" && amixer set Master 200 && mpg123 /tmp/tts.mp3\")' | sh 2> /dev/null",
      "tts_interpolate": "echo \"{text}\" | python3 -c 'from urllib.parse import quote_plus;from sys import stdin;print(\"wget -O /tmp/tts.mp3 -U Mozilla \\\"http://translate.google.com/translate_tts?q=\"+quote_plus(stdin.read()[:100])+\"&ie=UTF-8&tl=en&total=1&idx=0&client=tw-ob&prev=input&ttsspeed=1\\\" && amixer set Master {volume} && mpg123 /tmp/tts.mp3\")' | sh 2> /dev/null",
      "restart_lumimqtt": "/etc/init.d/lumimqtt restart",
      "reboot": "/sbin/reboot"
    }
}

Usage examples

Action Topic Payload
Run command "blink" lumi/<ID>/blink/set {"color": "red"}
Run command "tts" lumi/<ID>/tts/set <ANYTHING>
Run command "tts_interpolate" lumi/<ID>/tts_interpolate/set {"text": "Hi, it is a test", "volume": 200}
Run command "restart_lumimqtt" lumi/<ID>/restart_lumimqtt/set <ANYTHING>
Run command "reboot" lumi/<ID>/reboot/set <ANYTHING>

OpenWrt installation

opkg update 
opkg install python3-pip python3-asyncio python3-evdev
pip3 install -U lumimqtt

To upgrade you can just run

pip3 install -U lumimqtt

Example run command:

lumimqtt

or (in background):

lumimqtt &

Autorun:

To run lumimqtt on start you need a file /etc/init.d/lumimqtt with the following content:

#!/bin/sh /etc/rc.common
START=98
USE_PROCD=1
start_service()
{
    procd_open_instance

    procd_set_param env LUMIMQTT_CONFIG=/etc/lumimqtt.json
    procd_set_param command lumimqtt
    procd_set_param respawn
    procd_set_param stdout 1
    procd_set_param stderr 1
    procd_close_instance
}

To install this file on the gateway you can run

wget https://raw.githubusercontent.com/openlumi/lumimqtt/main/init.d/lumimqtt -O /etc/init.d/lumimqtt
chmod +x /etc/init.d/lumimqtt
/etc/init.d/lumimqtt enable
/etc/init.d/lumimqtt start

lumimqtt's People

Contributors

agramgurka avatar coderus avatar definitio avatar devbis avatar gerasiov avatar m66b avatar muniter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lumimqtt's Issues

lumimqtt with homebridge

Hey, I do have a pretty default installation of the OpenWRT + zigbee2mqtt + lumimqtt
And I was able to connect the remote homebridge to the MQTT broker that runs on the gateway.

I can see all Zigbee devices connected to it but I can't get the gateway itself (LED control, light sensor, audio and so on).

Should I configure gateway lumimqtt somehow or use a specific homebridge plugin to get access to the gateway led and speaker?

Thanks

how to connect xiaomi gateway DGNWG05LM with hassio via MQTT

Hi,
Mike here from Italy.
I have the Xiaomi Gateway DGNWG05LM and I have hacked it with your guide and repositories:
xiaomi-gateway-openwrt
zigbee2mqtt
lumimqtt

I am not that expert in this type of communication so I am stucking in how to make my hassio communicating with the gateway.
Can you please help me in the next steps?

best regards and thanks
mike

does not connect by domain name

I use domain names on my router to easily connect to devices on the local network. example: device.local. When trying to connect to mqtt broker on a domain, an error occurs: it cannot connect. According to the device's IP, there is no such problem

Ability to disable smoothing effects

Some automations, like indicating status of virtual assistant, need instant reaction. It will be nice to implement some option to disable smoothing effects of light. May be add this option in lumimqtt.json file?

Can't install lumimqtt via pip

Hi! I've installed fresh build of openlumi and I can't install lumimqtt.

LuCI openwrt-19.07 branch (git-21.018.57536-6ba9740) / OpenWrt 19.07.7 r11306-c4a6851c72

Python 3.7.10 (default, Jun 14 2021, 09:52:25)
[GCC 7.5.0] on linux

pip 20.1.1 from /usr/lib/python3.7/site-packages/pip (python 3.7)

pip3 install -U lumimqtt
Collecting lumimqtt
  Using cached lumimqtt-1.0.12-py3-none-any.whl (24 kB)
Collecting aio-mqtt>=0.2.0
  Using cached aio_mqtt-0.2.0-py3-none-any.whl (18 kB)```
Collecting evdev>=1.0.0
  Using cached evdev-1.4.0.tar.gz (26 kB)
Building wheels for collected packages: evdev
  Building wheel for evdev (setup.py) ... error
  ERROR: Failed building wheel for evdev
  Running setup.py clean for evdev
Failed to build evdev
Installing collected packages: aio-mqtt, evdev, lumimqtt
    Running setup.py install for evdev ... error
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-283vc_uu/evdev/setup.py'"'"'; __file__='"'"'/tmp/pip-install-283vc_uu/evdev/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-qe_naiqs/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python3.7/evdev Check the logs for full command output.

can this run next to zigbee2mqtt ?

Hi, I am having trouwble settings this up. My openlumi gateway has zigbee2mqtt and that works with all the sensors but I cannot get HA to autodiscover my gateway for LED control... super weird.

I have my settings like this:

{
    "mqtt_host": "mqtt://192.168.1.67:1883",
    "mqtt_user": "mqtt",
    "mqtt_password": "<password>",
    "topic_root": "lumi/{MAC}",
    "sensor_retain": false,
    "sensor_threshold": 50,
    "sensor_debounce_period": 60
}

my systemlogs

Fri Mar 12 19:28:16 2021 daemon.err lumimqtt[1739]: INFO:lumimqtt.__main__:Start lumimqtt 1.0.9
Fri Mar 12 19:28:16 2021 daemon.err lumimqtt[1739]: ERROR:lumimqtt.lumimqtt:Connection lost. Will retry in 10 seconds
Fri Mar 12 19:28:26 2021 daemon.err lumimqtt[1739]: ERROR:lumimqtt.lumimqtt:Connection lost. Will retry in 10 seconds
Fri Mar 12 19:28:36 2021 daemon.err lumimqtt[1739]: ERROR:lumimqtt.lumimqtt:Connection lost. Will retry in 10 seconds
Fri Mar 12 19:28:46 2021 daemon.err lumimqtt[1739]: ERROR:lumimqtt.lumimqtt:Connection lost. Will retry in 10 seconds
Fri Mar 12 19:28:56 2021 daemon.err lumimqtt[1739]: ERROR:lumimqtt.lumimqtt:Connection lost. Will retry in 10 seconds
Fri Mar 12 19:29:06 2021 daemon.err lumimqtt[1739]: ERROR:lumimqtt.lumimqtt:Connection lost. Will retry in 10 seconds
Fri Mar 12 19:29:16 2021 daemon.err lumimqtt[1739]: ERROR:lumimqtt.lumimqtt:Connection lost. Will retry in 10 seconds
Fri Mar 12 19:29:19 2021 authpriv.info dropbear[1940]: Child connection from 192.168.1.39:51714
Fri Mar 12 19:29:24 2021 authpriv.notice dropbear[1940]: Password auth succeeded for 'root' from 192.168.1.39:51714
Fri Mar 12 19:29:26 2021 daemon.err lumimqtt[1739]: ERROR:lumimqtt.lumimqtt:Connection lost. Will retry in 10 seconds
Fri Mar 12 19:29:36 2021 daemon.err lumimqtt[1739]: ERROR:lumimqtt.lumimqtt:Connection lost. Will retry in 10 seconds
Fri Mar 12 19:29:46 2021 daemon.err lumimqtt[1739]: ERROR:lumimqtt.lumimqtt:Connection lost. Will retry in 10 seconds
Fri Mar 12 19:29:56 2021 daemon.err lumimqtt[1739]: ERROR:lumimqtt.lumimqtt:Connection lost. Will retry in 10 seconds

case of network is down

the script does not reconnect to the mqtt server when the network is down ?
I have to use cron with the task 0 */3 * * * /etc/init.d/lumimqtt restart
but even in this form, thank you for the script

Luminance sensor reading too low

Hello,
First of all - thank you for this project, I have a lot of fun with it.
I'm very happy overall, but run across a problem with my DGNWG05LM gateway luminance sensor readings.
I have another Aquara gateway(DGNWG02LM+original fw) in the same room and the sensor readings differ too much.
OpenLumi lux values are very low compared with the other aquara values(up to 1500 lux), please see the pictures.
Morning: image
Afternoon: image

Seems like in the morning multiplying the value with factor 15 could make them equal.
With more sunshine the factor is decreasing. Can you please check where the problem could be?
Is there a way to calibrate the sensor or adjust the values ?
Thank you in advance

Alarm mode support

Is it possible to use the hub alarm mode?
I've installed openwrt on my DGNWG05LM gateway. Still wondering witch firmware to install.
I want to use both the zigbee sensors and the hub alarm and light.
Thanjs for your contribution!

ERROR:lumimqtt.lumimqtt:Connection lost. Will retry in 10 seconds

Hello,
I've hacked my gateway and installed lumimqtt following the readme of openlumi and lumimqtt. My /etc/lumimqtt.json like this:

{
    "mqtt_host": "192.168.0.101",
    "mqtt_port": 1883,
    "mqtt_user": "hass",
    "mqtt_password": "xxxxxx",
    "topic_root": "lumi/{MAC}",
    "sensor_retain": true,
}

and when I run lumimqtt

INFO:lumimqtt.__main__:Start lumimqtt 1.0.10
ERROR:lumimqtt.lumimqtt:Connection lost. Will retry in 10 seconds

It just kept showing the ERROR.

I am sure the mqtt host can be reached by pinging it in OpenWrt. All other devices can connect to this server.

What could be the reason? Thanks in advance!

offline status after reboot

После перезагрузки хаба всегда статус в mqtt - offline. Пока не зайду с помощью mqtt explorer и не поменяю статус вручную на online ни свет, ни кнопка, ни датчик света не работают. Можно при запуске lumimqtt сделать установку статуса. Спасибо

Home Assistant Errors

So, I have 3 Aqara Gateways flashed with OpenWrt firmware and have the MPD software configured and working with Home Assistant. The problem is that every time I restart Home Assistant or I try to play something through the MPD entities it plays but also I get an error notification like this one: Login attempt or request with invalid authentication from . Requested URL: '/media/local/cover.png'. (Music Player Daemon 0.21.26). Can you help in fixing this? It is not breaking anything but it is annoying. Thank you!

Home Assistant discovery

Сделайте пожалуйста отключение Home Assistant discovery через файл конфигурации /etc/lumimqtt.json, это требуется для систем автоматизации которые не используют этот протокол но при этом в mqtt топиках присутствует мусор .

lumimqtt not starting

Hello,
I'm trying to install lumimqtt on a ZHWG11LM with openwrt 21.02.7 . But it doesn't start:

Traceback (most recent call last):
  File "/usr/bin/lumimqtt", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3.9/site-packages/lumimqtt/__main__.py", line 105, in main
    aio.run(amain())
  File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
  File "/usr/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
  File "/usr/lib/python3.9/site-packages/lumimqtt/__main__.py", line 86, in amain
    for device in devices(
  File "/usr/lib/python3.9/site-packages/lumimqtt/platform.py", line 92, in devices
    return sensors(binary_sensors) + buttons() + lights() + \
  File "/usr/lib/python3.9/site-packages/lumimqtt/platform.py", line 75, in lights
    lights_.append(Light(name=name, devices=device_dirs, topic=name))
  File "/usr/lib/python3.9/site-packages/lumimqtt/light.py", line 39, in __init__
    self.red = LED(f'{name}_red', devices['red'])
  File "/usr/lib/python3.9/site-packages/lumimqtt/light.py", line 21, in __init__
    self.brightness = int(self.read_raw(self.device_file))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType' ```

Gateway connects with a different client id each time

Hello just installed, The functionality is great. But as the title says every time the gateway connects to the mqtt broker It does so with a different client id.

Last four reboots. Creates the following devices in Home Assistant MQTT integration.

xiaomi_gateway_0x116a18881e53
xiaomi_gateway_0x212617c4e71a
xiaomi_gateway_0x63e75752b847
xiaomi_gateway_0xc46e7b7df285
xiaomi_gateway_0xef23022fc624

Current configuration /etc/lumimqtt.json

{
    "mqtt_host": "10.3.30.15",
    "mqtt_port": 1883,
    "mqtt_user": "user",
    "mqtt_password": "password",
    "topic_root": "lumi/main-room-gateway",
    "sensor_retain": false,
    "sensor_threshold": 50,
    "sensor_debounce_period": 60
}

EDIT:

I can see in the code the use of uuid.get_node to obtain the device mac address.

from uuid import getnode as get_mac

dev_id = hex(get_mac())

And according to the documentation if it can't get the MAC address It will use a random number, therefore in every reboot we are getting a different "client" and a "new" device being connected to the mqtt broker. Maybe a better idea would be using the wlan mac provided by ddwrt.

Or even easier let the user just set the client id. And let's make clear It should be unique in their mqtt network.

lumimqtt keeps losing connection

Dear @devbis ,

Thank you for this nice piece of software it keeps usage of an old product.

I have some problems, where lumimqtt loses connection, sometimes it manages to get back and other times it just keeps disconnected; at such occasions I restart the device, but this is not practical as it also servers as a router to my zigbee network.

I've seen people adding cron tasks to mitigate similar problems, any suggestion?

Running version is 1.0.16

Below are the errors, if more info is needed, please advise me on how to attain

INFO:lumimqtt.light:Change light from ON 255 #39ff1f to OFF 0 #39ff1f
ERROR:lumimqtt.lumimqtt:Connection lost. Will retry in 10 seconds
ERROR:lumimqtt.lumimqtt:Connection closed
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/lumimqtt/lumimqtt.py", line 367, in _periodic_publish
    await self._publish_sensor(sensor, value)
  File "/usr/lib/python3.9/site-packages/lumimqtt/lumimqtt.py", line 392, in _publish_sensor
    await self._client.publish(
  File "/usr/lib/python3.9/site-packages/aio_mqtt/client.py", line 301, in publish
    await self._wait((PacketType.PUBACK, packet_id))
  File "/usr/lib/python3.9/site-packages/aio_mqtt/client.py", line 367, in _wait
    return await future
  File "/usr/lib/python3.9/site-packages/lumimqtt/lumimqtt.py", line 504, in _connect_forever
    await connect_result.disconnect_reason
  File "/usr/lib/python3.9/site-packages/aio_mqtt/client.py", line 815, in _keepalive_mechanism_task
    raise ServerDiedError()
aio_mqtt.exceptions.ServerDiedError
INFO:lumimqtt.lumimqtt:Connected to 192.168.1.135 with client id 'lumimqtt_0x38839a639cf0'
ERROR:lumimqtt.lumimqtt:Connection lost. Will retry in 10 seconds
ERROR:lumimqtt.lumimqtt:Connection closed
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/lumimqtt/lumimqtt.py", line 377, in _periodic_publish
    await self._publish_light(light)
  File "/usr/lib/python3.9/site-packages/lumimqtt/lumimqtt.py", line 402, in _publish_light
    await self._client.publish(
  File "/usr/lib/python3.9/site-packages/aio_mqtt/client.py", line 301, in publish
    await self._wait((PacketType.PUBACK, packet_id))
  File "/usr/lib/python3.9/site-packages/aio_mqtt/client.py", line 367, in _wait
    return await future
  File "/usr/lib/python3.9/site-packages/lumimqtt/lumimqtt.py", line 481, in _connect_forever
    await self._client.publish(
  File "/usr/lib/python3.9/site-packages/aio_mqtt/client.py", line 301, in publish
    await self._wait((PacketType.PUBACK, packet_id))
  File "/usr/lib/python3.9/site-packages/aio_mqtt/client.py", line 367, in _wait
    return await future
  File "/usr/lib/python3.9/site-packages/aio_mqtt/client.py", line 815, in _keepalive_mechanism_task
    raise ServerDiedError()
aio_mqtt.exceptions.ServerDiedError
ERROR:lumimqtt.lumimqtt:Connection lost. Will retry in 10 seconds
ERROR:asyncio:Future exception was never retrieved
future: <Future finished exception=ServerDiedError()>
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/lumimqtt/lumimqtt.py", line 377, in _periodic_publish
    await self._publish_light(light)
  File "/usr/lib/python3.9/site-packages/lumimqtt/lumimqtt.py", line 402, in _publish_light
    await self._client.publish(
  File "/usr/lib/python3.9/site-packages/aio_mqtt/client.py", line 301, in publish
    await self._wait((PacketType.PUBACK, packet_id))
  File "/usr/lib/python3.9/site-packages/aio_mqtt/client.py", line 367, in _wait
    return await future
  File "/usr/lib/python3.9/site-packages/lumimqtt/lumimqtt.py", line 481, in _connect_forever
    await self._client.publish(
  File "/usr/lib/python3.9/site-packages/aio_mqtt/client.py", line 301, in publish
    await self._wait((PacketType.PUBACK, packet_id))
  File "/usr/lib/python3.9/site-packages/aio_mqtt/client.py", line 367, in _wait
    return await future
  File "/usr/lib/python3.9/site-packages/aio_mqtt/client.py", line 815, in _keepalive_mechanism_task
    raise ServerDiedError()
aio_mqtt.exceptions.ServerDiedError
INFO:lumimqtt.lumimqtt:Connected to 192.168.1.135 with client id 'lumimqtt_0x38839a639cf0'
INFO:lumimqtt.lumimqtt:Wait for network interruptions...

lumimqtt crashes

Wed Jun  1 18:32:30 2022 daemon.err lumimqtt[20937]: Traceback (most recent call last):
Wed Jun  1 18:32:30 2022 daemon.err lumimqtt[20937]:   File "/usr/bin/lumimqtt", line 8, in <module>
Wed Jun  1 18:32:30 2022 daemon.err lumimqtt[20937]:     sys.exit(main())
Wed Jun  1 18:32:30 2022 daemon.err lumimqtt[20937]:   File "/usr/lib/python3.9/site-packages/lumimqtt/__main__.py", line 88, in main
Wed Jun  1 18:32:30 2022 daemon.err lumimqtt[20937]:     loop.run_until_complete(server.start())
Wed Jun  1 18:32:30 2022 daemon.err lumimqtt[20937]:   File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
Wed Jun  1 18:32:30 2022 daemon.err lumimqtt[20937]:   File "/usr/lib/python3.9/site-packages/lumimqtt/lumimqtt.py", line 106, in start
Wed Jun  1 18:32:30 2022 daemon.err lumimqtt[20937]:     t.result()
Wed Jun  1 18:32:30 2022 daemon.err lumimqtt[20937]:   File "/usr/lib/python3.9/site-packages/lumimqtt/lumimqtt.py", line 356, in _periodic_publish
Wed Jun  1 18:32:30 2022 daemon.err lumimqtt[20937]:     await self._publish_sensor(sensor, value)
Wed Jun  1 18:32:30 2022 daemon.err lumimqtt[20937]:   File "/usr/lib/python3.9/site-packages/lumimqtt/lumimqtt.py", line 381, in _publish_sensor
Wed Jun  1 18:32:30 2022 daemon.err lumimqtt[20937]:     await self._client.publish(
Wed Jun  1 18:32:30 2022 daemon.err lumimqtt[20937]:   File "/usr/lib/python3.9/site-packages/aio_mqtt/client.py", line 291, in publish
Wed Jun  1 18:32:30 2022 daemon.err lumimqtt[20937]:     await self._send_publish(message, packet_id)
Wed Jun  1 18:32:30 2022 daemon.err lumimqtt[20937]:   File "/usr/lib/python3.9/site-packages/aio_mqtt/client.py", line 612, in _send_publish
Wed Jun  1 18:32:30 2022 daemon.err lumimqtt[20937]:     packet.extend(struct.pack('!H', packet_id))
Wed Jun  1 18:32:30 2022 daemon.err lumimqtt[20937]: struct.error: 'H' format requires 0 <= number <= 65535

Periodic reporting of light status

Currently lumimqtt doesn't report the light status periodically nor reports it on_connect or reconnect, this is problematic because the status of the light gets out of sync with home assistant when home assistant restarts.

Tasmota takes the approach of sending status when it connects to the mqtt broker and every 300 seconds. Which seems pretty reasonable to me, and would be something great to have in this project as well.

No such file or directory: '/dev/input/event0'

I've installed lumimqtt on a OpenLumi gateway (ZHWG11LM):

$ pip3 install -U lumimqtt
Collecting lumimqtt
  Downloading lumimqtt-1.0.14-py3-none-any.whl (27 kB)
Collecting aio-mqtt>=0.2.0
  Downloading aio_mqtt-0.2.0-py3-none-any.whl (18 kB)
Requirement already satisfied: evdev>=1.0.0 in /usr/lib/python3.9/site-packages (from lumimqtt) (1.4.0)
Installing collected packages: aio-mqtt, lumimqtt
Successfully installed aio-mqtt-0.2.0 lumimqtt-1.0.14

If I try to start the daemon the startup aborts with the following error:

$ lumimqtt
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/evdev/device.py", line 126, in __init__
FileNotFoundError: [Errno 2] No such file or directory: '/dev/input/event0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/lumimqtt", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3.9/site-packages/lumimqtt/__main__.py", line 80, in main
    for device in devices(
  File "/usr/lib/python3.9/site-packages/lumimqtt/platform.py", line 92, in devices
    return sensors(binary_sensors) + buttons() + lights() + \
  File "/usr/lib/python3.9/site-packages/lumimqtt/platform.py", line 44, in buttons
    buttons_.append(Button(name=name,
  File "/usr/lib/python3.9/site-packages/lumimqtt/button.py", line 41, in __init__
    self.ev_device = InputDevice(self.device_file)
  File "/usr/lib/python3.9/site-packages/evdev/device.py", line 128, in __init__
FileNotFoundError: [Errno 2] No such file or directory: '/dev/input/event0'

Do I need to load a kernel module manually to have /dev/input/event0 available? Did I miss something?

Kind regards,

Sebastian

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.