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.
Permalink
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
.gitignore
LICENSE Initial commit Aug 27, 2019
README.md Update README.md Jan 10, 2020
changelog added inverted mode Jan 10, 2020
hacs.json added hacs.json Aug 30, 2019
info.md Update info.md Jan 10, 2020
install initial checkin Aug 27, 2019

README.md

hass-momentary

Momentary Switch Component for Home Assistant

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

NOTES!

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

Notes

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.

Thanks

Many thanks to:

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

Installation

HACS

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.

Manually

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:

momentary:

To create a momentary on switch use the following:

switch:
  - 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:

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