Change Onkyo NR Volume using Xiaomi Magic Cube Controller and Domoticz

  Domoticz

This how-to explains the basics of how you can read and store variables, and perform mathamatics on them via Lua in Domoticz. (Video Below)



Make sure your Xiaomi Magic Cube controller and Onkyo NR are setup in domoticz.

Go to Events and create a new lua event triggered based on device.

Paste the code below, make sure the names of the devices match your configuration. The print commands are just done for convenience to see what happens in the domoticz log. The device states anti_clock_wise and clock_wise are predefined in domoticz (version 3.8153 at this moment).

commandArray = {}

print ("All based event fired");
if (devicechanged['Xiaomi Cube'] == 'anti_clock_wise') then
 print('Volume Naar Beneden')
 print(otherdevices_svalues['Master volume onkyo'])
nieuwvolume = (otherdevices_svalues['Master volume onkyo']-3)
 print(' nieuw:' .. nieuwvolume .. ' ')
 commandArray['Master volume onkyo'] = 'Set Level:'..nieuwvolume..' '
 commandArray['Xiaomi Cube'] = 'Off'

elseif (devicechanged['Xiaomi Cube'] == 'clock_wise') then
 print('Volume Naar Boven')
 print(otherdevices_svalues['Master volume onkyo'])
nieuwvolume = (otherdevices_svalues['Master volume onkyo']+3)
 print(' nieuw:' .. nieuwvolume .. ' ')
 commandArray['Master volume onkyo'] = 'Set Level:'..nieuwvolume..' '
 commandArray['Xiaomi Cube'] = 'Off'
end
return commandArray

 

 


LEAVE A COMMENT