Pilight configuration

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

Hey guys, I feel a little like I’m banging my head against a wall here. I’d appreciate any input!

I’ve got pilight, homeassistant and Alexa Voice service installed on a Pi3, HA is installed in virtual env.

I’ve got various rf sockets that I control using HA with homebridge and/or alexa. All working nicely. But I want to be able to use a remote too, so that if I have a guest staying they can use a remote control to operate said lights and this then update in HA. I also want to add further RF stuff like door and weather monitoring etc, but I can’t get HA to receive from pilight.

The Pilight gui reflects my remote control operating, and it works when using HA dashboard. But when I use the remote, it doesn’t update the HA dashboard with whether it’s on/off.

Firstly, here’s my pilight config.json:

{
    "devices": {
            "ambilight": {
                    "protocol": [ "kaku_switch" ],
                    "id": [{
                            "id": 5628626,
                            "unit": 1
                    }],
                    "state": "off"
            }
    },
    "rules": {},
    "gui": {
            "ambilight": {
                    "name": "ambilight",
                    "group": [ "Lights" ],
                    "media": [ "all" ],
                    "readonly": 0
            }
    },
    "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/webgui",
            "webserver-http-port": 5001,
            "webserver-https-port": 5002,
            "webserver-cache": 1,
            "port": 5000,
            "gpio-platform": "none"
    },
    "hardware": {
            "433nano": {
                    "comport": "/dev/ttyUSB0"
            }
    },
    "registry": {
            "webserver": {
                    "ssl": {
                            "certificate": {
                                    "secure": 0,
                                    "location": "/etc/pilight/pilight.pem"
                            }
                           }
                    }
            },
            "pilight": {
                    "firmware": {
                            "version": 1,
                            "lpf": 8,
                            "hpf": 1600
                    },
                    "version": {
                            "current": "8.0.8"
                    }
            }
}}

Here’s my HA configuration.yaml:

pilight:
  host: 127.0.0.1
  port: 5000

My switch.yaml:

- platform: pilight
  switches:
    Ambilight:
      on_code:
        protocol: kaku_switch
        unit: 0
        id: 5628626
        'on': 1
      off_code:
        protocol: kaku_switch
        unit: 0
        id: 5628626
        'off': 1
      on_code_receive:
        protocol: kaku_switch
        id: 5628626
        unit: 0
        state: 'on'
        echi: false
      off_code_receive:
        protocol: kaku_switch
        id: 5628626
        unit: 0
        state: 'off'
        echo: false

Here’s my output from pilight-receive:

{
	"message": {
		"id": 5628626,
		"unit": 1,
		"state": "on"
	},
	"origin": "receiver",
	"protocol": "arctech_switch",
	"uuid": "0000-b8-27-eb-09d9a5",
	"repeats": 1
}
{
	"message": {
		"id": 5628626,
		"unit": 1,
		"state": "off"
	},
	"origin": "receiver",
	"protocol": "arctech_switch",
	"uuid": "0000-b8-27-eb-09d9a5",
	"repeats": 1
}

So when I operate the switch in HA, it operates the switch in plight gui. But if i use the remote, it operates the pilight gui but doesn’t update the HA dashboard.

Any idea where I might be going wrong? Thanks!

This is probably supposed to be echo I think :wink:

Thanks Keith, you know how you stare at code for so long and miss the obvious!
Well unfortunately it made no difference.

I don’t see why it shouldn’t be working, I don’t get any errors in homeassistant.log. Weirdly if I run pilight-daemon -d when pilight isn’t running it stops picking up the remote and HA’s dashboard button but only responds to the pilight gui which does give output.

It’s my understanding that with the pilight details in HA configuration.yaml that whenever pilight picks up a remote signal it dumps it on HA’s event bus, is there anyway to see whether that’s actually happening?

I thought i’d have a go with using automation to try and switch an existing HA switch. So added this to my automations.yaml:

- alias: "lamp off"
  initial_state: true
  hide_entity: false
  trigger:
    platform: event
    event_type: pilight_received
    event_data:
      protocol: kaku_switch
      uuid: 0000-b8-27-eb-09d9a5
      id: '5628626'
      unit: 1
      state: 'off'
  action:
    - service: homeassistant.turn_off
      entity_id: switch.lounge_lamp

- alias: lamp on
  initial_state: true
  hide_entity: false
  trigger:
    platform: event
    event_type: pilight_received
    event_data:
      protocol: kaku_switch
      uuid: 0000-b8-27-eb-09d9a5
      id: 5628626
      unit: 1
      state: 'on'
  action:
    - service: homeassistant.turn_off
      entity_id: switch.lounge_lamp

This doesn’t give me anything either so assuming that HA isnt’t getting anything from pilight. Hmm, i’m stumped.

Maybe try changing the echo: false to true, so that pilight will send the code out again, then It might tell HA about it?

EDIT: Spotted it I think your unit in the yaml is wrong :stuck_out_tongue:

Thanks for your input Keith, that wasn’t actually it but you pointed me in the right direction. The unit was down to me messing with different configs/switches. Mate, i’m so chuffed, now I can use it for other stuff too.

I can point where I went wrong. So I looked into the echo option, and found this thread. Davidlp explains its use. But I noticed from his config how he had a different protocol for on_code and on_received_code. My switch protocol was showing up under pilight-receive as arctech_switch, but couldn’t get it to work to send with that, as pilight uses kaku_Switch. I changed my on_code_receieved to arctech_switch and boom, she works! Hurrah!

So my final switch.yaml looks like this, just for clarification if anyone else comes stumped on the same thing.

- platform: pilight
  switches:
    Ambilight:
      on_code:
        protocol: kaku_switch
        unit: 1
        id: 5628626
        'on': 1
      off_code:
        protocol: kaku_switch
        unit: 1
        id: 5628626
        'off': 1
      on_code_receive:
        protocol: arctech_switch
        id: 5628626
        unit: 1
        state: 'on'
        echo: true
      off_code_receive:
        protocol: arctech_switch
        id: 5628626
        unit: 1
        state: 'off'
        echo: true

Thanks for your help Keith, I appreciate your time and input mate, many thanks!

No worries glad you got it working, I have lot of respect for pilight it’s a great piece software :slight_smile: BTW mark it as solved so anyone can find it :slight_smile:

According to the pilight documentation protocol kaku_switch uses option “state” but then when defining the entry on the configuration.yaml we make use of ‘on’/‘off’ instead of “state”. What is that I have missed in the documentation?
The reason for asking is that I made use of state: 'on'and state: 'off'on the configuration.yaml file and obviously I could not get it to work.

I have installed Pilight on a second Raspberry Pi.
On my other Pi i have write in the configuration.yaml:

pilight:
  host: 192.168.1.107
  port: 5000

But it dont works :frowning:
Pilight will not find in Home Assistant.

When i write in the /etc/pilight/config.json file

„port“: 5000

and then rebooting the Pi is it always delete.

Hello,

  1. in PIlight you have to change settings when Pilight is stopped, otherwise it will overwrite the config on shutdown.
  2. Until now I never received updates from pilight sensors, i only can send switch commands to Pilight