Xiaomi IR Remote

Others (MiLight, Hue, Toon etc...)
Post Reply
DAVIZINHO
Posts: 114
Joined: Sunday 27 August 2017 18:00
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Spain
Contact:

Xiaomi IR Remote

Post by DAVIZINHO » Thursday 28 September 2017 17:24

Hello,
I have domoticz configure and working fine with miio library (with air purifier configured OK)

I have a XIAOMI IR REMOTE, and i want to integrate it in domoticz. Anyone have idea???

thanks

DAVIZINHO
Posts: 114
Joined: Sunday 27 August 2017 18:00
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Spain
Contact:

Re: Xiaomi IR Remote

Post by DAVIZINHO » Friday 08 December 2017 21:48

nobody have the xiaomi IR remote??

DAVIZINHO
Posts: 114
Joined: Sunday 27 August 2017 18:00
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Spain
Contact:

Re: Xiaomi IR Remote

Post by DAVIZINHO » Wednesday 27 December 2017 14:33

Hello again,

I still investigating and fin some info:

python library that suuports Xiaomi IR Remote:
https://github.com/rytilahti/python-miio#id27

I install the library in my raspberry, but im a noob with python and i dont know how to progress :-(

wmmudde
Posts: 21
Joined: Monday 31 July 2017 14:33
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Xiaomi IR Remote

Post by wmmudde » Saturday 10 March 2018 23:54

Have this working allready?

DAVIZINHO
Posts: 114
Joined: Sunday 27 August 2017 18:00
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Spain
Contact:

Re: Xiaomi IR Remote

Post by DAVIZINHO » Monday 12 March 2018 15:12

Yes, it works fine:

you must use this library:
https://github.com/rytilahti/python-miio

and the create scripts:
IR.PY for learn the comand and save it to a codes.txt file

Code: Select all

#!/usr/bin/python3
import sys
import ipaddress
from typing import Any
from miio import ChuangmiIr,DeviceException
import time
import json
num_lines = sum(1 for line in open('codes.txt'))
print ('Stored Ir Keys  ->'+ str(num_lines) )
id = num_lines + 1
ir =  ChuangmiIr('your.IP','your token')
ir.learn(key=1)
time.sleep(10)
print (ir.read(key=1).get("code"))

with open('codes.txt', 'a') as file:
 	file.write(ir.read(key=1).get("code")+ '\n')
#
and this other script to irsend.py to send the comand (irsend.py 15), this send the comand in line 15 of your codes.txt

Code: Select all

#!/usr/bin/python3
import sys
import ipaddress
from typing import Any
from miio import ChuangmiIr,DeviceException
import time
f=open('/home/pi/Xiaomi/IR/SALON/codes.txt')
codeline=f.readlines()
#id = codeline[int(sys.argv[1])-1]
id_aux = codeline[int(sys.argv[1])-1].split(" ")
id=id_aux[0]
ir =  ChuangmiIr('YOUR.IP','YOUR.TOKEN')
ir.play(id,frequency='')

then integrate with virtual switches in domoticz and ready.

Sorry for the poor explanation but i dont have much time :-(

nickmorgan
Posts: 2
Joined: Friday 16 March 2018 11:25
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Xiaomi IR Remote

Post by nickmorgan » Friday 16 March 2018 11:50

I will correct not much
In the script irsend.py the last line should look like this

Code: Select all

ir.play_raw (id,frequency='')
only so I sent the code

You can also send commands with the following code

Code: Select all

mirobo --ip 192.168.0.25 --token 689c4056fe28ebb3a2e8c2fe350e51ba raw_command miIO.ir_play '{"freq": 38400, "code": "base64..."}'
which is much easier to install into other scripts

Sorry for my bad english :)

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests