Coder Social home page Coder Social logo

dali2mqtt's Introduction

Diogo Gomes

Diogo Gomes graduated in Computers and Telematics Engineering from the University of Aveiro in 2003 with first of his class honors, and concluded his Phd by the same University on Resource Optimization for Broadcast Networks in 2009. He's currently an Associate Professor at the University of Aveiro. In the last 20 years has participated in several EU funded projects such as IST-Mobydick, IST-Daidalos, IST-Akogrimo, IST-C-MOBILE, ICT-C-Cast, ICT-Onelab2, H2020-5GinFIRE and H2020-5GASP where besides conducting research on QoS, IP Mobility, Multicast/Broadcast, Service & Application Development and Network Orchestration has always been deeply involved in the deployment of prototypes and demonstrators. Current research interest are applying Artificial Inteligence to Internet of Things (IoT) Scenarios (e.g. Energy Disaggregation, Smart EV Charging, Multi-Access Edge Computing) and 5G Technologies such as NFV and ZSM

He his a strong Open Source Advocate and was one of the founders of the University Linux User Group and has personally contributed to several OSS projects such Home Assistant. He's a passionate Hacker and Maker and president of a local association - Hack'Aveiro.

Twitter Follow Linkedin: dgomes

dali2mqtt's People

Contributors

crami avatar dependabot[bot] avatar dgomes avatar hadatko avatar ipallis avatar kbacia7 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  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dali2mqtt's Issues

Map HA dali brightness level to DALI min-max range

After we query lamps about supported brightness range we can create map of home assistant brightness level to dali range.
My proposition:

  1. HA 100% - Dali level 254, 255 is reserved
  2. HA from 99% to 1% - map from Dali 254 to physical minimum( received from DALI device ) or default 85(85 is default for tridonic devices)
  1. HA 0% - DALI lamp off

ad.2 calculation of DALI brightness steps steps, (254(max) - 85(min))/99 next round the number up

Above proposal solves the problem of the inability to set the brightness below 34% for lamps with Minimal brightess level like 85 and similar

Installation?

I have made many attempts to install the dali2mqtt.
I want to install it on a Raspberry Pi 4B with Linux Debian 12 (Bookworm) as the operating system.
I am working directly on my Raspberry Pi. (screen, keyboard) under the username "homeassistant". The Hasseb USB DALI Master in a USB port.
I do the installation in the folder home/homeassistant/.
When I run the instruction "venv/bin/python3 -m dali2mqtt.dali2mqtt", I get as a result the configuration of my DALI devices. I complete the rest of the installation.
The problem is that when I control or turn on or off my lights, I do not receive any messages in homeassistant.
Can you possibly list step by step how I should do the installation? Or can you explain the problem?

WIP: New installation - master branch fixes

Hi,
I tride prepare new instalation of dali2mqtt using manual from readme and meet couple problems:

  1. missing information about system requirement, I propse new step in documentation
    Install the following dependacy's with this command:
apt-get install \
git \
python3-pip \
python3-venv \
libhidapi-dev \
  1. Move python dependency wheel from requirements.txt to pip install wheel becouse when it's installed from requirements other modules use installation in legacy mode.
Using legacy 'setup.py install' for paho-mqtt, since package 'wheel' is not installed.
Using legacy 'setup.py install' for pathtools, since package 'wheel' is not installed.
Using legacy 'setup.py install' for pyusb, since package 'wheel' is not installed.
Using legacy 'setup.py install' for voluptuous, since package 'wheel' is not installed.
Using legacy 'setup.py install' for watchdog, since package 'wheel' is not installed.
Using legacy 'setup.py install' for python-slugify, since package 'wheel' is not installed.
Using legacy 'setup.py install' for pyhidapi, since package 'wheel' is not installed.
Using legacy 'setup.py install' for slugify, since package 'wheel' is not installed.
  1. Missing option in default config.yaml created after first run. Second run of the scripts return error
mqtt_username: zigbee2mqtt
mqtt_password: password

Add lamp identification option

Add support to identification option in DALI bus.
From dali doc:
Starts a temporary identification process such as flashing the lamps, making a sound or transmitting an RF beacon.

Dali groups

Hello Diogo,

Apparently python-dali supports groups, are there plans to inegrate this into dali2mqtt?

sde1000/python-dali#55

I have created a couple HA grouping, but there is always a slight delay between them, using dali groups with same lamps this does not occur.
And just to let you know, for the past months, dali2mqtt has been working flawlessly!

No errors though no light activity

I have installed the library, not using venv (didn't get it to work that way) and it seems to run fine.
I configured it with 1 light in config.ini.
Home assistant sees the MQTT lights but when i switch light 0 it does not do anything.

When i attach the hasseb adapter to a windows machine i can switch the ballast on and off using the stock hasseb software.
Can i debug this in any way? Or is there more config to do then just setting the mqtt broker in config?

I am running in a virtual environment, but the windows machine is too. Further i am running hass.io.
Dali2mqtt is runing on a ubuntu virtual machine.

dali_driver: hasseb dali_lamps: 1 ha_discover_prefix: homeassistant mqtt_base_topic: dali2mqtt mqtt_port: 1883 mqtt_server: 192.168.5.120

Create more tests

We have a seed test, we should expand our test coverage with more tests

Lamp delation

fallows conversation from #39 (comment)

Abandoned devices: we should no longer publish them to the discovery topic. In HA there is yet to exist an API to remove devices... currently you need to use the UI

Will you to accept PR with code for deleting missing lamps(remove from device.yaml)? By deleting I'm mean cleaning mqtt on the broker by the dali2mqtt. I know it's hack but it will help mqtt entity in the HA to stay clean.

Support on_command_type from MQTT Lights

Add support for brightness change without payload 'on' command. We can support this by userconfig variable from the config.yaml so anyone can choose what prefer.

on_command_type description
Defines when on the payload_on is sent. Using last (the default) will send any style (brightness, color, etc) topics first and then a payload_on to the command_topic. Using first will send the payload_on and then any style topics. Using brightness will only send brightness commands instead of the payload_on to turn the light on.

from: https://www.home-assistant.io/integrations/light.mqtt/#on_command_type

Dali_lamps setting ignored?

In config.ini ( the readme says config.yaml btw?) the dali_lamps setting is default to 4.
When i change this to 2 i would expect the initial searching to stop at lamp 1 ?
It just continues to lamp 3 though, resulting in 4 entries in my home-assistant set-up with 2 that don't exist actually.

Documentation missing run steps for dali-mqtt-daemon.py

Hi,

I think that before command systemctl start dali2mqtt.service there should be console exec of dali-mqtt-daemon.py like venv/bin/python3 ./dali-mqtt-daemon.py

Benefits of the change:

  1. creation of config.ini
  2. console information about creation of config.ini, no need to check logs
  3. less chance of making a mistake by noobs

Bug in device name

This line

self.device_name = slugify(friendly_name)
on Python 3.9.2 should change to self.device_name = slugify(str(friendly_name)). Could you please fix it?

ERROR: AttributeError: 'TridonicDALIUSBNoResponse' object has no attribute 'value'

Hi, i am starting to use this project and from begging i am getting errors. This is first one. I cannot provide much information about that because it disappear meantime and now i have different issue. So far related to this one:

i connected this https://svitimprotebe.cz/eshop/dali-usb/ tridonic usb dali converter to my server and connected to it one dali device. Then i created docker container where all dependencies are installed. The error looks like from python-dali module but actually it looks like this project is trying to access values from errors. I would say this rows but cannot confirm as mentioned:
image

FROM alpine
RUN apk add git python3 py3-pip py3-paho-mqtt py3-slugify py3-usb py3-yaml py3-text-unidecode py3-voluptuous py3-watchdog hidapi 
RUN pip3 install python-dali hidapi --break-system-packages
RUN git clone https://github.com/dgomes/dali2mqtt.git && cd dali2mqtt
ENTRYPOINT ["tail", "-f", "/dev/null"]
/dali2mqtt # python3 -m dali2mqtt.dali2mqtt
2024-02-02 19:29:08,209 ERROR: Could not load device names config <devices.yaml>, a new one will be created after successfull start
2024-02-02 19:29:08,209 DEBUG: Using <tridonic> driver
2024-02-02 19:29:08,227 DEBUG: Connecting to mqtt:1883
2024-02-02 19:29:08,230 ERROR: Could not load device names config <devices.yaml>, a new one will be created after successfull start
2024-02-02 19:29:08,305 DEBUG: Found lamp at address 2
2024-02-02 19:29:09,883 INFO: Found 1 lamps
2024-02-02 19:29:09,909 ERROR: AttributeError: 'TridonicDALIUSBNoResponse' object has no attribute 'value'
2024-02-02 19:29:15,910 DEBUG: Connecting to mqtt:1883
2024-02-02 19:29:15,913 ERROR: Could not load device names config <devices.yaml>, a new one will be created after successfull start
2024-02-02 19:29:15,972 DEBUG: Found lamp at address 2
2024-02-02 19:29:17,551 INFO: Found 1 lamps
2024-02-02 19:29:17,577 ERROR: AttributeError: 'TridonicDALIUSBNoResponse' object has no attribute 'value'
2024-02-02 19:29:20,578 DEBUG: Connecting to mqtt:1883
2024-02-02 19:29:20,580 ERROR: Could not load device names config <devices.yaml>, a new one will be created after successfull start
2024-02-02 19:29:20,639 DEBUG: Found lamp at address 2
2024-02-02 19:29:22,217 INFO: Found 1 lamps
2024-02-02 19:29:22,243 ERROR: AttributeError: 'TridonicDALIUSBNoResponse' object has no attribute 'value'
2024-02-02 19:29:31,244 DEBUG: Connecting to mqtt:1883
2024-02-02 19:29:31,247 ERROR: Could not load device names config <devices.yaml>, a new one will be created after successfull start
2024-02-02 19:29:31,306 DEBUG: Found lamp at address 2
2024-02-02 19:29:32,884 INFO: Found 1 lamps

Remove lamps from MQTT on exit

I think that good idea will be removing all lamps from MQTT on exit of script. Currently after a few hours of experincing we can have many lamps on MQTT which doesn't exists

Set Power on level brightness according to last brightness state from HA

DALI bus support setting brightness level of the lamp after power on we can use this to store last brightness state received from HA.
Situation:

  1. change brightness level in HA
  2. dali2mqtt send new new brightness level to lamp
  3. dali2mqtt store active brightness level in the lamp

In my configuration with conventional switch it will be great to support this because after power reset lamp will be using last state.

Color light and multiple busses support ?

Hi,

I'm new to dali so I could write some nonsense here.

it does not seems that color light (using multiple channel) are supported , is it?
if not, could it be supported directly from here or should it be supported by python-dali first ? Seems that a layer of abstraction is lacking between a light representation and a dali channel. multiple light type (cct, rgb, rgbw, rgbcct) covering different range of channels with a dedicated payload parsing for each would be necessary.
I'm also wondering if the dali protocol altogether can tell when a single balast uses multiples channels. if not proper device discovery is impossible and the device map would need to come from a config file.

also, I believe I will largely exceed 64 channel on my setup so I need to separate my house into multiple dali busses and connect several dali-usb controllers to my server. Could this plugin (and python-dali) manage multiple dali busses ?

Send DALI devices as separate MQTT Devices

Hi,
At the moment each DALI devices is send with one MQTT device setting. Configuration causes that DALI devices are discovered separate entities but one device by HA.

This is limitation because actual version(1.14.x) of HA can't assign area to entities only to devices.

My proposition: adding configuration option to choose how DALI devices are exported via MQTT to HA.

@dgomes what you about this?
If you are ok with this we(@JustNet) can prepare patch with PR.

Fix max lamp implementation vs DALI range

Hi,
In script we can set dali-lamps number but latter this map to max_range which is responsible for limiting the addresses to be searched. I think that implementation is wrong. Let's assume situation with four lamps:

  1. lamp 1 address 0
  2. lamp 2 address 2
  3. lamp 3 address 4
  4. lamp 4 address 6
    In the current implementation script will find only the first two lamps.

I think that we need to separate number of lamps from dali address range. This will allow people to use non continuous address number for the lamps.

dali2mqtt reset config to default values

After lasts commits to master branch, running dali2mqtt resets config.yaml to default settings, in results, changing any of config values doesn't take effect.

To reproduce:

  1. Change mqtt_server in config.yaml
  2. Run dali2mqtt
  3. In new terminal window look at config.yaml, mqtt_server is localhost

And last, we wanna change config.yaml based on arguments passed to script? I always had feeling that passing parameters to scripts via arguments (like --mqtt-server) is for temporialy changing this value, not save new value to configuration

Don't overwrite config file after each run

Script when closing alway overwrite config file with setting fetched on start.
This create situation where we can't change configuration without exiting script. Better aproache is to read file at startut, and don't override on exiting.

Periodic lamp status reports

As I do have native dali light switches which also control the lights i do not get the "real" status over mqtt. It would be nice if we could implement periodic status messages.

I think we have to do driver_object.send(gear.QueryActualLevel(short_address)) in periodic intervals (all 5-10s) for every lamp and emit a mqtt message with the result.

Looking at the code I currently have no idea where to implement this in a nice way. If there are any ideas please post here so I can try to implement this. Or send me code :-)

Add summary of found lamps

We have a idea to add summary of lamps, not only for debug purposes, to inform user about found lamps:

Found N lamps

  • short address: X, brightness level: Y
  • short address: X, brightness level: Y
  • short address: X, brightness level: Y

The unauthenticated git protocol on port 9418 is no longer supported.

We need to change link in requirements.txt from

git+git://github.com/awelkie/pyhidapi@master#egg=pyhidapi==1.0.0

to

git+https://github.com/awelkie/pyhidapi@master#egg=pyhidapi==1.0.0

From github

Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.

Create CI with Actions??

With github, we can create automatic test platform.
This will help with checking basic test and discard when script don't pass them.

mqtt topics

Hello,
I installed dali2mqtt and it is up and running. It detects my Dali USB-HID device and one fixture named "philips"
I want to use this software without Home Assistant. I am running Node-RED with an MQTT broker, but I am unsure which MQTT topics I should use.

The topic dali2mqtt/status works and provides the output "online" but I have tried for instance: dali2mqtt/philips/light/status without any response.
Can you please list the MQTT topics that can be used? Thanks.

Async HID driver support

I've created a fork of this amazing project where it uses the Async HID drivers instead of the synchronous drivers.
https://github.com/rohanramaswamy/dali2mqtt
Unfortunately this breaks support for sync drivers and dali server.
I have tested it with hasseb and it works well, and tridonic should also work.
Additionally i've added support for color temperature which works well with home assistant.
I would love to know if there's any interest in something like this and appreciate any feedback,

Preserve dali lamp configuration across restart

I think that dali lamp scan/full scan should happen only on the first run of the script. After lamp are found information should be saved to file. After restart dali2mqtt script should check if the lamp configuration file exist if so lamps should be fetch from file.

Benefits from the change:

  1. we don't lose lamps after the restart, in my environment with conventional switch I need to manual switch all the lamps before starting dali2mqtt other wise lamps will be missing. If you have 10+ amps it's really annoying.
  2. we can assign normal entity id, name like kitchen, bathroom etc.

After adding base support for storing lamp information we can use mqtt command to trigger lamp scan, search for new lamps, change configuration like entity_id, name etc.

pyusb requirement

Pyusb is a dependency for pyusb, it seems as though this is preinstalled on most systems, though not al.
Maybe add it to the requirements.txt?

pyusb==1.0.2

No MQTT Topics - device removed after starting dali_mqtt_daemon.py

Hi all,

I have installed dali2mqtt according to your instructions.

But on the MQTT server I don't see any topics from the lamps.
But I see the status of the dali2mqtt.

What could be the problem?

Here are the output:

~/dali2mqtt-venv/bin/python3 ~/dali2mqtt/dali_mqtt_daemon.py --config ~/dali2mqtt/config.yaml --log-level debug --log-color 
2021-09-07 16:37:16,567 DEBUG: Loading devices names from <devices.yaml>
2021-09-07 16:37:16,574 DEBUG: Using <tridonic> driver
2021-09-07 16:37:16,666 DEBUG: Connecting to 192.168.4.201:1883
2021-09-07 16:37:16,681 DEBUG: Loading devices names from <devices.yaml>
2021-09-07 16:37:18,566 INFO: Found 2 lamps
mosquitto_sub -h 192.168.4.201 -u myuser -P mypassword -t dali/+ -v
dali/status offline
dali/status online

thx

Brightness levels based on real data

After #13 we can set brightness_scale in HA config for devices, based on real max_level.
Change brightness level can now support levels from min_level to max_level
And I think that maybe I should add class to represent DALI Lamps as objects and store collected data? For better reading code and more OOP way

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.