* Add teardown method to pilight tests
This is necessary to stop the HomeAssistant instance that was started
in the setUp method. Without this there happen random test failures.
This is necessary to stabilize the tests for PR #5045.
Signed-off-by: Jan Losinski <losinski@wh2.tu-dresden.de>
* Update test_pilight.py
* Add a method to throttle calls to services
This adds CallRateDelayThrottle. This is a class that provides an
decorator to throttle calls to services. Instead of the Throttle in
homeassistant.util it does this by delaying all subsequent calls
instead of just dropping them. Dropping of calls would be bad if we
call services to actual change the state of a connected hardware (like
rf controlled power plugs).
Ihe delay is done by rescheduling the call using
track_point_in_utc_time from homeassistant.helpers.event so it should
not block the mainloop at all.
* Add unittests for CallRateDelayThrottle
Signed-off-by: Jan Losinski <losinski@wh2.tu-dresden.de>
* Introduce a send_delay for pilight component
If pilight is used with a "pilight USB Nano" between the daemon and the
hardware, we must use a delay between sending multiple signals.
Otherwise the hardware will just skip random codes. We hit this
condition for example, if we switch a group of pilight switches on or
off. Without the delay, random switch signals will not be transmitted by
the RF transmitter.
As this seems not necessary, if the transmitter is directly connected
via GPIO, we introduce a optional configuration to set the delay.
* Add unittests for pilight send_delay handling
This adds an unittest to test the delayed calls to the send_code
service.