Pilight configuration

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.

Yes, I see the same. Very weird. I checked the hotfix with 32.0 and it seemed to work, this is maybe another bug.

Hi David,
This is what I found out:

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

Ok THX. Maybe the event data was changed. I’ll look into that.

@DavidLP Can you please explain what is the function of on_code_receive and off_code_receive? What is the usecase?

Below is a part of my configuration. But it seems to work with and without the code.

switch:
  - platform: pilight
    switches:
      Staande lamp:
        on_code:
          protocol: kaku_dimmer
          id: 8945842
          unit: 0
          'on': 1
          dimlevel: 2
        off_code:
          protocol: kaku_dimmer
          id: 8945842
          unit: 0
          'off': 1
      Witte lamp:
        on_code:
          protocol: kaku_switch
          id: 8945842
          unit: 1
          'on': 1
        off_code:
          protocol: kaku_switch
          id: 8945842
          unit: 1
          'off': 1
        on_code_receive:
          protocol: kaku_switch
          id: 8945842
          unit: 1
          state: 'on'
          echo: false
        off_code_receive:
          protocol: kaku_switch
          id: 8945842
          unit: 1
          state: 'off'
          echo: false    indent preformatted text by 4 spaces

hey,

i’m also new to HA and Pilight and want to install both on one Pi (my RPi Zero W). Hass.io is running fine, but what do i have to do to install Pilight? I read some posts above, that you have to install it from source. What does that mean (sorry, I’m a newbie :slight_smile: ) Is installing pilight from source described at the end of this guide?
http://manual.pilight.org/installation.html

Thanks!

Just seen this and thought I’d answer it tho’ you probably know by now, the on/off_code_receive is for when you have a remote that is switching the target on/off, it means HA and the target stay in sink when a remote is used.

I don’t think you can install pilight under Hassio, with Hassio you use docker addons so if no one has written one you will have to write it yourself.

There already is an 3rd Party Aden :slight_smile:

https://github.com/pschmitt/hassio-addons

1 Like