Pilight yaml configuration probem

I am having problem configuring pilight. I want to configure my Etekcity outlets and control them through Home Assistant.

Pilight is working normally, I can turn on and off the outlet and pilight detects change of state even if I use the remote.

I also want to configure HA with pilight_switch…and I just cannot get the yaml config working. As ID pilight-receive gets the following output:

{
        "message": {
                "id": "A2",
                "unit": 4,
                "state": "on"
        },
        "origin": "receiver",
        "protocol": "clarus_switch",
        "uuid": "0000-b8-27-eb-7b7b97",
        "repeats": 1
}

But if I enter A2 as ID in yaml there is an error, because int is expected. What is the right configuration?

Don’t know how to set “on” and “off” command as well since pilight-receive gets the same input for on and off only the state is reported as “off” when pressing the off button on the remote.

My yaml:

- platform: pilight
  switches:
    etekcity1:
      on_code:
        protocol: clarus_switch
        unit: 4
#        id: A2
        'on': 1
      off_code:
        protocol: clarus_switch
        unit: 4
#        id: A2
        'off': 1

@DavidLP answered a lot of questions in another topic which helped me get pilght running, unfortunately I am stuck now.

Any help would be greatly appreciated.

1 Like

I have the same problem, hopefully there is a solution as it would be great to integrate Pilight with Home Assistant!

FYI - I have opened an issue for this on GitHub: https://github.com/home-assistant/home-assistant/issues/5119

2 Likes

Great, thank you!

I hope somebody can fix it, it should be fairly easy. Instead of int, the allowed argument should also be a string.

Yes you got it right. The argument should be also valid for string. I commited a bug fix but it would be nice if you guys could test before this gets merged and breaks other configs. HOWTO follows in next post.

Please check the pilight switch bugfix. This howto will not work under Windows out of the box.

  1. You need to go to to the homeassistant/components/switch folder. If you checked out the code using git then this is easy and you should now where the code is ;-). If you installed home-assistant via pip install homeassistant or python setup.py install you have to search for this folder in your site-package path of your python distribution. To get the location of the site-package folder type:
    python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'
    In the site-package you should see the homeassistant/components/switch folder

  2. Within the homeassistant/components/switch folder run:
    wget https://raw.githubusercontent.com/DavidLP/home-assistant/dev/homeassistant/components/switch/pilight.py to overwrite your file with the fixed one.

  3. Restart hass and check if devices work. Thanks!

1 Like

I’ll test it. I installed HASS using All-In-One Installer.

How can I locate my homeassistant/components/switch folder?

Great! Find your site-package path first as mentioned above.

Ok, I put python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())' in terminal and got response for my site-package:

/usr/lib/python2.7/dist-packages

Went to this directory on my pi, but there is no homeassistant/components/switch folder…

So in terminal I go to:

cd /usr/lib/python2.7/dist-packages

and then to:

cd homeassistant/components/switch ?

Where I would have to run command you wrote in your previous post?

Well, this command gives you only the correct site-package path when you call it within the virtual environment used by hass. Let’s just find the correct folder manually. The all-in-one-docu says that the virtual environment is in /srv/homeassistant/homeassistant_venv. In this folder (incl. subfolders) you can find site-package and thus the hass code.

Great, thank you, I found the directory in

/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/switch

Unfortunately I have to go now and will be back in the evening to finish it and I’ll report back.

Hi David, many thanks for the fix!!!

I have just tested and all is working well. I have 5 clarus_switch protocol devices all with alphanumeric IDs and all are working.

@SmartValley - FYI: When I originally ran the wget it didn’t overwrite the file and instead saved a new copy pilight.py.1, I had to rename the original file then run the wget again.

Thanks for the fix again David, so happy that everything is now in Home Assistant :smiley:!

1 Like

That’s nice to hear. Thank you for testing. I am going to recommend releasing the bug-fix for the next hass release.

cheers,
David

2 Likes

I am back and it works perfectly!!! Thank you for amazing work @DavidLP !!!

Thank you for the tip @Dullage, worked like a charm! :smiley:

Really happy that all is integrated in Home Assistant now, I can also use the RF remote and Home Assistant detects change of state perfectly.

1 Like

Can you share your config for the switch. I keep getting an error.

If you didn’t use the bugfix @DavidLP posted in his reply, it will not work for you, because the fix hasn’t been yet implemented in HA. Have a look GitHub and GitHub2. They are still working on it. I hope it gets merged for 0.37.

Otherwise, there is my config for one of the switches:

- platform: pilight
  switches:
    etekcity1:
      on_code:
        protocol: clarus_switch
        unit: 4
        id: A2
        'on': 1
      off_code:
        protocol: clarus_switch
        unit: 4
        id: A2
        'off': 1
      on_code_receive:
        protocol: clarus_switch
        unit: 4
        id: A2
        state: 'on'
      off_code_receive:
        protocol: clarus_switch
        unit: 4
        id: A2
        state: 'off'

Hope it helps :slight_smile:

Thanks, that works

Just wondering if anyone else is experiencing random triggers with the pilight switch?

Alphanumeric ids should start working in version 0.37.1. Also there is a new protocol option called echo. This should be set to false if the on_code_receive matches the on_code (same also for off). This prevents to resend a received code, since one can assume that the hardware was toggled already.

    switch_01:
      on_code:
        protocol: intertechno_switch
        id: 58318848
        unit: 2
        'on': 1
      on_code_receive:
        - protocol: arctech_switch
          id: 58318848
          unit: 2
          state: 'on'
          echo: false
      off_code:
        protocol: intertechno_switch
        id: 58318848
        unit: 2
        'off': 1
      off_code_receive:
        - protocol: arctech_switch
          id: 58318848
          unit: 2
          state: 'off'
          echo: false

Thank you, I’ll test when 0.37.1 is available.

Random triggers means that there is an entry in the log file that a switch switched (please check). If this is the case one could reduce the false positives by requiring a code to be received several times to be considered correct. This is a pilight library feature and can be activated in the config. E.g.: receive-repeats: 2 would only trigger anything if the code is received 2 times consecutively. All 433 remotes I came across do actually send codes several times.