Skip to content
Momentary Switch Component for Home Assistant
Python Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
custom_components/momentary added inverted mode Jan 10, 2020
images adaded jetbrains image Aug 27, 2019
LICENSE Initial commit Aug 27, 2019 Update Jan 10, 2020
changelog added inverted mode Jan 10, 2020
hacs.json added hacs.json Aug 30, 2019 Update Jan 10, 2020
install initial checkin Aug 27, 2019


Momentary Switch Component for Home Assistant

A simple switch component that once turned on will turn itself off.


This release includes a mode configuration allowing the switch to be momentarily on or off. Existing configurations will work with the new code but use the new configuration going forward.

Table Of Contents

  1. Notes
  2. Thanks
  3. Installation
    1. Migrating from Old Layout
    2. Manually
    3. From Script
  4. Component Configuration


Wherever you see /config in this README it refers to your home-assistant configuration directory. For me, for example, it's /home/steve/ha that is mapped to /config inside my docker container.


Many thanks to:

  • JetBrains for the excellent PyCharm IDE and providing me with an open source license to speed up the project development.



hacs_badge Momentary is going to be part of the default HACS store. If you're not interested in development branches this is the easiest way to install.


Copy the momentarydirectory into your /config/custom_components directory.

From Script

Run the install script. Run it once to make sure the operations look sane and run it a second time with the go parameter to do the actual work. If you update just rerun the script, it will overwrite all installed files.

install /config
# check output looks good
install go /config

Component Configuration

Add the following to your configuration.yaml to enable the component:


To create a momentary on switch use the following:

  - platform: momentary
    name: Empty House Trigger
    mode: on
    toggle_for: 5
    cancellable: True

The following additional parameters can be specified against the switches:

Field Type Default Description
name strings Name of the switch. Has to be supplied.
mode string on Is the switch a momentary ON or OFF switch. Use on for on and off for off.
toggle_for seconds 1 Amount of time to turn toggle switch for.
cancellable Boolean False Allow switched to be untoggled manually.
on_for seconds 1 DEPRECATED Amount of time to turn the switch on for.
allow_off Boolean False DEPRECATED Allow switched to be turned off manually.

To add multiple switches repeat the whole component configuration:

  - platform: momentary
    name: Empty House Trigger
    mode: on
    toggle_for: 5
  - platform: momentary
    name: Bad Weather Trigger
    mode: off
      milliseconds: 500
You can’t perform that action at this time.