send Message to Enigma 2 set top boxes

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.
Post Reply
User avatar
lonebaggie
Posts: 106
Joined: Tuesday 31 January 2017 14:21
Target OS: Raspberry Pi
Domoticz version: beta
Location: England
Contact:

send Message to Enigma 2 set top boxes

Post by lonebaggie » Saturday 09 September 2017 13:58

I have written a quick script to send a message to the TV screen via Enigma Set top box.

Create new User variable event and cut and paste the following script

Code: Select all

-- This script is used to send Messages to Enigma2 boxes
-- This script will trigger on any uservariables being changed
-- Place messages in string User variable  EnigmaMessage 
-- Once sent message will be removed from EnigmaMessage
-- If not running Enigma Scan remove Fuction split, table Vars  and amend variable Ip to be the IP address of Enigma2 box

-- Note to trigger switch Uservarible must be triggered by external Program or use Switch-Link

-- Version 1.0

-- Setup Variables
commandArray = {}


-- Set functions
function split(pString, pPattern)
    local Table = {}  
    local fpat = "(.-)" .. pPattern
    local last_end = 1
    local s, e, cap = pString:find(fpat, 1)
    while s do
        if s ~= 1 or cap ~= "" then
            table.insert(Table,cap)
        end
        last_end = e+1
        s, e, cap = pString:find(fpat, last_end)
    end
    if last_end <= #pString then
        cap = pString:sub(last_end)
        table.insert(Table, cap)
   end
   return Table
end
-- Set Variables 

-- Remove following two lines if not running Enigma-Scan
-- REplace with ip = "ip of Enigma 2 box"
Vars = split(uservariables["EnigmaParams"],"|")
ip = Vars[1]
message  = uservariables["EnigmaMessage"]

-- Start Program

print("Start Enigma Message")
if message ~= nul then
    url = ("http://" .. ip .. "/web/message?text=" .. message .. "&type=1&timeout=15")
    url = string.gsub(url, " ", "%%20")
    commandArray[1]={["OpenURL"] = url}
    message = ""
    commandArray[2]={["Variable:EnigmaMessage"] = message}
end
return commandArray  
If you are not running my previous enigma scripts viewtopic.php?f=38&t=16866 remove and amend the lines indicated in the script.

The script will only be called when the User variables updates. This is normally from an external programs via Json. Updating from commandarray or from within Domoticz will not trigger User Variable scripts . However I have also written script-link which allows you to link switches to User variables which will trigger scripts see

viewtopic.php?f=38&t=19217

For set messages on switches you could also use the http notification option see

viewtopic.php?f=4&t=13217&p=124071&hili ... a2#p124071


Hope this proves useful

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests