Pilight configuration

Hello, I’m a newbie

I added pilight to my configuration.yaml

pilight:
  host: 10.0.0.166
  port: 5000

however in the user interface I received this error:

16-08-22 21:44:25 homeassistant.bootstrap: Error during setup of component pilight
Traceback (most recent call last):
File “/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/bootstrap.py”, line 156, in _setup_component
result = component.setup(hass, config)
File “/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/pilight.py”, line 46, in setup
from pilight import pilight
File “/home/hass/.homeassistant/deps/pilight/init.py”, line 3, in
version = get_distribution(‘pilight’).version
File “/srv/hass/hass_venv/lib/python3.4/site-packages/pkg_resources/init.py”, line 556, in get_distribution
dist = get_provider(dist)
File “/srv/hass/hass_venv/lib/python3.4/site-packages/pkg_resources/init.py”, line 430, in get_provider
return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
File “/srv/hass/hass_venv/lib/python3.4/site-packages/pkg_resources/init.py”, line 967, in require
needed = self.resolve(parse_requirements(requirements))
File “/srv/hass/hass_venv/lib/python3.4/site-packages/pkg_resources/init.py”, line 853, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The ‘pilight’ distribution was not found and is required by the application

Home Assistant runs on a RPI 2 and I installed it with the all-in-one in the virtualenv on a fresh raspbian jessie.
Do anyone know how I could solve this? Thanks in advance.

It looks like pilight is not installed and cant be installed by HA.

In the Troubleshooting section for Pilight there’s tips for installing it from source. Try that and report back if you encounter any other problems.

Thanks I’ve installed pilight from source and even running a working pilight configuration however HA still gives the same error above.

Could it depend on the virtualenv?

I honestly don’t know.
I’ll try to have a look at installing it myself this weekend to have a better look.

I’ve solved it with these steps:

(hass)$ pip3 install --upgrade pilight

And used the example config from GitHub.
pilight: host: 127.0.0.1 port: 5000
switch: platform: pilight switches: test switch: on_code: protocol: intertechno_old unit: 3 id: 12 'on': 1 off_code: protocol: intertechno_old unit: 3 id: 12 'off': 1

1 Like

Hi,

just to understand the issue. You had a wrong version of the python pilight client installed (pilight 0.0.1) and solved it by upgrading to the needed version (pilight 0.0.2)?
I wonder why home assistant could not install pilight on the fly. This has to be related to the virtual environment.

David

Hey

I got the same issue as you hade in the original post, the pip3 install --upgrade pilight fixed that.

But now I get

16-08-31 20:18:35 homeassistant.bootstrap: Error during setup of component pilight
Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/pilight.py", line 50, in setup
    port=config[DOMAIN][CONF_PORT])
  File "/home/hass/.homeassistant/deps/pilight/pilight.py", line 67, in __init__
    self.receive_socket.connect((host, port))
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/bootstrap.py", line 157, in _setup_component
    result = component.setup(hass, config)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/pilight.py", line 54, in setup
    config[CONF_HOST], config[CONF_PORT], err)
KeyError: 'host'

Did you add the port in pilight configuration?
/etc/pilight/config.json

I thought that the pilight component talked directly to the pilight-daemon on port 5000 as standard? What do I need to add in the config.json?

You were absolutely correct! I hade not configured the daemon port in the config.json file as you suspected. I thought that I read somewhere that the default was 5000. I was wrong as the default is random port.

For others this is how my settings part in config.json looks

   "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
    },

Thank you.

1 Like

Yes the default port is not 5000 (anymore?). See here: https://www.pilight.org/configuring/settings/
I will mention this the next time I update the readme of the pilight component. Sorry for the inconvenience.

1 Like

Hello i’m a newbie too. I consider myself a noob.

This helped me with some problems i had:
(hass)$ pip3 install --upgrade pilight

But now i get this this message in ha:
16-09-07 13:46:18 homeassistant.bootstrap: Invalid config for [pilight]: expected a dictionary for dictionary value @ data[‘pilight’]. Got [OrderedDict([(‘host’, ‘127.0.0.1’), (‘port’, 5000)])]

This is what i have in my configuration.yaml:

pilight:
   - host: 127.0.0.1
     port: 5000

And my pilight config.json is ok, because i can use pilight ( i also added the port: 5000).
somebody knows what i am doing wrong?

Try without the dash:

pilight:
  host: 127.0.0.1
  port: 5000

I think the component description was changed too quickly. The dash should be supported in the next release.

Thank you so much!! It is working fine now.
i feel so stupid i tried a lot of things but nothing that simple.

Maybe one of you can help.
So I updated pilight in the virtual environment and that seems to have gone well.
But I got errors in HASS.
Then I changed the pilight config.json (in etc/pilight/config.json) to also have “port”, as Zybe has it as well.
Mind you that the line “port” wasn’t in the config.json yet! So I added it.
But when in HASS I put port 5000 I get this error:

16-09-17 12:39:37 homeassistant.bootstrap: Error during setup of component pilight
Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/pilight.py", line 50, in setup
    port=config[DOMAIN][CONF_PORT])
  File "/home/hass/deps/pilight/pilight.py", line 67, in __init__
    self.receive_socket.connect((host, port))
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/bootstrap.py", line 157, in _setup_component
    result = component.setup(hass, config)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/pilight.py", line 54, in setup
    config[CONF_HOST], config[CONF_PORT], err)
KeyError: 'host'

And when I put 5001 in HASS, I get this error:

16-09-17 12:43:52 homeassistant.bootstrap: Error during setup of component pilight
Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/pilight.py", line 50, in setup
    port=config[DOMAIN][CONF_PORT])
  File "/home/hass/deps/pilight/pilight.py", line 72, in __init__
    answer_1 = json.loads(self.receive_socket.recv(1024).decode())
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/bootstrap.py", line 157, in _setup_component
    result = component.setup(hass, config)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/pilight.py", line 54, in setup
    config[CONF_HOST], config[CONF_PORT], err)
KeyError: 'host'

If anyone has any idea, please shout :slight_smile:
Maybe I changed the wrong config.json? I’m running HASS in a virtual environment, so is the config.json then in another location perhaps?

It seems like you have the same error I had.

This is my /etc/pilight/config.json

"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
        },

And this is the configuration.yaml

pilight:
  host: 10.10.1.128
  port: 5000

I think you need to check what port pilight is running on. I think that you can use netstat or lsof for that, but i’m sorry to say that I do not know the exact command.

The fing app is very convenient to check hosts and ports in your lan.

hmmm it seems like I didn’t save any settings last time because now when I try to do it it says access denied.
How can I change the file?
I tried winscp login with my pi admin username + password and then the shell setting: sudo su -
which didn’t work, so I also tried with shell setting: default
also doesn’t work.

Either I don’t know how it works, or it doesn’t find everything. I have also pi-hole running on the same pi, but it doesn’t show it when I do a service scan on the pi.

I read at the pilight site that you need to stop philight before doing any changes to the config.json as it will be overwritten.

I just ssh to the pi, do “sudo nano config.json” then ctrl+o to save and ctrl+x to exit. then start pilight.

1 Like