433MHz receiver on Raspberry Pi

Yes! Works perfect! Super! I think now I can also check the 433mhz light switch if it was pressed or not ! super - this is for updateing the gui when automations turned light on/off…

I think this is a question for @DavidLP

I’ve got Pilight set up and everything is working on the whole the only issue I have is this.

I have a 433 motion sensor in Pilight and when it detects movement it sends a lot of messages like this:

{
    "message": {
            "systemcode": 24,
            "unitcode": 31,
            "state": "on"
    },
    "origin": "receiver",
    "protocol": "elro_800_switch",
    "uuid": "0000-b8-27-eb-2b36a5",
    "repeats": 1
}
{
    "message": {
            "unitcode": 521538,
            "state": "closed"
    },
    "origin": "receiver",
    "protocol": "ev1527",
    "uuid": "0000-b8-27-eb-2b36a5",
    "repeats": 1
}
{
    "message": {
            "systemcode": 24,
            "unitcode": 31,
            "state": "on"
    },
    "origin": "receiver",
    "protocol": "elro_800_switch",
    "uuid": "0000-b8-27-eb-2b36a5",
    "repeats": 2
}
{
    "message": {
            "unitcode": 521538,
            "state": "closed"
    },
    "origin": "receiver",
    "protocol": "ev1527",
    "uuid": "0000-b8-27-eb-2b36a5",
    "repeats": 2
}
{
    "message": {
            "systemcode": 24,
            "unitcode": 31,
            "state": "on"
    },

So basically the PIR spits out an elro_800_switch as “on” when there is movement and a ev1527 as “closed” when the sensor closes (or at least this is my interpretation). The problem I’m having is that if my pilight sensor in HA is set to watch the ‘state’ of the ev1527 it shows as Closed at all times and if I set it up to watch the ‘state’ of elro_800_switch it always shows as “on”. Any good ideas to workaround this problem?

Also the above is just a portion of the output that the PIR spits out for just one event of movement - is there anyway either in pilight or the HA sensor to limit how much a pilight sensor can throw into the event bus?

Thanks in advance.

Hi privatesam,

To your first question (event bus spamming):

You get a lot of messages because the binary stream fits a lot of different (or not so different …) protocolls. Usually it makes sence to compile pilight only with the procotolls of the devices you own (check troubleshooting section in the manual).

Additionally there are two other methods in place to prevent event bus spamming:

  1. There is a whitelist feature in the pilight hub component. In your case you can e.g. specify that only messages with the ev1527 protocol are put onto the event bus.
  2. Messages are often repeated, to make sure that the receiver gets it. While you see all repeated messages in the pilight-debug output you show, they are not put onto the HA event bus! Only the first repeat is forwarded to home-assistant.

To you second question (sensor for movement):

As you found out the motion detector only sends a message when a movement is detected, but since there is no no movement message I would not use a HASS sensor for this. A sensor has a state, but movement is not state but a trigger. So just create an automation that trriggers on the movement event, without a sensor.

cheers,
David

Thanks so much for the reply. So useful to know about the whitelist - I think I had skimmed that when I read the documentation but that perfect.

I think I understand what you mean for using the automation instead - i.e its a trigger not a state, but how do I express this in a HASS automation - what do I write for the ‘movement event’ under the trigger section? I would normally write an automation off the back of a state change in a motion sensor.

i have seen several threads on the forum about motion detectors who only send movement and no “no movement”
most people seek a way to set the sensor to “no movement” after a little time.
i dont recall if there were any succesfull results, but i think its wise to search the forum.

some off them were also about door sensors which didnt detect close, just opening.

i dont see a way to make a trigger from a movement without a sensor.
there is no event for movement, just for state change.

@privatesam @ReneTode

You want an event that is fired when the received pilight code says that the movement sensor triggered.
Thus do the following e.g.: (like I mentioned above in this thread ;-)):

automation:
   trigger:
     platform: event
     event_type: pilight_received
     event_data:
       protocol: ev1527
       uuid: 0000-b8-27-eb-2b36a5
    ...

You do not have to misuse the state change of a sensor as a trigger.

cheers,
David

are there any more events that are not mentioned in the documentation?

i looked at


to check out if there were other events, pilight recieved isnt mentioned as a possible event.

OHHHHH!!!

I see! Brilliant thanks for this. Through my ‘understanding’ of the documentation there were two ways to integrate Pilight - through a Switch and a Sensor - I didn’t realise we could address Pilight events directly like that! I guess Pilight is just pumping its events onto the HASS event bus. Gives me some more ideas!

Thanks for taking the time to explain this David - maybe I/someone should write this as a note for the Pilight documentation in case, like me, they didn’t get it.

@ReneTode @privatesam
I agree that the event system is not known /does not have to be known to the average user and the explanation in the pilight docu is much too short here. An example how to trigger on a move event would be great. Maybe one of you want to extend the docu?

@ReneTode:
Your link explains some build-in events of Home Assistant. But a lot of components create their own events. The internal communication in HASS is done via the event bus. When you have a hub compenent for some protocol/interface the received data is put on the event bus to make them available to other components. These other components are e.g. switches, lights, automation, etc.This concept is for example also used for the mqtt components. To check what events are created in your setup just click on the developer tools:

@privatesam

Yes, the real deal is the pilight hub component offering pilight_received events and a send service. The switch / sensor components just make use of this hub component.

This concept is very generic. One can e.g. just look for a temperatur value in the data to trigger an automation. No additional components are needed.

cheers,
David

thx for the explenation david.

in my case there is not much more there, then in the documentation. :wink:
but it is nice to know there is more, because then i can help others more.

i didnt know that components also could have own events. on the formentioned page it only says that components can fire and listen to events. not that they can have its own type off event. thats why i asked.

Hi, I receive this error ?

17-02-26 16:01:41 ERROR (Thread-10) [homeassistant.components.pilight] Unable to connect to 192.168.1.239 on port 5000: [Errno 111] Connection refused
17-02-26 16:01:41 ERROR (MainThread) [homeassistant.bootstrap] component pilight failed to initialize

that’s a pilight error. Need to check your /etc/pilight/config.json and make sure either a) your ports are set up correctly or b) that pilight is actually running (ps -A | grep pilight)

Is it running?

pi@raspberrypi:~ $ ps -A | grep pilight
  518 ?        00:00:00 pilight-daemon
pi@raspberrypi:~ $

is it correct?

{
	"devices": {},
	"rules": {},
	"gui": {},
	"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
	},
	"hardware": {
		"433gpio": {
			"sender": 0,
			"receiver": 1
		}
	},
	"registry": {
		"pilight": {
			"version": {
				"current": "7.0"
			}
		}
	}
}

stop/kill pilight and edit the /etc/pilight/config.json file. If pilight is running it’ll just throw away any changes done.

after the line

webserver-http-port": 5001,

add the line

"port": 5000,

and restart pilight. After that you should be good to go

how to do this?

get the pid of it

ps -A | grep pilight-daemon

and then

sudo kill (the pid of pilight)

quick and easy

did it, now the file looks like below.

In configuration is fine lwith 5000 or should be 5001?

pilight:
host: 192.168.1.239
port: 5000

{
	"devices": {},
	"rules": {},
	"gui": {},
	"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,
                "port": 5000,
		"webserver-cache": 1
	},
	"hardware": {
		"433gpio": {
			"sender": 0,
			"receiver": 1
		}
	},
	"registry": {
		"pilight": {
			"version": {
				"current": "7.0"
			}
		}
	}
}

it looks like mine now. I was having the same issue and that was what I needed to do in order to get it to work.

I’m having problems triggering automations based on pilight_received events.
I can se it on the event bus:

Bus:Handling <Event pilight_received[L]: protocol=arctech_switch, uuid=0000-74-xx-66-271e3b, id=60562, unit=0, state=on>

And my automation is:

- action:
  - data:
      entity_id: switch.martins_lampa_sovrum
    service: homeassistant.turn_on
  alias: '[TOGGLE] Martins lampa'
  id: '2413717836378'
  trigger:
  - event_data:
      id: '60562'
      protocol: arctech_switch
      state: 'on'
      unit: '0'
      uuid: 0000-74-xx-66-271e3b
    event_type: pilight_received
    platform: event

But the automation is never triggered.