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.
So the first question is: is this the right solution or are there better ones (see the code below) ?
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
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:
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 )
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.
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