Compare commits

...

183 Commits

Author SHA1 Message Date
Joostlek
f2a3fd169b Fix 2025-11-13 17:54:30 +01:00
Joostlek
bff162255d Merge branch 'dev' into flussButtonApi 2025-11-13 17:48:31 +01:00
Marcello
becc106678 Merge branch 'dev' into flussButtonApi 2025-10-17 13:22:27 +02:00
Marcello
ca211b9504 more coverage 2025-10-17 13:21:58 +02:00
Marcello
110379402f using the conftest for testing 2025-10-17 12:11:26 +02:00
Marcello
2a9c9cf783 using await hass.config_entries.async_unload(mock_config_entry.entry_id) 2025-10-17 11:27:54 +02:00
Marcello
f9195d2212 using the conftest. fixture 2025-10-17 09:05:14 +02:00
Marcello
185eb91116 Update tests/components/fluss/test_init.py
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2025-10-17 07:37:47 +02:00
Marcello
6f4073a2b0 Merge branch 'dev' into flussButtonApi 2025-10-17 07:34:08 +02:00
Marcello
3542619e3a confirmation that it's being used 2025-10-14 14:54:53 +02:00
Marcello
b84285107b making button testable again 2025-10-14 14:52:16 +02:00
Marcello
526e225c8c Merge branch 'dev' into flussButtonApi 2025-10-14 11:22:26 +02:00
Marcello
7a9bcb52f9 test update for button 2025-10-14 11:21:59 +02:00
Marcello
6bdc60ae78 Merge branch 'flussButtonApi' of https://github.com/fluss/home-assistant into flussButtonApi 2025-10-14 11:05:37 +02:00
Marcello
24948c4794 updating the coordintator 2025-10-14 11:05:32 +02:00
Marcello
81cac62b26 Merge branch 'dev' into flussButtonApi 2025-10-14 10:35:54 +02:00
Marcello
67f0ab5ab2 fixing up the test 2025-10-13 13:47:10 +02:00
Marcello
afc2192723 updating the conftest file for multiple devices 2025-10-13 11:02:36 +02:00
Marcello
ef7aef84a3 using async configure 2025-10-13 10:48:02 +02:00
Marcello
8989cf037d snap shot platform 2025-10-13 10:35:01 +02:00
Marcello
b993b7c375 telling HA to. set up integration in the. test 2025-10-13 10:14:03 +02:00
Marcello
615ab3e165 Merge branch 'flussButtonApi' of https://github.com/fluss/home-assistant into flussButtonApi 2025-10-13 09:38:49 +02:00
Marcello
0eea2e66d4 direc mock and moving the test mock into the confest 2025-10-13 09:38:46 +02:00
Marcello
917a6f0adf Merge branch 'dev' into flussButtonApi 2025-10-13 09:09:52 +02:00
Marcello
3d6386ef8d Update tests/components/fluss/test_config_flow.py
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2025-10-10 14:30:30 +02:00
Marcello
02c9c43697 Update tests/components/fluss/test_config_flow.py
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2025-10-10 14:30:05 +02:00
Marcello
2423b56d93 the unique id is the api key 2025-10-10 14:26:56 +02:00
Marcello
dd5a3d2dad importing fluss domain 2025-10-10 14:22:57 +02:00
Marcello
b32bdd35b2 parsing api key in _async_abort_entries_match 2025-10-10 14:20:09 +02:00
Marcello
6cc636a547 Update tests/components/fluss/conftest.py
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2025-10-10 13:57:01 +02:00
Marcello
954a803087 Update homeassistant/components/fluss/strings.json
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2025-10-10 13:37:08 +02:00
Marcello
c57a46f777 Merge branch 'dev' into flussButtonApi 2025-10-10 13:09:38 +02:00
Marcello
286a3a0b53 Merge branch 'dev' into flussButtonApi 2025-10-10 13:04:51 +02:00
Marcello
f22e016efe Merge branch 'dev' into flussButtonApi 2025-10-10 12:24:29 +02:00
Marcello
430f7045ff changing it. todo 2025-10-10 12:23:48 +02:00
Marcello
b7c795e01f unique-config-entry 2025-10-10 12:10:44 +02:00
Marcello
10032ec3fc bettter comment forentity-disabled-by-default 2025-10-10 11:13:34 +02:00
Marcello
524a9f6851 button is an entity 2025-10-10 11:11:35 +02:00
Marcello
5ef84db2de type setting and using session 2025-10-10 10:07:25 +02:00
Marcello
2d1d8c1832 Merge branch 'dev' into flussButtonApi 2025-10-10 08:20:16 +02:00
Marcello
1c2b60e00b updating quality check 2025-10-10 08:20:01 +02:00
Marcello
c2fa3c7e3a Update homeassistant/components/fluss/quality_scale.yaml
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2025-10-10 08:17:57 +02:00
Marcello
adfcdd1425 Update homeassistant/components/fluss/quality_scale.yaml
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2025-10-10 08:17:40 +02:00
Marcello
c843221e09 Update homeassistant/components/fluss/coordinator.py
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2025-10-10 08:17:17 +02:00
Marcello
d2ff0c236d Update homeassistant/components/fluss/__init__.py
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2025-10-10 08:16:45 +02:00
Marcello
112d4dc745 Update homeassistant/components/fluss/coordinator.py
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2025-10-10 08:16:22 +02:00
Marcello
d5d4d667b7 Merge branch 'dev' into flussButtonApi 2025-10-09 08:52:02 +02:00
Marcello
4bb8358bc2 updating quality scale 2025-10-09 08:51:03 +02:00
Marcello
02539023db half way i guesss 2025-10-08 08:34:11 +02:00
Marcello
f675e73bfd Merge branch 'flussButtonApi' of https://github.com/fluss/home-assistant into flussButtonApi 2025-10-08 08:14:13 +02:00
Marcello
9862df3fea fixing test errors 2025-10-08 08:13:58 +02:00
Marcello
f323c4fe18 Merge branch 'dev' into flussButtonApi 2025-10-08 08:04:32 +02:00
Marcello
b83b3ad123 rename to test_init.py 2025-10-07 08:33:03 +02:00
Marcello
e1504e600a don't. need to test entity 2025-10-07 08:31:32 +02:00
Marcello
ea3e46d7bf no need to test the coordinittaor 2025-10-07 08:30:13 +02:00
Marcello
642ed83e27 don't. test the coorddintatoor 2025-10-07 08:27:54 +02:00
Marcello
81b4679dfa ddon't need to mock hass 2025-10-07 08:27:08 +02:00
Marcello
6abca41273 no fixture 2025-10-07 08:21:51 +02:00
Marcello
52ce506b5c merging into 1 2025-10-07 08:19:04 +02:00
Marcello
ed4094bf97 no need to test. this 2025-10-07 08:15:03 +02:00
Marcello
6e0a4b5506 moving mock config entrry i think 2025-10-07 08:14:03 +02:00
Marcello
f004aca704 no direct. integration for the test 2025-10-06 09:21:18 +02:00
Marcello
05e458a056 using the mock_config_entry to setup the integration via hass.config_entries.async_setup(entry.entry_id) 2025-10-06 09:06:16 +02:00
Marcello
9736429950 Update tests/components/fluss/__init__.py
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2025-10-06 08:50:02 +02:00
Marcello
ca44bc0bc3 recovery error. check 2025-10-06 08:47:31 +02:00
Marcello
a6a1b0b85f Merge branch 'flussButtonApi' of https://github.com/fluss/home-assistant into flussButtonApi 2025-10-06 08:46:48 +02:00
Marcello
28856d2d84 no need for ttry block and device dict 2025-10-06 08:46:44 +02:00
Marcello
b45be9ae59 Merge branch 'dev' into flussButtonApi 2025-10-06 08:32:51 +02:00
Marcello
9bd09017bb Merge branch 'dev' into flussButtonApi 2025-08-25 12:38:31 +02:00
Marcello
117574d109 hopefully this is platnum standards 2025-08-25 12:38:19 +02:00
Marcello
3c2419a02a adjusting the test files 2025-08-25 09:23:58 +02:00
Marcello
c1f25d59a2 Addjustiing from the suggestedcomments 2025-08-25 08:46:35 +02:00
Marcello
7abcb9c8b8 Update homeassistant/components/fluss/coordinator.py
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-08-25 08:03:32 +02:00
Marcello
35663175db Update homeassistant/components/fluss/button.py
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-08-25 08:01:35 +02:00
Marcello
a28b447bb2 Merge branch 'dev' into flussButtonApi 2025-07-25 09:50:50 +02:00
Marcello
9f5132f685 move common fixtures to conftest.py 2025-07-25 09:50:29 +02:00
Marcello
ebdc70997f removing test data schema validation
HA takes care of that
2025-07-25 09:45:31 +02:00
Marcello
16a8bec8d1 paramitising errors 2025-07-25 09:44:18 +02:00
Marcello
0f38a7f811 updating configflow test 2025-07-25 09:39:24 +02:00
Marcello
aa8e13f48b Update tests/components/fluss/test_config_flow.py
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-07-25 09:31:16 +02:00
Marcello
243e96fded using async call 2025-07-21 10:37:23 +02:00
Marcello
64fdec14f6 get the button from the entity registry instead 2025-07-21 10:27:12 +02:00
Marcello
6606754521 not mock internals 2025-07-21 10:23:10 +02:00
Marcello
1f571c7fce let the integration set up itself and patch accordingly 2025-07-21 10:10:48 +02:00
Marcello
914fe97e22 adding. device info type 2025-07-21 10:03:15 +02:00
Marcello
a71a17191c using a fixture instead 2025-07-21 10:02:03 +02:00
Marcello
486686ae75 Update tests/components/fluss/test_button.py
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-07-21 09:53:52 +02:00
Marcello
ca2747dfc5 using conf api key instead for test button 2025-07-21 09:51:39 +02:00
Marcello
e847bd44e7 no longer. need validate device 2025-07-21 09:45:59 +02:00
Marcello
c6a96d8d42 adding return types 2025-07-21 09:42:22 +02:00
Marcello
df3f80f24c Merge branch 'flussButtonApi' of https://github.com/fluss/home-assistant into flussButtonApi 2025-07-21 09:30:47 +02:00
Marcello
4489f90e46 exempt 2025-07-21 09:30:26 +02:00
Marcello
8791323092 Update homeassistant/components/fluss/quality_scale.yaml
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-07-21 09:28:06 +02:00
Marcello
1ffe7492cf Update homeassistant/components/fluss/quality_scale.yaml
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-07-21 09:27:49 +02:00
Marcello
21b941aef2 Update homeassistant/components/fluss/config_flow.py
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-07-21 09:27:29 +02:00
Marcello
178c280991 Update homeassistant/components/fluss/config_flow.py
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-07-21 09:24:04 +02:00
Marcello
3560ce5935 Update homeassistant/components/fluss/config_flow.py
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-07-21 09:08:01 +02:00
Marcello
f1512f9577 Update homeassistant/components/fluss/quality_scale.yaml
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-07-21 09:06:31 +02:00
Marcello
ce5a89b9b9 Update homeassistant/components/fluss/manifest.json
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-07-21 08:57:58 +02:00
Marcello
45e85e9cd2 using device name in the device info attr 2025-07-21 08:56:49 +02:00
Marcello
04c312c4c0 Update homeassistant/components/fluss/entity.py
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-07-21 08:05:07 +02:00
Marcello
aa2844a89a Update homeassistant/components/fluss/button.py
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-07-21 07:55:41 +02:00
Marcello
0de64f6892 Update homeassistant/components/fluss/button.py
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-07-21 07:51:21 +02:00
Marcello
32a9de7968 Merge branch 'dev' into flussButtonApi 2025-06-18 08:04:15 +02:00
Marcello
3f7628cd90 adding. the june 17 requested changes 2025-06-18 08:03:40 +02:00
Marcello
3a15527e12 removing description, better paramter call 2025-06-17 13:04:03 +02:00
Marcello
2028138371 Update homeassistant/components/fluss/__init__.py
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2025-06-17 10:29:41 +02:00
Marcello
a33b1792ff Merge branch 'dev' into flussButtonApi 2025-06-17 09:58:16 +02:00
Marcello
43db503ead finishing up the rest the rest of. the. finish suggestions 2025-06-17 09:53:50 +02:00
Marcello
484ee3eeea fixing some changes 2025-06-13 15:38:58 +02:00
Marcello
4b44064946 Merge branch 'dev' into flussButtonApi 2025-05-16 14:56:01 +02:00
Marcello
745228ff89 Applying changes the requested 2025-05-16 14:50:09 +02:00
Marcello
1a069b52f1 Merge branch 'dev' into flussButtonApi 2025-05-16 10:38:46 +02:00
Marcello
c95e5b8883 Revert "See if this works?"
This reverts commit 7309ed04a3.
2025-05-15 11:31:03 +02:00
Marcello
7309ed04a3 See if this works? 2025-05-15 11:26:58 +02:00
Marcello
bb62e9ec62 Merge branch 'dev' into flussButtonApi 2025-05-14 06:52:25 +02:00
Marcello
b2939a7bab Merge branch 'dev' into flussButtonApi 2025-04-30 10:42:25 +02:00
Marcello
5946ee1da6 updating the the quality scale. 2025-04-30 10:09:38 +02:00
Marcello
02f207ea7d Revert "updating test for config flow"
This reverts commit 198f71d69d.
2025-04-30 08:34:52 +02:00
Marcello
1877ecc845 updating the quality scale 2025-04-29 15:09:50 +02:00
Marcello
c7ebde041f stop point 2025-04-01 13:33:15 +02:00
Marcello
ef86318d3e full coverage of the test 2025-04-01 13:21:58 +02:00
Marcello
198f71d69d updating test for config flow 2025-04-01 13:18:41 +02:00
Marcello
a40579c813 Applying the requested fixes 2025-03-25 15:12:17 +02:00
Marcello
a67244e955 Update homeassistant/components/fluss/const.py
removing it since it's no longer needed

Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-03-25 15:06:39 +02:00
Marcello
6404e45dea Update homeassistant/components/fluss/button.py
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-03-25 15:06:00 +02:00
Marcello
db0d1878cf Update homeassistant/components/fluss/__init__.py
raise this until we implement re-auth (in follow up)

Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-03-24 14:58:56 +02:00
Marcello
01db715d56 Update homeassistant/components/fluss/__init__.py
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-03-24 14:57:56 +02:00
Marcello
dd7ce1eaa9 adding this for now 2025-03-24 14:48:00 +02:00
Marcello
0aef6abbe7 Merge branch 'dev' into flussButtonApi 2025-03-24 14:07:52 +02:00
Marcello
2809503dfa Merge branch 'dev' into flussButtonApi 2025-03-18 10:55:25 +02:00
Marcello
bec73b9e0a Merge branch 'dev' into flussButtonApi 2025-03-17 13:41:57 +02:00
Marcello
4efc7e9160 Fix lint errors: add explicit return type annotations in test functions 2025-03-12 07:06:34 +00:00
Marcello
f3bc9e2feb Merge branch 'dev' into flussButtonApi 2025-03-12 07:50:03 +02:00
Marcello
b79b0da224 Merge branch 'dev' into flussButtonApi 2025-03-11 12:25:35 +02:00
Marcello
51b9285886 updating the init test file 2025-03-11 12:23:09 +02:00
Marcello
0bff111d81 Merge branch 'dev' into flussButtonApi 2025-03-11 10:19:57 +02:00
Marcello
b3ee022669 Merge branch 'dev' into flussButtonApi 2025-03-07 07:30:32 +02:00
Marcello
62c3bcc3ca Merge branch 'dev' into flussButtonApi 2025-03-06 12:20:44 +02:00
Marcello
8d46dbc9d2 Merge branch 'dev' into flussButtonApi 2025-03-06 12:11:25 +02:00
Marcello
b24d0e2998 Merge branch 'dev' into flussButtonApi 2025-03-06 12:07:27 +02:00
Marcello
467bb1bade Merge branch 'dev' into flussButton 2025-03-06 10:31:56 +02:00
Marcello
620cc3b6e3 Merge branch 'dev' into flussButton 2025-03-05 07:21:44 +02:00
Marcello
e0363d277f Merge branch 'dev' into flussButton 2025-03-03 12:45:13 +02:00
Marcello
c0cc359672 Removing hard coded api url and using a new library version 2025-03-03 12:44:01 +02:00
Marcello
4c36dd6f5b Merge branch 'dev' into flussButton 2025-02-18 07:53:27 +02:00
Marcello
de7d2c9714 Merge branch 'dev' into flussButton 2025-02-17 11:44:08 +02:00
Marcello
bb42dfa8c6 Revert "version bump"
This reverts commit 6532d6bfc6.
2025-02-17 09:09:43 +02:00
Marcello
6532d6bfc6 version bump 2025-02-17 08:52:52 +02:00
Marcello
b63e36f4bb Merge branch 'dev' into flussButton 2025-02-17 08:09:36 +02:00
Marcello
efbba90cad Merge branch 'dev' into flussButton 2025-02-13 15:10:48 +02:00
Marcello
b7a0b61933 Merge branch 'dev' into flussButton 2025-02-13 07:24:16 +02:00
Marcello
a681070b77 Merge branch 'dev' into flussButton 2025-02-12 10:51:39 +02:00
Marcello
2497713507 Merge branch 'dev' into flussButton 2025-02-10 07:16:49 +02:00
Marcello
990ef3b0ef Merge branch 'dev' into flussButton 2025-02-07 15:04:32 +02:00
Marcello
08cd9c1ba6 adjusting to the request 2025-02-07 12:23:11 +02:00
Marcello
4632ea34a7 Update homeassistant/components/fluss/button.py
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-02-07 12:09:30 +02:00
Marcello
404662f4af Update homeassistant/components/fluss/config_flow.py
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-02-07 11:43:09 +02:00
Marcello
b865c48bab Update homeassistant/components/fluss/config_flow.py
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-02-07 11:42:55 +02:00
Marcello
044fd08046 Update homeassistant/components/fluss/__init__.py
Co-authored-by: Josef Zweck <josef@zweck.dev>
2025-02-07 11:42:44 +02:00
NjDaGreat
1270ebc1a4 Version Bump 2024-10-31 13:04:50 +00:00
NjDaGreat
4aa41eaeac Extra Changes 2024-10-31 13:02:24 +00:00
NjDaGreat
04d9273021 Some Test Changes to ensure coverage 2024-10-31 11:48:17 +00:00
NjDaGreat
ae2c893d7b Added a Validation check for deviceId and refactored async setup entry 2024-10-31 10:42:16 +00:00
NjDaGreat
36b2949f32 Suggested Changes 2024-10-09 14:22:36 +00:00
NjDaGreat
330ed228be added the flussButton class to button.py and deleted device.py 2024-10-07 09:49:38 +00:00
NjDaGreat
81ca4bc181 Made some changes to the test for better interactions with API 2024-09-27 11:29:08 +00:00
NjDaGreat
20c539150d Made some changes to test file and api library required 2024-09-26 15:05:41 +00:00
NjDaGreat
60c76377bf Some General House Keeping to ensure adherance 2024-09-25 11:22:26 +00:00
NjDaGreat
3e0c40a047 Separated API into its own library 2024-09-25 09:42:59 +00:00
NjDaGreat
7c65c0df83 Fixed a couple issues as well as added a test file 2024-07-17 22:49:41 +00:00
NjeruFluss
976ebac457 Merge branch 'home-assistant:dev' into flussButton 2024-07-17 16:44:05 +02:00
NjeruFluss
7376835c7c Merge branch 'dev' into flussButton 2024-07-17 08:11:26 +02:00
NjeruFluss
4fc6b440e8 Merge branch 'dev' into flussButton 2024-07-16 10:04:00 +02:00
NjeruFluss
a1aaac5578 Merge branch 'home-assistant:dev' into flussButton 2024-07-16 09:03:10 +02:00
NjeruFluss
98fc5c22d1 Merge branch 'dev' into flussButton 2024-07-10 15:30:30 +02:00
NjeruFluss
ff1d4aaa76 Merge branch 'dev' into flussButton 2024-07-10 11:48:05 +02:00
NjeruFluss
34481d9b36 Merge branch 'dev' into flussButton 2024-07-09 16:40:45 +02:00
NjeruFluss
5d708e04d5 Update entity.py
Added some contextual names
2024-07-09 13:49:09 +02:00
NjDaGreat
7d016e8689 Removed commented code 2024-07-09 11:36:57 +00:00
NjDaGreat
43153dd61f Removed unnecessary code 2024-07-09 11:23:47 +00:00
NjDaGreat
56c4959639 APIstorage 2024-06-28 14:14:43 +00:00
NjDaGreat
196610fe33 button functionality added for fluss device 2024-06-28 13:40:34 +00:00
19 changed files with 791 additions and 0 deletions

2
CODEOWNERS generated
View File

@@ -516,6 +516,8 @@ build.json @home-assistant/supervisor
/tests/components/flo/ @dmulcahey
/homeassistant/components/flume/ @ChrisMandich @bdraco @jeeftor
/tests/components/flume/ @ChrisMandich @bdraco @jeeftor
/homeassistant/components/fluss/ @fluss
/tests/components/fluss/ @fluss
/homeassistant/components/flux_led/ @icemanch
/tests/components/flux_led/ @icemanch
/homeassistant/components/forecast_solar/ @klaasnicolaas @frenck

View File

@@ -0,0 +1,31 @@
"""The Fluss+ integration."""
from __future__ import annotations
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_API_KEY, Platform
from homeassistant.core import HomeAssistant
from .coordinator import FlussDataUpdateCoordinator
PLATFORMS: list[Platform] = [Platform.BUTTON]
type FlussConfigEntry = ConfigEntry[FlussDataUpdateCoordinator]
async def async_setup_entry(
hass: HomeAssistant,
entry: FlussConfigEntry,
) -> bool:
"""Set up Fluss+ from a config entry."""
coordinator = FlussDataUpdateCoordinator(hass, entry, entry.data[CONF_API_KEY])
await coordinator.async_config_entry_first_refresh()
entry.runtime_data = coordinator
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True
async def async_unload_entry(hass: HomeAssistant, entry: FlussConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

View File

@@ -0,0 +1,38 @@
"""Support for Fluss Devices."""
from homeassistant.components.button import ButtonEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from .coordinator import FlussApiClientError, FlussDataUpdateCoordinator
from .entity import FlussEntity
type FlussConfigEntry = ConfigEntry[FlussDataUpdateCoordinator]
async def async_setup_entry(
hass: HomeAssistant,
entry: FlussConfigEntry,
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
"""Set up the Fluss Devices, filtering out any invalid payloads."""
coordinator = entry.runtime_data
devices = coordinator.data
async_add_entities(
FlussButton(coordinator, device_id, device)
for device_id, device in devices.items()
)
class FlussButton(FlussEntity, ButtonEntity):
"""Representation of a Fluss button device."""
async def async_press(self) -> None:
"""Handle the button press."""
try:
await self.coordinator.api.async_trigger_device(self.device_id)
except FlussApiClientError as err:
raise HomeAssistantError(f"Failed to trigger device: {err}") from err

View File

@@ -0,0 +1,54 @@
"""Config flow for Fluss+ integration."""
from __future__ import annotations
from typing import Any
from fluss_api import (
FlussApiClient,
FlussApiClientAuthenticationError,
FlussApiClientCommunicationError,
)
import voluptuous as vol
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_API_KEY
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN, LOGGER
STEP_USER_DATA_SCHEMA = vol.Schema({vol.Required(CONF_API_KEY): cv.string})
class FlussConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Fluss+."""
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Handle the initial step."""
errors: dict[str, str] = {}
if user_input is not None:
api_key = user_input[CONF_API_KEY]
self._async_abort_entries_match({CONF_API_KEY: api_key})
try:
FlussApiClient(
user_input[CONF_API_KEY], session=async_get_clientsession(self.hass)
)
except FlussApiClientCommunicationError:
errors["base"] = "cannot_connect"
except FlussApiClientAuthenticationError:
errors["base"] = "invalid_auth"
except Exception: # noqa: BLE001
LOGGER.exception("Unexpected exception occurred")
errors["base"] = "unknown"
if not errors:
return self.async_create_entry(
title="My Fluss+ Devices", data=user_input
)
return self.async_show_form(
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
)

View File

@@ -0,0 +1,9 @@
"""Constants for the Fluss+ integration."""
from datetime import timedelta
import logging
DOMAIN = "fluss"
LOGGER = logging.getLogger(__name__)
UPDATE_INTERVAL = 60 # seconds
UPDATE_INTERVAL_TIMEDELTA = timedelta(seconds=UPDATE_INTERVAL)

View File

@@ -0,0 +1,50 @@
"""DataUpdateCoordinator for Fluss+ integration."""
from __future__ import annotations
from typing import Any
from fluss_api import (
FlussApiClient,
FlussApiClientAuthenticationError,
FlussApiClientError,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from homeassistant.util import slugify
from .const import LOGGER, UPDATE_INTERVAL_TIMEDELTA
type FlussConfigEntry = ConfigEntry[FlussDataUpdateCoordinator]
class FlussDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
"""Manages fetching Fluss device data on a schedule."""
def __init__(
self, hass: HomeAssistant, config_entry: FlussConfigEntry, api_key: str
) -> None:
"""Initialize the coordinator."""
self.api = FlussApiClient(api_key, session=async_get_clientsession(hass))
super().__init__(
hass,
LOGGER,
name=f"Fluss+ ({slugify(api_key[:8])})",
config_entry=config_entry,
update_interval=UPDATE_INTERVAL_TIMEDELTA,
)
async def _async_update_data(self) -> dict[str, dict[str, Any]]:
"""Fetch data from the Fluss API and return as a dictionary keyed by deviceId."""
try:
devices = await self.api.async_get_devices()
except FlussApiClientAuthenticationError as err:
raise ConfigEntryAuthFailed(f"Authentication failed: {err}") from err
except FlussApiClientError as err:
raise UpdateFailed(f"Error fetching Fluss devices: {err}") from err
return {device["deviceId"]: device for device in devices.get("devices", [])}

View File

@@ -0,0 +1,36 @@
"""Base entities for the Fluss+ integration."""
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .coordinator import FlussDataUpdateCoordinator
class FlussEntity(CoordinatorEntity[FlussDataUpdateCoordinator]):
"""Base class for Fluss entities."""
_attr_has_entity_name = True
_attr_name = None
def __init__(
self,
coordinator: FlussDataUpdateCoordinator,
device_id: str,
device: dict,
) -> None:
"""Initialize the entity with a device ID and device data."""
super().__init__(coordinator)
self.device_id = device_id
self._device = device
self._attr_unique_id = f"{device_id}"
self._attr_device_info = DeviceInfo(
identifiers={("fluss", device_id)},
name=device.get("deviceName"),
manufacturer="Fluss",
model="Fluss+ Device",
)
@property
def device(self) -> dict:
"""Return the stored device data."""
return self._device

View File

@@ -0,0 +1,11 @@
{
"domain": "fluss",
"name": "Fluss+",
"codeowners": ["@fluss"],
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/fluss",
"iot_class": "cloud_polling",
"loggers": ["fluss-api"],
"quality_scale": "bronze",
"requirements": ["fluss-api==0.1.9.17"]
}

View File

@@ -0,0 +1,69 @@
rules:
# Bronze
action-setup:
status: exempt
comment: |
No actions present
appropriate-polling: done
brands: done
common-modules: done
config-flow-test-coverage: done
config-flow: done
dependency-transparency: done
docs-actions: done
docs-high-level-description: done
docs-installation-instructions: done
docs-removal-instructions: done
entity-event-setup: done
entity-unique-id: done
has-entity-name: done
runtime-data: done
test-before-configure: done
test-before-setup: done
unique-config-entry: done
# Silver
action-exceptions: todo
config-entry-unloading: done
docs-configuration-parameters: done
docs-installation-parameters: done
integration-owner: done
log-when-unavailable: done
parallel-updates: todo
reauthentication-flow: todo
test-coverage: todo
# Gold
entity-translations: done
entity-device-class: done
devices: done
entity-category: done
entity-disabled-by-default:
status: exempt
comment: |
Not needed
discovery: todo
stale-devices: todo
diagnostics: todo
exception-translations: todo
icon-translations:
status: exempt
comment: |
No icons used
reconfiguration-flow: todo
dynamic-devices: todo
discovery-update-info: todo
repair-issues:
status: exempt
comment: |
No issues to repair
docs-use-cases: done
docs-supported-devices: todo
docs-supported-functions: done
docs-data-update: todo
docs-known-limitations: done
docs-troubleshooting: todo
docs-examples: todo
# Platinum
async-dependency: done
inject-websession: done
strict-typing: todo

View File

@@ -0,0 +1,20 @@
{
"config": {
"step": {
"user": {
"description": "Your Fluss API key, available in the profile page of the Fluss+ app",
"data": {
"api_key": "[%key:common::config_flow::data::api_key%]"
},
"data_description": {
"api_key": "The API key found in the profile page of the Fluss+ app."
}
}
},
"error": {
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
"unknown": "[%key:common::config_flow::error::unknown%]"
}
}
}

View File

@@ -213,6 +213,7 @@ FLOWS = {
"flipr",
"flo",
"flume",
"fluss",
"flux_led",
"folder_watcher",
"forecast_solar",

View File

@@ -2062,6 +2062,12 @@
"config_flow": true,
"iot_class": "cloud_polling"
},
"fluss": {
"name": "Fluss+",
"integration_type": "hub",
"config_flow": true,
"iot_class": "cloud_polling"
},
"flux": {
"name": "Flux",
"integration_type": "hub",

3
requirements_all.txt generated
View File

@@ -968,6 +968,9 @@ flexit_bacnet==2.2.3
# homeassistant.components.flipr
flipr-api==1.6.1
# homeassistant.components.fluss
fluss-api==0.1.9.17
# homeassistant.components.flux_led
flux-led==1.2.0

View File

@@ -844,6 +844,9 @@ flexit_bacnet==2.2.3
# homeassistant.components.flipr
flipr-api==1.6.1
# homeassistant.components.fluss
fluss-api==0.1.9.17
# homeassistant.components.flux_led
flux-led==1.2.0

View File

@@ -0,0 +1,92 @@
"""Test Script for Fluss+ Initialisation."""
from __future__ import annotations
from unittest.mock import MagicMock, patch
from fluss_api import (
FlussApiClient,
FlussApiClientAuthenticationError,
FlussApiClientCommunicationError,
FlussApiClientError,
)
import pytest
from homeassistant.components.fluss import PLATFORMS
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
@pytest.mark.parametrize(
("side_effect", "expected_exception"),
[
(FlussApiClientAuthenticationError, ConfigEntryAuthFailed),
(FlussApiClientCommunicationError, ConfigEntryNotReady),
(FlussApiClientError, ConfigEntryNotReady),
],
)
async def test_async_setup_entry_errors(
hass: HomeAssistant,
mock_config_entry: MagicMock,
side_effect: Exception,
expected_exception: type[Exception],
) -> None:
"""Test setup errors."""
with (
patch("fluss_api.FlussApiClient", side_effect=side_effect),
pytest.raises(expected_exception),
):
await hass.config_entries.async_setup(mock_config_entry.entry_id)
assert mock_config_entry.state is ConfigEntryState.SETUP_ERROR
@pytest.mark.asyncio
async def test_async_setup_entry_success(
hass: HomeAssistant,
mock_config_entry: MagicMock,
mock_api_client: FlussApiClient,
) -> None:
"""Test successful setup."""
with patch("fluss_api.FlussApiClient", return_value=mock_api_client):
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
assert mock_config_entry.state is ConfigEntryState.LOADED
hass.config_entries.async_forward_entry_setups.assert_called_once_with(
mock_config_entry, PLATFORMS
)
@pytest.mark.asyncio
async def test_async_unload_entry(
hass: HomeAssistant,
mock_config_entry: MagicMock,
mock_api_client: FlussApiClient,
) -> None:
"""Test unloading entry."""
# Set up the config entry first to ensure it's in LOADED state
with patch("fluss_api.FlussApiClient", return_value=mock_api_client):
await hass.config_entries.async_setup(mock_config_entry.entry_id)
assert mock_config_entry.state is ConfigEntryState.LOADED
# Test unloading
with patch(
"homeassistant.components.fluss.async_unload_platforms", return_value=True
):
assert await hass.config_entries.async_unload(mock_config_entry.entry_id)
assert mock_config_entry.state is ConfigEntryState.NOT_LOADED
@pytest.mark.asyncio
async def test_platforms_forwarded(
hass: HomeAssistant,
mock_config_entry: MagicMock,
mock_api_client: FlussApiClient,
) -> None:
"""Test platforms are forwarded correctly."""
with patch("fluss_api.FlussApiClient", return_value=mock_api_client):
await hass.config_entries.async_setup(mock_config_entry.entry_id)
assert mock_config_entry.state is ConfigEntryState.LOADED
hass.config_entries.async_forward_entry_setups.assert_called_with(
mock_config_entry, [Platform.BUTTON]
)

View File

@@ -0,0 +1,74 @@
"""Shared test fixtures for Fluss+ integration."""
from __future__ import annotations
from unittest.mock import AsyncMock, patch
import pytest
from homeassistant.components.fluss.const import DOMAIN
from homeassistant.const import CONF_API_KEY
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
@pytest.fixture
def mock_config_entry() -> MockConfigEntry:
"""Return the default mocked config entry."""
return MockConfigEntry(
domain=DOMAIN,
title="Fluss Integration",
data={CONF_API_KEY: "test_api_key"},
unique_id="test_api_key",
)
@pytest.fixture
def mock_api_client() -> AsyncMock:
"""Mock Fluss API client with single device."""
with (
patch(
"homeassistant.components.fluss.coordinator.FlussApiClient",
autospec=True,
) as mock_client,
patch(
"homeassistant.components.fluss.config_flow.FlussApiClient",
new=mock_client,
),
):
client = mock_client.return_value
client.async_get_devices.return_value = {
"devices": [{"deviceId": "1", "deviceName": "Test Device"}]
}
client.async_trigger_device.return_value = None
yield client
@pytest.fixture
def mock_api_client_multiple_devices() -> AsyncMock:
"""Mock Fluss API client with multiple devices."""
with patch(
"homeassistant.components.fluss.coordinator.FlussApiClient",
autospec=True,
) as mock_client:
client = mock_client.return_value
client.async_get_devices.return_value = {
"devices": [
{"deviceId": "2a303030sdj1", "deviceName": "Device 1"},
{"deviceId": "ape93k9302j2", "deviceName": "Device 2"},
]
}
client.async_trigger_device.return_value = None
yield client
@pytest.fixture
async def init_integration(
hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_api_client: AsyncMock
) -> MockConfigEntry:
"""Set up the Fluss integration for testing."""
mock_config_entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
return mock_config_entry

View File

@@ -0,0 +1,118 @@
"""Tests for the Fluss Buttons."""
from __future__ import annotations
from unittest.mock import AsyncMock, patch
from fluss_api import FlussApiClient, FlussApiClientError
import pytest
from syrupy.assertion import SnapshotAssertion
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import device_registry as dr, entity_registry as er
from tests.common import MockConfigEntry, snapshot_platform
async def test_async_setup_entry_multiple_devices(
hass: HomeAssistant,
mock_api_client_multiple_devices: AsyncMock,
mock_config_entry: MockConfigEntry,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test setup with multiple devices."""
mock_config_entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
mock_api_client_multiple_devices.async_get_devices.assert_called_once()
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
async def test_button_press_success(
hass: HomeAssistant,
mock_api_client: FlussApiClient,
entity_registry: er.EntityRegistry,
init_integration: MockConfigEntry,
snapshot: SnapshotAssertion,
) -> None:
"""Test successful button press."""
state = hass.states.get("button.test_device")
assert state
assert state == snapshot(name="button_state")
entry_reg = entity_registry.async_get(state.entity_id)
assert entry_reg
device_registry = dr.async_get(hass)
device = device_registry.async_get(entry_reg.device_id)
assert device == snapshot(name="device_info")
await hass.services.async_call(
BUTTON_DOMAIN,
SERVICE_PRESS,
{ATTR_ENTITY_ID: "button.test_device"},
blocking=True,
)
mock_api_client.async_trigger_device.assert_called_once_with("1")
async def test_button_press_error(
hass: HomeAssistant,
mock_api_client: FlussApiClient,
init_integration: MockConfigEntry,
) -> None:
"""Test button press with API error."""
state = hass.states.get("button.test_device")
assert state
mock_api_client.async_trigger_device.side_effect = FlussApiClientError("API Boom")
with pytest.raises(HomeAssistantError, match="Failed to trigger device: API Boom"):
await hass.services.async_call(
BUTTON_DOMAIN,
SERVICE_PRESS,
{ATTR_ENTITY_ID: "button.test_device"},
blocking=True,
)
async def test_no_devices_setup(
hass: HomeAssistant,
mock_api_client: FlussApiClient,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test setup with no devices."""
mock_api_client.async_get_devices.return_value = {"devices": []}
mock_config_entry.add_to_hass(hass)
with patch("fluss_api.FlussApiClient", return_value=mock_api_client):
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert hass.states.get("button.test_device") is None
async def test_unload_entry(
hass: HomeAssistant,
init_integration: MockConfigEntry,
) -> None:
"""Test unloading the entry."""
assert init_integration.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(init_integration.entry_id)
await hass.async_block_till_done()
assert init_integration.state is ConfigEntryState.NOT_LOADED
state = hass.states.get("button.test_device")
if state:
assert state.state == "unavailable"
assert state.attributes.get("restored") is True
else:
assert state is None

View File

@@ -0,0 +1,100 @@
"""Tests for the Fluss+ config flow."""
from unittest.mock import AsyncMock, patch
from fluss_api import (
FlussApiClientAuthenticationError,
FlussApiClientCommunicationError,
)
import pytest
from homeassistant.components.fluss.const import DOMAIN
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_API_KEY
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
async def test_show_form(hass: HomeAssistant) -> None:
"""Test that the form is shown."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
async def test_successful_flow(hass: HomeAssistant, mock_api_client: AsyncMock) -> None:
"""Test successful config flow."""
user_input = {CONF_API_KEY: "valid_api_key"}
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=user_input
)
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "My Fluss+ Devices"
assert result["data"] == user_input
@pytest.mark.parametrize(
("exception", "expected_error"),
[
(FlussApiClientAuthenticationError, "invalid_auth"),
(FlussApiClientCommunicationError, "cannot_connect"),
(ValueError, "unknown"),
],
)
async def test_step_user_errors(
hass: HomeAssistant,
exception: Exception,
expected_error: str,
mock_api_client: AsyncMock,
) -> None:
"""Test error cases for user step with recovery."""
user_input = {CONF_API_KEY: "some_api_key"}
class_mock = mock_api_client._mock_parent
class_mock.side_effect = exception
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=user_input
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": expected_error}
class_mock.side_effect = None
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input,
)
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "My Fluss+ Devices"
assert result["data"] == user_input
async def test_unexpected_exception_logging(
hass: HomeAssistant, mock_api_client: AsyncMock
) -> None:
"""Test logging of unexpected exceptions."""
user_input = {CONF_API_KEY: "some_api_key"}
with patch(
"homeassistant.components.fluss.config_flow.LOGGER.exception"
) as mock_logger:
class_mock = mock_api_client._mock_parent
class_mock.side_effect = Exception("Unexpected error")
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=user_input
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "unknown"}
mock_logger.assert_called_once_with("Unexpected exception occurred")

View File

@@ -0,0 +1,74 @@
"""Test script for Fluss+ integration initialization."""
from unittest.mock import AsyncMock, patch
from fluss_api import (
FlussApiClientAuthenticationError,
FlussApiClientCommunicationError,
FlussApiClientError,
)
import pytest
from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
async def test_async_setup_entry_authentication_error(
hass: HomeAssistant, mock_config_entry
) -> None:
"""Test that an authentication error during setup leads to SETUP_ERROR state."""
mock_config_entry.add_to_hass(hass)
with patch(
"homeassistant.components.fluss.coordinator.FlussApiClient.async_get_devices",
side_effect=FlussApiClientAuthenticationError("Invalid credentials"),
):
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert mock_config_entry.state is ConfigEntryState.SETUP_ERROR
@pytest.mark.asyncio
@pytest.mark.parametrize(
"error_type",
[
FlussApiClientCommunicationError("Network error"),
FlussApiClientError("General error"),
],
ids=["communication_error", "general_error"],
)
async def test_async_setup_entry_error(
hass: HomeAssistant, mock_config_entry, error_type
) -> None:
"""Test that non-authentication errors during setup lead to SETUP_RETRY state."""
mock_config_entry.add_to_hass(hass)
with patch(
"homeassistant.components.fluss.coordinator.FlussApiClient",
side_effect=error_type,
):
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert mock_config_entry.state is ConfigEntryState.SETUP_ERROR
@pytest.mark.asyncio
async def test_load_unload_config_entry(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_api_client: AsyncMock,
) -> None:
"""Test the Fluss configuration entry loading/unloading."""
mock_config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert mock_config_entry.state is ConfigEntryState.LOADED
assert len(mock_api_client.async_get_devices.mock_calls) == 1
await hass.config_entries.async_unload(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert mock_config_entry.state is ConfigEntryState.NOT_LOADED