Initial values must be sent in the loop for mysensors 2.0. Move that from setup to loop, within an if statement as my example on the main mysensors doc page. Check for the values in receive function.
Hi,
I’m using Livolo switches with raspberry pi and connected simple rf transmitter without using arduino.
I use the transmitter code from LamPi project.
read the instructions there to calc a remote id and key id. then for each switch I use a different remote id. if the switch has multiple gongs I use same remote id and different key id.
then from hass I use command line to execute the transmitter with the right code.
i am using LIVOLO switches… just use the command componenet …thats all
like ant other command line switch
something like: /home/pi/livolo/transmiter/codesend …
off course you can put an transmitter directly to a pi, but it is a lot less flixibel.
with mysensors you can put your transmitter anywhere in your house, you could also use multiple transmitters.
if i look at my own case when i put a transmitter directly on my PI i can only reach a very small part of my house.
@faljeremy you probably also have an transmitter connected to your PI. you need somthing to send the code.
Right.
How do you transmit commands from rpi to your Arduino? With RF and Arduino is placed somewhere where it can get the signal and then transmit the switch code? WiFi,…?
I thought of using nodemcu.
it is possible to send the command through any network.
for me it is the only way.
i have an 500 year old winecellar with walls that are thick enough that no signal comes trough.
but a networkcable is there.
so i send through the network my commands to the arduino and can send it then all accross the cellar.
off course i could also put an RPI in the cellar, but i buy at least 5 arduino’s for the price off 1 RPI. so that way i can put sensors and transmitters easy all around the place.
I think I started understanding:
Here is my 2.0 changed example sketch:
/*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* http://www.mysensors.org/build/ir
*/
#define MY_DEBUG
#define MY_RADIO_NRF24
#include <MySensors.h>
#include <SPI.h>
#include <IRLib.h>
#define SN "IR Sensor"
#define SV "1.0"
#define CHILD_ID 1
bool initialValueSent = false;
char code[10] = "abcd01234";
char oldCode[10] = "abcd01234";
MyMessage msgCodeRec(CHILD_ID, V_IR_RECEIVE);
MyMessage msgCode(CHILD_ID, V_IR_SEND);
MyMessage msgSendCode(CHILD_ID, V_STATUS);
void setup() {
}
void presentation() {
sendSketchInfo(SN, SV);
present(CHILD_ID, S_IR);
}
void loop()
{
if (!initialValueSent) {
Serial.println("Sending initial value");
send(msgCodeRec.set(code));
send(msgCode.set(code));
send(msgSendCode.set(0));
Serial.println("Requesting initial value from controller");
request(CHILD_ID, V_STATUS);
wait(2000, C_SET, V_STATUS);
}
// IR receiver not implemented, just a dummy report of code when it changes
if (String(code) != String(oldCode)) {
Serial.print("Code received ");
Serial.println(code);
send(msgCodeRec.set(code));
strcpy(oldCode, code);
}
}
void receive(const MyMessage &message) {
if (message.type==V_STATUS) {
Serial.println("Receiving initial value from controller");
initialValueSent = true;
// IR sender not implemented, just a dummy print.
if (message.getBool()) {
Serial.print("Sending code ");
Serial.println(code);
}
send(msgSendCode.set(message.getBool() ? 1 : 0));
// Always turn off device
wait(100);
send(msgSendCode.set(0));
}
if (message.type == V_IR_SEND) {
// Retrieve the IR code value from the incoming message.
String codestring = message.getString();
codestring.toCharArray(code, sizeof(code));
Serial.print("Changing code to ");
Serial.println(code);
send(msgCode.set(code));
}
}
Now I can see the switch and the sensor started on HA.
Do I need to check initial value for all Sub Types (V_STATUS, V_IR_RECEIVE and V_IR_SEND)?
Do I need to use both SEND and RECEIVE types for my objective?
I got a communication when using developer tools service {“V_IR_SEND”: “0xC284”} based on the serial monitor report:
TSP:MSG:READ 0-0-19 s=1,c=1,t=32,pt=0,l=6,sg=0:0xC284
Changing code to 0xC284
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=32,pt=0,l=6,sg=0,ft=1,st=ok:0xC284
Code received 0xC284
!TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=33,pt=0,l=6,sg=0,ft=0,st=fail:0xC284
Did not get action when changed the boolean switch, but I think my AppDaemon is not starting on reboot… lets start it manually again…
yeah, without a running appdaemon its not gonna function
when you get the code in the arduino serial output then you can start to try to split the code you send and output that to your serial.
if you have the code rightly split, you can put in the livolo lib and send the code to your livolo.
Yes, now I got it working with AppDaemon (it is not starting on reboot)
Is it normal a 2 seconds delay between change boolean and sending to node?
I got those serial monitor lines:
Changing code to A17035B16
!TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=32,pt=0,l=9,sg=0,ft=0,st=fail:A17035B16
TSP:MSG:READ 0-0-19 s=1,c=1,t=32,pt=0,l=10,sg=0:A17035B16t
Changing code to A17035B16
!TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=32,pt=0,l=9,sg=0,ft=1,st=fail:A17035B16
TSP:MSG:READ 0-0-19 s=1,c=1,t=32,pt=0,l=9,sg=0:A5504B16f
Changing code to A5504B16f
!TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=32,pt=0,l=9,sg=0,ft=2,st=fail:A5504B16f
Code received A5504B16f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=33,pt=0,l=9,sg=0,ft=3,st=ok:A5504B16f
Notice there is a “f” in the end of 1 character shorter codes. Is it supposed to exist?
the switch gives you a t or a f at the end off the code.
t for switching on and f for switching off.
if you dont want that you can just ignore that part.
sometimes there is a short delay. depending on the speed of your hardware. i have it to, even a bit longer sometimes.
for starting appdaemon at reboot i found this on the github:
To run AppDaemon at reboot, I have provided a sample init script in the ./scripts directory. These have been tested on a Raspberry PI - your mileage may vary on other systems. There is also a sample Systemd script.
You seen to have a communication problem. All sent messages from the node failed to be received in your last log.
not al @martinhjelmare, the last one is send.
but that is the sending back part from the node to the gateway.
that part is actually unneccesary.
if the code arrives to the node, there is no actual need to confirm that it arrived there.
if it doesnt arrive there you know it soon enough
I made a test changing all 9 switches to off and got this on the node:
Sending code A7849B56t
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=ok:1
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=ok:0
TSP:MSG:READ 0-0-19 s=1,c=1,t=32,pt=0,l=9,sg=0:A5504B16f
Changing code to A5504B16f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=32,pt=0,l=9,sg=0,ft=0,st=ok:A5504B16f
Code received A5504B16f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=33,pt=0,l=9,sg=0,ft=0,st=ok:A5504B16f
TSP:MSG:READ 0-0-19 s=1,c=1,t=32,pt=0,l=8,sg=0:A5504B8f
Changing code to A5504B8f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=32,pt=0,l=8,sg=0,ft=0,st=ok:A5504B8f
Code received A5504B8f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=33,pt=0,l=8,sg=0,ft=0,st=ok:A5504B8f
TSP:MSG:READ 0-0-19 s=1,c=1,t=32,pt=0,l=10,sg=0:A17035B16f
Changing code to A17035B16
!TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=32,pt=0,l=9,sg=0,ft=0,st=fail:A17035B16
Code received A17035B16
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=33,pt=0,l=9,sg=0,ft=1,st=ok:A17035B16
TSP:MSG:READ 0-0-19 s=1,c=1,t=32,pt=0,l=9,sg=0:A5504B56f
Changing code to A5504B56f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=32,pt=0,l=9,sg=0,ft=0,st=ok:A5504B56f
Code received A5504B56f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=33,pt=0,l=9,sg=0,ft=0,st=ok:A5504B56f
TSP:MSG:READ 0-0-19 s=1,c=1,t=2,pt=0,l=1,sg=0:1
Receiving initial value from controller
Sending code A5504B56f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=ok:1
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=ok:0
TSP:MSG:READ 0-0-19 s=1,c=1,t=32,pt=0,l=10,sg=0:A17035B56f
Changing code to A17035B56
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=32,pt=0,l=9,sg=0,ft=0,st=ok:A17035B56
Code received A17035B56
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=33,pt=0,l=9,sg=0,ft=0,st=ok:A17035B56
TSP:MSG:READ 0-0-19 s=1,c=1,t=2,pt=0,l=1,sg=0:1
Receiving initial value from controller
Sending code A17035B56
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=ok:1
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=ok:0
TSP:MSG:READ 0-0-19 s=1,c=1,t=32,pt=0,l=8,sg=0:A7849B8f
Changing code to A7849B8f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=32,pt=0,l=8,sg=0,ft=0,st=ok:A7849B8f
Code received A7849B8f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=33,pt=0,l=8,sg=0,ft=0,st=ok:A7849B8f
TSP:MSG:READ 0-0-19 s=1,c=1,t=2,pt=0,l=1,sg=0:1
Receiving initial value from controller
Sending code A7849B8f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=ok:1
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=ok:0
TSP:MSG:READ 0-0-19 s=1,c=1,t=32,pt=0,l=9,sg=0:A17035B8f
Changing code to A17035B8f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=32,pt=0,l=9,sg=0,ft=0,st=ok:A17035B8f
Code received A17035B8f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=33,pt=0,l=9,sg=0,ft=0,st=ok:A17035B8f
TSP:MSG:READ 0-0-19 s=1,c=1,t=2,pt=0,l=1,sg=0:1
Receiving initial value from controller
Sending code A17035B8f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=ok:1
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=ok:0
TSP:MSG:READ 0-0-19 s=1,c=1,t=32,pt=0,l=9,sg=0:A7849B19f
Changing code to A7849B19f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=32,pt=0,l=9,sg=0,ft=0,st=ok:A7849B19f
Code received A7849B19f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=33,pt=0,l=9,sg=0,ft=0,st=ok:A7849B19f
TSP:MSG:READ 0-0-19 s=1,c=1,t=2,pt=0,l=1,sg=0:1
Receiving initial value from controller
Sending code A7849B19f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=ok:1
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=ok:0
TSP:MSG:READ 0-0-19 s=1,c=1,t=32,pt=0,l=9,sg=0:A7849B56f
Changing code to A7849B56f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=32,pt=0,l=9,sg=0,ft=0,st=ok:A7849B56f
Code received A7849B56f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=33,pt=0,l=9,sg=0,ft=0,st=ok:A7849B56f
TSP:MSG:READ 0-0-19 s=1,c=1,t=2,pt=0,l=1,sg=0:1
Receiving initial value from controller
Sending code A7849B56f
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=ok:1
TSP:MSG:SEND 19-19-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=ok:0
some of them respond to gateway and others not…
and I realized I don’t need the node give gateway feedback, just receive the code and sendo the RF command…
I will try making a final sketch with translation from A0000B000f to livolo.sendButton(0000, 000)
what can give problems is that you sometimes send a to big code.
for instance A17035B56 that should arrive as A17035B56f
i think you need to extend your charcode to 11 (char code[11] = “A12345B123”)
Did you check out the RFLink project?
www.nemcon.nl/blog2
It supports dozens of protocols and hundreds of devices including Livolo.
Not just 433mhz but also 868mhz and 2.4 Ghz…
Yep… and it is as good as or better than the RFXTRX.
I tried build one myself using cheap chinese RX / TX but I created a useless receiver. So I have already ordered it from nodo shop…
But not supports HA yet… Someone have already asked for the compatibility on both sides:
Got All working!!!
here is the final sketch:
#define MY_DEBUG
#define MY_RADIO_NRF24
#include <SPI.h>
#include <MySensors.h>
#include <IRLib.h>
#include <livolo.h>
#define CHILD_ID 1
Livolo livolo(8);
bool initialValueSent = false;
char code[11] = "17035B420t";
MyMessage msg(CHILD_ID, V_STATUS);
MyMessage msgCode(CHILD_ID, V_IR_SEND );
MyMessage msgCodeRec(CHILD_ID, V_IR_RECEIVE);
void setup() {
}
void presentation() {
sendSketchInfo("LivoloRF", "1.0");
present(CHILD_ID, S_IR);
}
void loop() {
if (!initialValueSent) {
Serial.println("Enviando valor inicial");
send(msg.set(0));
send(msgCode.set(code));
send(msgCodeRec.set(code));
Serial.println("Solicitando valor inicial do gateway");
request(CHILD_ID, V_STATUS);
wait(3000, C_SET, V_STATUS);
}
}
void receive(const MyMessage &message) {
if (message.type==V_STATUS) {
if (!initialValueSent) {
Serial.println("Valor inicial recebido!");
initialValueSent = true;
}
}
if (message.type==V_IR_SEND) {
String codigototal = message.getString();
if (message.sensor==CHILD_ID){
codigototal.remove(codigototal.length() - 1); //erase the "t" or "f" last char of the string
int symbpos = codigototal.indexOf('&');
String remotev = codigototal.substring(0, symbpos);
String buttonv = codigototal.substring(symbpos + 1);
Serial.print("TRANSMITINDO: ");
Serial.println("Controle(" + remotev + "), Botão(" + buttonv + ")");
livolo.sendButton(remotev.toInt(), buttonv.toInt());
}
}
}
Is there a way to tell the input_boolean toggle instead of turn on or turn off?
Asking that because once I don’t have feedback from Livolo, when I create an automation action I won’t know the last state to use input_boolean.turn_on or turn_off service.
thanks