Pilight configuration

Thanks! That worked! :slight_smile:

hello together,

i am a newbie also. and i get in troublle with the configuation of pilight in HA. i receieved this error in the user interface:

16-10-12 10:41:58 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 102, in _setup_component
result = component.setup(hass, config)
File “/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/pilight.py”, line 49, 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 559, in get_distribution
dist = get_provider(dist)
File “/srv/hass/hass_venv/lib/python3.4/site-packages/pkg_resources/init.py”, line 433, 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 970, in require
needed = self.resolve(parse_requirements(requirements))
File “/srv/hass/hass_venv/lib/python3.4/site-packages/pkg_resources/init.py”, line 856, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The ‘pilight’ distribution was not found and is required by the application

i added to my configuration.yaml:

pilight:
host:
port: 5000

and into the 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
},

pilight is running and works well.

i have updated HA and also pilight.
But, it doesn´t work.

Do anyone know how I could solve this? many thanks in advanced.

This looks like a bug in python packaging and virtual environments. It effectively says that pilight was not installed but the code is downloaded. Can you try to install pilight manually in your virtual environment? E.g. pip3 install pilight==0.0.2

hi davidlp,

thanks for your comment.

if i install pillight maually, i get that massage:

pi@raspberrypi:~ $ pip3 install pilight==0.0.2
Requirement already satisfied (use --upgrade to upgrade): pilight==0.0.2 in /usr/local/lib/python3.4/dist-packages

:frowning:

Next version of home assistant 0.31 will have a fix to make this hopefully work. Until then you can try to install pilight in your virtual environment, as I suggested.

i have installed HA again. and it works now. :slight_smile: thanks.

Hi

I’m new at HA, too.

HA is running on MacOS with Python 3.5.2
and pilight on a raspberry pi 1

Pilight config.json is fine.

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

configuration.yaml

I tried this

pilight:
  host: 192.168.2.9
  port: 5000

I configured ALL pilight devices in the pilight config.json.

Home assistant shows nothing in the Dashboard. Do I have to configure the devices directly in the configuration.yaml? I thought that HA reads the config data from the pilight config.json??

Thx for helping.

Edit:
Ok figured out I have to configure switches in home assistant, too.

I got a toggle and I can switch the light on and off.
But I dont get an receive status in HA if I switch on in the Pilight web interface

pilight:
  host: 192.168.2.9
  port: 5000

switch:
  - platform: pilight
    switches:
      Ambilight:
        on_code:
          protocol: kaku_switch
          unit: 3
          id: 12345
          'on': 1
        off_code:
          protocol: kaku_switch
          unit: 3
          id: 12345
          'off': 1
        on_code_receive:
          protocol: kaku_switch
          unit: 3
          id: 12345
          'on': 1
        off_code_receive:
          protocol: kaku_switch
          unit: 3
          id: 12345
          'off': 1

If you use the actual kaku switch like your remote or wall switch and cannot see it change in HA. Try changing on and off_code_receive:
protocol to arctech_switch instead of kaku_switch.

hi, thx for reply.

I do not use a remote or wall switch.

I only use the Web GUI from Pilight.

If I change in HA from off to on, I see the same thing in the Pilight Web GUI.

If I change in the Pilight Web GUI from off to on, nothing happened in HA.

So I guess, its because HA get no receive status from the Pilight.

Oké. I just tested it myself. Did take a while because i don’t have the webserver enabled and had no devices configured, because i don’t use the pilight gui. And i also don’t see the state changes. I think it is because when you send a code only the sender is used to send the code, the receiver doesn’t listen for that code. So it is not an received code and HA won’t change the state. If you were using a remote for example then the code would have been received by Pilight and thus also by HA.

But may i ask why you want to use the pilight webgui, in my opinion it looks not that nice :smile: ?

Thx for testing this out.

Its not the Web Gui I want to use. Its because at this moment, I configured pilight to work with homebridge and the Pilight iOS app pilightControll (which also use the Pilight API and state changes work well) and it is the same problem. At this moment all config is done in the pilight config.json. I have a lot of devices added and I try to test Home-Assistant.

I guess there a must be a way see the state changes in HA because the API can do this.

Edit
And I thought the Pilight API delivers all device information. So I’m little confused that I have to add Protocol, ID, Unid…to Home-Assistant. :smile:

No problem! I didn’t know you could set up pilight to work with homebrige. I have Home-Assistant setup with homebridge.
But there’s always a way to make it work, but i’m afraid i can’t help you with it. (above my knowledge :slight_smile:)

Yeah i read the pilight api can do that, but i don’t think it is used for home assistant, because that means you have to setup everything in pilight and keep maintaining it. (for you it would have been great, but for people who want to have everything in one place this way is better because you only have to configure it within home assistant.

I added HA to homebridge, too.
But at this moment HA runs on a Mac Mini Server and Pilight and Homebridge on the Raspberry Pi 1. I hope, after a little HA practice I can switch completely to HA and I runs this on a Pi 3.
Thanks for the help :wink:

Anybody having this error after uprading to 0.32.1 :

16-11-06 11:30:35 homeassistant.components.switch: Error while setting up platform pilight
Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 148, in _async_setup_platform
    entity_platform.add_entities, discovery_info
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/switch/pilight.py", line 63, in setup_platform
    properties.get(CONF_OFF_CODE_RECIEVE)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/switch/pilight.py", line 84, in __init__
    if any(self._code_on_receive) or any(self._code_off_receive):
TypeError: 'NoneType' object is not iterable

Same error for me and 0.32.1

Will investigate. Guess a workaround is to just define a fake on_code_receive. The manual shows how.

I did this.

Now I see the Toggle in HA, but nothing happened if I switch on/off.

No pilight errors logged

Can you pls look, if its possible to get a stat receive, if the switch are configured in the Pilight config.cfg ?
Auto discovery switch would be realy nice, too. The Pilight API can do this.

- platform: pilight
  switches:
    Ambilight:
      on_code:
        protocol: kaku_switch
        unit: 3
        id: 19608594
        'on': 1
      off_code:
        protocol: kaku_switch
        unit: 3
        id: 19608594
        'off': 1
      on_code_receive:
        protocol: daycom
        unit: 3
        id: 19608594
        state: 'on'
      off_code_receive:
        protocol: daycom
        unit: 3
        id: 19608594
        state: 'off'

I did some checking and figured out this:
I changed the following:
/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/switch/pilight.py
SWITCHES_SCHEMA = vol.Schema({
vol.Required(CONF_ON_CODE): COMMAND_SCHEMA,
vol.Required(CONF_OFF_CODE): COMMAND_SCHEMA,
vol.Optional(CONF_NAME): cv.string,
vol.Optional(CONF_OFF_CODE_RECIEVE, default={}): COMMAND_SCHEMA,
vol.Optional(CONF_ON_CODE_RECIEVE, default={}): COMMAND_SCHEMA,

The component loads but still the switches don’t work. The message says json
{‘protocol’: [‘kaku_switch_old’], ‘unit’: 1, ‘id’: 1, ‘on’: 1}

But when i test a pilight send service with:
{“protocol”: [“kaku_switch_old”], “unit”: 1, “id”: 1, “on”: 1}
it does work

It looks like the issue is in the json it is sending to the pilight deamon. But this is as far as my knowledge goes.

Please do not forget that the github repository is meant for issues. I created a new issues. In the forum the issues might not be seen.
I created a quick hotfix, thus the pilight switch will hopefully start working again in release 0.32.2.

Ok will remember that. I’m on 32.2 now an the component loads. But when a switch is toggled i get this error message:

16-11-07 13:36:13 homeassistant.components.pilight: Pilight send failed for {‘unit’: ‘0’, ‘on’: 1, ‘id’: 12690930, ‘protocol’: [‘kaku_switch’]}

So sending is not working yet, and i don’t see received messages.

i created an issue on github (first time) #4282.