Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RfRaw combining #5

Open
aliasKC opened this issue Sep 22, 2020 · 1 comment
Open

RfRaw combining #5

aliasKC opened this issue Sep 22, 2020 · 1 comment

Comments

@aliasKC
Copy link

aliasKC commented Sep 22, 2020

Hello,
when a "RfRaw massage" (possible because portisch firmware on the Rf bridge) is transmittet, homebridge stops working. Error massage: "TypeError: Cannot read property 'Data' of undefined". I think this error comes from mqtt-motionssensor does not filter the RfRaw massages quit well. The skript only expects "rfReceived" massages to be transmitted. You can see this at index.js row 66. I am not able to solve this issue because i dont know much about this.. Using RfRaw is quit important to me, to get every outlet work. Thank you.

@githubberboy
Copy link

githubberboy commented Nov 10, 2021

I've experienced the same problem. I've solved modifying the index.js as follow.

Line43

this.client.on('message', function (topic, message) {
		try {
			var data = JSON.parse(message);
			if (data === null) return null;
			self.value = Boolean(parseInt(data,10));
			self.service.getCharacteristic(Characteristic.MotionDetected).setValue(self.value);
		} catch (e) {
			var data = message.toString();
			if (data === null) return null;
			if (data === self.onValue) self.value = 1;
			if (data === self.offValue) self.value = 0;
			self.service.getCharacteristic(Characteristic.MotionDetected).setValue(self.value);
		}

and adding this before:

	this.onValue = (config["onValue"] !== undefined) ? config["onValue"] : "ON"; 
	this.offValue = (config["offValue"] !== undefined) ? config["offValue"] : "OFF";

Now you can set in config.json the onValue and offValue (1,0,ON,OFF...)

     "accessory": "mqtt-motionsensor",
     "name": "xxx",
     "url": "xxx",
     "topic": "xxx",
     "username": "",
     "password": "",
     "onValue": "ON",
     "offValue": "OFF"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants