Jan Bouwhuis
e13f8996f2
Fix Import ReceivePayloadType ( #124431 )
...
* Fix Import ReceivePayloadType
* Do not assert export `ReceivePayloadType` on mqtt integration level as helper should be used.
2024-08-22 20:13:30 +02:00
Jan Bouwhuis
7887bcba89
Allow to set options for an MQTT enum sensor ( #123248 )
...
* Add options attribute support for MQTT sensor
* Add comment
2024-08-22 19:16:08 +02:00
epenet
0bb8c4832d
Enable raise-within-try (TRY301) rule in ruff ( #123351 )
2024-08-12 09:16:33 +02:00
Marc Mueller
7453b7df63
Improve mqtt schema typing ( #120407 )
2024-06-25 13:03:18 +02:00
Jan Bouwhuis
375f48142c
Fix handling undecoded mqtt sensor payloads ( #118633 )
2024-06-02 21:25:05 +02:00
J. Nick Koston
811ec57c31
Convert mqtt entity discovery to use callbacks ( #118200 )
2024-05-26 16:12:40 -10:00
J. Nick Koston
98d7821f47
Avoid creating template objects in mqtt sensor if they are not configured ( #118194 )
2024-05-26 12:09:06 -10:00
J. Nick Koston
e74292e358
Move sensor mqtt state update functions to bound methods ( #118188 )
2024-05-26 10:42:09 -10:00
Jan Bouwhuis
b7f1f805fa
Simplify subscription mqtt entity platforms ( #118177 )
2024-05-26 09:25:54 -10:00
J. Nick Koston
5d37217d96
Avoid expensive inspection of callbacks to setup mqtt subscriptions ( #118161 )
2024-05-26 01:22:44 -10:00
J. Nick Koston
9be829ba1f
Make mqtt internal subscription a normal function ( #118092 )
...
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
2024-05-25 11:34:24 -10:00
Jan Bouwhuis
6f81852eb4
Rename MQTT mixin classes ( #118039 )
2024-05-24 15:41:59 +02:00
Jan Bouwhuis
f12aee28a8
Improve error logging on invalid MQTT entity state ( #118006 )
...
* Improve error logging on invalid MQTT entity state
* Explain not hanlding TpeError and ValueError
* Move length check closer to source
* use _LOGGER.exception
2024-05-24 13:11:52 +02:00
Jan Bouwhuis
9333965b23
Create bound callback_message_received method for handling mqtt callbacks ( #117951 )
...
* Create bound callback_message_received method for handling mqtt callbacks
* refactor a bit
* fix ruff
* reduce overhead
* cleanup
* cleanup
* Revert changes alarm_control_panel
* Add sensor and binary sensor
* use same pattern for MqttAttributes/MqttAvailability
* remove useless function since we did not need to add to it
* code cleanup
* collapse
---------
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-05-24 11:18:25 +02:00
Jan Bouwhuis
050fc73056
Refactor shared mqtt schema's to new module ( #117944 )
...
* Refactor mqtt schema's to new module
* Remove unrelated change
2024-05-23 01:12:25 +02:00
Jan Bouwhuis
5ddf21e4da
Cleanup MQTT sensor last_reset_topic config parameter a year after removal ( #116657 )
2024-05-03 00:04:58 +02:00
Jan Bouwhuis
e28d4f0eae
Validate state_class with last_reset_value_template for mqtt sensors ( #113099 )
2024-03-12 09:08:03 +01:00
Marc Mueller
59a6035d3f
Add empty line after module docstring [j-m] ( #112700 )
2024-03-08 09:01:29 -05:00
Jan Bouwhuis
c7b6c9da31
Remove work-a-round for mqtt sensors with an entity_category set to config
( #107199 )
...
* Remove work-a-round for mqtt sensors with an entity_category set to `config`
* Cleanup strings
2024-01-05 09:24:52 +01:00
Jan Bouwhuis
cbccdbc6fa
Fix entity category for sensor fails mqtt sensor platform setup ( #103449 )
2023-11-08 00:03:47 +01:00
Jan Bouwhuis
4a4d2ad743
Fix mqtt config validation error handling ( #103210 )
...
* Fix MQTT config check
* Fix handling invalid enity_category for sensors
* Improve docstr
* Update comment
* Use correct util for yaml dump
2023-11-02 10:57:00 +01:00
Jan Bouwhuis
25ab622b51
Rename mqtt entry setup helpers to reflect their purpose ( #102378 )
...
Rename mqtt entry setup helpers
2023-10-20 13:36:24 +02:00
Jan Bouwhuis
7d9014ae41
Do not fail MQTT setup if events or sensors configured via yaml can't be validated ( #102309 )
...
* Add event and sensor
* Cleanup unused code
* Schema cannot be None for supported platform
2023-10-20 12:09:52 +02:00
Jan Bouwhuis
db0c5bbbea
Fix mqtt sensor or binary_sensor state not saved after expiry ( #101670 )
...
Fix mqtt sensor state not saved after expire
2023-10-08 20:57:14 +02:00
Jan Bouwhuis
59a26010ba
Cleanup redundant mqtt entity constructors ( #100939 )
...
* Remove redundant mqtt entity constructors
* Remove unrelated change
* Follow up comment
* Revert changes to mqtt update platform
---------
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-09-26 23:03:11 +02:00
Jan Bouwhuis
aed3ba3acd
Avoid redundant calls to async_ha_write_state
in MQTT (binary) sensor ( #100438 )
...
* Only call `async_ha_write_state` on changes.
* Make helper class
* Use UndefinedType
* Remove del
* Integrate monitor into MqttEntity
* Track extra state attributes and availability
* Add `__slots__`
* Add monitor to MqttAttributes and MqttAvailability
* Write out loop
* Add test
* Make common test and parameterize
* Add test for last_reset attribute
* MqttMonitorEntity base class
* Rename attr and update docstr `track` method.
* correction doct
* Implement as a decorator
* Move tracking functions into decorator
* Rename decorator
* Follow up comment
2023-09-21 13:33:26 +02:00
J. Nick Koston
6e743a5bb2
Switch mqtt to use async_call_later where possible ( #99486 )
2023-09-02 11:55:11 -05:00
Jan Bouwhuis
447fbf58c9
Change naming of MQTT entities to correspond with HA guidelines ( #95159 )
...
* Set has_entity_name if device_name is set
* revert unneeded formatting change
* Add image platform
* Follow up comment
* Don't set `has_entity_name` without device name
* Only set has_entity_name if a valid name is set
* Follow device_class name and add tests
* Follow up comments add extra tests
* Move to helper - Log a warning
* fix test
* Allow to assign None as name explictly
* Refactor
* Log info messages when device name is not set
* Revert scene schema change - no device link
* Always set has_entity_name with device mapping
* Always set `_attr_has_entity_name`
* Cleanup
2023-07-21 12:52:10 +02:00
Jan Bouwhuis
661aedde90
Remove MQTT platform schema warnings ( #93785 )
2023-05-31 09:02:48 +02:00
Jan Bouwhuis
3a7f9ab57d
Remove mqtt sensor support for last_reset_topic
( #93792 )
...
* Remove mqtt sensor support for `last_reset_topic`
* Add cases for empty last reset messages
2023-05-30 21:07:07 -04:00
Jan Bouwhuis
e36fd5f222
Allow None device_class and UOM for mqtt entities ( #91240 )
...
* Allow None device_class and UOM for mqtt entities
* Rever not needed changes
* Revert another unwanted change
2023-04-12 19:14:16 +02:00
Jan Bouwhuis
366baef7f6
Allow enum as MQTT sensor device_class ( #89391 )
2023-03-08 22:35:06 +01:00
Jan Bouwhuis
a9becd8e0e
Raise ValueError on date parsing of MQTT sensor with invalid date format ( #89036 )
...
* Suppress ValueError on date parsing of MQTT sensor
* Simplify, but not update state on invalid payload
* Still raise an an invalid date
* Make datetime state unknown on invalid format
* remove unrelated added new line
2023-03-05 17:06:48 +01:00
Jan Bouwhuis
c78cae4483
Fix handling None
or empty value for numeric MQTT sensor ( #87004 )
...
* Allow `None` for numeric sensor, ignore empty val
* Add test case with omitting a value
* Use _numeric_state_expected property
* Only respect None if numeric state is expected
2023-02-07 11:23:23 +01:00
Jan Bouwhuis
73e3b30906
Add suggested_display_precision
config option for MQTT sensor ( #87129 )
...
* Add precision for MQTT sensor
* Correct tests
* Use _attr_suggested_display_precision
* Rename option and add abbreviation
* Make abbr more compact
2023-02-07 08:55:35 +01:00
Marc Mueller
077ca97ef8
Fix local_partial_types
errors ( #86410 )
...
Fix local_partial_types errors
2023-01-23 10:29:11 +01:00
Franck Nijhof
800b8abe39
Code styling tweaks to the MQTT integration ( #85463 )
2023-01-08 22:07:10 +01:00
Jan Bouwhuis
ee21bc5d7f
Allow MQTT device_class or state_class to be set as None
( #85106 )
...
* Allow MQTT device_class to be set as `None`
* Add test
* Also allow sensor state_class to be `None`
2023-01-04 15:21:07 +01:00
Franck Nijhof
baef267f33
String formatting and max line length - Part 3 ( #84394 )
2022-12-22 13:35:47 +01:00
Jan Bouwhuis
4335b0db25
Clean up or correct from removed deprecation for MQTT platform ( #82684 )
...
Clean up or correct from removed deprecation
2022-11-25 16:11:22 +01:00
Jan Bouwhuis
7c2e7863d2
Remove legacy YAML support from MQTT ( #82102 )
2022-11-17 22:55:31 +01:00
Jan Bouwhuis
47dba6f6bc
Improve MQTT type hints part 5 ( #80979 )
...
* Improve typing scene
* Improve typing select
* Improve typing sensor
* move expire_after - and class level attrs
* Follow up comment
* Solve type confict
* Remove stale sentinel const
* Update homeassistant/components/mqtt/sensor.py
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
* Make _expire_after a class attribute
* Code styling
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2022-11-08 12:55:41 +01:00
epenet
9b2a8901b1
Adjust payload sentinel in mqtt ( #81553 )
...
* Adjust payload sentinel in mqtt
* Add type hints
* Update sensor.py
* Adjust vacuum
* Add type hints
* Adjust schema basic
* Remove invalid hint
2022-11-07 12:31:11 +01:00
epenet
9afabc17ae
Use attr in mqtt sensor ( #81402 )
2022-11-02 19:50:11 +01:00
Jan Bouwhuis
db0785827f
Revert "Do not write state if payload is ''
" for MQTT sensor ( #81347 )
...
* Revert "Do not write state if payload is ''"
This reverts commit 869c11884e
.
* Add test
2022-11-01 16:25:01 +01:00
Jan Bouwhuis
8aa30cce26
Fix state saving when sharing topics for MQTT entities ( #79421 )
...
* Do not write old state sharing availability topic
* Add a test
* Support for all availability topics
* delay async_write_ha_state till last callback
* Process write req after processing callback jobs
* Do not count subscription callbacks
* Simplify
* Stale docsting
* No topic needed for delays state write
* No need to clear when reloading
* Move test to test_mixins.py
* Only set up sensor platform for test
2022-10-11 10:49:54 +02:00
Jan Bouwhuis
9c9c8b324a
Ignore an '' value_template result for MQTT sensor ( #79417 )
...
Do not write state if payload is ''
2022-10-01 19:00:54 +03:00
Jan Bouwhuis
354411feed
Link manually added MQTT entities the the MQTT config entry ( #78547 )
...
Co-authored-by: Erik <erik@montnemery.com>
2022-09-18 12:55:31 -04:00
epenet
f62fbbe524
Use _attr_force_update in mqtt ( #77902 )
2022-09-07 23:42:16 +02:00
Jan Bouwhuis
5930f056a8
Mqtt support config_entry unload ( #70149 )
...
* squashed commits for rebase
* Flake
* Fix reloading issue manual legacy items
* Improve ACS sync for unsubscribe at disconnect
* Processed review comments
* Update homeassistant/components/mqtt/client.py
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* No need to await entry setup
* Remove complication is_connected
* Update homeassistant/components/mqtt/__init__.py
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2022-07-12 11:07:18 +02:00