Przypisanie BinarySensor do virtual relay

User avatar
Duch__
Posts: 2199
Joined: Wed Aug 24, 2016 7:26 pm
Location: Opole
Been thanked: 6 times

Post

Jak programowo przypisać czujnik binarny do przekaźnika furtki?

Code: Select all

  vrelay = new Supla::Control::VirtualRelay();
  vrelay->getChannel()->setDefault(SUPLA_CHANNELFNC_CONTROLLINGTHEGATEWAYLOCK);
  vrelay->setInitialCaption("vrelay");

  stan_vrelay->setDefaultFunction(SUPLA_CHANNELFNC_OPENINGSENSOR_GATEWAY);
  stan_vrelay->setInitialCaption("Stan vrelay"); 

Chcę by cloud wiedział że "stan_vrelay" jest domyślnym czujnikiem otwarcia dla "vrelay", bez konieczności wyklikiwania tego w CLOUD.

W termostatacie fajnie to działa:

Code: Select all

hvac_0->setBinarySensorChannelNo(numer_kanału);
Natomiast z vrelay to nie działa.
User avatar
veeroos
Posts: 1081
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

A może by tak:

Code: Select all

auto vr = new Supla::Control::VirtualRelay();
  vr->setDefaultFunction(SUPLA_CHANNELFNC_POWERSWITCH);

  auto vb = new Supla::Sensor::VirtualBinary();
  vb->setDefaultFunction(SUPLA_CHANNELFNC_OPENINGSENSOR_GATEWAY);
  vb->setInitialCaption("Stan vrelay"); 

  vr->addAction(Supla::SET, vb, Supla::TURN_ON);
  vr->addAction(Supla::CLEAR, vb, Supla::TURN_OFF);
  
  
nie testowane więc może nie działać :D, ale kompiluje się poprawnie
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005
User avatar
vajera
Posts: 7290
Joined: Wed Oct 31, 2018 7:58 am
Location: Biedrusko
Has thanked: 289 times
Been thanked: 161 times

Post

Duch__ wrote: Tue Apr 21, 2026 6:18 am Jak programowo przypisać czujnik binarny do przekaźnika furtki?

Code: Select all

  vrelay = new Supla::Control::VirtualRelay();
  vrelay->getChannel()->setDefault(SUPLA_CHANNELFNC_CONTROLLINGTHEGATEWAYLOCK);
  vrelay->setInitialCaption("vrelay");

  stan_vrelay->setDefaultFunction(SUPLA_CHANNELFNC_OPENINGSENSOR_GATEWAY);
  stan_vrelay->setInitialCaption("Stan vrelay"); 

Chcę by cloud wiedział że "stan_vrelay" jest domyślnym czujnikiem otwarcia dla "vrelay", bez konieczności wyklikiwania tego w CLOUD.

W termostatacie fajnie to działa:

Code: Select all

hvac_0->setBinarySensorChannelNo(numer_kanału);
Natomiast z vrelay to nie działa.
Tutaj masz moje identyczne pytanie do Krzysztofa z lutego i Jego odpowiedź poniżej - tego raczej nie da się ustawić lokalnie.
Bramka Zigbee <=> SUPLA
Więcej informacji tutaj:
https://forum.supla.org/viewforum.php?f=127
FAQ https://forum.supla.org/viewtopic.php?t=17277
User avatar
klew
Posts: 13908
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

Aktualnie to nie jest konfigurowalne.
Serwer jakoś automatycznie to konfiguruje przy dodawaniu urządzeń, ale nie pamiętam szczegółów.
Najlepsze suple dla Twojego domu :mrgreen:
User avatar
veeroos
Posts: 1081
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

Screenshot_2026-04-21-10-39-20-233_org.supla.android.jpg
Screenshot_2026-04-21-10-39-25-684_org.supla.android.jpg
Jak pięknie działa 😁
You do not have the required permissions to view the files attached to this post.
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005
User avatar
veeroos
Posts: 1081
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

a teraz program, przerobilem program VirtualRelay z biblioteki, nie dało mi to "spać"

Code: Select all

/*
  Copyright (C) AC SOFTWARE SP. Z O.O.

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#define STATUS_LED_GPIO 2

#include <SuplaDevice.h>
#include <supla/control/button.h>
#include <supla/network/esp_wifi.h>
#include <supla/device/status_led.h>
#include <supla/storage/littlefs_config.h>
#include <supla/network/esp_web_server.h>
#include <supla/network/html/device_info.h>
#include <supla/network/html/protocol_parameters.h>
#include <supla/network/html/status_led_parameters.h>
#include <supla/network/html/wifi_parameters.h>
#include <supla/control/virtual_relay.h>
Supla::Control::VirtualRelay *vr = nullptr;
#include <supla/storage/eeprom.h>
#include <supla/sensor/virtual_binary.h>
Supla::Sensor::VirtualBinary *vb = nullptr;
#include <supla/control/action_trigger.h>

Supla::Eeprom eeprom;

Supla::ESPWifi wifi;
Supla::LittleFsConfig configSupla;

Supla::Device::StatusLed statusLed(STATUS_LED_GPIO, true); // inverted state
Supla::EspWebServer suplaServer;

namespace Custom {
  enum c_actions {
  
    VIRTUAL_ON_,
    VIRTUAL_OFF_, 
  
  };
};

class CustomActions: public Supla::ActionHandler, public Supla::Element {
  public:
  CustomActions() {}

  void handleAction(int event, int action) {
    auto cfg = Supla::Storage::ConfigInstance();
    if (action == Custom::VIRTUAL_ON_) {
      //SuplaDevice.handleAction(vb->set());
      vb->set();
    }
    if (action == Custom::VIRTUAL_OFF_) {
      //SuplaDevice.handleAction(vb->clear());
      vb->clear();

    }
  }
};
CustomActions *CustomA = new CustomActions;

void setup() {
  Serial.begin(115200);

  // HTML www component
  new Supla::Html::DeviceInfo(&SuplaDevice);
  new Supla::Html::WifiParameters;
  new Supla::Html::ProtocolParameters;
  new Supla::Html::StatusLedParameters;

  vb = new Supla::Sensor::VirtualBinary();
  vb->setDefaultFunction(SUPLA_CHANNELFNC_OPENINGSENSOR_GATEWAY);

  vr = new Supla::Control::VirtualRelay();
  vr->setDefaultFunction(SUPLA_CHANNELFNC_POWERSWITCH);
  vr->addAction(Custom::VIRTUAL_ON_, CustomA, Supla::ON_TURN_ON);
  vr->addAction(Custom::VIRTUAL_OFF_, CustomA, Supla::ON_TURN_OFF);

  SuplaDevice.setInitialMode(Supla::InitialMode::StartInCfgMode);
  SuplaDevice.begin();
}

void loop() {
  SuplaDevice.iterate();
}
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005
User avatar
klew
Posts: 13908
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

@veeroos jeśli przestawisz funkcję relay'a na "otwieranie furtki" to pewnie przestanie Ci to działać, bo ona pobiera stan z powiązanego czujnika i określa to serwer.
I chyba o to pyta Duch
Najlepsze suple dla Twojego domu :mrgreen:
User avatar
veeroos
Posts: 1081
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

klew wrote: Tue Apr 21, 2026 8:44 am @veeroos jeśli przestawisz funkcję relay'a na "otwieranie furtki" to pewnie przestanie Ci to działać, bo ona pobiera stan z powiązanego czujnika i określa to serwer.
I chyba o to pyta Duch
To akurat na pewno przestanie działać, zobaczymy czy o to koledze chodziło czy nie. Zawsze może napisać jakąś inną customową akcję realizującą się jak zostanie wywołane otwarcie bramy, może zrobić na Toggle, pierwszy impuls ustawi czujnik na otwarte, a drugi impuls na zamknięte. Wtedy wykorzysta tylko jedną akcję i zamiast set() czy clear() da toggle (), chyba że źle myślę to mnie popraw.
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005
User avatar
klew
Posts: 13908
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

veeroos wrote: Tue Apr 21, 2026 8:53 am To akurat na pewno przestanie działać, zobaczymy czy o to koledze chodziło czy nie. Zawsze może napisać jakąś inną customową akcję realizującą się jak zostanie wywołane otwarcie bramy, może zrobić na Toggle, pierwszy impuls ustawi czujnik na otwarte, a drugi impuls na zamknięte. Wtedy wykorzysta tylko jedną akcję i zamiast set() czy clear() da toggle (), chyba że źle myślę to mnie popraw.
Chodzi o to, że dla funkcji "bramowych" stan bramy jest brany z czujnika binarnego podpiętego do relaya, a nie z relaya.
Nie ma znaczenia jaki stan relaya sobie ustawisz.
Najlepsze suple dla Twojego domu :mrgreen:
User avatar
veeroos
Posts: 1081
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

wiem, dlatego dziwię się, że ma to być brane nie z fizycznego czujnika tylko z kanału.
Sprawdziłem przed chwilą i funkcja toggle działa, tylko że furtkę można ręcznie zamykać więc nie ma sensu tego stosować. Generalnie pytał o przypisanie czujnika do przekaźnika furtki. Sprawdziłęm to, dałem funkcję virtualRelay na otwieranie furtki i tyle czasu ile był wystawiony przekaźnik tyle czasu sygnał na czujniku był zmieniony, zastosowałem mój program, nie ten z toggle, tylko ten co wstawiłem, czyli w teorii działa jak autor chciał
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005

Return to “supla-dev”