Closed sebastienvg closed 9 years ago
You can do it with the MySensorsSwitch. You can this to turn things on with a mysensors node with IR. But a buttons device would be great to have in this plugin
hey @sweebee
{ "id": "VProjectorOn", "name": "VProjector On", "class": "MySensorsSwitch", "nodeid": 190, "batterySensor": true, "sensorid": 3 },
sounds right?
Yes, should work
I know it's not the right place to ask, but does anyone have any working sketch to have more than one IR command sent from the sensor? I have to to play around with the code but without success at all.
You can better ask this on the mysensors forum. But i'll guess you use the original ir sketch?
The easiest way to use more commands is adding more sensors (childs) to the sketch. Wait for a message from pimatic and if pimatic sends a ON command on sensor (child) 1 then switch the tv on and add on sensor 2 the van or something.
void incomingMessage(const MyMessage &message) {
if (message.type == V_LIGHT) { // Check if received message is a switch message
int device = message.sensor; // Get the received child id and save it in to device
boolean state = atoi( message.data ); // Get the receive state of the switch and save it into state
if(device == 1) { // do something if device 1 (TV) is received
if(state == true) { // If state = true (on)
// Send IR on signal to TV
} else { // If state = false (off)
// Send IR off signal to TV
}
}
if(device == 2) { // do something if device 2 (van) is received
if(state == true) { // If state = true (on)
// Send IR on signal to van
} else { // If state = false (off)
// Send IR off signal to van
}
}
}
}
thank you so much @sweebee trying this right now.
added support for sending the IR hex codes from pimatic rule..
Shouldn't it be V_VAR1 instead of V_LIGHT?
Not a big change.. Can be done easily ☺ On Jun 8, 2015 12:38 AM, "Wiebe Nieuwenhuis" notifications@github.com wrote:
Shouldn't it be VAR instead of V_LIGHT
— Reply to this email directly or view it on GitHub https://github.com/DheerajKhajuria/pimatic-mysensors/issues/27#issuecomment-109789248 .
@DheerajKhajuria I really appreciate that you added the feature and so quickly but I can't use it because I am unsure how to adapt the sketch. Is it as simple as changing the following line from the example @sweebee provided above
if (message.type == V_LIGHT) { // Check if received message is a switch message
to something like
if (message.type == V_IR_SEND ) { // Check if received message is a switch message
or do I need to define the device in the config.json differentely?
{
"id": "VProjectorOn",
"name": "VProjector On",
"class": "MySensorsSwitch",
"nodeid": 190,
"batterySensor": true,
"sensorid": 3
},
right now if I have a rule like
If Projector On is pressed
send Ir nodeid:"190" sensorid:"3" cmdcode:"0x342333"
but I can't see anything coming from the IR led, however if I use @sweebee example then a rule like
if Projector On is pressed
then turn on VProjector on for 2 seconds
I can see the IR signal sent, but this way you have to define all the "buttons in the Arduino code that's painful and not update friendly.
Any help would be much appreciated.
yes simply like " if (message.type == V_IR_SEND ) { .... }"
On Tue, Jun 9, 2015 at 4:38 AM, Sebastien Vayrette-Gavard < notifications@github.com> wrote:
@DheerajKhajuria https://github.com/DheerajKhajuria I really appreciate that you added the feature and so quickly but I can't use it because I am unsure how to adapt the sketch. Is it as simple as changing the following line from the example @sweebee https://github.com/sweebee provided above
if (message.type == V_LIGHT) { // Check if received message is a switch message
to something like
if (message.type == V_IR_SEND ) { // Check if received message is a switch message
— Reply to this email directly or view it on GitHub https://github.com/DheerajKhajuria/pimatic-mysensors/issues/27#issuecomment-110167948 .
Hey DheerajKhajuria!
I am very new into programming and I try to learn and understand by reading a lot but I am stuck here at this point. I can get my sensor to print an "OK" if the message.type==V_IR__SEND. I also can switch my IR devices by using sweebee's method of assigning the hex codes to the relay states, but how do I get the sensor to send the hex code I send per rule? What I learned is that message.data the sensor receives from pimatic is const char (or something like that) and that irsend.send needs unsigned long. Am I totally wrong? Can you give me hints or show me the right way how I can get irsend.send to use the payload of the message from my pimatic rule?
Soooo....
solved it! Instead of sending HEX code, I calculate and send it in decimal. So in Pimatic rules instead of
send Ir nodeid:"14" sensorid:"1" cmdcode:"0xF7E01F"
I use
send Ir nodeid:"14" sensorid:"1" cmdcode:"16244767"
And this is what I have done in the node sketch:
void incomingMessage(const MyMessage &message) {
if (message.type==V_IR_SEND) {
long Code = message.getULong();
irsend.send(NEC, Code, 32);
}
}
Learning can be so funny!!!
Now it's time to go and spread some LED Stripes around the house :)
I wish I could use pimatic-mysensors to control infrared devices such as turn on and off TVs and audio appliances or even FAN. Is there anyway to do that already or this needs to be implemented?