home-assistant.io/source/_components/binary_sensor.mysensors.markdown
Franck Nijhof ebca3218c7
🔥Removes linkable_title everywhere (#9772)
* Automatically create linkable headers

* Visually improve position of linkable header chain icon

* Do not auto link  headers on homepage

* Remove linkable_title everywhere

* 🚑 Re-instante linkable_title plugin as NOOP
2019-07-04 19:08:27 +02:00

2.0 KiB

layout title description date sidebar comments sharing footer logo ha_category ha_release ha_iot_class
page MySensors Binary Sensor Instructions on how to integrate MySensors binary sensors into Home Assistant. 2016-04-13 14:20 +0100 true false true true mysensors.png
DIY
Binary Sensor
0.14 Local Push

Integrates MySensors binary sensors into Home Assistant. See the main component for configuration instructions.

The following sensor types are supported:

MySensors version 1.4 and higher

S_TYPE V_TYPE
S_DOOR V_TRIPPED
S_MOTION V_TRIPPED
S_SMOKE V_TRIPPED

MySensors version 1.5 and higher

S_TYPE V_TYPE
S_SPRINKLER V_TRIPPED
S_WATER_LEAK V_TRIPPED
S_SOUND V_TRIPPED
S_VIBRATION V_TRIPPED
S_MOISTURE V_TRIPPED

For more information, visit the serial api of MySensors.

Example sketch

/**
 * Documentation: http://www.mysensors.org
 * Support Forum: http://forum.mysensors.org
 *
 * http://www.mysensors.org/build/binary
 */


#include <MySensor.h>
#include <SPI.h>
#include <Bounce2.h>

#define SN "BinarySensor"
#define SV "1.0"
#define CHILD_ID 1
#define BUTTON_PIN 3  // Arduino Digital I/O pin for button/reed switch.

MySensor gw;
Bounce debouncer = Bounce();
MyMessage msg(CHILD_ID, V_TRIPPED);

void setup()
{
  gw.begin();
  gw.sendSketchInfo(SN, SV);
  // Setup the button.
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  // After setting up the button, setup debouncer.
  debouncer.attach(BUTTON_PIN);
  debouncer.interval(5);
  gw.present(CHILD_ID, S_DOOR);
  gw.send(msg.set(0));
}

void loop()
{
  if (debouncer.update()) {
    // Get the update value.
    int value = debouncer.read();
    // Send in the new value.
    gw.send(msg.set(value == LOW ? 1 : 0));
  }
}