For the love of gawd can we get a momentary switch already?

cause why would i need to make a universal remote for the web front end?

i mean, that’s just crazy talk.

Because you love Home Assistant, and can’t wait to flesh that idea out a bit more so it’s a more of a conversation starter :slight_smile:

Don’t make me look silly for believing your crazy talk now!

as opposed to the 20 other posts requesting a momentary switch component?

we need a button component that DOES NOT have an ON/OFF state. it simply fires when you push the button.

ah but you say, “that’s what a script is for.”

so if i want like 20+ buttons for a standard universal remote, i’m supposed have 20+ individual scripts? kluuuuge.

2 Likes

Wouldn’t HADashboard, and Floorplan fit the bill there?

I just got an RM PRO and made it learn the remotes then imported the IR codes into HA. Then I used floorplan to create some remotes and mapped the switches from the RM PRO to the buttons on the floorplan - works a treat :smiley:

ok, i like that idea.

I would like to see a plain button too. Just something that can trigger a simple script or service. We already have…

The one thing missing in that list is an Input button if you ask me.

And yes; we can use scripts, but I personally do not like how they show up in the front end with their ‘activate’ label. In a lot of cases, this representation is too elaborate already.
For example, I can call an URL to move my camera up/down/left/right. I would like to have something like this (a label with four buttons)…
Move camera 🠜 🠝 🠟 🠞

But at the moment I’m stuck using this…
Move camera left ACTIVATE
Move camera up ACTIVATE
Move camera down ACTIVATE
Move camera right ACTIVATE

… which takes up a lot of screen real-estate without adding anything. If anything, it makes things unnecessarily complicated.

Regarding the use of floorplan etc.: Yes, we can solve it using a tool or plugin like that. However, I find it a bit shocking that we have to use something so elaborate just to get a (few) simple buttons. I see those more as a workaround than a solution.

I’m interested to hear your thoughts @Bit-River @stone @keithh666 (and other readers, ofcourse!)

3 Likes

Possible duplicate of:

I agree with the OP.
I’m happy to be shot down flamed and corrected castigated and made to feel small like many forum folks love to do, but after six months of trying to learn HA and everything surrounding it, it seems to me that the most basic mechanical input device for HA to mimic or accept was overlooked ?
A switch_momentary.

We have a latching switch effectively as a basic I/O function, and that works a treat for me with great ease and no fuss at all for matching hardware like mains sockets and real lights, I was very happy at how fast I got those to do great stuff, but later when I added RF door switches and some RF key fobs it got tough fast. Components like RFlink hub, create basic light. entities for each RF device (or every button code on each RF device) and it gets very messy very fast to make that into a usable momentary switch or binary sensor.

At the moment for instance, to make a Sonoff DW1 door switch behave like the momentary device it really is, I have too:
Identify the RFlink automatically created light.entity device name once it appears in hassio, and then manually create a switch in configuration.yaml to make it appear a switch in hassio, then I create a template binary sensor in configuration.yaml to make a virtual binary sensor from that entity, then use two automations to make that reset to closed after a few seconds to mimic the physical RF switch.
If I have 12 window and door switches like that one (because they cost half what a open/closed signalling switch costs) they I’m tapping away at my PC for hours when I should be building or installing hardware to actually do some automation…

Anyway, maybe I missed some crucial bit of info that would cut out three or four of those steps. If so PLEASE tell me straight up what it is cos if it’s there I’ve repeatedly missed it :slight_smile:

Humble user,
Martin

3 Likes

By momentary switch, you mean a button on the interface that when pressed preforms the action and then is back in its original state ready for the next press?

If so, the magical thing you’ve been missing is called ‘script’.

If you put a script on the front end, it (by default) puts a button called activate. Pressing this button runs the script, which is to send the rf command. Press it a second time, it sends the rf command again, exactly as a momentary switch would.

Admittedly the ACTIVATE button is not so pretty, but there’s multiple custom_ui options to solve this.

Hope this helps.

You could also use template switches with the state set to false. the switch will always return to off.

switch:
  - platform: template
    switches:
      copy:
        value_template: "{{ false }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.source
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.source
1 Like

Thanks gentlemen, both of you.
No I’d not found script in relation to momentary switch so I’ll have a look.

Yep you are right, I’m meaning a momentary switch as is in the physical sense of a switch that is spring loaded so that once the user stops pressing it the signal, trigger or connection is gone. A morse code key would be a classic example, as is any button on a TV remote control, car alarm fob or door bell button that does not stay latched on etc.

rabittn, I will try your code snip, I don’t understand it yet, but I’ll try it :slight_smile:

Actually I think were at opposite ends of what I want to do perhaps. I don’t want the HA interface to set a switch off after I press a button on the interface, I want the HA interface to set a sensor to off in HA after a few seconds delay after the ‘on’ event, because the sensor has no ‘off’ transmission of it’s own.
I’ll continue to tinker with some ideas.

I’m not following tbh. You want to press a button, switch something on, and then it switch off again after a few seconds?

Still script…

script:
  button_test:
    alias: Button 
    sequence:
      - service: homeassistant.turn_on
        entity_id: THING
      - delay: 00:00:03
      - service: homeassistant.turn_off 
        entity_id: THING

Where THING is the entity ID of the device you’re switching.

5 Likes

Use a script and put a tiny delay in the action of that script and HA will represent it as a momentary switch.

Thanks. Yeah I’m not sure I’m clear about it yet, but I can try the script (which I’ve never done before) and see if it does what I think I’m looking for :slight_smile:

I’ll reword the issue just in case, and use my physical example.
I have a couple of door and window RF transmitter and want to fit many more, they communicate to HA via an 433Mhz RF hub. The RF hub only sends an ‘on’ to HA for each entity, and never an ‘off’ (because these RF transmitters have only one code). HA hassio GUI shows the door opened forever unless I manually ‘off’ it in the hassio gui. Then it’s ready to be tripped again, and do automations. I’d like either the RF hub or HA to ‘reset’ the entity back to ‘off’.
I’ve just reflashed my Sonoff RF bridge to Tasmota FW (from Espurna FW) and I’ll see if I can recreate the entities and try the script on them. I also have a DIY RFLink hub which I’m playing with.

I would start your own topic. What you are looking for is a binary sensor to automatically switch back to off. This topic is more about momentary switches.

What your are looking to do can most definitely be done. Tag me in your new topic and we can have a look.

Hi, I’ve started a new topic, but I did not see where to add member tags. So the link is below.

Hi,

I hope it is still relevant - here is my solution for push button using appdaemon app:

import appdaemon.plugins.hass.hassapi as hass

class door_command(hass.Hass):
    
    def initialize (self):
        self.listen_state(self.callback, "input_boolean.push_button")

    def callback (self, entity, attribute, old, new_state, kwargs):
        if new_state == 'off':
                self.turn_on(entity_id = "input_boolean.push_button")
        else:
                # do your stuff

I 100% support this, earlier when I used Domoticz we head something called “Push on/off button” that just sendt on or off commands, it was super useful and something I miss in HA.