twrecked / hass-momentary Goto Github PK
View Code? Open in Web Editor NEWMomentary Switch Component for Home Assistant
License: GNU Lesser General Public License v3.0
Momentary Switch Component for Home Assistant
License: GNU Lesser General Public License v3.0
So I added:
momentary:
to my config.yaml
But where do I add the following? Because I added it to a manual card on the lovelace dashboard but it doesn't seem to work. So I have an input select in my Automations.yaml called: input_select.spa_first_blower. Which is linked to the entity called: pool1_channels2_mode in configuration.yaml
So how do I link that to your card?
Where do I put the following and how to I link it to the Entity or the Input_Select, which in addition, which one do I link it to?
In summary: my API to my SPA cycles through states, 'auto' 'on' 'off'. it does not allow me to select one using input select, I actually need to cycle. So I am trying to create a button which allows me to cycle through and shows the current status on the dashboard so that after we finish in the spa we can set it back to 'off'
switch:
platform: momentary
name: Empty House Trigger
mode: on
toggle_for: 5
cancellable: True
I have added the requested info below. The communication is via REST Api with their systems. The problem I am having with the below is that input_select with a drop down does not work because the API does not allow you to select a 'state' it only allows you to cycle through the individual modes - off, on, auto. Ideally I would like to have a button that just sets the state but I am not sure how I would even do that.
So my backup was just to have a button that says "Top Spa Bubbles" and the current state that it is in, so you can press it - check the state and press it again and check the new state.
Thank you for your help!
In my config.yaml I have
spa_first_blower:
name: Top Spa Bubbles
options:
id: '1628215649697'
alias: Top Spa Bubbles On
description: ''
trigger:
platform: state
entity_id: input_select.spa_first_blower
to: 'on'
condition: []
action:
service: rest_command.poolaction
data:
action_code: 1
device_number: 2
value: 2
delay: 2
service: homeassistant.update_entity
entity_id: sensor.pool1_channels2_mode
mode: single
id: '1628215649696'
alias: Top Spa Bubbles Off
description: ''
trigger:
platform: state
entity_id: input_select.spa_first_blower
to: 'off'
condition: []
action:
service: rest_command.poolaction
data:
action_code: 1
device_number: 2
value: 0
delay: 2
service: homeassistant.update_entity
entity_id: sensor.pool1_channels2_mode
mode: single
Hi There,
Im more then happy to help you and make this integration better.
I installed the 7.0a3 version and created a 'momentary.yaml' file. Added my switches into it.
HA created new switches without momentary_ part in front. For me better to have this into the entity name.
So added 'Momentary' in front of the name.
Now HA creates second entities with the new names. It doesn't remove the old entities.
I removed the integration. Removed the old entities. Add integration and now I have the correct entities without the old once in system as well.
Off-topic: In future we are able to create switches in HA system itself without the .yaml file? Thats whole idea of the config eco system right?
So I added:
momentary:
to my config.yaml
But where do I add the following? Because I added it to a manual card on the lovelace dashboard but it doesn't seem to work. So I have an input select in my Automations.yaml called: input_select.spa_first_blower. Which is linked to the entity called: pool1_channels2_mode in configuration.yaml
So how do I link that to your card?
Where do I put the following and how to I link it to the Entity or the Input_Select, which in addition, which one do I link it to?
In summary: my API to my SPA cycles through states, 'auto' 'on' 'off'. it does not allow me to select one using input select, I actually need to cycle. So I am trying to create a button which allows me to cycle through and shows the current status on the dashboard so that after we finish in the spa we can set it back to 'off'
switch:
Hello,
Thank you for the Momentary Switch component.
I am running 0.116.4 and recently noticed the following 'warning' entry: "SwitchDevice is deprecated, modify MomentarySwitch to extend SwitchEntity"
Has this been observed by others? Can you advice how to fix this?
Regards,
Since updating to HA Core 2024.5.0 I now this error in the HA logs:
Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:239
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 5:26:48 AM (1 occurrences)
Last logged: 5:26:48 AM
[281472740648384] Unexpected exception
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
response = await hass.services.async_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2738, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2779, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1047, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1680, in async_turn_on
await self.hass.async_add_executor_job(ft.partial(self.turn_on, **kwargs))
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/momentary/switch.py", line 213, in turn_on
self._start_activity(True)
File "/config/custom_components/momentary/switch.py", line 210, in _start_activity
self.async_schedule_update_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1258, in async_schedule_update_ha_state
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1008, in async_write_ha_state
self.hass.verify_event_loop_thread("async_write_ha_state")
File "/usr/src/homeassistant/homeassistant/core.py", line 440, in verify_event_loop_thread
frame.report(
File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 162, in report
_report_integration(what, integration_frame, level, error_if_integration)
File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 203, in _report_integration
raise RuntimeError(
RuntimeError: Detected that custom integration 'momentary' calls async_write_ha_state from a thread at custom_components/momentary/switch.py, line 210: self.async_schedule_update_ha_state(). Please report it to the author of the 'momentary' custom integration.
Logger: homeassistant.helpers.frame
Source: helpers/frame.py:190
First occurred: 5:26:48 AM (1 occurrences)
Last logged: 5:26:48 AM
Detected that custom integration 'momentary' calls async_write_ha_state from a thread at custom_components/momentary/switch.py, line 210: self.async_schedule_update_ha_state(), please report it to the author of the 'momentary' custom integration
whenever one of my momentary switches is turned on. I was running version 0.6.3 but just updated to 0.7.0.alpha.6 and still have the issue.
Greetings;
I just came upon your momentary switch and have installed and configured it. However, I am not clear on how I actually make the switch trigger things.
My current setup is using various command lines in switches, but inclusion in momentary throws error messages.
For example, from my configuration.yaml:
- platform: momentary name: Increase + mode: on toggle_for: milliseconds: 500 command_on: !secret arizer_increase command_off: !secret arizer_light_off value_template: "{{ value | regex_search('ACTIVE', ignorecase=True) }}"
produces the following error:
Invalid config for [switch.momentary]: [command_on] is an invalid option for [switch.momentary]. Check: switch.momentary->command_on. (See ?, line ?).
If I create a second switch entity inside the configuration.yaml, upon reboot of the core or host the system will only recognize the second entry in the config file. Is there a setting I'm missing or does the functionality to support multiple switch entities not exist?
Hi All,
I love this integration. Would be so nice to have option that the integration can check if there is a HA restart and before the restart switch was on and for how long. Then when HA run again keep state and go with the timer where its end because of restart.
Example:
switch 1 is on for total 7200 seconds. HA restart after 30min of turn on this switch.
When HA is restart, switch keep on and there is 5400 seconds left before it turns off.
I'm using:
alias: track_fan_toilette_off
description: ""
trigger:
- platform: state
entity_id:
- light.fan_salle_de_bain_light
to: "off"
condition: []
action:
- service: homeassistant.turn_off
data: {}
target:
entity_id: switch.momentary_auto_off_fan_toilette
mode: single
and
switch:
- cancellable: true
mode: 'on'
name: auto off fan toilette
platform: momentary
toggle_for: 15
When I turn off the physical switch, switch.momentary_auto_off_fan_toilette
turn off, but it reactivates after 15 secs.
I'm expecting my config to turn off switch.momentary_auto_off_fan_toilette
after 15 secs but not the reverse.
With the latest v0.3, when multiple switches are setup, hass frontend doesn't load and no errors are present in the log. Rolling back to v.2, all works as expected.
I am running hasbian docker v 97.2
Similar to momentary ON, please allow an invert so that this can be used as momentary OFF. I would like to have a device ON all the time, but turned OFF for a couple of seconds only in emergency situations. Thank you.
I did upgrade to version v0.6.1.1, after that toggle_for was not working.
Following my configuration
switch stay 'off' for no more tha 1s intead of 30sec.
I'm running HA as docker on Raspberry PI 4, version is 2023.1.2.
Would you help me?
Thanks in advance
Regards
Stefano
Hello
I would like to use shorter on_for
time if it possible.
I tried smaller values than 1s but it is not working.
Is it possible change this?
Thanks
Great Job
Hello,
I have added a switch as per the documentation.
However, I don't understand how to link this to an entity ?
Ultimate goal is to display a button on lovelace that would trigger this switch
Thanks for your help !
What does the push button look like in the frontend?
It's be nice to be able to change the icon next to button. Thx.
Is there a way to install version 0.7 using HACS?
When the latest version of Home Assistant is starting up with the 0.5 release of the Momentary integration installed, I see the following error in the logs, indicating an issue which needs to be resolved before it becomes breaking:
Logger: homeassistant.loader
Source: loader.py:802
First occurred: 6:00:42 PM (1 occurrences)
Last logged: 6:00:42 PMNo 'version' key in the manifest file for custom integration 'momentary'. This will not be allowed in a future version of Home Assistant. Please report this to the maintainer of 'momentary'
Just tried to remove the prefix and got this error.
Is there some wrong with my entry
Version
HA
core-2021.7.2
Error loading /config/configuration.yaml: could not determine a constructor for the tag '!stop_spray_and_dose'
in "/config/configuration.yaml", line 65, column 11
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.