Control openhab functions via IR (NOT VICE VERSA)

I did this by creating a tasmota rule on the d1 itself through tasmota web console. When I get to my computer next I can send the rule I use so you can change it to your needs.

The rule essentially acts as follows:

  • I use the DATA from your string mentioned above and have that publish an MQTT message that toggles another MQTT device of my choosing. For example: cmnd/Lamp-1/POWER TOGGLE
  • So now that I think of it, this solution is openhab agnostic (except that my pi with openhab is running my MQTT broker) and is more along the lines of device to device via MQTT.

The Tasmota Rule:

ON IrReceived#Data=0xA2AD807F DO publish cmnd/LR-Lamp-1/POWER TOGGLE ENDON

Replace your data string after “IrReceived#Data=” and replace everything between “publish” and “ENDON” with whatever MQTT message you want to publish.

Then I believe since your devices you are trying to control are not MQTT devices you could use openhab MQTT binding and rule to control your device. This is where the MQTT message you create in tasmota would be used.

UPDATE: I have solved a couple problems thanks to you.

  1. I now have a working connection between OpenHab and the broker, and a working tasmota thing reading the correct status. I have created a channel inside that thing, and a “fake item” showing the string of text I receive from tasmota. This is what I see now when I trigger a command on my Logitech Harmony:

so as you can see now I have my output string there.
2) I have found why I couldn’t add any channel to the existing items. It was due to the fact that the “openwebnet” items were coded in a .items file, so the only way I could add the channel from tasmota was to add it into the configuration file and now

Now only 2 problems remain:

  1. do I have to set the rules in a .rules file since all my configurations for “openwebnet” is done through text files or I can create it via wizard from the administration interface?
  2. I’d like to use the same IR command to trigger ON/OFF to avoid code and button duplication. Can I do that in the rule ? I have no experience at all about rule writing so I’m 100% blind :slight_smile:

Thank you for all your contributions helping me getting to this point !

UPDATE: I got a rule working to turn ON the lights (but I have no idea how to switch them off using the same command to update the status :slight_smile: getting closer!! )
UPDATE 2: the rule works only once, because it operates on the change of the string iIRTasmStatus, but that string stays the same, buffered until I send a different command and clean up the string. I should “reset” that state from the rule as soon as I have applied the correct command.
It should work something like this : IR command received → action toggle switch from ON to OFF or vice versa depending on the state → set the string state to NULL and wait for another command. This is the ideal scenario, I have no idea if I can implement it like that…
UPDATE 3: I added an action to change the item state to NULL after executing a command. But now I have to solve the problem of switching from ON to OFF since the rule allows me to set either ON or OFF but not toggle between them.

Is it possible to toggle a switch without changing item definition, for example through a script like
" if itemLight1 state is ON then set itemLight1 state to OFF else set itemLight1 state to ON " and trigger the script instead of sending a command to the switch directly? (I know I can fire up a script from the rule, but I have no idea about how to write a script like the one I have sketched here)

I’m almost there I know!!
Thank you all for your help!!

PROBLEM SOLVED !!
I have created a script inside the rule like this

type: application/javascript
script: |-
if (itemRegistry.getItem(‘iP2_Vetrine’).getState() == ‘ON’)
{
events.sendCommand(‘iP2_Vetrine’,‘OFF’)
}
else events.sendCommand(‘iP2_Vetrine’,‘ON’)
type: script.ScriptAction

Using this snippet 4 times in 4 different rules, parsing the corresponding IR codes from Tasmota, now I am able to turn my lights on and off using a Harmony Remote ! Cheer up !!!
Thanks everybody for your precious help and patience in helping me solve this problem !!
:blush:

2 Likes

Great news! :slight_smile:

Some final remarks from my side:

Please feel free to write a Tutorial for the community. :smirk:

You can even get by without a single line of code (at the cost of doubling the number of rules):

Of course, in some cases you could move all or part of the logic to the IR receiver (as suggested by @Miller87), but openHAB and its peripheral devices are already a complex distributed system and a distributed set of rules on top quickly reaches its limits in terms of maintainability.

This is just to confirm that the auvisio S06 (NX-4519-675, REV1_2018_09_11) I ordered from Pearl (Germany) a few days ago can be flashed with Tasmota:

Yes, I know that one could use tuya-convert to flash the device, but to get things done I eliminated the software pitfalls and soldered some wires to the ESP8266EX and used the Tasmotizer to flash the firmware. YMMV. :slight_smile:

Firmware: http://ota.tasmota.com/tasmota/release/tasmota-ir.bin

REGEX for Incoming Value Transformation:

REGEX:s/.*ol":"(.*)","Bits":(.*),"Data":"(.*)","DataLSB.*}}/$1_$2_$3/g

The reception range is quite impressive (5+ m) - I haven’t tested the integrated IR transmitter yet.

I also bought two of them (no specific job for that yet, but just in case…) and flashed them successfully via tuya-convert, but I had to use debian buster, as tuya convert will use some strange IP addresses with debian bullseye (luckily this is down in the issues of tuya-convert on github). Nevertheless, worked fine after getting around this issue.

… and then there is a Tuya-Zigbee version (ZS06) that is supported by Zigbee2MQTT: TuYa ZS06 control via MQTT | Zigbee2MQTT, e.g. Tuya Zigbee Smart IR Fernbedienung Universal Infrarot Fernbedienung für Smart Home für AC TV DVD arbeitet mit Alexa Google hause| | - AliExpress

Reading through the Zigbee2MQTT documentation for the ZS06 I get the impression that the flashed S06 seems to be more flexible.