for who needed a script that turns on/off Google assistant on a rpi [Solved]
Posted: Saturday 13 July 2019 17:22
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.
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
}
}