Listen on a tcp port for commands?

I have a custom component for Lutron Caseta Smart Bridge Pro/Ra2 Select if you are interested. It has sensors for pico remotes along with lights, switches, covers and scenes.

Could you share your code?

Hi all! Any updates on this topic? I’m looking to listen tcp/ip messages to update some objects based on Mobotix camera outputs (T25M), allowing to send a doorbell notify to Home Assistant.

I can help with Python programming and tests if is somthing is already on the road.

Thanks!

2 Likes

I also have a Mobotix doorbell and would love to connect it to HA… Just how? :slight_smile:

I’m surprised there is still not a TCP listen component for hass. This is a link to the “hack” I wrote long ago. RTI Remote Integration (one way)

Hi, I have a similar setup with a Mobotix T25M doorbell and I’d like to receive TCP messages in HA from it.
Any news on the TCP or HTTP listener?

A hack that I found to be working is to set Data Protocol to RAW TCP/IP in IP Notify profile and set the message to:

POST /api/webhook/doorbell HTTP/1.0
Content Type: application/json


Please keep in mind that there must be one extra new line after last string and you can’t actually send any additional data.

4 Likes

Wow thanks! I will give it a try and report back here.

I have create an appdaemon app to listen on port 8888 of hassio. In the log, I can’t see any errors.

2020-01-22 20:25:52.831115 INFO tcp_listener: Socket successfully created
2020-01-22 20:25:52.833895 INFO tcp_listener: socket binded to 8888
2020-01-22 20:25:52.836517 INFO tcp_listener: socket is listening

Unfortunately, it is not possible to send any messages to the port 8888 of hassio.
Is there anything I have forgotten to make solution work.

Here is the code of appdaemon app:

import socket
import appdaemon.plugins.hass.hassapi as hass

class TCPListener(hass.Hass):

   def initialize(self):             
     # next create a socket object 
     s = socket.socket()
     self.log("Socket successfully created")
  
     # reserve a port on your computer in our 
     # case it is 12345 but it can be anything 
     port = 8888
     s.bind(('', port))
     self.log("socket binded to %s" %(port))
  
     # put the socket into listening mode 
     s.listen(10)      
     self.log("socket is listening")
  
     # a forever loop until we interrupt it or  
     # an error occurs 
     while True:
  
       # Establish connection with client. 
       c, addr = s.accept()
       self.log('Got connection from', addr)
  
       # send a thank you message to the client.  
       c.send('Thank you for connecting')
  
       # Close the connection with the client 
       c.close()

   def terminate(self):
       self.log("terminate")

Do I have to open the port 8888 in docker.

Telnet on the port is also not successful.

It’s working! After one year search i found a solution to integrate the “ringing” from my mobotix T24 into Home-Assistant.

Thank you very much.

You are welcome! Please remember though that you can’t pass any POST data unfortunately.

good morning, i have a mobotix m24, what exactly do i need to do to receive the ip notification? where do i inerit the string?

You need to add an IP Notify Profile.

Okay, and how do I get the hassio at IP:8123? grazie

I’m sorry I don’t think I fully understand your question. You need to login to Mobotix admin section and add a new IP Notify profile as I outlined above.

Sorry, I do not fully understand the setup. I know about the IP Notify Profile, also about the raw TCP/IP.

I do not understand the POST format though. Should there not be some crytic numbes for the webhook to be recognised by HA? What is the setup on the HA side?

Could you maybe post an example? Thanks in advance!

No, webhooks do not require authentication. Just make sure there there is one blank line after the command:

POST /api/webhook/doorbell HTTP/1.0
Content Type: application/json

Automation in HA would look something like this:

- alias: Doorbell webook
    initial_state: 'on'
    trigger:
      platform: webhook
      webhook_id: doorbell
    action:
      ...
3 Likes

But how does HA know the webhook doorbell?

webhook_id: doorbell

Thanks in advance!

I don’t think I understand your question.

Hello designjunge, can you describe you howto please ?
My admin section / ip notification

curl -X POST http://192.168.1.159:8123/api/webhook/doorbell works fine

automation

- alias: "Webhook Sonnette on"
  trigger:
    platform: webhook
    webhook_id: doorbell
  action:
    service: switch.turn_on
    entity_id: switch.flag_sonnette

Tks for your help.

2 Likes