dnpwwo / Domoticz-Google-Plugin

MIT License
40 stars 10 forks source link

Radio in Google Home (mini) #9

Closed GieBek closed 4 years ago

GieBek commented 5 years ago

Thank you very much for this plugin.

However, please help me, how to start the radio and set the set volume, I mean commands in eg LUA or dzVents.

Please, write a small, simple script.

Thank you and best regards.

GieBek commented 5 years ago

Thank you again for this plugin. I managed to write something. It works 100% quieter, louder turn on and off. Beautiful.

`return { on = { devices = {'Salon - Sensor'}, -- Change out PIR },

execute = function(dz, PIR) local Radio = dz.devices('Google - Salon Playing') -- Change out light local Volume = dz.devices('Google - Salon Volume') --dz.log(Radio.name .. ' state: ' .. Radio.state .. '; level: ' .. Radio.level )

    local dimTimeTable  = { --  [   'timeSlot'   ]  = volume
                               -- ['at 00:00-08:00']  = 15,
                                ['at 08:01-09:59']  = 18,
                                ['at 10:00-21:00']  = 24,
                                ['at 21:01-23:59']  = 13,
                          }

    if PIR.state ~= 'On' then 
        Radio.switchOff().afterMin(1)
        --Radio.setVolume(volume-10).afterMin(3)
        --Radio.stop().afterMin(1)
       -- dz.log(Radio.name .. ' switched Off')
    else
        for timeSlot, volume in pairs (dimTimeTable) do
           if dz.time.matchesRule(timeSlot) and Radio.state == 'Off' then
                --if Radio.state == 'stop' then --and Radio.state ~= 'stop' and Radio.state ~= 'pause' then
                    Volume.dimTo(volume-12)
                    Radio.switchOn()
                    Volume.dimTo(volume-10).afterSec(2)
                    Volume.dimTo(volume-8).afterSec(4)
                    Volume.dimTo(volume-6).afterSec(6)
                    Volume.dimTo(volume-4).afterSec(8)
                    Volume.dimTo(volume-2).afterSec(10)
                    Volume.dimTo(volume-1).afterSec(11)
                    Volume.dimTo(volume).afterSec(12)
                    --dz.log(Radio.name .. ' switched On (Volumelevel: ' .. volume .. ')' )
                    return false
                --end
            end
        end
    end
end

}`