Pilight and pilight_received as a trigger

I’m trying to use a 433 remote control but something is wrong. I’ve tried:

- alias: Test kontroll nexa on
    initial_state: 'on'
    trigger:
      platform: event
      event_type: pilight_received
      event_data:
        protocol: arctech_switch
        uuid: '0000-b8-27-eb-4395d9'
        unit: '11'
        state: 'on'
    action:
      - service: notify.notify
        data_template:
          message: >
            Event data is {{ trigger.event.data.event }}

…but there is no event data is the notifications. Are you supposed to use the values you get from:

sudo pilight-receive -S 127.0.0.1 -P 5000

…directly or do you have to enter them into the pilight config file first. I was under the impression that the entries into the _/etc/pilight/settings.json_was only for the pilight webinterface, which I’m not interested in. But since the yaml above doesn’t work, I’d be happy for some guidance.

So the automation is triggering?

If so, change logger to ‘info’ and take a look at the event data and tailor your message off the json response.

1 Like

That was good advice, thank you. If I look at the log, when only using event_type: pilight_received as a trigger without the event_data part, I see:

Bus:Handling <Event pilight_received[L]: id=26591534, protocol=arctech_switch, unit=11, state=on, uuid=0000-b8-27-eb-4395d9>

With the even_data included I don’t see anything relevant in the log, so I guess my trigger isn’t matching. To me, it looks like it should. Do you see what’s wrong?

Looks to me like your trigger matches the event. Is the event firing or is the event data emtpy? You may just need {{ trigger.event }}. That may push all the info you care about

I don’t think it’s firing: last_triggered: null

remove the quotes around 11? That appears to be a number not a string.

1 Like

I’ll try that. I tried using just the protocol in the event_data. Now it’s firing. Still, notify gives me no data so I went to the log. The strange thing is, even though I’ve changed nothing, the log function doesn’t work any more. it just says:

2018-05-11 19:01:27 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting

Well, I don’t think you ahve any event data. Event data is data passed in the data section. Everything your event contains is at the root level. So I would think it would just be {{ trigger.event }} to see everything. {{ trigger.event.state }} to get the state, {{ trigger.event.unit }} to get the unit and so forth.

1 Like

I tried your suggestion now. It works! Thank you.

1 Like

As it turns out, it was trigger.event.data["state"] I was looking for.

So the working setup would be:

- alias: Test control nexa
  initial_state: 'on'
  trigger:
    platform: event
    event_type: pilight_received
    event_data:
      protocol: arctech_switch
      uuid: '0000-b8-27-eb-4395d9'
      unit: 11
  action:
    - service: input_number.set_value
      data_template:
        entity_id: input_number.dimmer_value
        value: >
          {% if (trigger.event.data["state"] == 'on') %}                                        
            {{ [(float(states.input_number.dimmer_value.state) + 10), 600]|min }}
          {% elif (trigger.event.data["state"] == 'off') %}                                           
            {{ [(float(states.input_number.dimmer_value.state) - 10), 0]|max }}
          {% else %}
            {{ -1 }}
          {% endif %}

it works, but the delay needed between two presses is a bit disappointing for my purposes. I think the problem is in the implementation of the HA module. With pilight-receive I see no such restriction. I understand why it’s there – over zealous controllers – but I wish there was a way to choose yourself how restrictive the filtering should be. Maybe @DavidLP could implement such a feature at some point. I think it would be great in the cases where you would want to use a button to increase/decrease a light incrementally with multiple presses or just holding the button. Would that be possible? Or is it already possible, and I’m just too daft to realize it?

I’m not entirely sure how the device itself works because I’ve never used it so I can’t really give input. Typically devices that have double press and hold capabilities report different events. There may be settings in the device it self to expose these events.