Page 1 of 1
how to use virtual switch,switch,media player ?
Posted: Sunday 15 September 2024 13:11
by reza
hi guys
i want use a misc remote. i have IR codes and i have an espeasy IR transmitter. in domoticz i want use a virtual switch as media player. how to use remote controller in dummy device?

- Media_Player.png (17.02 KiB) Viewed 1291 times
i can not use remote and this is no settings for this.
Re: how to use virtual switch,switch,media player ?
Posted: Wednesday 18 September 2024 8:20
by habahabahaba
You have to write dzVents script actioned by your virtual switch.
So there you write all commands
Re: how to use virtual switch,switch,media player ?
Posted: Wednesday 18 September 2024 8:43
by waltervl
And in the Dzvents documentation there is section about how to set the commands
https://www.domoticz.com/wiki/DzVents:_ ... dia_Server
Re: how to use virtual switch,switch,media player ?
Posted: Saturday 21 September 2024 10:07
by reza
can you give me a simple dzvents code for control with virtual switch (media player) for use media player remote control. for example for play/pause or vol+ or vol-
for example i have this code for Vol+(with a espeasy ir trasmitter):
http://192.168.1.199/control?cmd=IRSEND,NEC,FF9867,32
Re: how to use virtual switch,switch,media player ?
Posted: Saturday 21 September 2024 14:00
by habahabahaba
In my case i have a virtual switch type of Selector for my TV.
But my IR controller needs internet so i need curl installed .
Code: Select all
return {
on = {
devices = {87}, -- IDx of your virtual switch
httpResponses = {
'TVcontrol_trigger' -- must match with Callback
}
},
logging = {
level = domoticz.LOG_INFO,
marker = 'TV control',
},
execute = function(domoticz, device)
local devID = ''
local APIkey = ''
--local position = device.state
local positionName = device.levelName
local switch = domoticz.devices(87)
local switchState = switch.level
-- check current state
if switchState == 0 then -- on/off
devID = '1
--domoticz.log('Zero', LOG_ERROR)
elseif switchState == 10 then -- chanel +
devID = '2'
--domoticz.log('10', LOG_ERROR)
elseif switchState == 20 then -- Vol +
devID = '3'
domoticz.log('20 ' .. positionName, LOG_ERROR)
elseif switchState == 30 then -- Vol ++
devID = '4'
--domoticz.log('30 ++', LOG_ERROR)
elseif switchState == 40 then -- Vol -
devID = '5'
--domoticz.log('40 -', LOG_ERROR)
elseif switchState == 50 then -- Vol -- Vl▼
devID = '6'
domoticz.log('50 --' .. positionName, LOG_ERROR)
elseif switchState == 60 then -- Chanel -
devID = '7'
--domoticz.log('60 -', LOG_ERROR)
elseif switchState == 70 then
devID = '8'
--domoticz.log('70', LOG_ERROR)
end
local Command = 'curl -H \"Authorization: Bearer '.. APIkey ..'\" -s -X POST \"https://api.iot.yandex.net/v1.0/scenarios/'.. devID ..'/actions\"'
domoticz.executeShellCommand(Command)
--domoticz.log(switchName, LOG_ERROR)
end
}
In your case if you are in local networ you can use
Code: Select all
domoticz.openURL({
url = '<YOUR URL>',
method = 'POST',
callback = 'TVcontrol_trigger', -- see httpResponses above.
}).afterSec(0)
Re: how to use virtual switch,switch,media player ?
Posted: Saturday 21 September 2024 15:11
by reza
habahabahaba wrote: ↑Saturday 21 September 2024 14:00
In my case i have a virtual switch type of Selector for my TV.
But my IR controller needs internet so i need curl installed .
thank you for help. i am beginner in dzVents. i try but i can not run this . i have an error
Code: Select all
2024-09-21 16:27:00.324 Error: dzVents: Error: (3.1.8) error loading module 'Script #2' from file '/home/pi/Domoticz/scripts/dzVents/generated_scripts/Script #2.lua':
2024-09-21 16:27:00.324 ...pi/Domoticz/scripts/dzVents/generated_scripts/Script #2.lua:30: unfinished string near ''1'
also can not open remote control of virtual device "media player" again.
can you help me more? thank you
please give me one complete dzVents code with that my url and espeasy for my vol+ that i can open remote of virtual device "media player" so i can to complete with other button , thank you
Re: how to use virtual switch,switch,media player ?
Posted: Saturday 21 September 2024 17:11
by habahabahaba
Try this
Code: Select all
local devId = 87 -- change to your switch IDx
return {
on = {
devices = {devId}, -- IDx of your virtual switch
httpResponses = {
'MediaPlayer' -- must match with Callback
}
},
logging = {
level = domoticz.LOG_INFO,
marker = 'TV control',
},
execute = function(domoticz, device)
local volUp = 'http://192.168.1.199/control?cmd=IRSEND,NEC,FF9867,32'
local switch = domoticz.devices(devId)
domoticz.openURL({
url = volUp,
method = 'POST',
callback = 'MediaPlayer', -- see httpResponses above.
}).afterSec(0)
domoticz.log('Volume Up of ' .. switch.name, LOG_INFO)
end
}
Re: how to use virtual switch,switch,media player ?
Posted: Sunday 22 September 2024 23:01
by reza
thank you. i try and this message write to log every some seconds and repeat.
Code: Select all
2024-09-23 00:26:50.692 Status: EventSystem: Script event triggered: /home/pi/Domoticz/dzVents/runtime/dzVents.lua
2024-09-23 00:26:50.757 Status: dzVents: Info: Handling httpResponse-events for: "MediaPlayer"
2024-09-23 00:26:50.757 Status: dzVents: Info: TV control: ------ Start internal script: Script #1: HTTPResponse: "MediaPlayer"
2024-09-23 00:26:50.775 Status: dzVents: Info: TV control: Volume Up of iii
2024-09-23 00:26:50.775 Status: dzVents: Info: TV control: ------ Finished Script #1
and again remote control on virtual device(media player) can not open and dont show any bottun.
Re: how to use virtual switch,switch,media player ?
Posted: Monday 23 September 2024 10:41
by habahabahaba
Sorry, i gave you example for the virtual switch, i dont know such device as virtual device (media player). May be you are using some plugin...
Anyway
one switch = one button
one selector switch = several buttons
Re: how to use virtual switch,switch,media player ?
Posted: Monday 23 September 2024 10:48
by habahabahaba

- 2024-09-23_11-41-34.png (4.3 KiB) Viewed 1204 times
Thats my virtual Selector Switch. I can put thare up to 10 buttons = up to 10 commands.
Oh, and does your URL "
http://192.168.1.199/control?cmd=IRSEND,NEC,FF9867,32" work from browser?
Re: how to use virtual switch,switch,media player ?
Posted: Wednesday 15 January 2025 21:14
by FireWizard
Hi all,
I would like to use the Multimedia switch also for controlling a Multimedia device.
If you create a switch, either by selecting as hardware "Dummy (Does nothing, use for virtual switches only) and
creating a virtual switch or using the http command, you will get a virtual switch.
If you change the switch to a "Media Player" switch you will get a "Remote" device at the right of the selected
"Switch icon".
This is also the case if you select multimedia hardware, such as a Panasonic TV, Kodi media player or Logitech media Server (LMS), etc
In this case you will get a pop-up remote, that can be operated.
However, with a virtual Media Player switch you get only a "dead picture" of the Remote and no pop-up window.
It is not clickable.
Did someone succeed to get it functioning?
Regards