pimatic / pimatic-homeduino

Pimatic plugin for using 433mhz devices and sensors with a connected Arduino with homeduino sketch
https://pimatic.org/
GNU General Public License v2.0
37 stars 29 forks source link

HomeduinoRFContactSensor inverted Graph #46

Closed WasVerzachter closed 8 years ago

WasVerzachter commented 8 years ago

Hi,

not sure to drop my question/request here; if wrong excuses for that. When using my HomeduinoRFContactSensor, it's normaly closed. Status in Homeduino is OK (and adjustable with labels), however when I click on the graph within Pimatic, the statusline is way up the baseline, however when the contact is open, the statusline drops to the baseline. Is it possible to invert the graph? I saw in the .coffee code the HomeduinoContactSensor supports the property inverted, the HomeduinoRFContactSensor not

homeduinorfcontactsensor

Would you be so kind to fix that? Thanks in advance, Was

sweetpi commented 8 years ago

The logic behind the decision to draw the graph this way is: The mapping of the attribute contact is "closed" = true and "opened" = false. The graph displays false as 0 and true as 1, resulting in the graph above.

The inverted attribute is unrelated to the graph. It just to invert the pin state, what is not applicable for RF sensors. I don't see a real reason to change this. It is more a request for a gui enhancement to have this ability.

You can invert the if condition in https://github.com/pimatic/pimatic-mobile-frontend/blob/3537b4958255be96fed7ac92346b8076b71d7177/app/pages/graph.coffee#L228 for your local installation. Im not planning to include a feature to swap the states. However if you can, fell free to submit a pull request with an enhancement, that allows to swap the states for each graph line.