Commit Graph

154 Commits (75f40ccb067685094226888874c83e0c91c3f3ee)

Author SHA1 Message Date
Paulus Schoutsen f1632496f0 Allow circular dependency with discovery (#2616) 2016-07-25 22:49:10 -07:00
Fabian Heredia Montiel 08226a4864 Type Hints - __main__ (#2574)
* Add __main__ type hints

* Fix most errors of __main__

* Add ignore for script.run()

* Add type annotations for from_config_dict and from_config_file

* Fix errors

* Fix requirement error

* Add mypy type check to tests

* Enable travis typing check

* Messed up the tox deps

* Laxer type checker
2016-07-20 22:38:52 -07:00
Paulus Schoutsen d1f4901d53 Migrate to cherrypy wsgi from eventlet (#2387) 2016-06-30 09:02:12 -07:00
Paulus Schoutsen 6714392e9c Move elevation to core config and clean up HTTP mocking in tests (#2378)
* Stick version numbers

* Move elevation to core config

* Migrate forecast test to requests-mock

* Migrate YR tests to requests-mock

* Add requests_mock to requirements_test.txt

* Move conf code from bootstrap to config

* More config fixes

* Fix some more issues

* Add test for set config and failing auto detect
2016-06-27 09:02:45 -07:00
Philip Lundrigan d13cc227cc Push State (#2365)
* Add ability to push state changes

* Add tests for push state changes

* Fix style issues

* Use better name to force an update
2016-06-26 00:33:23 -07:00
Jan Harkes 5f92ceeea9 Allow for restart without using parent/child processes. (#1793)
* Allow for restart without using parent/child processes.

Assuming that we normally correctly shut down running threads and
release resources, we just do some minimal scrubbing of open file
descriptors and child processes which would stay around across an
exec() boundary.

* Use sys.executable instead of multiprocessing.spawn.get_executable()

* Limit how many file descriptors we try to close.

Don't even try to close on OSX/Darwin until we figure out how to
recognize guarded fds because the kernel will yell at us, and kill
the process.

* Use the close on exec flag on MacOS to clean up.

* Introduce a small process runner to handle restart on windows.

* Handle missing signal.SIGHUP on Windows.
2016-05-19 23:20:59 -07:00
Paulus Schoutsen 2e79e9d5bb Correct celcius to celsius (#1860) 2016-04-19 20:30:44 -07:00
Paulus Schoutsen 68d92c3196 Use standardised datetime format 2016-04-16 01:46:50 -07:00
Jan Harkes 5bd58351c7 Move service scheme validation into Service.__call__
Keeps where the schema is stored and validated close.
2016-03-31 21:13:40 -04:00
Jan Harkes 64030b9d48 Add validation schema as optional argument to service registration. 2016-03-31 14:59:36 -04:00
Paulus Schoutsen 13d7f742a7 Add thread names 2016-03-12 16:54:31 -08:00
Fabian Affolter 897b5c668f Fix PEP257 issues 2016-03-08 00:06:04 +01:00
Paulus Schoutsen e80309c03c Fix imports (using isort) 2016-02-18 21:27:50 -08:00
Paulus Schoutsen 68803a46b6 Thread pool tweaks 2016-02-14 23:01:49 -08:00
Paulus Schoutsen dabb8d5bbc Merge pull request #1246 from balloob/feature/remove-state-fire-event
Have remove state fire state_changed event
2016-02-14 10:33:59 -08:00
Paulus Schoutsen ada2fb4ec0 Fire event when we remove a state 2016-02-13 22:57:40 -08:00
Per Sandström 9e816cfd3f lock _states to prevent size change during iteration 2016-02-14 06:34:00 +01:00
Paulus Schoutsen 1571b33e4a Fix: state_as_number always return float 2016-02-13 00:08:32 -08:00
Paulus Schoutsen e83f8da342 Merge pull request #1185 from balloob/perf-states
Make State class more immutable
2016-02-10 18:53:02 -08:00
Paulus Schoutsen af8f6bcaba Remove deprecated methods from core 2016-02-09 23:59:31 -08:00
Paulus Schoutsen b0948bef5f Make State class immutable 2016-02-09 23:27:01 -08:00
Ryan Kraus a001780afb Fix Ctrl+C with Subprocesses
Added KeyboardInterrupt handling back to block_till_stopped method.
This is because Keyboard Interrupts are sent to both the parent and
child process in no particular order so both need to handle the
interrupt.
2016-02-06 21:50:06 -05:00
Ryan Kraus 11a2b8888b Fixes for issue #1114
1. Moved RESTART_EXIT_CODE to constants so it can safely be used by
__main__.py.
2. Allowed __main__/main to return the desired exit code.
3. Forwarded the child processes exit code to the parent process to be
duplicated.
4. Added —debug flag to pass command to force Home Assistant to run in
only one process. A warning is printed to STDERR to indicate HASS is in
debug mode. Another is printed if HASS requests a restart in debug
mode. A restart request in debug mode will quit.
5. Added an argument to __main__/main/setup_and_run_hass to indicate
that it is running in the top process. This tells it to return the exit
code rather than exiting.
2016-02-06 09:48:36 -05:00
Ryan Kraus 1a5d18fd66 Merge pull request #1012 from balloob/restart-service
Restart service
2016-02-02 07:15:40 -05:00
Paulus Schoutsen b7722ec452 Allow usage of words domain, service, call_id in service data 2016-01-30 15:18:26 -08:00
Ryan Kraus a41b66bb94 Cleaned up block_till_stop in core.py
1. Removed handling of KeyboardInterrupt. This will no longer happen
now that HASS is run in a subprocess. The KeyboardInterrupt will not be
sent to the parent process which will send a SIGTERM to the HASS
process.
2. Fixed logger warning about not being able to bind to SIGTERM.
3. Removed check for Windows OSs when binding to SIGTERM. This check
was originally put in place when HASS was binding to SIGQUIT. SIGTERM
exists in NT OSs, so the check is no longer required.
3. Now returning exit code of 100 when requesting a restart. This will
allow the parent process to only restart HASS if it is specifically
requested and not just on any encountered crash.
2016-01-29 22:02:39 -05:00
Ryan Kraus b596fa33d6 Implemented restart service
Implemented an OS and environment safe restart service. This works by
running Home Assistant in a child process. If the child process
terminates with an exit code > 0, HASS is restarted. SIGTERM and
KeyboardInterrupts to the parent process are forwarded to the child
process. KeyboardInterrupts will only be forwarded once. The second
KeyboardInterrupt will be handled by the parent.
2016-01-26 22:39:59 -05:00
Paulus Schoutsen bc19ef66bf Move split_entity_id to helpers 2016-01-23 22:49:49 -08:00
Paulus Schoutsen de08f0afaa Load YAML config into an ordered dict 2016-01-23 22:41:01 -08:00
Andrew Thigpen 11f32d0500 Add is_state_attr method.
Returns True if the entity exists and has an attribute with the given
name and value.
2015-12-31 14:58:18 -06:00
Paulus Schoutsen d9b30d1421 Pep257 fixes for core. 2015-12-27 21:14:35 -08:00
Paulus Schoutsen 934b097bc7 Rename date_util to dt_util
Follows the rest of Home Assistant
2015-12-06 09:12:36 -08:00
Paulus Schoutsen f8668075d0 Fix State.copy() 2015-12-06 09:12:36 -08:00
Ryan Kraus 135eb0a0ac Fixed hass daemon management
1) Changed signal to exit hass to SIGTERM
2) Updated initd script to send SIGTERM
3) Updated systemd script to never send SIGKILL.
2015-11-15 17:43:38 -05:00
Paulus Schoutsen f1aa685cf2 Add version to config API 2015-10-25 21:00:22 -07:00
Paulus Schoutsen 5ad27d8cdb Add support for zones to Home Assistant 2015-09-28 23:13:13 -07:00
Paulus Schoutsen 4e3bd5f2a9 Add service descriptions 2015-09-26 23:17:04 -07:00
Paulus Schoutsen 19d40612e6 Add home_range to device tracker 2015-09-20 09:35:03 -07:00
Andrew Thigpen 6519e589b5 Add option to skip pip install on startup.
Since the requirements only change when the software is updated,
this adds a command line switch to disable pip installs on
startup.  The default behavior is maintained when the switch is
not specified.  Skipping pip helps a lot with startup on older RPi
hardware.
2015-09-04 16:50:57 -05:00
Paulus Schoutsen 53fb46b44b Merge pull request #304 from rmkraus/daemon
Fixed signal binding exception
2015-09-01 01:14:22 -07:00
Ryan Kraus e7caac212d Fixed signal binding exception
Cleanly handle error for failed SIGQUIT binding. This can happen when
running in a thread.
2015-09-01 04:03:51 -04:00
Paulus Schoutsen c1f172f33a Merge pull request #303 from rmkraus/daemon
Updating Daemon Code
2015-09-01 00:58:03 -07:00
Paulus Schoutsen 58afbecd05 Speed up tests 2015-09-01 00:18:26 -07:00
Ryan Kraus ff470c8ffe Added core daemon function as flags.
Created three additional flags for the hass command:
-v -  Toggle verbose log file output
—pid-file -  Specify PID file path
—daemon -  Launch as daemon (nix only)

The core now binds to SIGQUIT on nix systems to trigger a clean
shutdown.

Modified HTTP server to write logging messages through the logging
module.
2015-09-01 02:12:00 -04:00
Ryan Kraus f5b98c86f0 Mostly PyLint and Flake8 updates.
Rewrote imports of exceptions to be from the exceptions module.
Made nmap scanner check for libnmap dependency without crashing.
Various flake8 and pylint updates.
2015-08-29 22:34:35 -04:00
Ryan Kraus 0b6358e759 Implemented comments from Paulus.
Revised main to use frontend and demo strings rather than importing
their domains.
Removed submodule validation.
Moved local library mounting to the bootstrap module and out of core.
Added requirements_all.txt for all dependencies.
Made core dependencies looser.
Small updates to setup.py.
2015-08-29 22:19:52 -04:00
Ryan Kraus 6fdf9b8d7c Many changes to cleanup config directory and lib installations.
Cleaned up default config directory determination.
Made bootstrap creators for HA always set config directory.
Made bootstrap creators set the local library in the Python Path.
Moved all exceptions to their own file to make imports easier.
Moved default configuration directory be in the users’ profile.
Moved pip installs to be done to a lib folder in the config directory.
Reduced requirements.txt to only the barebones reqs.
2015-08-29 21:11:24 -04:00
Paulus Schoutsen 086961d109 Add temperature util, helpers 2015-08-16 22:06:01 -07:00
Paulus Schoutsen b61b3c611d Extract temperature util 2015-08-16 21:36:33 -07:00
Paulus Schoutsen 1b89a502c4 Extract core into own submodule 2015-08-16 20:44:46 -07:00
Paulus Schoutsen a491df761f Integrated core.py into module-init 2013-09-30 00:20:27 -07:00
Paulus Schoutsen f04e9b07a9 State machine categories don't have to be initialized anymore 2013-09-29 16:02:58 -07:00
Paulus Schoutsen 8ac8700154 Added API 2013-09-28 11:09:36 -07:00
Paulus Schoutsen a1f238816b Code reorganized into a more Pythonic structure. 2013-09-24 18:39:58 -07:00