How to handle 4 state switch (QIAchip, EV1527)?

hello,

I’m playing with Home Assistant for a week, (after trying Domoticz and OpenHab) and most of the things I needed could be implemented fluently. So I’m really satisfied after the problems with the other 2 packages.
But some parts are not that easy and it’s difficult to find examples on the web.

I’m stucked on implementing a 4 state switch, of which I use 3 to control blinds.
For the moment I’ve a solution that largely works as expected.

  1. So the first question is: is this the right solution or are there better ones (see the code below) ?
  2. The second question is, why shouldn’t I solve every non trival situation with mqtt ? (I’ve struggled for more than 10 hours with this script and I think it would guaranteed be solved with mqtt within an hour) ?
switch:
  platform: rflink
  device_defaults:
    fire_event: true
  devices:
    ev1527_005df_01:
      name: "Noten Button A"
# and 3 more of these switches

cover:
  - platform: template
    covers:
      garage_door:
        friendly_name: "Garage Door"
        open_cover:
          service: script.open_garage_door
        close_cover:
          service: script.close_garage_door
        stop_cover:
          service: script.stop_garage_door
script:
  open_garage_door:
    alias: "Turn on lampa and set timer"
    sequence:
      - service: switch.turn_on
        data :
          entity_id: switch.noten_button_a
      - delay : "00:00:01"          
      - service: switch.turn_off
        data :
          entity_id: switch.noten_button_a 
# and 2  more scripts

best regards, Stef

MQTT is a protocol for sending data between clients, so I’m not sure what you mean by this.

sorry maybe I wasn’t clear enough,
I’ll try to explain, suppose I could handle the blinds through mqtt messages
Then this is the whole configuration code I need to write in Home Assistant is:

cover Blinds_Achter:
  platform      : mqtt
  name          : "Blinds-Achter"
  command_topic : "ha/blind_cover_Achter/set"

I already have an MQTT-broker running.
Furthermore It’s easy for me to let RFLink communicate with mqtt-messages instead of serial, because I rewrote the code of RFLink to put in an ESP8266 / ESP32 )

Does that explain what I meant ?

best regards, Stef

If the device receiving the MQTT message turns the switch on and off (which I think is the purpose of your scripts), then I think that is all you need, but I have to admit I am not really certain what you are trying to do.

Hey
Can you please share your MQTT bridge to RFlink iam prefer MQTT also.
Thank you!

I’ve added MQTT communication in RFLink-ESP and it seems to work nice.

source code: https://github.com/Stef-aap/RFLink-ESP
documentation is here: https://stef-aap.github.io/RFLink-ESP/, see page Home Assistant - MQTT

Example, switch definition in configuration.yaml:

cover Blinds_MQTT_Test:
  platform      : mqtt
  name          : "Blinds MQTT Test"
  command_topic : "ha/from_HA/EV1527_5DF"
  payload_open  : "S1"
  payload_close : "S2"
  payload_stop  : "S4"
  state_topic   : "ha/from_RFLink/EV1527_5DF"
  state_open    : "S1"
  state_closed  : "S2"
  state_stop    : "S4"

best regards, Stef

Very nice nice:) Are you using a esp32 or esp8266 instead of an mega 2560 r3 You have picture of the wiring?
Or are you connecting with esp8266 or esp32 RX and TX to mega 2560 r3 and sending the communication via serial?
I have a setup with mega 2560 r3 but i think its not so fast.

The ESP32 is about 8 times faster and even the ESP8266 is 2 times faster. I used both the ESP8266 and ESP32, both with the standaard Rx and Tx connections (although you don’t need Rx and Tx if you’re using MQTT. For receiver and transmitter you just use 2 pins that are available, in the code it can be changed easily:

#ifdef ESP32
  #define TRANSMIT_PIN    5    // Data to the 433Mhz transmitter on this pin
  #define RECEIVE_PIN    19    // On this input, the 433Mhz-RF signal is received. LOW when no signal.
#else
  #define TRANSMIT_PIN    5    // Data to the 433Mhz transmitter on this pin
  #define RECEIVE_PIN     4    // On this input, the 433Mhz-RF signal is received. LOW when no signal.
#endif

Can i use this one ?

no,
that’s an FSK (Freqeuncy Shift Keying) module controlled from an SPI bus.

You need something like this:
https://nl.aliexpress.com/item/433MHz-RF-Remote-Control-Switch-Relay-Receiver-Module-Learning-Code1527-with-433-MHz-Wireless-Transmitter-Module/32844597411.html
or,
this is a better receiver: https://nl.aliexpress.com/item/RXB6-433Mhz-Superheterodyne-Wireless-Receiver-Module-ARM-AVR/32714431287.html