Commit Graph

63 Commits

Author SHA1 Message Date
Petro31
ff2c901930 Update trigger based template entity resolution order (#140660)
* Update trigger based template entity resolution order

* add test

* fix most comments

* Move resolution to base class

* add comment

* remove uncessary if statement

* add more tests

* update availability tests

* update logic stage 1

* phase 2 changes

* fix trigger template entity tests

* fix trigger template entities

* command line tests

* sql tests

* scrape test

* update doc string

* add rest tests

* update sql sensor _update signature

* fix scrape test constructor

* move state check to trigger_entity

* fix comments

* Update homeassistant/components/template/trigger_entity.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Update homeassistant/helpers/trigger_template_entity.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Update homeassistant/helpers/trigger_template_entity.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* update command_line and rest

* update scrape

* update sql

* add case to command_line sensor

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2025-04-25 13:17:25 +02:00
epenet
7b1b229718 Standardize homeassistant imports in component tests (a-l) (#136806) 2025-01-29 10:00:45 +01:00
G Johansson
797eb606fe Fix correct handling in ManualTriggerEntity (#130135) 2024-11-21 20:46:03 +01:00
G Johansson
666e8e133e Cover state is enum (#127144)
* Change light state to use enum

* Adjust cover tests

* Update cover

* Fix covers

* Some tests

* More tests

* Fix tests

* Fix
2024-10-08 18:39:04 +02:00
G Johansson
178cb0659a Guard for no discovery info in command_line (#123717) 2024-08-12 21:35:02 +02:00
atlflyer
ec536bda3d Add json_attributes_path configuration for command_line sensor (#116656)
Add json attributes path config to command line sensor
2024-07-06 18:52:27 +02:00
J. Nick Koston
4881205831 Fix event loop blocking I/O in command_line tests (#121098) 2024-07-03 14:22:38 -05:00
Sid
3efee10b95 Enable Ruff RUF013 (#115333) 2024-04-10 08:55:59 +02:00
atlflyer
ef7836be73 Add icon to command_line cover config (#114645)
* Add icon to command_line cover config

* Remove unwanted #noqa tag

* Remove redundancy from new test name

* Apply requested changes
2024-04-02 20:59:57 +03:00
J. Nick Koston
65358c129a Replace periodic tasks with background tasks (#112726)
* Phase out periodic tasks

* false by default or some tests will block forever, will need to fix each one manually

* kwarg works

* kwarg works

* kwarg works

* fixes

* fix more tests

* fix more tests

* fix lifx

* opensky

* pvpc_hourly_pricing

* adjust more

* adjust more

* smarttub

* adjust more

* adjust more

* adjust more

* adjust more

* adjust

* no eager executor

* zha

* qnap_qsw

* fix more

* fix fix

* docs

* its a wrapper now

* add more coverage

* coverage

* cover all combos

* more fixes

* more fixes

* more fixes

* remaining issues are legit bugs in tests

* make tplink test more predictable

* more fixes

* feedreader

* grind out some more

* make test race safe

* one more
2024-03-08 21:45:10 -05:00
Marc Mueller
38adfbf1a3 Add empty line after module docstring [tests a-e] (#112708) 2024-03-08 08:50:25 -05:00
J. Nick Koston
c0f7ade92b Convert command_line to use asyncio for subprocesses (#111927)
* Convert command_line to use asyncio for subprocesses

* fixes

* fix

* fixes

* more test fixes

* more fixes

* fixes

* preen
2024-03-01 23:15:10 -05:00
G Johansson
749ef45727 Add availability to command_line (#105300)
* Add availability to command_line

* Add tests

* freezer
2024-01-15 18:20:34 +01:00
G Johansson
2d3318e767 Remove platform YAML from Command line (#103202) 2023-11-04 16:17:31 +01:00
RoboMagus
1db3d3c158 icon for commandline sensors (#101195)
* Add icon to schema for commandline sensor and binary_sensor

* Add icon tests
2023-10-01 20:17:53 +02:00
G Johansson
a3808383d5 Fix binary sensor test in command_line (#101198) 2023-10-01 16:18:05 +02:00
G Johansson
2e263560ec Fix Command Line template error when data is None (#97845)
Command Line template error
2023-08-05 16:21:39 +02:00
Marc Mueller
e905ac173f Fix command_line tests RuntimeWarnings (#97731) 2023-08-04 09:34:55 +02:00
G Johansson
4c395c0124 Fix date and timestamp device class in Command Line Sensor (#97663)
* Fix date in Command Line sensor

* prettier
2023-08-03 13:59:37 +02:00
Jan Bouwhuis
50442c5688 Speedup tests command_line integration (#96349) 2023-07-11 18:31:32 +02:00
Jan Bouwhuis
f12f8bca03 Avoid CI fail in command_line tests (#96324)
* Avoid CI fail in command_line tests

* Speedup tests manual update
2023-07-11 15:27:31 +02:00
Allen Porter
12129e9d21 Update service call return values and error handling (#94657)
* Update return signature of service calls

* Add timeout error handling in websocket api for service calls

* Update recorder tests to remove assertion on service call

* Remove timeout behavior and update callers that depend on it today

* Fix tests

* Add missing else

* await coro directly

* Fix more tests

* Update the intent task to use wait instead of timeout

* Remove script service call limits and limit constants

* Update tests that depend on service call limits

* Use wait instead of wait_for and add test

* Update homeassistant/helpers/intent.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-06-16 07:01:40 -07:00
G Johansson
bd74f03d0b Fix reload service in Command Line (#94436)
* Fix reload in Command Line

* Add read new yaml
2023-06-12 21:51:57 +02:00
G Johansson
f931cc3d1c Fix manual update for Command Line (#94433)
Manual update command line
2023-06-12 21:50:23 +02:00
Ville Skyttä
ca936d0b38 Replace bandit with ruff (#93200) 2023-06-08 22:46:04 +02:00
G Johansson
038b0e6d23 Add scan interval to Command Line (#93752)
* Add scan interval

* Handle previous not complete

* Fix faulty text

* Add tests

* lingering

* Cool down

* Fix tests
2023-06-02 23:35:11 -04:00
Ville Skyttä
ced67e5800 Import util.dt as dt_util in components/[a-d]* (#93756) 2023-05-30 00:02:06 +03:00
G Johansson
46e7486ce6 Move yaml configuration to integration key for command_line (#92824)
* Inital init commit

* bs and cover

* notify

* sensor

* switch

* Issues

* Finalize __init__

* First pass tests

* Fix Binary sensors

* Test cover

* Test notify

* Test sensor

* Tests switch

* Fix coverage

* Add codeowner

* Fix caplog

* test issue

* Flaky test notify

* Fix async

* Adjust yaml structure

* Change yaml format again

* Issue strings

* Fix tests

* string review comment
2023-05-29 08:00:50 +02:00
G Johansson
6ad4e13b38 Manual trigger entity and refactor command_line switch (#91506)
* TriggerEntity to CoordinatorTriggerEntity

* _render_templates

* split manual vs coordinator

* name

* ManualTriggerEntity

* value

* Remove ManualTriggerEntity

* ManualTriggerEntity

* process_manual_data

* Add test

* imports

* Move ManualTriggerEntity

* cmd_line switch

* Review comments

* Fix templating

* Review comments

* Remove unneeded logging
2023-05-08 10:19:37 +02:00
Steven Rollason
2b46734bd3 Fix command_template sensor value_template not being used if json_attributes set (#90603)
* Allow value_template to be used if json_attributes set

* Set state to None if no value_template and json_attributes used

* Refactor check for no value_template when json_attributes used

* Updated and additional unit test

* Updated to set _attr_native_value and return if value_template is None

* Update unit test docstring

* Updated test docstring based on feedback
2023-04-06 21:06:31 +02:00
G Johansson
96698813ef Cleanup command_line (#90268)
* Cleanup command_line

* Fix ipv6 resolver

* Fix fix

* Fix tests

* Align states
2023-03-27 21:19:09 +02:00
G Johansson
02389960ce Refactor Command line sensor to inherit TemplateSensor (#81222)
* Refactor sensor

* Remove not needed

* block until done

* reset test

* test sensor

* Add time
2023-03-13 17:23:25 +01:00
Erik Montnemery
234610b1cc Simplify command_line sensor tests (#89576) 2023-03-12 14:47:43 +01:00
epenet
853bd52a22 Adjust entity registry access in tests (1) (#88950) 2023-03-01 09:11:14 +01:00
J. Nick Koston
03eea7bd3f Avoid subprocess memory copy when c library supports posix_spawn (#87958)
* use posix spawn on alpine

* Avoid subprocess memory copy when c library supports posix_spawn

By default python 3.10 will use the fork() which has to
copy all the memory of the parent process (in our case
this can be huge since Home Assistant core can use
hundreds of megabytes of RAM). By using posix_spawn
this is avoided.

In python 3.11 vfork will also be available
https://github.com/python/cpython/issues/80004#issuecomment-1093810689
https://github.com/python/cpython/pull/11671 but we won't
always be able to use it and posix_spawn is considered safer
https://bugzilla.kernel.org/show_bug.cgi?id=215813#c14

The subprocess library doesn't know about musl though
even though it supports posix_spawn https://git.musl-libc.org/cgit/musl/log/src/process/posix_spawn.c
so we have to teach it since it only has checks for glibc
1b736838e6/Lib/subprocess.py (L745)

The constant is documented as being able to be flipped here:
https://docs.python.org/3/library/subprocess.html#disabling-use-of-vfork-or-posix-spawn

* Avoid subprocess memory copy when c library supports posix_spawn

By default python 3.10 will use the fork() which has to
copy memory of the parent process (in our case
this can be huge since Home Assistant core can use
hundreds of megabytes of RAM). By using posix_spawn
this is avoided and subprocess creation does not
get discernibly slow the larger the Home Assistant
python process grows.

In python 3.11 vfork will also be available
https://github.com/python/cpython/issues/80004#issuecomment-1093810689
https://github.com/python/cpython/pull/11671 but we won't
always be able to use it and posix_spawn is considered safer
https://bugzilla.kernel.org/show_bug.cgi?id=215813#c14

The subprocess library doesn't know about musl though
even though it supports posix_spawn https://git.musl-libc.org/cgit/musl/log/src/process/posix_spawn.c
so we have to teach it since it only has checks for glibc
1b736838e6/Lib/subprocess.py (L745)

The constant is documented as being able to be flipped here:
https://docs.python.org/3/library/subprocess.html#disabling-use-of-vfork-or-posix-spawn

* missed some

* adjust more tests

* coverage
2023-02-13 09:02:51 -05:00
Franck Nijhof
e4a78420b8 Enable Ruff PT013 (#86757)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-01-27 09:09:46 +01:00
Franck Nijhof
24fdd588fd Code styling tweaks to the tests - Part 1 (#86192) 2023-01-20 13:52:46 +01:00
atlflyer
da11cef29a Report error code in log when command fails (#74319) 2022-07-02 09:58:08 -04:00
G Johansson
3771c154fa Improve code quality command_line (#65333) 2022-02-12 08:19:37 -06:00
Gabriel Rauter
d26275011a Add unique_id configuration variable to command_line integration (#58596) 2022-01-03 11:44:47 +01:00
Marius
b61dede826 Add command_line icon_template (#58877)
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2021-12-03 10:06:32 -08:00
Paulus Schoutsen
31153ac155 Move fixtures part 1 (#58902) 2021-11-01 20:47:05 -07:00
Marc Mueller
f1d48ddfe3 Update pylint to 2.8.0 (#49637) 2021-04-24 14:39:24 -10:00
jan iversen
6a4f414236 Change HomeAssistantType to HomeAssistant (#49522) 2021-04-21 15:53:06 -10:00
Marc Mueller
106dc4d28a Don't import stdlib typing types from helpers.typing (#49104) 2021-04-12 18:43:14 +02:00
Dermot Duffy
be8584c0bc Overhaul command_line tests (#46682) 2021-03-01 17:27:04 +01:00
Franck Nijhof
65cf2fcb6f Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
Franck Nijhof
27350f41c9 Improve command_line switch tests (#40749) 2020-09-30 13:29:43 +02:00
Paulus Schoutsen
6de02fc1b9 Fix some more usages of asynctest (#39570) 2020-09-02 14:53:07 +02:00
Franck Nijhof
1c2ebdf307 Upgrade black to 20.8b1 (#39287) 2020-08-27 13:56:20 +02:00