VirtualRelay a tryb manual/auto

User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Cześć, potrzebuję zrobić przełącznik MANUAL/AUTO w aplikacji. Chciałem do tego uzyć virtualRelay, ale zdaje się nie można mu przypisać dwóch różnych ikonek dla stanu włączonego i wyłączonego. Kombinacje z virtualrelay i termometrem też odpadają. da się to jakoś zrobić?
Czy muszę użyć klasycznego relay, tylko jak wyciągnąć info czy jest włączony czy wyłączony i na tej podstawie coś tam robić. Kiedyś natknąłem się na coś takiego jak isON(), czy jakoś tak, tego szukać?
Pomóżcie.
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Generalnie wszystko mi to ładnie działa na virtualrelay(tryb auto/manual), tylko chciałbym żeby użytkownik widział jaki tryb ma włączony poprzez zmieniające się ikony. Da się?
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
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

SOYER wrote: Wed Jun 14, 2023 5:11 pm Generalnie wszystko mi to ładnie działa na virtualrelay(tryb auto/manual), tylko chciałbym żeby użytkownik widział jaki tryb ma włączony poprzez zmieniające się ikony. Da się?
W Cloud jak wybierzesz włąsną ikonę dla przekaźnika, to masz do wgrania dwa pliki - dla stanu włączonego i wyłączonego:
2023-06-14_22-25.png
You do not have the required permissions to view the files attached to this post.
Najlepsze suple dla Twojego domu :mrgreen:
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Wiem, tak mam zrobione dla zwykłych przekaźników, ale dlaczego mi to nie działa dla virtualRelay? Nie przełącza obrazków.
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Sprawdziłem jeszcze raz, na virtual relay nie zmieniają sie ikonki, nawet te standardowe supla, cały czas jest ikonka od off
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
lukfud
Posts: 2480
Joined: Thu Nov 23, 2017 11:33 pm
Location: Warszawa
Has thanked: 13 times
Been thanked: 11 times

Post

SOYER wrote: Thu Jun 15, 2023 2:10 pm Sprawdziłem jeszcze raz, na virtual relay nie zmieniają sie ikonki, nawet te standardowe supla, cały czas jest ikonka od off
Oczywiście, że się zmieniają, korzystam z wirtualnych cały czas.
https://www.facebook.com/groups/supladiy
https://www.facebook.com/groups/suplazamel
https://www.facebook.com/groups/suplaauraton
https://smartnerzeczy.pl
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

To co mam nagrać filmik, że jednak się nie zmieniają u mnie?
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Wiem gdzie może być problem. Tylko jak znaleźć ten wątek na forum...
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Używam takiego kodu który kiedyś mi podesłał kolega @klew, to powiązany virtual relay z termometrem. Kod służy do ustawiania różnych wartości. Zapewne tu czegoś brakuje, że mi się nie zmieniają ikonki.

Code: Select all

class RelayAsInput : public Supla::Control::VirtualRelay {//temp wł pompy
 public:
  explicit RelayAsInput(int step = 1) : step(step) {
  }
  virtual ~RelayAsInput() {}
  void onInit() override {}
  void turnOn(_supla_int_t duration = 0) override {

    (void)(duration);
    int newTemp = temp.getValue() + step;
    if (newTemp > 90) {
      newTemp = 90;
    }
    temp.setValue(newTemp);//newTemp
    tempON = newTemp;
    Supla::Storage::ScheduleSave(2000);
  }

  void turnOff(_supla_int_t duration = 0) override {
    (void)(duration);
    int newTemp = temp.getValue() - step;
    if (newTemp < 5) {
      newTemp = 5;
    }
    temp.setValue(newTemp);
    tempON = newTemp;
    Supla::Storage::ScheduleSave(2000);
  }

  int getValue() {
    return temp.getValue();
  }

  void setValue(int value) {
    temp.setValue(value);
    Supla::Storage::ScheduleSave(2000);
  }

  void onLoadState() override {
    int temperature = 0;
    Supla::Storage::ReadState(reinterpret_cast<unsigned char *>(&temperature),
                              sizeof(int));
    temp.setValue(temperature);
    tempON = temperature;
  }

  void onSaveState() override {
    int temperature = temp.getValue();
    Supla::Storage::WriteState(reinterpret_cast<unsigned char *>(&temperature),
                               sizeof(int));
  }

 protected:
  Supla::Sensor::VirtualThermometer temp;
  int step = 1;
};
Czy tam czegoś brakuje, czy to nie ten trop?
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
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

SOYER wrote: Thu Jun 15, 2023 2:45 pm Używam takiego kodu który kiedyś mi podesłał kolega @klew, to powiązany virtual relay z termometrem. Kod służy do ustawiania różnych wartości. Zapewne tu czegoś brakuje, że mi się nie zmieniają ikonki.

Code: Select all

class RelayAsInput : public Supla::Control::VirtualRelay {//temp wł pompy
 public:
  explicit RelayAsInput(int step = 1) : step(step) {
  }
  virtual ~RelayAsInput() {}
  void onInit() override {}
  void turnOn(_supla_int_t duration = 0) override {

    (void)(duration);
    int newTemp = temp.getValue() + step;
    if (newTemp > 90) {
      newTemp = 90;
    }
    temp.setValue(newTemp);//newTemp
    tempON = newTemp;
    Supla::Storage::ScheduleSave(2000);
  }

  void turnOff(_supla_int_t duration = 0) override {
    (void)(duration);
    int newTemp = temp.getValue() - step;
    if (newTemp < 5) {
      newTemp = 5;
    }
    temp.setValue(newTemp);
    tempON = newTemp;
    Supla::Storage::ScheduleSave(2000);
  }

  int getValue() {
    return temp.getValue();
  }

  void setValue(int value) {
    temp.setValue(value);
    Supla::Storage::ScheduleSave(2000);
  }

  void onLoadState() override {
    int temperature = 0;
    Supla::Storage::ReadState(reinterpret_cast<unsigned char *>(&temperature),
                              sizeof(int));
    temp.setValue(temperature);
    tempON = temperature;
  }

  void onSaveState() override {
    int temperature = temp.getValue();
    Supla::Storage::WriteState(reinterpret_cast<unsigned char *>(&temperature),
                               sizeof(int));
  }

 protected:
  Supla::Sensor::VirtualThermometer temp;
  int step = 1;
};
Czy tam czegoś brakuje, czy to nie ten trop?
Ten kanał nie zmienia stanu. Użyj zwykłego VirtualRelay
Najlepsze suple dla Twojego domu :mrgreen:

Return to “Pomoc”