Compare commits

...
Author SHA1 Message Date
J. Nick Koston ee0c7d87a3 Merge remote-tracking branch 'origin/dev' into HEAD 2026-11-14 08:37:20 -06:00
J. Nick Koston 90d06e0967 Merge remote-tracking branch 'origin/dev' into hubfn-migrate-d 2026-11-05 11:46:32 -06:00
J. Nick Koston 865c9b0048 Merge dev into hubfn-migrate-d 2026-11-04 21:09:07 -06:00
J. Nick Koston ebbf41dc00 Merge hubfn-migrate-c into hubfn-migrate-d 2026-11-04 20:18:40 -06:00
J. Nick Koston 6441c80313 [motion] Tidy the sensor type hints, publisher asserts and define order 2026-11-04 20:11:27 -06:00
J. Nick Koston 85b21c1e68 [motion] Leave the systa_bus and mk2pvrouter migration to its own PR
That migration now comes after the motion PRs in the chain.
2026-11-04 20:11:27 -06:00
J. Nick Koston 5404ffaab6 [motion] Drop the binary sensor setup priority override
The start-up order of the initial false needs no change.
2026-11-04 20:11:27 -06:00
J. Nick Koston ba78de9088 [motion] Set up binary sensors before the hub's first update 2026-11-04 20:11:27 -06:00
J. Nick Koston d11eeeeb53 [systa_bus] Type the deprecated platform id as a string for the language schema 2026-11-04 20:11:27 -06:00
J. Nick Koston 42e5646f35 [motion] Use HUB_PUBLISHER and the derived data publisher name 2026-11-04 20:11:27 -06:00
J. Nick Koston af91a598fa [motion] Publish children through a generated hub function 2026-11-04 20:11:27 -06:00
J. Nick Koston acc7746e22 [mk2pvrouter] Follow the HubFunction publisher convention
Rename the functions to value and dump publishers declared with HUB_PUBLISHER,
pass the hub's tag to the children's dump helpers, rename the child schema,
and test the hub against a recorder of the last published tag and value.
2026-11-04 20:11:27 -06:00
J. Nick Koston 05708acebc [systa_bus] Follow the HubFunction publisher convention
Rename the functions to aqua and dump publishers declared with HUB_PUBLISHER,
log the children's dump lines through small C++ helpers with the bus's tag,
move aqua_temperature() into systa_bus.h, and deprecate the ignored platform
id and setup_priority keys instead of declaring an id that is never created.
2026-11-04 20:11:27 -06:00
J. Nick Koston 31e409b1cf [systa_bus] Keep accepting the platform id and setup_priority keys 2026-11-04 20:11:27 -06:00
J. Nick Koston ecd664523c [mk2pvrouter] Publish children through a generated hub function 2026-11-04 20:11:27 -06:00
J. Nick Koston 567cbbe598 [systa_bus] Publish children through a generated hub function 2026-11-04 20:11:27 -06:00
J. Nick Koston 390c3216b1 Merge remote-tracking branch 'origin/hubfn-migrate-c' into hubfn-migrate-d
# Conflicts:
#	esphome/components/motion/__init__.py
#	esphome/components/motion/motion_component.h
#	esphome/core/defines.h
#	tests/component_tests/motion/test_hub_function.py
2026-11-04 12:56:01 -06:00
J. Nick Koston ca7aa429df [motion] Tidy the sensor type hints, publisher asserts and define order 2026-11-04 12:52:49 -06:00
J. Nick Koston eb48e6a07a [motion] Leave the systa_bus and mk2pvrouter migration to its own PR
That migration now comes after the motion PRs in the chain.
2026-11-04 12:52:49 -06:00
J. Nick Koston fd16d0c0a8 [motion] Drop the binary sensor setup priority override
The start-up order of the initial false needs no change.
2026-11-04 12:52:49 -06:00
J. Nick Koston b0000fffc3 [motion] Set up binary sensors before the hub's first update 2026-11-04 12:52:49 -06:00
J. Nick Koston a4407839b0 [systa_bus] Type the deprecated platform id as a string for the language schema 2026-11-04 12:52:49 -06:00
J. Nick Koston cfe7eec9d0 [motion] Use HUB_PUBLISHER and the derived data publisher name 2026-11-04 12:52:49 -06:00
J. Nick Koston cfd059e198 [motion] Publish children through a generated hub function 2026-11-04 12:52:49 -06:00
J. Nick Koston f821f32725 [mk2pvrouter] Follow the HubFunction publisher convention
Rename the functions to value and dump publishers declared with HUB_PUBLISHER,
pass the hub's tag to the children's dump helpers, rename the child schema,
and test the hub against a recorder of the last published tag and value.
2026-11-04 12:52:49 -06:00
J. Nick Koston 5fbdb34aa3 [systa_bus] Follow the HubFunction publisher convention
Rename the functions to aqua and dump publishers declared with HUB_PUBLISHER,
log the children's dump lines through small C++ helpers with the bus's tag,
move aqua_temperature() into systa_bus.h, and deprecate the ignored platform
id and setup_priority keys instead of declaring an id that is never created.
2026-11-04 12:52:49 -06:00
J. Nick Koston d1d5f9fd79 [systa_bus] Keep accepting the platform id and setup_priority keys 2026-11-04 12:52:49 -06:00
J. Nick Koston 84fd0ab834 [mk2pvrouter] Publish children through a generated hub function 2026-11-04 12:52:49 -06:00
J. Nick Koston 53edf32bf2 [systa_bus] Publish children through a generated hub function 2026-11-04 12:52:49 -06:00
J. Nick Koston d6a2345596 [sy6970] Drop the unreachable fallback strings from the bus and charge status tables 2026-11-04 12:52:48 -06:00
J. Nick Koston be9ee69672 [sy6970] Share the child publishing loop across the three platforms 2026-11-04 12:52:48 -06:00
J. Nick Koston 5702320808 [sy6970] Check the decode of every child in the hub function test 2026-11-04 12:52:48 -06:00
J. Nick Koston 75369a15d8 [tm1638] Follow the HubFunction convention
Use HUB_PUBLISHER and the derived setter, and export the KEYS parameter
as a module constant.
2026-11-04 12:52:48 -06:00
J. Nick Koston 5851a9e58d [tca8418] Follow the HubFunction convention
Use HUB_PUBLISHER and the derived setter, and export the KEY and PRESSED
parameters as module constants.
2026-11-04 12:52:48 -06:00
J. Nick Koston cc1f2388eb [sy6970] Follow the HubFunction convention and use string tables
Use HUB_PUBLISHER and the derived setter, pass the hub constants directly
to the sensor decode with a scale argument, and publish the status text
from PROGMEM string tables.
2026-11-04 12:52:48 -06:00
J. Nick Koston 490ce313af [tm1638] Publish children through a generated hub function 2026-11-04 12:52:48 -06:00
J. Nick Koston 407e9c5f7c [tca8418] Publish children through a generated hub function 2026-11-04 12:52:48 -06:00
J. Nick Koston 205e4d0041 [sy6970] Publish children through a generated hub function 2026-11-04 12:52:48 -06:00
J. Nick Koston 8b3a5f8855 Merge remote-tracking branch 'origin/hubfn-migrate-c' into hubfn-migrate-d
# Conflicts:
#	esphome/components/motion/__init__.py
#	esphome/components/motion/motion_component.h
#	esphome/core/defines.h
#	tests/component_tests/motion/test_hub_function.py
2026-11-04 12:47:12 -06:00
J. Nick Koston 5bd999b9f3 [motion] Tidy the sensor type hints, publisher asserts and define order 2026-11-04 12:43:47 -06:00
J. Nick Koston 21add4c229 [motion] Leave the systa_bus and mk2pvrouter migration to its own PR
That migration now comes after the motion PRs in the chain.
2026-11-04 12:43:47 -06:00
J. Nick Koston c44787922a [motion] Drop the binary sensor setup priority override
The start-up order of the initial false needs no change.
2026-11-04 12:43:47 -06:00
J. Nick Koston 9e1457f669 [motion] Set up binary sensors before the hub's first update 2026-11-04 12:43:47 -06:00
J. Nick Koston 3ec9858efc [systa_bus] Type the deprecated platform id as a string for the language schema 2026-11-04 12:43:47 -06:00
J. Nick Koston f56c1dfbf3 [motion] Use HUB_PUBLISHER and the derived data publisher name 2026-11-04 12:43:47 -06:00
J. Nick Koston 630a68d39e [motion] Publish children through a generated hub function 2026-11-04 12:43:47 -06:00
J. Nick Koston e1451e0ab9 [mk2pvrouter] Follow the HubFunction publisher convention
Rename the functions to value and dump publishers declared with HUB_PUBLISHER,
pass the hub's tag to the children's dump helpers, rename the child schema,
and test the hub against a recorder of the last published tag and value.
2026-11-04 12:43:47 -06:00
J. Nick Koston ae3fe12d94 [systa_bus] Follow the HubFunction publisher convention
Rename the functions to aqua and dump publishers declared with HUB_PUBLISHER,
log the children's dump lines through small C++ helpers with the bus's tag,
move aqua_temperature() into systa_bus.h, and deprecate the ignored platform
id and setup_priority keys instead of declaring an id that is never created.
2026-11-04 12:43:47 -06:00
J. Nick Koston 22cb8fddb3 [systa_bus] Keep accepting the platform id and setup_priority keys 2026-11-04 12:43:47 -06:00
J. Nick Koston 6f237e1f80 [mk2pvrouter] Publish children through a generated hub function 2026-11-04 12:43:47 -06:00
J. Nick Koston 31f80dd4f4 [systa_bus] Publish children through a generated hub function 2026-11-04 12:43:47 -06:00
J. Nick Koston e5b4a553bb [sy6970] Drop the unreachable fallback strings from the bus and charge status tables 2026-11-04 12:43:46 -06:00
J. Nick Koston 10b16d9457 [sy6970] Share the child publishing loop across the three platforms 2026-11-04 12:43:46 -06:00
J. Nick Koston 77a61f976e [sy6970] Check the decode of every child in the hub function test 2026-11-04 12:43:46 -06:00
J. Nick Koston 34eedcd255 [tm1638] Follow the HubFunction convention
Use HUB_PUBLISHER and the derived setter, and export the KEYS parameter
as a module constant.
2026-11-04 12:43:46 -06:00
J. Nick Koston 744015d873 [tca8418] Follow the HubFunction convention
Use HUB_PUBLISHER and the derived setter, and export the KEY and PRESSED
parameters as module constants.
2026-11-04 12:43:46 -06:00
J. Nick Koston 2772596338 [sy6970] Follow the HubFunction convention and use string tables
Use HUB_PUBLISHER and the derived setter, pass the hub constants directly
to the sensor decode with a scale argument, and publish the status text
from PROGMEM string tables.
2026-11-04 12:43:46 -06:00
J. Nick Koston 3dc11980eb [tm1638] Publish children through a generated hub function 2026-11-04 12:43:46 -06:00
J. Nick Koston d10c4e5fad [tca8418] Publish children through a generated hub function 2026-11-04 12:43:46 -06:00
J. Nick Koston 1732e607e7 [sy6970] Publish children through a generated hub function 2026-11-04 12:43:46 -06:00
J. Nick Koston 21a00e55c5 [ai] Say where the hub function define and dump call go, and drop the repeated paragraph 2026-11-04 12:43:44 -06:00
J. Nick Koston 62d90e7be7 [ai] State the general hub function rule and point embedded-memory at it 2026-11-04 12:43:44 -06:00
J. Nick Koston f922de9ee4 [ai] Follow the derived HubFunction setter in the field decoding example 2026-11-04 12:43:44 -06:00
J. Nick Koston fd51924790 [ai] Show the field decoding example with cg.HubFunction and inline the single-bit match 2026-11-04 12:43:44 -06:00
J. Nick Koston bef064a90c [ai] Show the bq25186 field decoding built from codegen expressions 2026-11-04 12:43:44 -06:00
J. Nick Koston ad63488c70 [ai] Use add_binary_status and the exact single-bit condition in the field decoding example 2026-11-04 12:43:44 -06:00
J. Nick Koston d7686206e4 [ai] Show the on-values bitmap and mark the bq25186 helpers as local in the field decoding example 2026-11-04 12:43:44 -06:00
J. Nick Koston 2d925c8060 Prefer generated decoding for fixed register fields in the codegen skill 2026-11-04 12:43:44 -06:00
J. Nick Koston ed9f3158e4 Merge branch 'hubfn-migrate-c' into hubfn-migrate-d 2026-11-04 12:16:11 -06:00
J. Nick Koston c95c0ab2ae Merge branch 'hubfn-migrate-a' into hubfn-migrate-c 2026-11-04 12:16:11 -06:00
J. Nick Koston 6614bc82be Merge branch 'skill-generated-field-decoding' into hubfn-migrate-a 2026-11-04 12:16:10 -06:00
J. Nick Koston 0ce6a3bbc4 Merge remote-tracking branch 'origin/bq25186-status-codegen' into skill-generated-field-decoding 2026-11-04 12:15:57 -06:00
J. Nick Koston a378010458 Merge remote-tracking branch 'origin/dev' into bq25186-status-codegen
# Conflicts:
#	tests/components/bq25186/__init__.py
#	tests/components/bq25186/test_bq25186_status.cpp
2026-11-04 12:15:45 -06:00
J. Nick Koston 149a8a9bbc Merge hubfn-migrate-c 2026-11-02 09:44:04 -06:00
J. Nick Koston b089cdff18 Merge hubfn-migrate-a 2026-11-02 09:42:45 -06:00
J. Nick Koston 5f60d9dfc0 Merge skill-generated-field-decoding 2026-11-02 09:41:29 -06:00
J. Nick Koston d9c0e4ca04 Merge bq25186-status-codegen 2026-11-02 09:40:10 -06:00
J. Nick Koston c0c5846458 Merge bq25186-status-tests 2026-11-02 09:38:51 -06:00
J. Nick Koston 24792dee10 Merge hub-function-helper 2026-11-02 09:37:11 -06:00
J. Nick Koston d451a25d12 Merge dev 2026-11-02 09:35:59 -06:00
J. Nick Koston 18134d1c0d Merge dev 2026-11-02 09:32:52 -06:00
J. Nick Koston c39f6178aa Merge branch 'hubfn-migrate-c' into hubfn-migrate-d 2026-10-31 22:00:01 -10:00
J. Nick Koston 6b7e990e6a Merge branch 'hubfn-migrate-a' into hubfn-migrate-c 2026-10-31 22:00:00 -10:00
J. Nick Koston 73b4330d29 Merge branch 'skill-generated-field-decoding' into hubfn-migrate-a 2026-10-31 21:59:59 -10:00
J. Nick Koston 11ad36866d Merge branch 'bq25186-status-codegen' into skill-generated-field-decoding 2026-10-31 21:59:57 -10:00
J. Nick Koston be81117dbe [sy6970] Drop the unreachable fallback strings from the bus and charge status tables 2026-10-31 21:55:29 -10:00
J. Nick Koston 0794ab32bb [bq25186] Keep each status decode in its platform file and drop the copy-only order test 2026-10-31 21:54:43 -10:00
J. Nick Koston b81746e98c Merge branch 'hubfn-migrate-c' into hubfn-migrate-d 2026-10-31 21:44:21 -10:00
J. Nick Koston 2d8475f116 Merge branch 'hubfn-migrate-a' into hubfn-migrate-c 2026-10-31 21:44:16 -10:00
J. Nick Koston 4fc8456821 Merge branch 'skill-generated-field-decoding' into hubfn-migrate-a 2026-10-31 21:44:12 -10:00
J. Nick Koston 2130c86a98 [ai] Say where the hub function define and dump call go, and drop the repeated paragraph 2026-10-31 21:43:57 -10:00
J. Nick Koston 25a6a1c9b5 [motion] Generate the temperature test config once for all five IMUs 2026-10-31 21:39:12 -10:00
J. Nick Koston 0a37700a53 Merge branch 'hubfn-migrate-c' into hubfn-migrate-d
# Conflicts:
#	esphome/core/defines.h
2026-10-31 21:38:52 -10:00
J. Nick Koston e95049660c [motion] Tidy the sensor type hints, publisher asserts and define order 2026-10-31 21:38:24 -10:00
J. Nick Koston 72ab0e5e05 Merge branch 'hubfn-migrate-a' into hubfn-migrate-c 2026-10-31 21:37:49 -10:00
J. Nick Koston 28d2730629 Merge branch 'skill-generated-field-decoding' into hubfn-migrate-a 2026-10-31 21:37:30 -10:00
J. Nick Koston a91ebfef34 Merge remote-tracking branch 'origin/bq25186-status-codegen' into skill-generated-field-decoding 2026-10-31 21:37:28 -10:00
J. Nick Koston 56308056fb [bq25186] Trim test comments 2026-10-31 21:37:13 -10:00
J. Nick Koston 4b44c4a60d Merge branch 'bq25186-status-tests' into bq25186-status-codegen 2026-10-31 21:36:57 -10:00
J. Nick Koston c0788031d4 [bq25186] Drop a comment that restates the test 2026-10-31 21:36:47 -10:00
J. Nick Koston a5ec8693a4 Merge branch 'hub-function-helper' into bq25186-status-tests 2026-10-31 21:36:37 -10:00
J. Nick Koston 59dfb4ce72 [core] Shorten the HubFunction docstring 2026-10-31 21:36:27 -10:00
J. Nick Koston 26f031caf8 [sy6970] Share the child publishing loop across the three platforms 2026-10-31 21:35:36 -10:00
J. Nick Koston 55503020af Merge branch 'skill-generated-field-decoding' into hubfn-migrate-a 2026-10-31 21:34:34 -10:00
J. Nick Koston 1a658bfdc1 [ai] State the general hub function rule and point embedded-memory at it 2026-10-31 21:32:57 -10:00
J. Nick Koston 8db46d301b Merge remote-tracking branch 'origin/bq25186-status-codegen' into skill-generated-field-decoding 2026-10-31 21:32:43 -10:00
J. Nick Koston c7c40154c6 [bq25186] Use the shared hub function test layout and drop a repeated comment 2026-10-31 21:32:19 -10:00
J. Nick Koston 2bd7cd8aa3 Merge branch 'bq25186-status-tests' into bq25186-status-codegen 2026-10-31 21:31:30 -10:00
J. Nick Koston e97b865653 Merge branch 'hub-function-helper' into bq25186-status-tests 2026-10-31 21:31:27 -10:00
J. Nick Koston 93bb8ef97b [core] Keep all HubFunction state in one dataclass and build parameter names in one place 2026-10-31 21:31:13 -10:00
J. Nick Koston 1e8b6e75c7 Merge branch 'hubfn-migrate-c' into hubfn-migrate-d 2026-10-31 21:23:22 -10:00
J. Nick Koston b593138e26 [motion] Leave the systa_bus and mk2pvrouter migration to its own PR
That migration now comes after the motion PRs in the chain.
2026-10-31 21:23:05 -10:00
J. Nick Koston b195ee3a75 Merge branch 'hubfn-migrate-c' into hubfn-migrate-d 2026-10-31 21:20:41 -10:00
J. Nick Koston 9b3b61df27 [motion] Drop the binary sensor setup priority override
The start-up order of the initial false needs no change.
2026-10-31 21:19:14 -10:00
J. Nick Koston 3bf646fa01 Merge branch 'hubfn-migrate-c' into hubfn-migrate-d 2026-10-31 21:14:07 -10:00
J. Nick Koston 66861ffd95 [motion] Set up binary sensors before the hub's first update 2026-10-31 21:13:53 -10:00
J. Nick Koston bed0bc99dd Merge branch 'hubfn-migrate-b' into hubfn-migrate-c 2026-10-31 21:13:21 -10:00
J. Nick Koston eac7a18ebd [systa_bus] Type the deprecated platform id as a string for the language schema 2026-10-31 21:12:33 -10:00
J. Nick Koston e0eb06f44b Merge branch 'hubfn-migrate-a' into hubfn-migrate-b 2026-10-31 21:11:44 -10:00
J. Nick Koston 1af65d8281 [sy6970] Check the decode of every child in the hub function test 2026-10-31 21:11:25 -10:00
J. Nick Koston 54560ce224 Merge branch 'skill-generated-field-decoding' into hubfn-migrate-a 2026-10-31 21:10:47 -10:00
J. Nick Koston 4db30fac45 Merge remote-tracking branch 'origin/bq25186-status-codegen' into skill-generated-field-decoding 2026-10-31 21:10:33 -10:00
J. Nick Koston e527aa4f2c [bq25186] Name the status parameter plainly in the C++ test's copy of the generated function 2026-10-31 21:09:20 -10:00
J. Nick Koston 55fead5f9a Merge branch 'bq25186-status-tests' into bq25186-status-codegen 2026-10-31 21:08:58 -10:00
J. Nick Koston ddb01c6f65 Merge branch 'hub-function-helper' into bq25186-status-tests 2026-10-31 21:08:56 -10:00
J. Nick Koston c4262e0c24 [core] Use plain names in the HUB_PUBLISHER test's copy of a generated function 2026-10-31 21:08:33 -10:00
J. Nick Koston 5946c1b2b0 [motion] Share one temperature publisher across the IMU hubs
lis3dh, bmi270, icm20689, qmi8658 and lsm6ds publish temperature through a
generated function on MotionComponent instead of their own callback lists;
the bmi270 magnetometer gets its own hub function.
2026-10-31 20:55:57 -10:00
J. Nick Koston 223e4fc79b [motion] Use HUB_PUBLISHER and the derived data publisher name 2026-10-31 20:55:32 -10:00
J. Nick Koston c72f5accad [motion] Publish children through a generated hub function 2026-10-31 20:55:32 -10:00
J. Nick Koston 0abdd69bc2 [mk2pvrouter] Follow the HubFunction publisher convention
Rename the functions to value and dump publishers declared with HUB_PUBLISHER,
pass the hub's tag to the children's dump helpers, rename the child schema,
and test the hub against a recorder of the last published tag and value.
2026-10-31 20:55:12 -10:00
J. Nick Koston 5060185da1 [systa_bus] Follow the HubFunction publisher convention
Rename the functions to aqua and dump publishers declared with HUB_PUBLISHER,
log the children's dump lines through small C++ helpers with the bus's tag,
move aqua_temperature() into systa_bus.h, and deprecate the ignored platform
id and setup_priority keys instead of declaring an id that is never created.
2026-10-31 20:55:12 -10:00
J. Nick Koston fc3a5322f6 [systa_bus] Keep accepting the platform id and setup_priority keys 2026-10-31 20:55:12 -10:00
J. Nick Koston 96f1547f94 [mk2pvrouter] Publish children through a generated hub function 2026-10-31 20:55:11 -10:00
J. Nick Koston 43e2388a5f [systa_bus] Publish children through a generated hub function 2026-10-31 20:55:11 -10:00
J. Nick Koston 107526e5ff Merge branch 'skill-generated-field-decoding' into hubfn-migrate-a 2026-10-31 20:55:04 -10:00
J. Nick Koston ba7fa90c47 Merge remote-tracking branch 'origin/bq25186-status-codegen' into skill-generated-field-decoding 2026-10-31 20:54:47 -10:00
J. Nick Koston 1c54560cc9 Merge branch 'bq25186-status-tests' into bq25186-status-codegen 2026-10-31 20:54:45 -10:00
J. Nick Koston 0bb857104e Merge branch 'hub-function-helper' into bq25186-status-tests 2026-10-31 20:54:42 -10:00
J. Nick Koston 560a364f0e [core] Add HUB_PUBLISHER_RETURNING for bool hub functions and note the access level 2026-10-31 20:49:16 -10:00
J. Nick Koston dfe29a686b [tm1638] Follow the HubFunction convention
Use HUB_PUBLISHER and the derived setter, and export the KEYS parameter
as a module constant.
2026-10-31 20:45:06 -10:00
J. Nick Koston 8c8ec1e457 [tca8418] Follow the HubFunction convention
Use HUB_PUBLISHER and the derived setter, and export the KEY and PRESSED
parameters as module constants.
2026-10-31 20:45:06 -10:00
J. Nick Koston 8f2cac7d15 [sy6970] Follow the HubFunction convention and use string tables
Use HUB_PUBLISHER and the derived setter, pass the hub constants directly
to the sensor decode with a scale argument, and publish the status text
from PROGMEM string tables.
2026-10-31 20:45:06 -10:00
J. Nick Koston 906dd482b2 [tm1638] Publish children through a generated hub function 2026-10-31 20:42:07 -10:00
J. Nick Koston 010db6f8d4 [tca8418] Publish children through a generated hub function 2026-10-31 20:42:07 -10:00
J. Nick Koston 53c32c7136 [sy6970] Publish children through a generated hub function 2026-10-31 20:42:07 -10:00
J. Nick Koston da0dcfc16f [ai] Follow the derived HubFunction setter in the field decoding example 2026-10-31 20:40:39 -10:00
J. Nick Koston 498b974f4d Merge remote-tracking branch 'origin/bq25186-status-codegen' into skill-generated-field-decoding 2026-10-31 20:40:33 -10:00
J. Nick Koston 0b0d6b3143 [bq25186] Use HUB_PUBLISHER and the derived HubFunction setter 2026-10-31 20:40:11 -10:00
J. Nick Koston 02348e77b9 Merge branch 'bq25186-status-tests' into bq25186-status-codegen 2026-10-31 20:39:32 -10:00
J. Nick Koston 5eb55a80ab Merge branch 'hub-function-helper' into bq25186-status-tests 2026-10-31 20:39:28 -10:00
J. Nick Koston 028cafaa12 [core] Derive the HubFunction setter from its name and add HUB_PUBLISHER
HubFunction("status", ...) now emits esphome__<hub>__status_fn and calls
set_status_publisher(), which HUB_PUBLISHER(status, ...) declares in C++.
2026-10-31 20:38:48 -10:00
J. Nick Koston 7ae3d056f4 [ai] Show the field decoding example with cg.HubFunction and inline the single-bit match 2026-10-31 20:22:50 -10:00
J. Nick Koston fa1f229d9c Merge remote-tracking branch 'origin/bq25186-status-codegen' into skill-generated-field-decoding 2026-10-31 20:22:31 -10:00
J. Nick Koston da45ee6afe [bq25186] Follow the prefixed HubFunction parameter name in the status tests 2026-10-31 20:20:11 -10:00
J. Nick Koston ea62a1be7b Merge branch 'bq25186-status-tests' into bq25186-status-codegen 2026-10-31 20:19:43 -10:00
J. Nick Koston 9653f46b38 Merge branch 'hub-function-helper' into bq25186-status-tests 2026-10-31 20:19:40 -10:00
J. Nick Koston 0c6f6cfe85 [core] Prefix HubFunction parameter and result names so entity ids cannot be hidden 2026-10-31 20:19:24 -10:00
J. Nick Koston dd4fc435ea [bq25186] Generate the status function with cg.HubFunction
Items now publish in config order; the local collection and FINAL job go.
2026-10-31 20:17:28 -10:00
J. Nick Koston 8f743eb978 Merge branch 'bq25186-status-tests' into bq25186-status-codegen
# Conflicts:
#	tests/unit_tests/test_cpp_generator.py
2026-10-31 20:06:36 -10:00
J. Nick Koston c0120a8eb1 Merge branch 'hub-function-helper' into bq25186-status-tests 2026-10-31 20:06:09 -10:00
J. Nick Koston 8b1d10aa70 [core] Guard HubFunction names and bool items, and cover reruns 2026-10-31 20:04:08 -10:00
J. Nick Koston 6eae676622 [core] Add cg.HubFunction to generate one function per hub from child statements
Also let cg.static_function take Statement objects in its body and add
MockObjClass.const_ref().
2026-10-31 20:01:14 -10:00
J. Nick Koston ffae10b153 [ai] Show the bq25186 field decoding built from codegen expressions 2026-10-31 19:46:08 -10:00
J. Nick Koston 66f04d4c77 Merge remote-tracking branch 'origin/bq25186-status-codegen' into skill-generated-field-decoding 2026-10-31 19:45:59 -10:00
J. Nick Koston 5a4ce03a9f [bq25186] Build the status statements from codegen expressions
cg.static_function now also takes Statement objects in its body.
2026-10-31 19:44:13 -10:00
J. Nick Koston aeac271542 [ai] Use add_binary_status and the exact single-bit condition in the field decoding example 2026-10-31 19:38:30 -10:00
J. Nick Koston fdc83fd36f Merge remote-tracking branch 'origin/bq25186-status-codegen' into skill-generated-field-decoding 2026-10-31 19:38:11 -10:00
J. Nick Koston 8026ce24ae [bq25186] Build the status C++ in add_binary_status and add_text_status
The platform files pass their field values; __init__.py owns the generated
statements. The generated code is unchanged.
2026-10-31 19:37:53 -10:00
J. Nick Koston e3bd6d9a05 [bq25186] Take the single-bit decode shortcut only for one-bit fields
Also include text_sensor.h in the status test, which owns text sensors.
2026-10-31 19:28:24 -10:00
J. Nick Koston dba53f5861 Merge remote-tracking branch 'origin/bq25186-status-codegen' into skill-generated-field-decoding 2026-10-31 19:26:38 -10:00
J. Nick Koston a91639ed3f [ai] Show the on-values bitmap and mark the bq25186 helpers as local in the field decoding example 2026-10-31 19:26:37 -10:00
J. Nick Koston ecc2ebc4f4 [bq25186] Fold the status codegen tests into one config and check the C++ copy against it
The generated decode test now covers the field tables, so test_status_fields.py
goes; decode expressions are compiled once.
2026-10-31 19:25:54 -10:00
J. Nick Koston 3489bc4f65 Prefer generated decoding for fixed register fields in the codegen skill 2026-10-31 19:15:24 -10:00
J. Nick Koston 229fcd5370 [bq25186] Check every generated status decode against the datasheet 2026-10-31 19:12:04 -10:00
J. Nick Koston 7be5d58ae6 Merge branch 'bq25186-status-tests' into bq25186-status-codegen
# Conflicts:
#	tests/components/bq25186/test_bq25186_status.cpp
2026-10-31 19:12:04 -10:00
J. Nick Koston 5876bb209d [bq25186] Check the status field tables against the datasheet
Reserve the expected order vector for clang-tidy.
2026-10-31 19:10:40 -10:00
J. Nick Koston 101285d019 [bq25186] Keep status publisher state in a dataclass and mask the text field in the helper 2026-10-31 19:09:02 -10:00
J. Nick Koston 92e4d26ad7 Merge branch 'bq25186-status-tests' into bq25186-status-codegen 2026-10-31 18:57:51 -10:00
J. Nick Koston 466e73b196 [bq25186] Generate the status entity publishing in code generation
The status binary and text sensors become plain entities; one generated
function per hub decodes the registers and publishes them, replacing the
field-description subclasses and the hub's entity lists.
2026-10-31 18:57:51 -10:00
J. Nick Koston b831057030 [bq25186] Record the publish order without std::to_string 2026-10-31 18:57:40 -10:00
J. Nick Koston 39e3e47f1e [bq25186] Add tests for the status binary and text sensors
Pin the decode of every status field, the text sensor change-only publish
(including the first poll), the binary sensor publish on every poll, and
the publish order.
2026-10-31 18:48:53 -10:00
24 changed files with 279 additions and 197 deletions

No files matched your search

+9
View File
@@ -9,3 +9,12 @@ CONF_BMI270_ID = "bmi270_id"
# C++ namespace / class
bmi270_ns = cg.esphome_ns.namespace("bmi270")
BMI270Component = bmi270_ns.class_("BMI270Component", MotionComponent, i2c.I2CDevice)
BMM150Data = bmi270_ns.namespace("bmm150").class_("BMM150Data")
# Magnetic field sensors need the BMM150, so USE_BMI270_BMM150 already gates the member
MAGNETOMETER_PUBLISHER = cg.HubFunction(
"magnetometer",
cg.void,
[(BMM150Data.const_ref(), "data")],
)
MAGNETOMETER_DATA = MAGNETOMETER_PUBLISHER.param("data")
+6 -4
View File
@@ -273,7 +273,7 @@ bool BMI270Component::update_data(motion::MotionData &data) {
// When the magnetometer is active, the 8 aux data bytes (0x04–0x0B) sit directly before
// the accel data, so one burst read from AUX_X_LSB fetches both.
#ifdef USE_BMI270_BMM150
const bool read_mag = this->magnetometer_ready_ && !this->magnetometer_callback_.empty();
const bool read_mag = this->magnetometer_ready_ && this->magnetometer_publisher_ != nullptr;
uint8_t buf[BMI270_AUX_DATA_LEN + REG_READ_LEN];
const uint8_t *mag_raw = buf;
const uint8_t *raw_data = read_mag ? buf + BMI270_AUX_DATA_LEN : buf;
@@ -315,19 +315,21 @@ bool BMI270Component::update_data(motion::MotionData &data) {
data.angular_rate[motion::Y_AXIS] = encode_value_le<int16_t>(&raw_data[GYR_OFFS + 2]) * scale;
data.angular_rate[motion::Z_AXIS] = encode_value_le<int16_t>(&raw_data[GYR_OFFS + 4]) * scale;
if (!this->temperature_callback_.empty()) {
#ifdef USE_MOTION_TEMPERATURE_PUBLISHER
if (this->temperature_publisher_ != nullptr) {
// Temperature: registers 0x22–0x23
// Formula from datasheet: T[°C] = raw / 512 + 23
static constexpr uint8_t TEMP_OFFS = BMI270_REG_TEMP_0 - BMI270_REG_DATA_8;
int16_t raw_t = encode_value_le<int16_t>(&raw_data[TEMP_OFFS]);
float temperature = (raw_t / 512.0f) + 23.0f;
this->temperature_callback_.call(temperature);
this->temperature_publisher_(temperature);
}
#endif
#ifdef USE_BMI270_BMM150
if (read_mag) {
const BMM150Data mag_data = bmm150_convert(this->mag_trim_, mag_raw);
this->magnetometer_callback_.call(mag_data);
this->magnetometer_publisher_(mag_data);
}
#endif
return true;
+1 -5
View File
@@ -8,7 +8,6 @@
#ifdef USE_BMI270_BMM150
#include "bmm150_aux.h"
#endif
#include <functional>
namespace esphome::bmi270 {
@@ -142,11 +141,10 @@ class BMI270Component final : public motion::MotionComponent, public i2c::I2CDev
void set_accel_odr(BMI270AccelODR o) { this->accel_odr_ = o; }
void set_gyro_range(BMI270GyroRange r) { this->gyro_range_ = r; }
void set_gyro_odr(BMI270GyroODR o) { this->gyro_odr_ = o; }
template<typename F> void add_temperature_listener(F &&cb) { this->temperature_callback_.add(std::forward<F>(cb)); }
#ifdef USE_BMI270_BMM150
void set_aux_device(BMI270AuxDevice device) { this->aux_device_ = device; }
void set_aux_device_address(uint8_t address) { this->aux_device_address_ = address; }
template<typename F> void add_magnetometer_listener(F &&cb) { this->magnetometer_callback_.add(std::forward<F>(cb)); }
HUB_PUBLISHER(magnetometer, const bmm150::BMM150Data &)
#endif
protected:
@@ -172,9 +170,7 @@ class BMI270Component final : public motion::MotionComponent, public i2c::I2CDev
BMI270AccelODR accel_odr_{BMI270_ACCEL_ODR_100};
BMI270GyroRange gyro_range_{BMI270_GYRO_RANGE_2000};
BMI270GyroODR gyro_odr_{BMI270_GYRO_ODR_200};
LazyCallbackManager<void(float)> temperature_callback_{};
#ifdef USE_BMI270_BMM150
LazyCallbackManager<void(const bmm150::BMM150Data &)> magnetometer_callback_{};
bmm150::BMM150Trim mag_trim_{};
BMI270AuxDevice aux_device_{BMI270_AUX_DEVICE_NONE};
uint8_t aux_device_address_{bmm150::BMM150_DEFAULT_I2C_ADDRESS};
+14 -32
View File
@@ -1,22 +1,23 @@
# YAML config keys
from esphome.automation import parent_ref
import esphome.codegen as cg
from esphome.components import sensor
from esphome.components.motion import (
temperature_sensor_schema,
temperature_sensor_to_code,
)
import esphome.config_validation as cv
from esphome.const import (
CONF_TEMPERATURE,
CONF_TYPE,
DEVICE_CLASS_TEMPERATURE,
ICON_MAGNET,
ICON_THERMOMETER,
STATE_CLASS_MEASUREMENT,
UNIT_CELSIUS,
UNIT_MICROTESLA,
)
from esphome.cpp_generator import MockObj
import esphome.final_validate as fv
from esphome.types import ConfigType
from . import CONF_BMI270_ID, BMI270Component, bmi270_ns
from . import CONF_BMI270_ID, MAGNETOMETER_DATA, MAGNETOMETER_PUBLISHER, BMI270Component
from .motion import CONF_AUX_DEVICE
AUTO_LOAD = ["bmi270"]
@@ -25,8 +26,6 @@ CONF_MAGNETIC_FIELD_X = "magnetic_field_x"
CONF_MAGNETIC_FIELD_Y = "magnetic_field_y"
CONF_MAGNETIC_FIELD_Z = "magnetic_field_z"
BMM150Data = bmi270_ns.namespace("bmm150").class_("BMM150Data")
_MAGNETIC_FIELDS = (CONF_MAGNETIC_FIELD_X, CONF_MAGNETIC_FIELD_Y, CONF_MAGNETIC_FIELD_Z)
@@ -34,16 +33,6 @@ def _parent_schema() -> cv.Schema:
return cv.Schema({cv.GenerateID(CONF_BMI270_ID): cv.use_id(BMI270Component)})
def _temperature_sensor_schema() -> cv.Schema:
return sensor.sensor_schema(
unit_of_measurement=UNIT_CELSIUS,
icon=ICON_THERMOMETER,
accuracy_decimals=2,
state_class=STATE_CLASS_MEASUREMENT,
device_class=DEVICE_CLASS_TEMPERATURE,
).extend(_parent_schema())
def _magnetic_field_sensor_schema() -> cv.Schema:
return sensor.sensor_schema(
unit_of_measurement=UNIT_MICROTESLA,
@@ -56,7 +45,9 @@ def _magnetic_field_sensor_schema() -> cv.Schema:
# `type` defaults to temperature so existing configs that omit it keep working unchanged.
CONFIG_SCHEMA = cv.typed_schema(
{
CONF_TEMPERATURE: _temperature_sensor_schema(),
CONF_TEMPERATURE: temperature_sensor_schema(
CONF_BMI270_ID, BMI270Component, type_key=False
),
**{x: _magnetic_field_sensor_schema() for x in _MAGNETIC_FIELDS},
},
default_type=CONF_TEMPERATURE,
@@ -79,22 +70,13 @@ FINAL_VALIDATE_SCHEMA = _final_validate
async def to_code(config: ConfigType) -> None:
sensor_type = config[CONF_TYPE]
var = await sensor.new_sensor(config)
parent = await cg.get_variable(config[CONF_BMI270_ID])
if sensor_type == CONF_TEMPERATURE:
data = MockObj("data")
value_lambda = await cg.process_lambda(
var.publish_state(data),
[(cg.float_, str(data))],
)
cg.add(parent.add_temperature_listener(value_lambda))
await temperature_sensor_to_code(config, CONF_BMI270_ID)
return
var = await sensor.new_sensor(config)
parent = await cg.get_variable(config[CONF_BMI270_ID])
axis = sensor_type[-1:]
data = MockObj("data")
value_lambda = await cg.process_lambda(
var.publish_state(getattr(data, axis)),
[(BMM150Data.operator("const").operator("ref"), str(data))],
MAGNETOMETER_PUBLISHER.add(
parent, parent_ref(var).publish_state(getattr(MAGNETOMETER_DATA, axis))
)
cg.add(parent.add_magnetometer_listener(value_lambda))
+4 -2
View File
@@ -109,11 +109,13 @@ bool ICM20689Component::update_data(motion::MotionData &data) {
data.angular_rate[motion::Y_AXIS] = encode_value<int16_t>(&raw_data[10]) * gyro_factor;
data.angular_rate[motion::Z_AXIS] = encode_value<int16_t>(&raw_data[12]) * gyro_factor;
if (!this->temperature_callback_.empty()) {
#ifdef USE_MOTION_TEMPERATURE_PUBLISHER
if (this->temperature_publisher_ != nullptr) {
// Datasheet formula: temperature (°C) = raw / 326.8 + 25.
const float temperature = encode_value<int16_t>(&raw_data[6]) / 326.8f + 25.0f;
this->temperature_callback_.call(temperature);
this->temperature_publisher_(temperature);
}
#endif
return true;
}
-6
View File
@@ -46,10 +46,6 @@ class ICM20689Component final : public motion::MotionComponent,
void set_accel_range(ICM20689AccelRange range) { this->accel_range_ = range; }
void set_gyro_range(ICM20689GyroRange range) { this->gyro_range_ = range; }
template<typename F> void add_temperature_listener(F &&callback) {
this->temperature_callback_.add(std::forward<F>(callback));
}
protected:
bool update_data(motion::MotionData &data) override;
@@ -59,8 +55,6 @@ class ICM20689Component final : public motion::MotionComponent,
ICM20689AccelRange accel_range_{ICM20689_ACCEL_RANGE_2G};
ICM20689GyroRange gyro_range_{ICM20689_GYRO_RANGE_250};
LazyCallbackManager<void(float)> temperature_callback_{};
};
} // namespace esphome::icm20689
+5 -32
View File
@@ -1,42 +1,15 @@
# YAML config keys
import esphome.codegen as cg
from esphome.components import sensor
import esphome.config_validation as cv
from esphome.const import (
CONF_TEMPERATURE,
CONF_TYPE,
DEVICE_CLASS_TEMPERATURE,
ICON_THERMOMETER,
STATE_CLASS_MEASUREMENT,
UNIT_CELSIUS,
from esphome.components.motion import (
temperature_sensor_schema,
temperature_sensor_to_code,
)
from esphome.cpp_generator import MockObj
from esphome.types import ConfigType
from . import CONF_ICM20689_ID, ICM20689Component
AUTO_LOAD = ["icm20689"]
CONFIG_SCHEMA = sensor.sensor_schema(
unit_of_measurement=UNIT_CELSIUS,
icon=ICON_THERMOMETER,
accuracy_decimals=2,
state_class=STATE_CLASS_MEASUREMENT,
device_class=DEVICE_CLASS_TEMPERATURE,
).extend(
{
cv.Optional(CONF_TYPE): cv.one_of(CONF_TEMPERATURE),
cv.GenerateID(CONF_ICM20689_ID): cv.use_id(ICM20689Component),
}
)
CONFIG_SCHEMA = temperature_sensor_schema(CONF_ICM20689_ID, ICM20689Component)
async def to_code(config: ConfigType) -> None:
var = await sensor.new_sensor(config)
parent = await cg.get_variable(config[CONF_ICM20689_ID])
data = MockObj("data")
value_lambda = await cg.process_lambda(
var.publish_state(data),
[(cg.float_, str(data))],
)
cg.add(parent.add_temperature_listener(value_lambda))
await temperature_sensor_to_code(config, CONF_ICM20689_ID)
+13 -5
View File
@@ -53,8 +53,11 @@ bool LIS3DHComponent::setup_accelerometer_() {
bool LIS3DHComponent::setup_temperature_() {
// Only power the ADC / temperature sensor when a temperature sensor is used.
uint8_t temp_cfg =
this->temperature_callback_.empty() ? 0x00 : (uint8_t) (LIS3DH_TEMP_CFG_ADC_EN | LIS3DH_TEMP_CFG_TEMP_EN);
uint8_t temp_cfg = 0x00;
#ifdef USE_MOTION_TEMPERATURE_PUBLISHER
if (this->temperature_publisher_ != nullptr)
temp_cfg = LIS3DH_TEMP_CFG_ADC_EN | LIS3DH_TEMP_CFG_TEMP_EN;
#endif
return this->write_byte(LIS3DH_REG_TEMP_CFG, temp_cfg);
}
@@ -162,11 +165,15 @@ bool LIS3DHComponent::update_data(motion::MotionData &data) {
data.acceleration[motion::Y_AXIS] = raw_y * scale;
data.acceleration[motion::Z_AXIS] = raw_z * scale;
if (this->temperature_callback_.empty() || this->publish_temperature_())
this->status_clear_warning();
#ifdef USE_MOTION_TEMPERATURE_PUBLISHER
if (this->temperature_publisher_ != nullptr && !this->publish_temperature_())
return true;
#endif
this->status_clear_warning();
return true;
}
#ifdef USE_MOTION_TEMPERATURE_PUBLISHER
bool LIS3DHComponent::publish_temperature_() {
int16_t raw;
if (!this->read_bytes_16_le(LIS3DH_REG_OUT_ADC3_L | LIS3DH_AUTO_INCREMENT, &raw, 1)) {
@@ -176,8 +183,9 @@ bool LIS3DHComponent::publish_temperature_() {
// Signed, left-justified, relative value with 1 °C per count of the high byte; the
// low byte carries the fractional bits in the modes that have them.
float temperature = raw / 256.0f + LIS3DH_TEMP_REFERENCE_C;
this->temperature_callback_.call(temperature);
this->temperature_publisher_(temperature);
return true;
}
#endif
} // namespace esphome::lis3dh
+2 -4
View File
@@ -107,14 +107,14 @@ class LIS3DHComponent : public motion::MotionComponent, public i2c::I2CDevice {
this->interrupt_high_pass_ = high_pass;
}
template<typename F> void add_temperature_listener(F &&cb) { this->temperature_callback_.add(std::forward<F>(cb)); }
protected:
bool update_data(motion::MotionData &data) override;
bool setup_accelerometer_();
bool setup_temperature_();
bool setup_interrupt_();
#ifdef USE_MOTION_TEMPERATURE_PUBLISHER
bool publish_temperature_();
#endif
LIS3DHRange range_{LIS3DH_RANGE_2G};
LIS3DHDataRate data_rate_{LIS3DH_DATA_RATE_100HZ};
@@ -128,8 +128,6 @@ class LIS3DHComponent : public motion::MotionComponent, public i2c::I2CDevice {
bool interrupt_latched_{false};
bool interrupt_active_high_{true};
bool interrupt_high_pass_{false};
LazyCallbackManager<void(float)> temperature_callback_{};
};
} // namespace esphome::lis3dh
+6 -30
View File
@@ -1,41 +1,17 @@
import esphome.codegen as cg
from esphome.components import sensor
import esphome.config_validation as cv
from esphome.const import (
CONF_TEMPERATURE,
CONF_TYPE,
DEVICE_CLASS_TEMPERATURE,
ICON_THERMOMETER,
STATE_CLASS_MEASUREMENT,
UNIT_CELSIUS,
from esphome.components.motion import (
temperature_sensor_schema,
temperature_sensor_to_code,
)
from esphome.cpp_generator import MockObj
from esphome.types import ConfigType
from . import CONF_LIS3DH_ID, LIS3DHComponent
# The LIS3DH temperature sensor is uncalibrated and only reports relative
# changes (roughly 1 °C per count), so a single decimal of accuracy is plenty.
CONFIG_SCHEMA = sensor.sensor_schema(
unit_of_measurement=UNIT_CELSIUS,
icon=ICON_THERMOMETER,
accuracy_decimals=1,
state_class=STATE_CLASS_MEASUREMENT,
device_class=DEVICE_CLASS_TEMPERATURE,
).extend(
{
cv.Optional(CONF_TYPE): cv.one_of(CONF_TEMPERATURE),
cv.GenerateID(CONF_LIS3DH_ID): cv.use_id(LIS3DHComponent),
}
CONFIG_SCHEMA = temperature_sensor_schema(
CONF_LIS3DH_ID, LIS3DHComponent, accuracy_decimals=1
)
async def to_code(config: ConfigType) -> None:
var = await sensor.new_sensor(config)
parent = await cg.get_variable(config[CONF_LIS3DH_ID])
data = MockObj("data")
value_lambda = await cg.process_lambda(
var.publish_state(data),
[(cg.float_, str(data))],
)
cg.add(parent.add_temperature_listener(value_lambda))
await temperature_sensor_to_code(config, CONF_LIS3DH_ID)
+5 -3
View File
@@ -177,18 +177,20 @@ bool LSM6DSComponent::update_data(motion::MotionData &data) {
data.acceleration[motion::Y_AXIS] = encode_value_le<int16_t>(&raw[LSM6DS_ACCEL_OFFSET + 2]) * accel_scale;
data.acceleration[motion::Z_AXIS] = encode_value_le<int16_t>(&raw[LSM6DS_ACCEL_OFFSET + 4]) * accel_scale;
// Temperature (lazy — only read if a listener is registered)
#ifdef USE_MOTION_TEMPERATURE_PUBLISHER
// Temperature (lazy — only read if a sensor is configured)
// Kept as a separate 2-byte read to avoid extending the burst to 14 bytes when
// temperature is not needed.
// Formula: T(°C) = raw / sensitivity + 25.0, sensitivity in LSB/°C per chip (0 LSB at 25 °C)
if (!this->temperature_callback_.empty()) {
if (this->temperature_publisher_ != nullptr) {
uint8_t raw_t[2];
if (this->read_bytes(LSM6DS_REG_OUT_TEMP_L, raw_t, 2)) {
int16_t temp_raw = encode_value_le<int16_t>(raw_t);
float temperature = temp_raw / static_cast<float>(this->temperature_sensitivity_) + 25.0f;
this->temperature_callback_.call(temperature);
this->temperature_publisher_(temperature);
}
}
#endif
return true;
}
-4
View File
@@ -103,8 +103,6 @@ class LSM6DSComponent final : public motion::MotionComponent, public i2c::I2CDev
void set_gyro_range(LSM6DSGyroRange r) { this->gyro_range_ = r; }
void set_gyro_odr(LSM6DSGyroODR o) { this->gyro_odr_ = o; }
template<typename F> void add_temperature_listener(F &&cb) { this->temperature_callback_.add(std::forward<F>(cb)); }
protected:
const LogString *chip_name_{nullptr};
bool update_data(motion::MotionData &data) override;
@@ -114,8 +112,6 @@ class LSM6DSComponent final : public motion::MotionComponent, public i2c::I2CDev
LSM6DSGyroRange gyro_range_{LSM6DS_GYRO_RANGE_2000};
LSM6DSGyroODR gyro_odr_{LSM6DS_GYRO_ODR_208};
uint16_t temperature_sensitivity_{256}; // LSB/°C: 16 on the LSM6DS3, 256 on the others
LazyCallbackManager<void(float)> temperature_callback_{};
};
} // namespace esphome::lsm6ds
+5 -32
View File
@@ -1,40 +1,13 @@
# YAML config keys
import esphome.codegen as cg
from esphome.components import sensor
import esphome.config_validation as cv
from esphome.const import (
CONF_TEMPERATURE,
CONF_TYPE,
DEVICE_CLASS_TEMPERATURE,
ICON_THERMOMETER,
STATE_CLASS_MEASUREMENT,
UNIT_CELSIUS,
from esphome.components.motion import (
temperature_sensor_schema,
temperature_sensor_to_code,
)
from esphome.cpp_generator import MockObj
from esphome.types import ConfigType
from . import CONF_LSM6DS_ID, LSM6DSComponent
CONFIG_SCHEMA = sensor.sensor_schema(
unit_of_measurement=UNIT_CELSIUS,
icon=ICON_THERMOMETER,
accuracy_decimals=2,
state_class=STATE_CLASS_MEASUREMENT,
device_class=DEVICE_CLASS_TEMPERATURE,
).extend(
{
cv.Optional(CONF_TYPE): CONF_TEMPERATURE,
cv.GenerateID(CONF_LSM6DS_ID): cv.use_id(LSM6DSComponent),
}
)
CONFIG_SCHEMA = temperature_sensor_schema(CONF_LSM6DS_ID, LSM6DSComponent)
async def to_code(config: ConfigType) -> None:
var = await sensor.new_sensor(config)
parent = await cg.get_variable(config[CONF_LSM6DS_ID])
data = MockObj("data")
value_lambda = await cg.process_lambda(
var.publish_state(data),
[(cg.float_, str(data))],
)
cg.add(parent.add_temperature_listener(value_lambda))
await temperature_sensor_to_code(config, CONF_LSM6DS_ID)
+45
View File
@@ -3,15 +3,23 @@ import logging
import re
from esphome import automation
from esphome.automation import parent_ref
import esphome.codegen as cg
from esphome.components.const import CONF_ON_DOUBLE_TAP, CONF_ON_TAP, CONF_TAP
from esphome.components.sensor import new_sensor, sensor_schema
import esphome.config_validation as cv
from esphome.const import (
CONF_ID,
CONF_ON_ERROR,
CONF_ON_SUCCESS,
CONF_TEMPERATURE,
CONF_THRESHOLD,
CONF_TYPE,
CONF_UPDATE_INTERVAL,
DEVICE_CLASS_TEMPERATURE,
ICON_THERMOMETER,
STATE_CLASS_MEASUREMENT,
UNIT_CELSIUS,
)
from esphome.core import CORE, ID
from esphome.cpp_generator import MockObj, MockObjClass
@@ -56,6 +64,43 @@ DATA_PUBLISHER = cg.HubFunction(
)
DATA = DATA_PUBLISHER.param("data")
# Each IMU's on-chip temperature sensor adds its publish of a new reading
TEMPERATURE_PUBLISHER = cg.HubFunction(
"temperature",
cg.void,
[(cg.float_, "temperature")],
define="USE_MOTION_TEMPERATURE_PUBLISHER",
)
TEMPERATURE = TEMPERATURE_PUBLISHER.param("temperature")
def temperature_sensor_schema(
hub_id_key: str,
hub_class: MockObjClass,
*,
accuracy_decimals: int = 2,
type_key: bool = True,
) -> cv.Schema:
"""Schema of an IMU temperature sensor; `type_key` adds the optional `type: temperature`."""
schema = sensor_schema(
unit_of_measurement=UNIT_CELSIUS,
icon=ICON_THERMOMETER,
accuracy_decimals=accuracy_decimals,
state_class=STATE_CLASS_MEASUREMENT,
device_class=DEVICE_CLASS_TEMPERATURE,
).extend({cv.GenerateID(hub_id_key): cv.use_id(hub_class)})
if type_key:
schema = schema.extend({cv.Optional(CONF_TYPE): cv.one_of(CONF_TEMPERATURE)})
return schema
async def temperature_sensor_to_code(config: ConfigType, hub_id_key: str) -> None:
"""Create an IMU temperature sensor and publish it from its hub's readings."""
var = await new_sensor(config)
hub = await cg.get_variable(config[hub_id_key])
TEMPERATURE_PUBLISHER.add(hub, parent_ref(var).publish_state(TEMPERATURE))
SENSOR_SCHEMA = cv.Schema(
{
cv.GenerateID(CONF_MOTION_ID): cv.use_id(MotionComponent),
@@ -85,6 +85,9 @@ class MotionComponent : public PollingComponent {
#ifdef USE_MOTION_DATA_PUBLISHER
HUB_PUBLISHER(data, const MotionData &)
#endif
#ifdef USE_MOTION_TEMPERATURE_PUBLISHER
HUB_PUBLISHER(temperature, float)
#endif
#ifdef USE_MOTION_TAP
/// Platforms with a tap block convert this to chip steps and clamp it.
+4 -2
View File
@@ -110,11 +110,13 @@ bool QMI8658Component::update_data(motion::MotionData &data) {
data.angular_rate[motion::Y_AXIS] = raw_y * scale;
data.angular_rate[motion::Z_AXIS] = raw_z * scale;
if (this->temperature_callback_.empty())
#ifdef USE_MOTION_TEMPERATURE_PUBLISHER
if (this->temperature_publisher_ == nullptr)
return true;
// Temperature: signed 16-bit, °C = raw / 256
int16_t raw_t = encode_value_le<int16_t>(&raw_data[TEMP_OFFS]);
this->temperature_callback_.call(raw_t / 256.0f);
this->temperature_publisher_(raw_t / 256.0f);
#endif
return true;
}
-3
View File
@@ -94,7 +94,6 @@ class QMI8658Component : public motion::MotionComponent, public i2c::I2CDevice {
void set_accel_odr(QMI8658AccelODR o) { this->accel_odr_ = o; }
void set_gyro_range(QMI8658GyroRange r) { this->gyro_range_ = r; }
void set_gyro_odr(QMI8658GyroODR o) { this->gyro_odr_ = o; }
template<typename F> void add_temperature_listener(F &&cb) { this->temperature_callback_.add(std::forward<F>(cb)); }
protected:
bool update_data(motion::MotionData &data) override;
@@ -104,8 +103,6 @@ class QMI8658Component : public motion::MotionComponent, public i2c::I2CDevice {
QMI8658AccelODR accel_odr_{QMI8658_ACCEL_ODR_1000};
QMI8658GyroRange gyro_range_{QMI8658_GYRO_RANGE_2048};
QMI8658GyroODR gyro_odr_{QMI8658_GYRO_ODR_1000};
LazyCallbackManager<void(float)> temperature_callback_{};
};
} // namespace esphome::qmi8658
+5 -32
View File
@@ -1,40 +1,13 @@
# YAML config keys
import esphome.codegen as cg
from esphome.components import sensor
import esphome.config_validation as cv
from esphome.const import (
CONF_TEMPERATURE,
CONF_TYPE,
DEVICE_CLASS_TEMPERATURE,
ICON_THERMOMETER,
STATE_CLASS_MEASUREMENT,
UNIT_CELSIUS,
from esphome.components.motion import (
temperature_sensor_schema,
temperature_sensor_to_code,
)
from esphome.cpp_generator import MockObj
from esphome.types import ConfigType
from . import CONF_QMI8658_ID, QMI8658Component
CONFIG_SCHEMA = sensor.sensor_schema(
unit_of_measurement=UNIT_CELSIUS,
icon=ICON_THERMOMETER,
accuracy_decimals=2,
state_class=STATE_CLASS_MEASUREMENT,
device_class=DEVICE_CLASS_TEMPERATURE,
).extend(
{
cv.Optional(CONF_TYPE): cv.one_of(CONF_TEMPERATURE),
cv.GenerateID(CONF_QMI8658_ID): cv.use_id(QMI8658Component),
}
)
CONFIG_SCHEMA = temperature_sensor_schema(CONF_QMI8658_ID, QMI8658Component)
async def to_code(config: ConfigType) -> None:
var = await sensor.new_sensor(config)
parent = await cg.get_variable(config[CONF_QMI8658_ID])
data = MockObj("data")
value_lambda = await cg.process_lambda(
var.publish_state(data),
[(cg.float_, str(data))],
)
cg.add(parent.add_temperature_listener(value_lambda))
await temperature_sensor_to_code(config, CONF_QMI8658_ID)
+1
View File
@@ -223,6 +223,7 @@
#define MODBUS_ON_REQUEST_COUNT 1
#define MODBUS_ON_RESPONSE_COUNT 1
#define USE_MOTION_DATA_PUBLISHER
#define USE_MOTION_TEMPERATURE_PUBLISHER
#define NFC_TAG_LISTENER_COUNT 1
#define PN532_BINARY_SENSOR_COUNT 1
#define PN532_ON_TAG_REMOVED_TRIGGER_COUNT 1
Whitespace-only changes.
@@ -0,0 +1,29 @@
---
esphome:
name: test
esp8266:
board: d1_mini
i2c:
sda: GPIO4
scl: GPIO5
motion:
- platform: bmi270
id: imu
aux_device: BMM150
- platform: bmi270
id: idle_imu
address: 0x69
aux_device: BMM150
sensor:
- platform: bmi270
bmi270_id: imu
id: mag_x
type: magnetic_field_x
- platform: bmi270
bmi270_id: imu
id: mag_z
type: magnetic_field_z
@@ -0,0 +1,21 @@
"""Tests for the generated bmi270 magnetometer publisher."""
from collections.abc import Callable
from pathlib import Path
def test_magnetometer_publisher_generated(
generate_main: Callable[[str | Path], str],
component_config_path: Callable[[str], Path],
) -> None:
"""Magnetic field sensors share one function; an idle hub gets none."""
main_cpp = generate_main(component_config_path("hub_function.yaml"))
assert (
"static void esphome__imu__magnetometer_fn("
"const bmi270::bmm150::BMM150Data & esphome__arg_data) {" in main_cpp
)
assert "::mag_x->publish_state(esphome__arg_data.x);" in main_cpp
assert "::mag_z->publish_state(esphome__arg_data.z);" in main_cpp
assert "imu->set_magnetometer_publisher(esphome__imu__magnetometer_fn);" in main_cpp
assert "idle_imu->set_magnetometer_publisher(" not in main_cpp
@@ -0,0 +1,73 @@
---
esphome:
name: test
esp32:
board: esp32dev
i2c:
- id: bus_a
sda: GPIO21
scl: GPIO22
- id: bus_b
sda: GPIO25
scl: GPIO26
spi:
clk_pin: GPIO18
mosi_pin: GPIO23
miso_pin: GPIO19
motion:
- platform: lis3dh
id: lis3dh_imu
i2c_id: bus_a
- platform: lis3dh
id: lis3dh_idle
i2c_id: bus_a
address: 0x19
- platform: bmi270
id: bmi270_imu
i2c_id: bus_a
- platform: bmi270
id: bmi270_idle
i2c_id: bus_a
address: 0x69
- platform: qmi8658
id: qmi8658_imu
i2c_id: bus_a
- platform: qmi8658
id: qmi8658_idle
i2c_id: bus_a
address: 0x6A
- platform: lsm6ds
id: lsm6ds_imu
i2c_id: bus_b
address: 0x6A
- platform: lsm6ds
id: lsm6ds_idle
i2c_id: bus_b
address: 0x6B
- platform: icm20689
id: icm20689_imu
cs_pin: GPIO5
- platform: icm20689
id: icm20689_idle
cs_pin: GPIO4
sensor:
- platform: lis3dh
lis3dh_id: lis3dh_imu
id: lis3dh_temperature
- platform: bmi270
bmi270_id: bmi270_imu
id: bmi270_temperature
- platform: qmi8658
qmi8658_id: qmi8658_imu
id: qmi8658_temperature
- platform: lsm6ds
lsm6ds_id: lsm6ds_imu
id: lsm6ds_temperature
- platform: icm20689
icm20689_id: icm20689_imu
id: icm20689_temperature
@@ -1,4 +1,4 @@
"""Tests for the generated motion data publisher."""
"""Tests for the generated motion data and temperature publishers."""
from collections.abc import Callable
from pathlib import Path
@@ -21,3 +21,30 @@ def test_data_publisher_generated(
assert "::shake->process_motion_data(esphome__arg_data);" in main_cpp
assert "imu->set_data_publisher(esphome__imu__data_fn);" in main_cpp
assert "idle_imu->set_data_publisher(" not in main_cpp
def test_temperature_publisher_generated(
generate_main: Callable[[str | Path], str],
component_config_path: Callable[[str], Path],
) -> None:
"""Each IMU with a temperature sensor gets a function; an idle hub gets none."""
main_cpp = generate_main(component_config_path("temperature.yaml"))
for platform, accuracy_decimals in (
("lis3dh", 1),
("bmi270", 2),
("icm20689", 2),
("qmi8658", 2),
("lsm6ds", 2),
):
fn = f"esphome__{platform}_imu__temperature_fn"
assert f"static void {fn}(float esphome__arg_temperature) {{" in main_cpp
assert (
f"::{platform}_temperature->publish_state(esphome__arg_temperature);"
in main_cpp
)
assert f"{platform}_imu->set_temperature_publisher({fn});" in main_cpp
assert f"{platform}_idle->set_temperature_publisher(" not in main_cpp
assert (
f"{platform}_temperature->set_accuracy_decimals({accuracy_decimals});"
in main_cpp
)