how to use virtual switch,switch,media player ?
Moderators: leecollings, remb0
-
- Posts: 112
- Joined: Tuesday 13 September 2016 9:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Contact:
how to use virtual switch,switch,media player ?
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? i can not use remote and this is no settings for this.
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? i can not use remote and this is no settings for this.
- habahabahaba
- Posts: 190
- Joined: Saturday 18 March 2023 14:44
- Target OS: Windows
- Domoticz version: 2024.4
- Contact:
Re: how to use virtual switch,switch,media player ?
You have to write dzVents script actioned by your virtual switch.
So there you write all commands
So there you write all commands
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: how to use virtual switch,switch,media player ?
And in the Dzvents documentation there is section about how to set the commands https://www.domoticz.com/wiki/DzVents:_ ... dia_Server
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 112
- Joined: Tuesday 13 September 2016 9:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Contact:
Re: how to use virtual switch,switch,media player ?
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
for example i have this code for Vol+(with a espeasy ir trasmitter):
http://192.168.1.199/control?cmd=IRSEND,NEC,FF9867,32
- habahabahaba
- Posts: 190
- Joined: Saturday 18 March 2023 14:44
- Target OS: Windows
- Domoticz version: 2024.4
- Contact:
Re: how to use virtual switch,switch,media player ?
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 .
In your case if you are in local networ you can use
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
}
Code: Select all
domoticz.openURL({
url = '<YOUR URL>',
method = 'POST',
callback = 'TVcontrol_trigger', -- see httpResponses above.
}).afterSec(0)
-
- Posts: 112
- Joined: Tuesday 13 September 2016 9:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Contact:
Re: how to use virtual switch,switch,media player ?
thank you for help. i am beginner in dzVents. i try but i can not run this . i have an errorhabahabahaba 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 .
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'
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
- habahabahaba
- Posts: 190
- Joined: Saturday 18 March 2023 14:44
- Target OS: Windows
- Domoticz version: 2024.4
- Contact:
Re: how to use virtual switch,switch,media player ?
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
}
-
- Posts: 112
- Joined: Tuesday 13 September 2016 9:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Contact:
Re: how to use virtual switch,switch,media player ?
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
- habahabahaba
- Posts: 190
- Joined: Saturday 18 March 2023 14:44
- Target OS: Windows
- Domoticz version: 2024.4
- Contact:
Re: how to use virtual switch,switch,media player ?
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
Anyway
one switch = one button
one selector switch = several buttons
- habahabahaba
- Posts: 190
- Joined: Saturday 18 March 2023 14:44
- Target OS: Windows
- Domoticz version: 2024.4
- Contact:
Re: how to use virtual switch,switch,media player ?
Thats my virtual Selector Switch. I can put thare up to 10 buttons = up to 10 commands.Who is online
Users browsing this forum: No registered users and 0 guests