Giter VIP home page Giter VIP logo

mysensors's Introduction

MySensors

Serial Gateway based on MySensors protocol communicating with HomeAssistant. Only Relays are visible as child id. All buttons are handled internally and gateway is sending relay status after action.

Buttons are set to:

  • Short click - flip status of relays in zone
  • Relese of long click - switch off all relays in zone
  • Double click - flip on relay in zone

At this point sketch is done for only ON/OFF status of relays.

Dependencies

  1. MySensors (2.3.2)
  2. OneButton (1.4.0)

Note: All above must be installed via Arduino IDE

Build

  1. Download Arduino IDE
  2. Download dependencies via Arduino IDE
  3. Download this repository
  4. Open sketch source file (gateway/gateway.ino) in Arduino IDE
  5. Click a Upload button to build and upload sketch

Modifications

See doc/Modification.md for detalis helping addopting this project for your needs.

Additional Info

Serial API

https://www.mysensors.org/download/serial_api_20

Sketches

https://www.mysensors.org/about/arduino#basic-structure-of-sketches

To do

  • longpress start/stop with flip as bistable switch
  • longpress start/stop with read as contactron
  • internally check if pump is not running without zones
  • lights dimming
  • add ds18b20 sensors reading
  • sense if HASS (HomeAssistant) is working to bypass heating control locally
  • small LCD for local control of heating
  • fix all Issues

License

GNU General Public License, version 2

mysensors's People

Contributors

kirizaki avatar th0m4sek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mysensors's Issues

Home-Assistant GUI not starting with connected board

I'm not sure if this is our bad implementation or something with Home-Assistant.
This issue need more investigation it is only reminder and some info for users.
It's enough to disconnect and connect back USB to start the GUI

Number of sensors

After some tests, it looks like script can't handle more than 30-35 sensors.

Sample code:

/**
 * @file Mapping.hpp
 * @author Grzegorz Krajewski
 *
 * Mappings.
 *
 * @license GPL V2
 */

#pragma once

#include <OneButton.h>
#include "../CustomSensor/CustomSensor.hpp"

namespace Relay {
  const uint8_t OFF  = 0;
  const uint8_t ON   = 1;
  const uint8_t FLIP = 2;
}
const bool ActiveLow = true;

// Child ID declaration of relays
const uint8_t SALOON_1_ID       = 1;
const uint8_t SALOON_2_ID       = 2;
const uint8_t SALOON_3_ID       = 3;
const uint8_t GAMING_ROOM_1_ID  = 4;
const uint8_t GAMING_ROOM_2_ID  = 5;
const uint8_t BEDROOM_ID        = 6;
const uint8_t BED_1_ID          = 7;
const uint8_t BED_2_ID          = 8;
const uint8_t GUESTS_ID         = 9;
const uint8_t BATHROOM_1_ID     = 10;
const uint8_t BATHROOM_2_ID     = 11;
const uint8_t MIRROR_ID         = 12;
const uint8_t FAN_ID            = 13;
const uint8_t KITCHEN_1_ID      = 14;
const uint8_t KITCHEN_2_ID      = 15;
const uint8_t KITCHEN_TABLE_ID  = 16;
const uint8_t WORKSHOP_ID       = 17;
const uint8_t CORRIDOR_ID       = 18;
const uint8_t PUMP_ID           = 19;
const uint8_t HEATING_1_ID      = 20;
const uint8_t HEATING_2_ID      = 21;
const uint8_t HEATING_3_ID      = 22;
const uint8_t HEATING_4_ID      = 23;
const uint8_t HEATING_5_ID      = 24;
const uint8_t HEATING_6_ID      = 25;
const uint8_t HEATING_7_ID      = 26;
const uint8_t TEST_1_ID         = 27;
const uint8_t TEST_2_ID         = 28;
const uint8_t TEST_3_ID         = 29;
const uint8_t TEST_4_ID         = 30;
const uint8_t TEST_5_ID         = 31;
const uint8_t TEST_6_ID         = 32;
const uint8_t TEST_7_ID         = 33;
const uint8_t TEST_8_ID         = 34;
const uint8_t TEST_9_ID         = 35;
const uint8_t TEST_10_ID        = 36;
const uint8_t TEST_11_ID        = 37;
const uint8_t TEST_12_ID        = 38;
const uint8_t TEST_13_ID        = 39;
const uint8_t TEST_14_ID        = 40;

// Vector contaning child ID, description, output pin, ActiveLow as option
std::vector<CustomSensor> customSensors = std::vector<CustomSensor>() = {
  { CustomSensor(SALOON_1_ID,       "Salon S1",       2) },
  { CustomSensor(SALOON_2_ID,       "Salon S2",       3) },
  { CustomSensor(SALOON_3_ID,       "Salon Lampka",   4) },
  { CustomSensor(GAMING_ROOM_1_ID,  "Gralnia S1",     5) },
  { CustomSensor(GAMING_ROOM_2_ID,  "Gralnia S2",     6) },
  { CustomSensor(BEDROOM_ID,        "Sypialnia",      7) },
  { CustomSensor(BED_1_ID,          "Lozko 1",        8) },
  { CustomSensor(BED_2_ID,          "Lozko 2",        9) },
  { CustomSensor(GUESTS_ID,         "Goscinny",       10) },
  { CustomSensor(BATHROOM_1_ID,     "Lazienka",       11) },
  { CustomSensor(BATHROOM_2_ID,     "Prysznic",       12) },
  { CustomSensor(MIRROR_ID,         "Lustro",         13) },
  { CustomSensor(FAN_ID,            "Wentylator",     14) },
  { CustomSensor(KITCHEN_1_ID,      "Kuchnia",        15) },
  { CustomSensor(KITCHEN_2_ID,      "Kuchnia ledy",   16) },
  { CustomSensor(KITCHEN_TABLE_ID,  "Kuchnia stolik", 17) },
  { CustomSensor(WORKSHOP_ID,       "Warsztat",       18) },
  { CustomSensor(CORRIDOR_ID,       "Korytarz",       19) },
  { CustomSensor(PUMP_ID,           "Pompa",          20) },
  { CustomSensor(HEATING_1_ID,      "Strefa 1",       21) },
  { CustomSensor(HEATING_2_ID,      "Strefa 2",       22) },
  { CustomSensor(HEATING_3_ID,      "Strefa 3",       23) },
  { CustomSensor(HEATING_4_ID,      "Strefa 4",       24) },
  { CustomSensor(HEATING_5_ID,      "Strefa 5",       25) },
  { CustomSensor(HEATING_6_ID,      "Strefa 6",       26) },
  { CustomSensor(HEATING_7_ID,      "Strefa 7",       27) },
  { CustomSensor(TEST_1_ID,         "TEST_1_ID",      28) },
  { CustomSensor(TEST_2_ID,         "TEST_2_ID",      29) },
  { CustomSensor(TEST_3_ID,         "TEST_3_ID",      30) },
  { CustomSensor(TEST_4_ID,         "TEST_4_ID",      31) },
  { CustomSensor(TEST_5_ID,         "TEST_5_ID",      32) },
  { CustomSensor(TEST_6_ID,         "TEST_6_ID",      33) },
  { CustomSensor(TEST_7_ID,         "TEST_7_ID",      34) },
  { CustomSensor(TEST_8_ID,         "TEST_8_ID",      35) },
  { CustomSensor(TEST_9_ID,         "TEST_9_ID",      36) },
  { CustomSensor(TEST_10_ID,        "TEST_10_ID",     37) },
  { CustomSensor(TEST_11_ID,        "TEST_11_ID",     38) },
  { CustomSensor(TEST_12_ID,        "TEST_12_ID",     39) },
  { CustomSensor(TEST_13_ID,        "TEST_13_ID",     40) },
  { CustomSensor(TEST_14_ID,        "TEST_14_ID",     41) },
};

// Pushbuttons declaration
// Remember that names should be consistent with main loop in gateway.ino
OneButton saloon(A1, true);
OneButton gamingRoom(A2, true);
OneButton bedroom(A3, true);
OneButton bed1(A4, true);
OneButton bed2(A5, true);
OneButton guests(A6, true);
OneButton bathroom(A7, true);
OneButton mirror(A8, true);
OneButton kitchen(A9, true);
OneButton kitchenTable(A10, true);
OneButton workshop(A11, true);
OneButton corridor(A12, true);

Only change is adding couple of sensors. After that, script doesn't work (compiles without error but after change state of button, nothing happens).

Poprawa sketchu

TODO: Add english translation

Hej
Mam fajny sketch który ogarnia przekaźniki dwu klik i przytrzymanie
Działa idealnie z Domoticzem ale mam problem w HA.
Chciałbym Cię prosić o pomoc.
Sketch tworzy dla wszystkich przycisków 2 encje
Pierwsza encja jest odpowiedzialna za 2 klik
Druga encja jest odpowiedzialna za długie przytrzymanie
W zależności który przycisk naciśniemy encja przyjmuje wartość tego przycisku.
sensors_bulb_0_33 jest od 2 klika i np jak naciesnę przycisk 1 dwa razy to sensor_bulb_0_33 przyjmie wartość 1 a jak nacisnę przycisk 5 to będzie sensor_bulb_33 5

Natomiast sensors_bulb_0_33_2 odpowiedzialny za długie przytrzymuje również przyjmuje wartości w zależności który przycisk przytrzymamy.

Problem polega na tym :
Jak w HA ustawię sobie że dwu klik pierwszego przycisku zapali dane światło to encja przyjmie wartość 1
sensors_bulb_0_33 1
Jak w ha ustawię że długie przytrzymanie zgasi te powyższe światła to encja przyjmie wartość 1 czyli:
sensors_bulb_0_33_2 1

No i to działa jednak drugi raz nie mogę zapalić tych świateł dwu klikiem bo ta encja już ma wartość 1
Musiał bym inny przycisk nacisnąć dwa razy żeby encja przybrała wartość innego przycisku i potem znowu przycisk NR1 dwa razy żeby przybrała wartość 1
W HA nie mogę tego zmienić ponieważ encja jest jako senosrs a nie mogę edytować sensorów.

Czy jest możliwość żeby w sketchu ustawić żeby sensors wracał do jakiejść default stanu po np. jednej sekundzie ?
albo żeby to nie był sensors tylko coś czym da się sterować z poziomu HA ?

https://pastebin.com/LLAcacFD

Problem with more sensors

english follows

Witam jeżeli dodaje więcej niż 31 przekaźników i podłączam Arduino do HomeAssistant
to w logach HA pojawi się komunikat

Gateway /dev/ttyUSB0 not ready after 15.0 secs so continuing with setup

w pliku mysensor.json pojaw się tylko
{}
jeżeli dodam 31 przekaźników wszystko jest ok

english:

If I add more then 31 sensors and connect Arduino to HomeAssistant, there is a message in HA's log:

Gateway /dev/ttyUSB0 not ready after 15.0 secs so continuing with setup

in mysensor.json there is only:
{}

if there is only 31 sensors, everything is ok.

Add documentation

We need some proper documentation.

This can be done in Wiki section of repository or in code with doxygen.

Open for proposals.

Code compilation problem

Hi, I'm trying to upload mysensors 1.6 to the Arduino Mega ( via Arduino IDE) and I get the message:

In file included from C:\Users\Pery\Desktop\Hassio\Mysensor\mysensors-1.6\gateway\gateway.ino:21:0:
c:\users\pery\appdata\local\temp\arduino_build_702272\sketch\automation\automation.hpp: In function 'void setupButtons()':
c:\users\pery\appdata\local\temp\arduino_build_702272\sketch\automation\automation.hpp:87:54: warning: invalid conversion from 'uint8_t {aka unsigned char}' to 'void*' [-fpermissive]
saloon.attachDoubleClick(clickCallback, SALOON_2_ID);
^
In file included from c:\users\pery\appdata\local\temp\arduino_build_702272\sketch\mapping\mapping.hpp:12:0,
from C:\Users\Pery\Desktop\Hassio\Mysensor\mysensors-1.6\gateway\gateway.ino:20:
C:\Users\Pery\Documents\Arduino\libraries\OneButton\src/OneButton.h:73:8: note: initializing argument 2 of 'void OneButton::attachDoubleClick(parameterizedCallbackFunction, void*)'
void attachDoubleClick(parameterizedCallbackFunction newFunction, void* parameter);
^~~~~~~~~~~~~~~~~

Can you tell me where I am wrong?

support for Relays activated by low state

Czy istnieje możliwość dodania do sketchu obsługi SSR sterowanych stanem niskim?
Obecnie wszystko działa, ale niestety stany przekaźników są błędnie prezentowane w HA.
Stany są odwrócone.

implement scene controller

to be use with double click, or maybe even use scen controller not binary sensors.
but this need to be testen on Ha and discussed before implementing anything.

add info to not use digital pin 0 and 1

Yhose are used for communication.
Maybe it is possible to check if they are part of customsensors class before compilation and stop compilation if they are.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.