Below is node sketch (v1.5.4) and openhab sitemap&items for simple control. More advanced control needs rules/scripts to make it more automation like.
Set up the circuit, load below code or example code given and open serial monitor. Press buttons on IR remote and read hex values on serial. Note down values for buttons you need. (i.e. power off 0x184C, power on 0x104C, chanel up 0x1860 etc, RC5 protocol) If below sketch is uploaded to node, then adapt domoticz to send needed IR codes like i did in sitemaps part or use automation rules to send required commands to node to tv.
Here is my node sketch:
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*******************************
*
* REVISION HISTORY
* Version 1.0 - Henrik EKblad
* Version 1.1 - V_IR_SEND / _RECEIVE 16.08.2016 Any hex command received over NRF is send with IR led
* Version 1.2 - Don't send repeting codes - 19.08.2016 T. Keles
* Version 1.3 - Repeating code blocking correction - 01.09.2016 T.Keles
*
* DESCRIPTION
* This sketch decodes IR remote and send to gateway.
* Rules can interpret this or simpleused to find out button codes.
* Controller sends string code values as V_IR_Send and incoming message is emitted by IR led.
* An IR LED must be connected to Arduino PWM pin 3.
* An optional ir receiver can be connected to PWM pin 8.
* All receied ir signals will be sent to gateway device stored in V_IR_RECEIVE
* http://www.mysensors.org/build/ir
*/
#include <MySensor.h>
#include <SPI.h>
#include <IRLib.h>
int RECV_PIN = 8;
#define CHILD_1 3 // childId
IRsend irsend;
IRrecv irrecv(RECV_PIN);
IRdecode decoder;
unsigned int Buffer[RAWBUF];
unsigned long prevMillis=0;
MySensor gw;
MyMessage msg(CHILD_1, V_IR_RECEIVE); //send decoded ir code
void setup()
{
irrecv.enableIRIn(); // Start the ir receiver
decoder.UseExtnBuf(Buffer);
gw.begin(incomingMessage,2);
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("IR Remote", "1.3");
// Register a sensors to gw. Use binary light for test purposes.
gw.present(CHILD_1, S_IR);
}
void loop()
{
gw.process();
if (irrecv.GetResults(&decoder)) {
unsigned long curMillis=millis();
irrecv.resume();
decoder.decode();
decoder.DumpResults(); // dumresults print values to serial monitor
if(curMillis-prevMillis>900){ // if last IR received less than 900ms pass it, otherwise send it to GW
//This value is experimental and added to bypass rapidly repeating codes
prevMillis=curMillis;
if(!(decoder.value==0 || decoder.value==0xffffff)){ // if value is valid
char buffer[10];
sprintf(buffer, "%08lX", decoder.value); //format it to 8byte Uppercase Hex format
gw.send(msg.set(buffer)); // Send ir result to gw
}
}
}
}
void incomingMessage(const MyMessage &message) {
char ircode[11] = {0}; // in case your code takes the form of 0xE0E0FF0F
//incoming ir code is string, however IRSend need unsigned long Below codes do the work
if (message.type == V_IR_SEND) {
String hexstring = message.getString();
hexstring.toCharArray(ircode, sizeof(ircode));
// get the code as an unsigned long
unsigned long code = strtoul(ircode, NULL, 0);
if(code==0 || code ==0xFFFFFFFF) {} //if code is not valid, do nothing
irsend.send(RC5,code,13); // blast incoming hex code to IR device
}
// Start receiving ir again...
irrecv.enableIRIn();
}
In openhab .items file:
String TV_power "TV" <television> (gHomeMedia) {mysensors="2;3;V_IR_SEND"}
String TV_channel "Channel" <television> (gHomeMedia) {mysensors="2;3;V_IR_SEND"}
String TV_volume "Volume" <television> (gHomeMedia) {mysensors="2;3;V_IR_SEND"}
String IR_Receive "IR Code [%s]" <television> (gHomeMedia) {mysensors="2;3;V_IR_RECEIVE"}
In openhab sitemap:
Frame label="TV Control" {
Switch item=TV_power label="TV Power" mappings=[0x184C=OFF, 0x104C=ON]
Switch item=TV_channel label="Channel" mappings=[0x1860=UP, 0x1061=DOWN] visibility=[TV_power==0x104C]
Switch item=TV_volume label="Volume" mappings=[0x1850="V+", 0x1051="V-"] visibility=[TV_power==0x104C]
Text item=IR_Receive