DheerajKhajuria / pimatic-mysensors

mysensors
http://forum.mysensors.org/topic/797/pimatic-mysensors-controller-plugin
GNU General Public License v2.0
23 stars 24 forks source link

Added the MySensorsMulti class and added a fix for battery percentages #37

Closed PascalLaurens closed 8 years ago

PascalLaurens commented 8 years ago

With the help of @sweebee and @mwittig, I created the MySensorsMulti class. It supports multiple sensors. You can combine the sensors (that send numbers, booleans, strings or battery information) that you want.

I also added a fix when battery percentages higher then 100% are being send.

sebastianha commented 8 years ago

Thanks for the multi sensor, that's exactly what I have been looking for. Please take a look at #39 which I came across, perhaps you agree with me.

One thing which came to my mind when using it: is there any reason to keep all the fixed-value sensor types which are currently available in pimatic-mysensors? Most of them can be mapped with the multi sensor, or am I wrong?

It would massively clean up the code and I think there could be examples available which replace all the "old" sensor definitions. I know that this would break old configs but I think this is worth it for better code maintainability and readability.

PascalLaurens commented 8 years ago

@sebastianha I'm glad you like the multi sensor. I agree on you with the emit part

I don't know how others think about the removal of other classes. Are you using the multi sensor class for a while?

I noticed that rules don't work very well with the multi sensor class. I have a PIR and a light sensor, added to a device with the multi class. They are being recognized by the rule system (like 'pir of Multi Sensor'), but a rule with the light sensor or a rule with the light sensor and the PIR doesn't work. When I use the standalone PIR and Light classes, the rules do work.

I think that has to be fixed, before removing other classes.

sebastianha commented 8 years ago

Oh, ok. I am relatively new to this. Could this be related to #39 ? I will take a look at rules and get deeper into pimatic, soon, perhaps I find the bug.

I developed a sensor which measures Temperature, Humidity and Pressure (DHT22, BMP180 and an optional DS18B20) which sends the data via 433MHz (one way, sender only) to a mysensors-protocol compliant Serial gateway.

I first added all the sensors individually (DHT, BMP, ...) but as it is one device I liked the multi-sensor with all sensors better.

Here is a photo of the sensor. It also does report battery percentage and can be charged via USB.

sensor

I think the goal should be to generalize the sensor definition because in the current state I think the code is barely maintainable and has to much duplicate logic/code.