Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Timer trait #98

Merged
merged 8 commits into from
Feb 11, 2024
Merged

Add Timer trait #98

merged 8 commits into from
Feb 11, 2024

Conversation

DewGew
Copy link
Owner

@DewGew DewGew commented Feb 8, 2024

Needs to add a dzVents script in Domoticz to act like a timer. Example:

return {
	on = {
            customEvents = { 'TIMER' },
	},
	logging = {
            level = domoticz.LOG_INFO,
            marker = "Timer"
        },
	execute = function(dzga, item)
	    if (item.isJSON) then
    	        local device = dzga.devices(item.json.idx)
    	    
    	    if (device.active and item.json.cancel) then
    	        dzga.log('Stop timer for ' .. device.name)
    	        device.cancelQueuedCommands()
            else
                dzga.log('No timer is running for' .. device.name)
            end
            if  item.json.on == true then
                device.cancelQueuedCommands()
                device.switchOn()
                dzga.log('Switch ' .. device.name .. ' On for: ' .. item.json.time .. ' sec')
                device.switchOff().afterSec(item.json.time)
            end
        end
    end
}

Use like this:

User: Turn on living room light for 5 minutes.
Google Assistant: Turning on living room light for 5 minutes?
User: Stop timer for living room light.
Google Assistant: Updating living room timer? (Turn off light/switch manually)

@DewGew DewGew added the enhancement New feature or request label Feb 8, 2024
@DewGew DewGew merged commit 03c6e9d into development Feb 11, 2024
2 checks passed
@DewGew DewGew deleted the DewGew-patch-1 branch February 11, 2024 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant