Pilight Connection "Timed Out" - Please help :-(

Hi All,

I seem to have been googling this all day and I’m getting nowhere so perhaps somebody can help. I’m new to Home Assistant but have been using Pilight successfully for a number of months. I was very happy to see it listed as a component and so I have been trying to set it up.

  • Note: I have home assistant set up on on Pi and Pilight on another.

My HA config file contains this:

pilight:
  host: 192.168.0.32
  port: 5001
  send_delay: 0.4

But the HA error log shows:

homeassistant.components.pilight: Unable to connect to 192.168.0.32 on port 5001: timed out

I can successfully talk to the Pilight API using Curl or Fiddler but HA doesn’t want to connect.

I took a look at the Pilight library used by HA and simplified the issue down to the following lines of code:

import socket

host = '192.168.0.32'
port = 5001

client_identification_sender = {"action": "identify"}

receive_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
receive_socket.settimeout(1)

receive_socket.connect((host, port))

receive_socket.send(json.dumps(client_identification_sender).encode())
answer_1 = json.loads(receive_socket.recv(1024).decode()) #This is the line that errors

So it appears to be the receiving of the reply data that is timing out and not the initial connection. I have tried extending the timeout and still get the issue.

  • Note: I am running the latest public builds of Home Assistant and Pilight.

Any help would be appreciated.

I’ve been trying to set up pilight for quite some time as well and I got it working in a way.

I think port 5001 in by default for web GUI, you have to add "port": 5000 at the end of pilight config.json (/etc/pilight/config.json). Make sure you stop pilight before you edit config.

Part of my config:

"settings": {
        "log-level": 6,
        "pid-file": "/var/run/pilight.pid",
        "log-file": "/var/log/pilight.log",
        "webserver-enable": 1,
        "webserver-root": "/usr/local/share/pilight/",
        "webserver-http-port": 5001,
        "webserver-cache": 1,
        "port": 5000
},
1 Like

That’s it! I was incorrectly looking at the HTTP port thinking that was it! Thank you!

Now I have another problem :frowning:…I now get the following errors:

expected int for dictionary value @ data['switches']['lamp']['off_code']['id']. Got B1
expected int for dictionary value @ data['switches']['lamp']['on_code']['id']. Got B1

I’m using the clarus_switch protocol which has IDs that are alphanumeric. Perhaps this is a drawback of the HA component only allowing protocols with integer IDs?

Glad you got it working now!

Heh, look at my thread. Same problem with yaml configuration, because I have clarus_switch as well. I hope somebody can help us figure it out…

1 Like

Nice to know that this works. You are most likely the first one doing that :wink:

Yep, works a treat after the help from @SmartValley to get the port configured :smiley:!

I’m really glad of it as well as my Pilight Pi is in a nice central location with good range to all the switches. The Home Assistant Pi is tucked away in a corner :slight_frown:.