Commit graph

66 commits

Author SHA1 Message Date
Franck Nijhof
baef267f33
String formatting and max line length - Part 3 () 2022-12-22 13:35:47 +01:00
Jan Bouwhuis
e15388a2a0
Improve MQTT type hints for dict get assignments ()
* 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 ()
Clean up or correct from removed deprecation
2022-11-25 16:11:22 +01:00
Jan Bouwhuis
7c2e7863d2
Remove legacy YAML support from MQTT () 2022-11-17 22:55:31 +01:00
Jan Bouwhuis
b4ad03784f
Improve MQTT type hints part 1 ()
* 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 () 2022-11-02 13:41:14 +01:00
Jan Bouwhuis
8aa30cce26
Fix state saving when sharing topics for MQTT entities ()
* 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 ()
Co-authored-by: Erik <erik@montnemery.com>
2022-09-18 12:55:31 -04:00
epenet
f62fbbe524
Use _attr_force_update in mqtt () 2022-09-07 23:42:16 +02:00
Jan Bouwhuis
5930f056a8
Mqtt support config_entry unload ()
* 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 () 2022-06-30 21:11:45 +02:00
Erik Montnemery
f05b4a0ca0
Fire event_mqtt_reloaded only after reload is completed () 2022-06-30 10:15:25 -07:00
Jan Bouwhuis
57daeaa174
Fix MQTT config schema to ensure correct validation ()
* 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 () 2022-06-02 11:32:31 -07:00
Erik Montnemery
635d7085cf
Move MQTT config schemas and client to separate modules ()
* 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 ()
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 ()
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 () 2022-02-16 14:07:21 -08:00
Maciej Bieniek
41c43fe639
Fix type of value in MQTT binary sensor () 2022-02-16 12:11:50 -08:00
Erik Montnemery
fe38e6ba87
Drop MQTT import flow ()
* 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 () 2022-02-10 09:18:35 +01:00
Erik Montnemery
33623c3fe8
Fix race in MQTT sensor and binary_sensor expire_after () 2022-02-07 15:47:23 -08:00
Erik Montnemery
f3a89de71f
Fix race when handling updated MQTT discovery data () 2022-02-02 17:12:22 -08:00
Jan Bouwhuis
2c07330794
Fix MQTT expire_after effects after reloading ()
* 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 () 2022-01-31 10:25:08 +01:00
Jan Bouwhuis
3ca18922e6
Mqtt rework on value templates ()
* 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 ()
* 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 ()
* 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 ()
* 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 ()
* Allow extra keys in MQTT discovery messages

* Remove extra keys
2021-10-25 13:47:06 +02:00
Jan Bouwhuis
879144b48d
MQTT rework constants ()
* 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 ()
* Enable basic type checking for mqtt

* Tweak
2021-07-05 10:33:12 +02:00
jan iversen
9410aefd0d
Integrations m*: Rename HomeAssistantType to HomeAssistant. () 2021-04-22 14:53:37 -07:00
Kristian Heljas
9e487eb260
Hoist mqtt name property and add icon support to MqttEntity ()
* 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 ()
* 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 () 2021-02-11 13:38:33 +01:00
Erik Montnemery
248802efd5
Add MQTT base entity () 2021-01-09 17:46:53 +01:00
Erik Montnemery
6dd6d9b368
Deduplicate MQTT entity discovery code () 2021-01-09 14:37:33 +01:00
Erik Montnemery
b85efd343f
Move MQTT entity helpers to separate file ()
* 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 ()
* 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 ()
* 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 () 2020-10-11 22:04:49 +02:00
Erik Montnemery
4d6e694d14
Fix discovery update of MQTT state templates () 2020-09-10 20:52:23 +02:00
J. Nick Koston
65e53b8251
Support reloading mqtt yaml configuration () 2020-09-02 20:16:21 -05:00
Michaël Arnauts
d7d7ee6524
Use global CONF_UNIQUE_ID for mqtt ()
* 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 () 2020-08-06 10:43:47 +02:00
Erik Montnemery
fb3049d6a2
Set MQTT sensor to state unavailable when value expires () 2020-07-08 16:20:19 -07:00
Erik Montnemery
9ade1de3d5
Support empty output of MQTT binary_sensor value_template ()
* Support empty output of MQTT binary_sensor value_template

* Strip white space

* Add test

* Add test
2020-07-04 17:48:02 +02:00
Erik Montnemery
b022e08db9
Rename BinarySensorDevice to BinarySensorEntity ()
* Rename BinarySensorDevice to BinarySensorEntity

* Tweak

* Move deprecation warning to __new__, add test

* Move deprecation warning back to __init__

* Move deprecation warning to __init_subclass
2020-04-23 21:57:07 +02:00
Tom
d6ab36bf8e
Set mqtt binary_sensor unavailable if expire_after specified ()
* Set self._expired=True if expire_after specified

* Added test_expiration_on_discovery_and_discovery_update_of_binary_sensor to mqtt/test_binary_sensor.py

* Fixed flake8 error

* Fixed isort error
2020-04-22 23:29:49 +02:00