Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The KNX IP Protocol #307

Open
dcec opened this issue Jul 1, 2019 · 25 comments
Open

The KNX IP Protocol #307

dcec opened this issue Jul 1, 2019 · 25 comments

Comments

@dcec
Copy link

dcec commented Jul 1, 2019

Describe the problem you have/What new integration you would like

Please describe your use case for this integration and alternatives you've tried:
The KNX IP Protocol is an international open standard for smart homes and smart buildings automation. It is a decentralized system.
Several home automation systems have KNX support.

Additional context

@brandond
Copy link

brandond commented Jul 1, 2019

This feels like something that would best be integrated directly into Home Assistant. How would you see this working with esphome?

@dcec
Copy link
Author

dcec commented Jul 2, 2019

KNX is one of the most common protocols for commercial and domestic building automation.
Is also possible to integrate on existing wired knx using a coupler like this project:
http://www.intranet-of-things.com/smarthome/infrastructure/knx/arduino/

@OttoWinter
Copy link
Member

@dcec Yes, that might be true - but please also explain why this would specifically be required in ESPHome directly as @brandond asked.

With these things it's probably a lot more useful to do all KNX stuff in Home Assistant (as that will always be more powerful and feature-rich than ESPHome could ever implement KNX). ESPHome is not supposed to be used on its own - it works best with HA by its side.

@dcec
Copy link
Author

dcec commented Jul 5, 2019

for example using esp32 for send xiaomi_mijia sensor data on knx network without Home Assistant

@plckr
Copy link

plckr commented Mar 9, 2020

@OttoWinter With knx you can communicate between esphome nodes
Here you can see more about knx -> https://github.com/arendst/Tasmota/wiki/KNX-features
An example use case: Control a light from node X, with a button in node Y

This method allow us to control any KNX node in the network. Tasmota can turn a light on which is linked to esphome

@webfrank
Copy link

Hi I use knx on tasmota without any broker and would be useful to do the same on esphome. I can deploy a totally autonomuos automation

@DocDoo
Copy link

DocDoo commented Jul 5, 2021

I would like this feature as well as it, like already mentioned, will allow me to improve the robustness of my setup by having ESPHome nodes interact directly with KNX (e.g. to provide the other KNX components with sensor information) as a first step for automation in a new build I'm planning.
It will then be easy for me, in a second step, to add Home Assistant for advanced automation and integration scenarios in a future improvement to my installation.

@RichieRich69
Copy link

This is incredibly useful as a fallback when home assistant is unavailable ea. When there is a update or home assistant falls to start for some reason.

@fxmike08
Copy link

fxmike08 commented May 4, 2022

Hi there,

I wrote a component, that is able to communicate with KNX (twisted pair) via esp32 (tested by me).
Can somebody help me with the procedure before opening pull request ? I suppose I also need to add docs info somehow.

For those who want to play around : code is available here.

The esphome.yaml looks like this:

uart:
  id: uart_bus
  tx_pin: 0
  rx_pin: 2
  baud_rate: 19200
  parity: even

knx:
  uart_id: uart_bus
  use_address: 10.10.1
  listen_group_address: ["0/0/3", "0/0/1"]
  lambda: |-
    KnxTelegram* telegram = knx.get_received_telegram();
    if(telegram->get_target_group() == "0/0/3" ){
      if(telegram->get_bool()){
         id(light_output).turn_on();
      } else {
        id(light_output).turn_off();
      }
    }
    return;
      
switch:
  - platform: gpio
    id: light_output
    name: "Desk Lamp"
    pin: 
      number: 13
      inverted: true

This was tested using "Siemens UP117/12 Bus Coupler" and "Wemos LOLIN D32 Pro" and by sending commands via ETS (by using knx ip interface).

Thanks,

@moritzj29
Copy link

I would argue that this issue is not closed since the external component only implements KNX TP but the issue is about KNX IP protocol. KNX IP does not require additional hardware (bus coupler) as it communicates directly over IP protocol (WiFi, Ethernet).

@DocDoo
Copy link

DocDoo commented Jul 5, 2022

I would argue that this issue is not closed since the external component only implements KNX TP but the issue is about KNX IP protocol. KNX IP does not require additional hardware (bus coupler) as it communicates directly over IP protocol (WiFi, Ethernet).

I agree with this argument, but very appreciate the excellent work done by @fxmike08 👍👍

@nagyrobi nagyrobi reopened this Jul 5, 2022
@kmplngj
Copy link

kmplngj commented Aug 17, 2022

I found this issues because I would like to use the new Feedback Cover with sensors for Open/Closed directly on the esp and KNX IP for KNX relays to switch open/closes actions on the door motor.

@borispulyer
Copy link

@fxmike08 I really appreciate your component. Is there any chance to get some more configuration examples, eg. for sending telegrams?

@fxmike08
Copy link

fxmike08 commented Feb 6, 2023

Hi Boris,

You have below an example on how to send knx telegrams. For some reason you have to add id to knx component in order to access it.

Please have in mind that if ESP start to crash and restart when sending telegrams, it means that you don't have proper connection between serial and tp-uart.

  external_components:
    - source:
        type: git
        url: https://github.com/fxmike08/esphome
        ref: KnxComponent
      components: [ knx ]
...
  uart:
    - id: uart_bus
      tx_pin: 1
      rx_pin: 3
      baud_rate: 19200
      parity: even
      debug:
        direction: BOTH
        dummy_receiver: false
        after:
          delimiter: "\n"
        sequence:
          - lambda: UARTDebug::log_binary(direction, bytes, 32);
...
  knx:
    id: knxd
    uart_id: uart_bus
    use_address: 10.10.1
    listen_group_address: ["0/0/3", "0/0/1"]
    lambda: |-
      KnxTelegram* telegram = knx.get_received_telegram();
      ESP_LOGD("KNX", "group: %s",telegram->get_target_group());
      if(telegram->get_target_group() == "0/0/3" ){
        if(telegram->get_bool()){
           ESP_LOGD("KNX", "KNX ON");
        } else {
           ESP_LOGD("KNX", "KNX OFF");
        }
          
      }
        
      return;
...
  api:
    services:
      - service: knx_write_group_bool
        variables:
          address: string
          value: bool
        then: 
          - lambda: |-
              id(knxd).group_write_bool(address.c_str(), value);
...
  - platform: gpio
    name: $friendly_devicename Relay 2
    id: relay_2
    pin:
      number: 19
    on_turn_on:
      - lambda: |-
          id(knxd).group_write_bool("0/0/3", true);

@borispulyer
Copy link

Thank you very much @fxmike08 - this helps me a lot. Great work!

@platini76
Copy link

platini76 commented Mar 13, 2023

can you please make an example of a rgb led with feedback and dimmer?

I want to reproduce this settings...

Screenshot 2023-03-13 alle 21 15 13

@fdepalo
Copy link

fdepalo commented Jun 7, 2023

@fxmike08 thank you for your effort, can we use a siemens bcu 5wg-1117-a2b12 directly to esp32 serial or it is just for tpuart chip like nanobcu ?

@fxmike08
Copy link

fxmike08 commented Jun 7, 2023

@fdepalo You can use siemens 5wg-1117-a2b12 to communicate directly with esp32 serial. Directly, but use a level shifter as Siemens for Rx & TX is 5V and esp32 is 3.3V.

@fdepalo
Copy link

fdepalo commented Jun 7, 2023

mistery solved, i am able to transmit but not to receive without the level shifter, thank you ;)

@fdepalo
Copy link

fdepalo commented Jun 10, 2023

Hi Boris,

You have below an example on how to send knx telegrams. For some reason you have to add id to knx component in order to access it.

Please have in mind that if ESP start to crash and restart when sending telegrams, it means that you don't have proper connection between serial and tp-uart.


  external_components:

    - source:

        type: git

        url: https://github.com/fxmike08/esphome

        ref: KnxComponent

      components: [ knx ]

...

  uart:

    - id: uart_bus

      tx_pin: 1

      rx_pin: 3

      baud_rate: 19200

      parity: even

      debug:

        direction: BOTH

        dummy_receiver: false

        after:

          delimiter: "\n"

        sequence:

          - lambda: UARTDebug::log_binary(direction, bytes, 32);

...

  knx:

    id: knxd

    uart_id: uart_bus

    use_address: 10.10.1

    listen_group_address: ["0/0/3", "0/0/1"]

    lambda: |-

      KnxTelegram* telegram = knx.get_received_telegram();

      ESP_LOGD("KNX", "group: %s",telegram->get_target_group());

      if(telegram->get_target_group() == "0/0/3" ){

        if(telegram->get_bool()){

           ESP_LOGD("KNX", "KNX ON");

        } else {

           ESP_LOGD("KNX", "KNX OFF");

        }

          

      }

        

      return;

...

  api:

    services:

      - service: knx_write_group_bool

        variables:

          address: string

          value: bool

        then: 

          - lambda: |-

              id(knxd).group_write_bool(address.c_str(), value);

...

  - platform: gpio

    name: $friendly_devicename Relay 2

    id: relay_2

    pin:

      number: 19

    on_turn_on:

      - lambda: |-

          id(knxd).group_write_bool("0/0/3", true);

@fxmike08 thank you again, is there something i can do to help you with debugging/development? The crash if tpuart is not connected is the only problem i am experiencing:)

@fxmike08
Copy link

@fdepalo Thank you for willingness to help, but at this point I don't know if you can help with something. When I'll have time I'll try to find a solution for serial crash (There is no way to check if serial is working).

@PaoloTK
Copy link

PaoloTK commented Jul 31, 2023

@fdepalo Thank you for willingness to help, but at this point I don't know if you can help with something. When I'll have time I'll try to find a solution for serial crash (There is no way to check if serial is working).

Hi @fxmike08, I'm working on a similar KNX integration for WLED. Can you explain where you sourced the library you're using and would it be possible to upload it to GitHub separately? I've found an older version of the same library hosted here:

https://github.com/majuss/KnxTpUart

@fxmike08
Copy link

fxmike08 commented Aug 14, 2023

@PaoloTK please find here the requested info.

Yes, KnxTpUart is the library used and modified to compile and for respecting the coding style of the esphome. Let me know if you need more info.

Regards.

@nerdoc
Copy link

nerdoc commented Oct 3, 2023

A really good reason to establish this component is, if (like in my house) an esphome component is not reachable all the time using WiFi (e.g. to far away), or (like here) WiFi is not always on. I could use a WT32-ETH01 with a LAN connection, - but: I have KNX cables literally everywhere in my house, and LAN cables only where I need them.

So using the KNX bus as wired connection to Homeassistant would be the perfect match. I just need to send updates to the server. And everytime I switch off WiFi, the continual capturing of sensor data is lost.

So I would definitely second a knx esphome component.

One question: Do you need to use the Siemens bus coupler, or is it possible to use others too, like the GIRA bus coupler?

@fxmike08
Copy link

@nerdoc Haven't test with other bus couplers, but I suspect it would work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests