There is several ways to handle this:
-the best for me should have a sensor stop included into the projector screen directly, but as you are asking for this I suppose it is not the case
-a second way could be to handle it into HA, by setting up a timer when the switch pass to ON, and at the end of the timer pass the switch to OFF, as I’m not an HA expert I prefer to let the other answer
-a third way but the worst I think would be to handle it into the gateway source code by adding a condition and a timer when an ON signal is received
Only the first one is working with one single command at home automation level
Hi, thanks for doing this. I built this following your guide and is working very well at receiving commands and sending messages to HASS via MQTT but I have a problem which may be to do with pulse length and frequency burst but I’m not 100% certain. I originally follwed Bruh automations guide https://www.youtube.com/watch?v=5UUazFbK-Hg&t=132s to run this on the pi itself but changed over to your MQTT solution and I can’t get the plugs to switch on. I know its all working fine as I also have my wireless rf doorbell connected and this works via the mosquitto_pub command, the doorbell rings but the switches do not switch at all - do you have any ideas? The only things I can think of is the pulse length all the switches were at 186 and the doorbell is 321 using Bens guide.
Hi 1technophile it was the pulse length. I added mySwitch.setPulseLength(186);
to the line above mySwitch.send(data, 24); in your code and its working great and the doorbell works too. Loving your work, thanks!
I’m using just the IR parts (have RF running nice on pi). I have captured all the codes for remotes but I’m not sure on my next step.
I have a mosquitto broker running fine but not sure about topics. I want to take these codes and have them in HA as switches and have them controllable through my Echo. Is this possible?
I already have 5 rf sockets working with Hue emulation, will I be able to to the same with mqtt commands as switches?
Once you captured your code you can try to emit them by publishing the following MQTT topic into mosquitto: mosquitto_pub -t home/commands/sendNEC -m 99999999
99999999 = the captured code value
If it is working the next step is the HA integration.
Here are some example that you have to adapt to the IR topic
while already having a MQTT broker running on HA (simple DHT22 on a nodemcu dev board), I liked your solution and tried it on a similar module as the geekcreit (doit.am with 12F) to get 433 MHz sockets into HA.
The RF RX/Tx modules are standard ones: MX-RM-5V (MX-05V)/FS1000A, but I couldn’t get it to work.
When I publish a command “1315156” on topic “home/commands/rf” through MQTT Spy, I get a callback (reproducable).
Do you have any idea what I might be doing wrong here?
.
WiFi connected
client mqtt not connected, trying to connect
Attempting MQTT connection…
connected
subscription OK to
home/commands/#
Hey I got a callback
Is it a nodemcu board? If yes could you indicate me the version? I had a similar bug with 0.9 version of nodemcu.
Maybe you have a link that refer your board.
Please check also that you are running the latest library versions.
I just checked back at the order (Oct-2016), it’s the geekcreit as well:
It says “ESP12E DEVKIT V2” on the back but has an 12F already installed.
The nodemcu FW is from today:
NodeMCU custom build by frightanic.com
branch: dev
commit: 7c9fdef77a89be76d4dfc1a15c4c94ad17a34f7c
SSL: false
modules: dht,file,gpio,mqtt,net,node,rfswitch,tmr,uart,wifi
build built on: 2016-12-25 20:41
powered by Lua 5.1.4 on SDK 2.0.0(656edbf)
RCSwitch.h - 2.6.0 was installed and didn’t update yesterday, so I removed it to make sure 2.6.2 is used and compiled/uploaded the ino again (on IDE 1.6.12), same result (callback) after a submitted rf command via mqtt.
What is the exact requirement of the Nodemcu 1.0 board? How can i obtain the version (I thought it’s a 1.0 but I don’t know how to check it)?
I think we have the same board, this doesn’t seem to be a board compatibility issue, i ordered it also from banggood.
Some other questions:
-did you used the same pins as described
-could you add some trace to the code after the “hey i got a callback” to see exactly where it stop.
Pins are exactly the same used.
I also connected an IR Rx to check the IR-to-MQTT reception, beside the garbage codes posted, this works as expected.
Back to the traces, I added the following:
// Callback function, when the gateway receive an MQTT value on the topics subscribed this function is called
void callback(char* topic, byte* payload, unsigned int length) {
// In order to republish this payload, a copy must be made
// as the orignal payload buffer will be overwritten whilst
// constructing the PUBLISH packet.
trc("Hey I got a callback ");
// Allocate the correct amount of memory for the payload copy
byte* p = (byte*)malloc(length);
trc("malloc");
// Copy the payload to the new buffer
memcpy(p,payload,length);
trc("memcpy");
// Conversion to a printable string
p[length] = '\0';
trc("conv");
String callbackstring = String((char *) p);
String topicNameRec = String((char*) topic);
//launch the function to treat received data
receivingMQTT(topicNameRec,callbackstring);
// Free the memory
free(p);
}
Could you try:
-to add this piece of code before p[length] = ‘\0’; trc(String(length));
-to put a value of signal shorter like 99, or 6666
-try with mosquitto instead of MQTT Spy
hello, the board from banggood with the link provided by prefectionist is working, nevertheless as it is written on the spec esp 12E and in reality it is a 12F it is difficult to be sure that you will receive the same as us.
Message payloads of “99” or “6666” produce the same result, just the string length changes to 2 and 4.
The only “custom” setup in my mosquitto broker is the “allow_anonymous false” along with a password file.
I am running out of ideas what might be so specific to my setup.
I also changed the FS1000A with the second one I ordered, same result.
I just checked the board manager and found the ESP8266 board support been locked at 2.0.0 (wifi freedom packet support) and that’s probably why the issue is similar to the nodemcu 0.9 issue. An upgrade to 2.3.0 solved it.
I am sorry as this was a local issue on my IDE and really appreciate your support.
I’m pretty sure I have everything set up correctly but no IR devices are responding.
I’m sending my code using mosquitto_pub with the right version of tv (sendLG in this case)
I’ve checked the IR is flashing and even recorded the IR transmission with the IR receiver and all checks out.
Depending on the IR led you are using you can be too far or not in the right direction. Try with the led at 10 cm to your TV IR receiver to check if it is the case. Did you made the circuit with a transistor?
Try also with the sendNEC command it looks more common, I have an LG tv and did my test with this command.