Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to support Open/Close button #17

Closed
rkotulan opened this issue Jan 22, 2022 · 40 comments
Closed

How to support Open/Close button #17

rkotulan opened this issue Jan 22, 2022 · 40 comments
Labels
help wanted Extra attention is needed

Comments

@rkotulan
Copy link

Hello,

My remote Telis 4 Modulis RTS5 Channel Pure Hand-Held Remote 1810765 has Open and Close button.
I can send prog, Up (one step), Down (one step), My command.

But I do not know how to simulate Open (roll blind up) and Close (roll blind down).

Any ideas?

@Legion2
Copy link
Owner

Legion2 commented Jan 22, 2022

With my remote the Up and Down commands, open/close the blinds. Maybe you need to send to commands to repoduce this behavior with your remote?

@Legion2 Legion2 added the help wanted Extra attention is needed label Jan 22, 2022
@rkotulan
Copy link
Author

I can send commands repeatedly. But my remote control does it differently.

@Legion2
Copy link
Owner

Legion2 commented Jan 22, 2022

Did you try other commands?

@rkotulan
Copy link
Author

Yes, 0x1 to 0xF :)

@Legion2
Copy link
Owner

Legion2 commented Jan 23, 2022

Without more information about the protocol your remote is using, I can't help you fixing the problem.

@rkotulan
Copy link
Author

rkotulan commented Jan 23, 2022

I understand, could you suggest to me some (easy) way (hw + sw) how to read data from my remote and decode it?

@Legion2
Copy link
Owner

Legion2 commented Jan 23, 2022

I have all the information about the protocol from this website and https://github.com/Nickduino/Somfy_Remote.

@rkotulan
Copy link
Author

Thanks, I will be back if I make some progress.

@Legion2
Copy link
Owner

Legion2 commented Jan 23, 2022

maybe #16 is related to this,

@rkotulan
Copy link
Author

Do you know what seed is in the frame?
It looks like the seed isn't random but actually the button code: 0x88 DOWN, 0x85 STOP, 0x86 UP.

@Legion2
Copy link
Owner

Legion2 commented Jan 23, 2022

No I don't understand that part

@vaguiner7
Copy link

Hello,

using the tool rtl_433 and the dongle I could see the result below that explain: It looks like the seed isn't random but actually the button code: 0x88 DOWN, 0x85 STOP, 0x86 UP.
Screenshot from 2022-01-24 09-59-40

Hex. codes of my remote control.

UP - f0f0ff34cb4b2ccb334ad2b4d2d532d353
STOP - f0f0ff34cccb2d4b32cb53355354b352d28
DOWN - f0f0ff34b54b534b4ccd55335552b554d48

@rkotulan
Copy link
Author

Thanks, what kind of remote do you have.
I tried these codes yesterday but it did not work for me.

I am going to order the dongle. :)

@vaguiner7
Copy link

My remote is SCE-R1 Gunmetal.

Yes, didn't work for me too, I think that is related to the buildFrame, the frame is different from the regular Somfy products.

@rkotulan
Copy link
Author

rkotulan commented Jan 24, 2022

You were able to decode your hex codes by hand?

@vaguiner7
Copy link

No, I used the tool rtl_433 to see my codes.

@rkotulan
Copy link
Author

@vaguiner7 The dongle came today. What command do you use for rtl_433?

@vaguiner7
Copy link

vaguiner7 commented Jan 25, 2022

Great,

I just used filtering the protocol somfy_rts: rtl_433 -R 167.

Screen Shot 2022-01-25 at 11 01 28

I really recommend the tool Universal Radio Hacker (urh) that you can use with the same dongle.
Screen Shot 2022-01-25 at 11 05 11

@rkotulan
Copy link
Author

rkotulan commented Jan 25, 2022

@vaguiner7 Thank you so much.

Finally I was able to make it work.

My problem was that method sendCC1101Command(Command command, int repeat = 4) has default repeat = 4. I this case the motor make just one step. When I send just one command then the blinds go up :)

@Legion2
Copy link
Owner

Legion2 commented Jan 25, 2022

@rkotulan would you like to add some documentation?

@rkotulan
Copy link
Author

@Legion2 sure I will write something.

@Leviathan09
Copy link

Finally I was able to make it work.

My problem was that method sendCC1101Command(Command command, int repeat = 4) has default repeat = 4. I this case the motor make just one step. When I send just one command then the blinds go up :)

@rkotulan Could you maybe post your complete solution in here?
I have a curtain which is using the same remote as you have and i'm trying to figure out how to controll that with my WemosD1.
And i think i have to solve a similar problem as you, because with the UP/DOWN command i can't fully OPEN/CLOSE the curtain.

@rkotulan
Copy link
Author

rkotulan commented Feb 28, 2022

@Leviathan09 Here is my code for ESP Home:

#include "esphome.h"
#include <ELECHOUSE_CC1101_SRC_DRV.h>
#include <NVSRollingCodeStorage.h>
#include <SomfyRemote.h>

#define EMITTER_GPIO 2

#define CC1101_FREQUENCY 433.42

#define COVER_OPEN 1.0f
#define COVER_CLOSED 0.0f

#define TILT_OPEN 1.0f
#define TILT_CLOSED 0.0f

class SomfyESPCover : public Cover {
private:
  SomfyRemote *remote;
  NVSRollingCodeStorage *storage;

public:
  SomfyESPCover(const char *name, const char *key, uint32_t remoteCode)
      : Cover() {
    storage = new NVSRollingCodeStorage(name, key);
    remote = new SomfyRemote(EMITTER_GPIO, remoteCode, storage);
  }

  CoverTraits get_traits() override {
    auto traits = CoverTraits();
    traits.set_is_assumed_state(true);
    traits.set_supports_position(false);
    traits.set_supports_tilt(true);
    return traits;
  }

  void sendCC1101Command(Command command, int repeat = 1) {
    ELECHOUSE_cc1101.SetTx();
    remote->sendCommand(command, repeat);
    ELECHOUSE_cc1101.setSidle();
  }

  void control(const CoverCall &call) override {
    if (call.get_position().has_value()) {
      float pos = *call.get_position();

      if (pos == COVER_OPEN) {
        ESP_LOGI("somfy", "OPEN");
        sendCC1101Command(Command::Up);
      } else if (pos == COVER_CLOSED) {
        ESP_LOGI("somfy", "CLOSE");
        sendCC1101Command(Command::Down);
      } else {
        ESP_LOGI("somfy", "WAT");
      }

      this->position = pos;
      this->publish_state();
    }

    if (call.get_stop()) {
      ESP_LOGI("somfy", "STOP");
      sendCC1101Command(Command::My);
    }

    if(call.get_tilt().has_value()) {
      float tilt = *call.get_tilt();      
      ESP_LOGI("somfy", "tilt: %.1f",tilt );
      if(tilt == TILT_OPEN) {
        sendCC1101Command(Command::Up, 4);
      } else {
        sendCC1101Command(Command::Down, 4);
      }
    }
  }

  void program() {
    ESP_LOGI("somfy", "PROG");
    sendCC1101Command(Command::Prog);
  }
};

class SomfyESPRemote : public Component {
public:
  std::vector<esphome::cover::Cover *> covers;

  void setup() override {
    // need to set GPIO PIN 4 as OUTPUT, otherwise no commands will be sent
    pinMode(EMITTER_GPIO, OUTPUT);
    digitalWrite(EMITTER_GPIO, LOW);

    ELECHOUSE_cc1101.Init();
    ELECHOUSE_cc1101.setMHZ(CC1101_FREQUENCY);
  }

  void add_cover(const char *name, const char *key, uint32_t remoteCode) {
    auto cover = new SomfyESPCover(name, key, remoteCode);
    covers.push_back(cover);
  }
};

The key point is to change sendCC1101Command to send command just once. When you send Up = Open, Down = Close just once the cover will Open / Close.

I enabled also tilt support. If you do not need you can disable it traits.set_supports_tilt(false);

If you need more details let me know.

@rkotulan
Copy link
Author

@Legion2
Documentation update
For remote control Telis 4 Modulis RTS5 I recommend sending the command Up or Down just once.
When the UP command is sent once, the blinds go up (Open).

sendCommand(Command::Up, 1);

When the DOWN command is sent once, the blinds go down (Close).

sendCommand(Command::Down, 1);

If you want to tilt the blinds, send the Up / Down command four times.

sendCommand(Command::Up, 4);

or

sendCommand(Command::Down, 4);

@Legion2
Copy link
Owner

Legion2 commented Feb 28, 2022

@rkotulan can you create a PR, else I can update the readme.

@Leviathan09
Copy link

Leviathan09 commented Mar 1, 2022

The key point is to change sendCC1101Command to send command just once. When you send Up = Open, Down = Close just once the cover will Open / Close.

I enabled also tilt support. If you do not need you can disable it traits.set_supports_tilt(false);

If you need more details let me know.

@rkotulan Thanks, really appreciate this.
Will check the code and try to understand it as i'm not that good at coding such stuff.

Edit:
@rkotulan Ok, first problem...it seems your code is not for ArduinoIDE i guess?
So how can i use it?

@rkotulan
Copy link
Author

rkotulan commented Mar 1, 2022

@Leviathan09 I use ESPHome + HomeAssistatnt.

How do you imagine you will control the curtain? With button connected to wemos?
It should not be a problem to rewrite the code for Arduino.

@Leviathan09
Copy link

@Leviathan09 I use ESPHome + HomeAssistatnt.

How do you imagine you will control the curtain? With button connected to wemos? It should not be a problem to rewrite the code for Arduino.

Okay, then i will try to figure out how ESPHome works or will check if a can adjust it for ArduinoIDE (have the example from MakerMeiks Somfy_Remote)
My plan is to use one of my dashboards from iobroker on a small tablet or my phone...and maybe also my Amazon Echo at least for full Open/Close

@rkotulan
Copy link
Author

rkotulan commented Mar 1, 2022

@Leviathan09 this might help https://github.com/DrozmotiX/ioBroker.esphome

@Leviathan09
Copy link

@rkotulan i tried it with ESPHome and HomeAssistant and was able to perform a compile process but it failed and i don't know why. As already mentiond i'm not really good and such "programming" stuff.
Maybe you can help me.

logs_esp-curtain_compile-1.txt

@rkotulan
Copy link
Author

rkotulan commented Mar 2, 2022

@Leviathan09 could you post here file my_custom_component.h ?

@Leviathan09
Copy link

@Leviathan09 could you post here file my_custom_component.h ?

@rkotulan it's just a copy of your code from above
Didn't change anything
Just to try it if i'm able to handle esphome

@rkotulan
Copy link
Author

rkotulan commented Mar 2, 2022

@Leviathan09 and how you YAML for ESPHome looks like?

@Leviathan09
Copy link

@Leviathan09 and how you YAML for ESPHome looks like?

yaml.txt

@rkotulan
Copy link
Author

rkotulan commented Mar 2, 2022

esphome:
  name: somfy
  platform: ESP32
  board: nodemcu-32s
  libraries:
    - EEPROM
    - SPI
    - [email protected]
    - [email protected]
  includes:
    - include/somfy/somfy_secrets.h
    - include/somfy/somfy_cover.h
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Somfy Fallback Hotspot"
    password: "123456789"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

web_server:
  port: 80

sensor:
  - platform: uptime
    name: Uptime Sensor

  - platform: wifi_signal
    name: "WiFi Signal Sensor"

cover:
  - platform: custom
    lambda: |-
      auto somfy_remote = new SomfyESPRemote();
      somfy_remote->add_cover("somfy", "Left", SOMFY_REMOTE_LIVING_ROOM_LEFT);
      somfy_remote->add_cover("somfy", "Right", SOMFY_REMOTE_LIVING_ROOM_RIGHT);
      App.register_component(somfy_remote);
      return somfy_remote->covers;

    covers:
      - id: "somfy_living_room_left"
        name: "Somfy roleta obývák levá"
      - id: "somfy_living_room_right"
        name: "Somfy roleta obývák pravá"

switch:
  - platform: template
    name: "PROG left"
    turn_on_action:
      - lambda: |-
          ((SomfyESPCover*)id(somfy_living_room_left))->program();
  - platform: template
    name: "PROG right"
    turn_on_action:
      - lambda: |-
          ((SomfyESPCover*)id(somfy_living_room_right))->program();

you need secon file somfy_secrets.h

#define SOMFY_REMOTE_LIVING_ROOM_LEFT 0x121310
#define SOMFY_REMOTE_LIVING_ROOM_RIGHT 0x121311

@rkotulan
Copy link
Author

rkotulan commented Mar 2, 2022

@Leviathan09 One thing, I have different board then you. I have similar to this one https://www.aliexpress.com/item/1005003818247483.html

@Leviathan09
Copy link

hm, okay
i think the board shouldn't be a problem

But as i don't really understand your stuff from above i think i have to wait for the weekend to take enough time
But thank you for your help so far

@rkotulan
Copy link
Author

rkotulan commented Mar 2, 2022

@Leviathan09 For build board is not problem but this line

#define EMITTER_GPIO 2

could depend on the board, but I am not sure.

@rkotulan
Copy link
Author

rkotulan commented Mar 6, 2022

@Legion2 please update documentation

@filzek
Copy link

filzek commented Dec 1, 2022

Great,

I just used filtering the protocol somfy_rts: rtl_433 -R 167.

Screen Shot 2022-01-25 at 11 01 28

I really recommend the tool Universal Radio Hacker (urh) that you can use with the same dongle. Screen Shot 2022-01-25 at 11 05 11

@vaguiner7 did you make the Library to work with TUBE? As we try to use it the TUBE seens to have a 7 Digits Hex ID, so, whenever we set it 6 or 7 digits it doest work.

Can you give me a help to try to solve this?

Using a RFLINK to sniff the RF communication it shows it as RTS and the Remote Control ID as 265822A

Also if @Legion2 could take a look at this would be awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants