Commit graph

70 commits

Author SHA1 Message Date
Jan Bouwhuis
661aedde90
Remove MQTT platform schema warnings (#93785) 2023-05-31 09:02:48 +02:00
Franck Nijhof
5e81d28116
Update black to 23.1.0 (#87188) 2023-02-02 18:35:24 +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
e15388a2a0
Improve MQTT type hints for dict get assignments (#83634)
* Improve type hints for dict get assignments

* Move _expire_after as class attr

* Remove extra check
2022-12-09 16:22:36 +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
b4ad03784f
Improve MQTT type hints part 1 (#80523)
* Improve typing alarm_control_panel

* Improve typing binary_sensor

* Improve typing button

* Add misssed annotation

* Move CONF_EXPIRE_AFTER to _setup_from_config

* Use CALL_BACK type

* Remove assert, improve code style
2022-11-02 20:33:18 +01:00
epenet
a255546e9d
Use attr in mqtt binary sensor and switch (#81403) 2022-11-02 13:41:14 +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
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
epenet
8ef87205f9
Improve type hints in mqtt (#74247) 2022-06-30 21:11:45 +02:00
Erik Montnemery
f05b4a0ca0
Fire event_mqtt_reloaded only after reload is completed (#74226) 2022-06-30 10:15:25 -07:00
Jan Bouwhuis
57daeaa174
Fix MQTT config schema to ensure correct validation (#73619)
* Ensure config schema validation

* Use correct schema for device_tracker

* Remove schema validation from the platform setup

* Remove loop to build schema
2022-06-20 08:51:12 +02:00
Erik Montnemery
b97d346df7
Fix reload of MQTT yaml config (#72901) 2022-06-02 11:32:31 -07:00
Erik Montnemery
635d7085cf
Move MQTT config schemas and client to separate modules (#71995)
* Move MQTT config schemas and client to separate modules

* Update integrations depending on MQTT
2022-05-31 09:32:44 +02:00
Jan Bouwhuis
17588c39a4
Move manual configuration of MQTT binary_sensor to the integration key (#72183)
Add binary_sensor

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2022-05-21 16:14:24 +02:00
Erik Montnemery
7e8d52e5a3
Fix race when handling rapid succession of MQTT discovery messages (#68785)
Co-authored-by: jbouwh <jan@jbsoft.nl>
2022-03-29 20:26:11 -07:00
Erik Montnemery
be0ef5ad6c
Correct MQTT binary_sensor and sensor state restoring (#66690) 2022-02-16 14:07:21 -08:00
Maciej Bieniek
41c43fe639
Fix type of value in MQTT binary sensor (#66675) 2022-02-16 12:11:50 -08:00
Erik Montnemery
fe38e6ba87
Drop MQTT import flow (#66160)
* Drop MQTT import flow

* Reload manually configured MQTT entities when config entry is setup

* Address review comments

* Actually remove the import flow
2022-02-10 21:09:57 +01:00
Jan Bouwhuis
678e56b8b7
Mqtt move to .const (#65631) 2022-02-10 09:18:35 +01:00
Erik Montnemery
33623c3fe8
Fix race in MQTT sensor and binary_sensor expire_after (#66040) 2022-02-07 15:47:23 -08:00
Erik Montnemery
f3a89de71f
Fix race when handling updated MQTT discovery data (#65415) 2022-02-02 17:12:22 -08:00
Jan Bouwhuis
2c07330794
Fix MQTT expire_after effects after reloading (#65359)
* Cleanup sensor expire triggers after reload

* fix test binary_sensor

* Also trigger cleanup parent classes

* Restore an expiring state after a reload

* correct discovery_update

* restore expiring state with remaining time

* Update homeassistant/components/mqtt/binary_sensor.py

description

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

* Log remaining time

* Move check

* check and tests reload

* remove self.async_write_ha_state()

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2022-02-02 16:14:52 +01:00
Jan Bouwhuis
bfaada34e2
Allow unknown state to be set (#65183) 2022-01-31 10:25:08 +01:00
Jan Bouwhuis
3ca18922e6
Mqtt rework on value templates (#62105)
* add MqttValueTemplate class

* support variables at initiation

* pass MqttEntity instead of hass

* Use MqttValueTemplace class for value templates

* make hass en enitity parameters conditional

* remove unused property and remove None assignment

* rename self._attr_value_template
2022-01-03 16:07:40 +01:00
epenet
2cc4d9846b
Add basic type hints to mqtt (#62875)
* Add basic type hints to mqtt

* Add hints to async_setup_platform

* Add type hint to async_setup_entry

* Fix pylint

* Set correct argument order in climate entity

Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-03 08:53:52 +01:00
Jan Bouwhuis
2a2a20fcb3
Add mqtt sensor configurable state encoding for sensor and binary_sensor platform (#60447)
* Add mqtt sensor state encoding

* Make encoding attribute not specific to states

* Move encoding attribute to schema base
2021-11-30 14:04:24 +01:00
Damien Duboeuf
67c2747027
Add MQTT object_id option (#58728)
* Add MQTT object_id option

* Add MQTT object_id option

* Add MQTT object_id option

* Add MQTT object_id option - Fix light and vacuum

* Add MQTT object_id option - Fix light and vacuum

* Add MQTT object_id option - Fix lock

* Add MQTT object_id option - Fix device

* Add MQTT object_id option - Fix device

* Update tests/components/mqtt/test_discovery.py

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

* Change deprecated method

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-11-08 14:02:18 +01:00
Erik Montnemery
640a7fee9d
Allow extra keys in MQTT discovery messages (#58390)
* Allow extra keys in MQTT discovery messages

* Remove extra keys
2021-10-25 13:47:06 +02:00
Jan Bouwhuis
879144b48d
MQTT rework constants (#57529)
* reference CONF_TOPIC to .const

* Organize common mqtt constants
2021-10-12 11:26:38 +02:00
Erik Montnemery
79ee112490
Enable basic type checking for mqtt (#52463)
* Enable basic type checking for mqtt

* Tweak
2021-07-05 10:33:12 +02:00
jan iversen
9410aefd0d
Integrations m*: Rename HomeAssistantType to HomeAssistant. (#49567) 2021-04-22 14:53:37 -07:00
Kristian Heljas
9e487eb260
Hoist mqtt name property and add icon support to MqttEntity (#47165)
* hoist common MqttEntity properties

* remove default name for MqttEntity

Default naming is sensible enough

* disable overriding common MqttEntity schema

* merge common MqttEntity schemas into MQTT_ENTITY_COMMON_SCHEMA
2021-03-11 13:42:13 +01:00
Ville Skyttä
dc880118a4
Lint suppression cleanups (#47248)
* Unused pylint suppression cleanups

* Remove outdated pylint bug references

* Add flake8-noqa config and note to run it every now and then

* Add codes to noqa's

* Unused noqa cleanups
2021-03-02 09:02:04 +01:00
tkdrob
b85ecc0bd2
Use core constants for mqtt (#46389) 2021-02-11 13:38:33 +01:00
Erik Montnemery
248802efd5
Add MQTT base entity (#44971) 2021-01-09 17:46:53 +01:00
Erik Montnemery
6dd6d9b368
Deduplicate MQTT entity discovery code (#44970) 2021-01-09 14:37:33 +01:00
Erik Montnemery
b85efd343f
Move MQTT entity helpers to separate file (#44838)
* Move MQTT entity helpers to separate file

* Fix imports

* Update MQTT number

* Review comments

* Fix formatting
2021-01-09 00:47:17 +01:00
Erik Montnemery
34bd70aee6
Fix race when handling MQTT discovery messages (#44730)
* Fix race when handling MQTT discovery messages

* Lint

* retrigger checks
2021-01-04 12:28:17 +01:00
Erik Montnemery
97edbaa85f
Small cleanup of MQTT (#44110)
* Use relative imports of mqtt component in mqtt platforms

* Correct parameters to _async_setup_entity

* Lint
2020-12-10 21:30:07 +01:00
Matthias Alphart
93a9a11065
Add config validator helper positive_float (#41640) 2020-10-11 22:04:49 +02:00
Erik Montnemery
4d6e694d14
Fix discovery update of MQTT state templates (#39901) 2020-09-10 20:52:23 +02:00
J. Nick Koston
65e53b8251
Support reloading mqtt yaml configuration (#39531) 2020-09-02 20:16:21 -05:00
Michaël Arnauts
d7d7ee6524
Use global CONF_UNIQUE_ID for mqtt (#38595)
* Use global CONF_UNIQUE_ID for mqtt

* Update __init__.py

* Update __init__.py

* Update __init__.py

Co-authored-by: Chris Talkington <chris@talkingtontech.com>
2020-08-09 16:00:14 -05:00
Erik Montnemery
4ed1f8023b
Suppress MQTT discovery updates without changes (#38568) 2020-08-06 10:43:47 +02:00