for who needed a script that turns on/off Google assistant on a rpi  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

for who needed a script that turns on/off Google assistant on a rpi  [Solved]

Post by pvklink »

For those who need a script to turn on/off google assistant on a raspberry pi..
script runs on two rpi's with domoticz, one for logging and put it on/off on the other rpi google assistant is actually running...
these two rpi's use a domoticz remote server config.

Code: Select all

return {
	on =    {
                devices = {'google assistant'},
             },
        
    logging =   { level   = domoticz.LOG_ERROR ,                                                
                  marker  = "google"},
              
    execute = function(dz,item,info)
    local compnaam = dz.settings.location.name

    if compnaam == 'Domoticz_desktop' then			-- you can put your own logging here
        local logcode = 3
        local messageTable = {}
        local add = 'add'
        local del = 'del'
        local chg = 'chg'
        
        local function globalMessage(action, message, logcode)
 
            if logcode == nil then logcode = 3 end
 
            if action == add and logcode > 0 then
                messageTable = dz.helpers.addMessage(dz, item, info, message, messageTable, logcode)
            elseif action == del then
                dz.globalData.mylogging = message
                dz.devices('timerlog').updateText(message)
            elseif action == chg then 
                dz.helpers.dumpMessages(dz, messageTable)
            end
 
        end

        globalMessage(add, ' GOOGLE: google assistant is ' .. item.state .. ' gezet',logcode)
        globalMessage(chg) -- dump

    else	-- the actually on off command. this part executes on the rpi with google assistant
    
        if item.name == 'google assistant' and item.state == 'On' then      
	        os.execute('sudo systemctl start google-assistant.service')
        else
	        os.execute('sudo systemctl stop google-assistant.service')
        end
    end

end
}
}
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest