Commit Graph
122 Commits
Author SHA1 Message Date
jan iversen 538a189168 Adjust modbus climate to use address/input_type (#51202) 2021-05-28 17:57:14 +02:00
jan iversen 00507539c1 Change Cover to use address/input_type (#51154)
* Change Cover to use address/input_type.

* Flake.
2021-05-28 13:23:44 +02:00
jan iversen e45196f9c9 Remove "old" config from modbus binary_sensor (#51117) 2021-05-28 12:06:46 +02:00
jan iversen 5afd16ef5d Move modbus schema validators to validators.py (#51121) 2021-05-28 11:38:31 +02:00
jan iversen 47f016b340 Remove old config from cover, including tests (#51118)
* Remove old config and standardize new config.

* Add missing safeguard.
2021-05-28 11:29:37 +02:00
jan iversen 8d365e8bf5 After merge, review. (#51139) 2021-05-27 08:28:31 +02:00
Yuriy Sannikovandjan Iversen 6391d75919 Refactor ModbusRegisterSensor class to get hub and configuration (#50234)
* refactor ModbusRegisterSensor to match the ModbusSwitch interface

* Please pylint, mypy etc.

* Remove PLATFORM.

Co-authored-by: jan Iversen <jancasacondor@gmail.com>
2021-05-26 19:28:14 +02:00
tkdrobandFranck Nijhof 028a07d86f Wrap up selectors (#50794)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-05-25 14:45:17 +02:00
jan iversen 8721675218 Use BaseSwitch class in modbus switch/fan/light (#51031) 2021-05-24 20:13:25 +02:00
jan iversen c74e65ac2d Streamline modbus test_init (#50990)
* Streamline test_init.

* Review comments.

* Remove hub name.
2021-05-24 14:53:54 +02:00
jan iversen 1546dbbf25 Add restore temperature to modbus climate (#50963)
* Add restore temperature to climate.

* please mypy.

* Review 2.
2021-05-24 14:03:44 +02:00
jan iversen be13a73db8 Allow manual scan and add delay in switch verify. (#50974) 2021-05-24 12:59:55 +02:00
jan iversen f55213d8b1 Update modbus cover to 100% coverage (#50996) 2021-05-23 10:18:35 -05:00
jan iversen 59ae78e5f0 Add restore_state to modbus binary_sensor (#50922)
* Add restore_state to binary_sensor.

* Update return value in State.
2021-05-22 13:38:05 +02:00
Vladimír Záhradníkandjan Iversen c979101a02 Add Modbus fan integration (#48558)
* Add Modbus fan entity

* Update to PR.

* Pylint.

Co-authored-by: jan Iversen <jancasacondor@gmail.com>
2021-05-21 09:56:47 +02:00
Vladimír Záhradníkandjan Iversen 80d172140f Add Modbus light integration (#42120)
* Add  Modbus Light and add unit tests

* Update to original PR.

* Review comments.

* Review 2.

Co-authored-by: jan Iversen <jancasacondor@gmail.com>
2021-05-21 08:57:17 +02:00
jan iversen c650deef98 Add base class for all modbus platforms (#50878)
* Add base for all platforms.

* Please pylint.
2021-05-20 16:56:11 +02:00
Maciej Bieniek e06a2a53c4 Add constructor return type in integrations L-N (#50888)
* Add constructor return type in integrations L-N

* Small fix
2021-05-20 13:06:44 +01:00
jan iversen b7fc537cd5 Remove non pymodbus_call from modbus.py. (#50813) 2021-05-19 11:39:53 +02:00
jan iversen 4c7fcae536 Small bug fixes in modbus due to async (#50812)
* Small bug fixes due to async.

* _available is true in turn_on/turn_off

* Remove double update.

* Set _available.
2021-05-19 10:13:48 +02:00
jan iversen ba827db8ec Update remaining modbus platforms to use pymodbus_call (#50768) 2021-05-17 22:12:18 +02:00
jan iversen 6b34ba012c Fix missing await in modbus platforms (followup on async PR) (#50710) 2021-05-17 14:20:51 +02:00
nikito7 0fac3ccebc Change Modbus error message to bytes (#50725) 2021-05-17 14:12:17 +02:00
jan iversen ff856a9bba Simplify calls to pymodbus (#50717)
* simplify pymodbus_call.

Do not call with a function object and a check attribute, call instead
with CALL_TYPE*.

Avoid if <type> call x else call y.
Call async_pymodbus_call directly, instead of unpacking/packing.

* Declare call type in __init__.

* Modbus.py back to 100% test coverage.
2021-05-17 11:20:12 +02:00
jan iversen 224cc779c4 Correct Modbus platform cover restore state (#50421)
* Correct cover restore state.

* Change mock usage.

* Add states to convert.
2021-05-16 08:40:19 +02:00
jan iversenandMartin Hjelmare ad7be91b6a Fix modbus blocking threads (#50619)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-05-15 19:54:17 +02:00
tkdrob a9660d5788 Add targets and selectors for services (L-M) (#50543) 2021-05-15 11:06:34 +02:00
jan iversen 19cdff10c3 Add "close_comm_on_error" to modbus configuration (#50583) 2021-05-14 10:54:23 +02:00
jan iversen dbf7430003 Bump pymodbus to v2.5.2 (#50582)
Solves a serial - rs-485 adapter issue.
2021-05-13 20:31:48 -07:00
jan iversen 70b09ed9a1 Handle relation between scan_interval and pymodbus timeout in modbus (#50363)
* Control scan_interval compared to pymodbus timeout.

add MINIMUM_SCAN_INTERVAL=5 seconds and validata with Voluptous.
Keep modbus.py 100% coverage.

* Please pylint.

* Review comments.

* pylint.
2021-05-10 19:28:38 +02:00
jan iversen ec08256ff0 Do not use async_* in a modbus sync function (#50343) 2021-05-09 19:50:23 +02:00
jan iversen 29eb31e9da Add configurable delay between connect and first request in modbus (#50124)
* Activate startup delay.

* Add removal of call_later if HA is stopped.

This is unlikely to happen, but just security measure.

* Removing timing interval.

async_fire_time_changed() needs to be called twice, first time the delay is
ended and second time update() is executed.

* Variable naming.
2021-05-08 13:28:35 +02:00
Vladimír Záhradník e0de6752af Fix incorrect attribute checks in Modbus hub (#50241) 2021-05-08 13:26:31 +02:00
jan iversen 552ca1c57b Fix modbus switch problems (#50117) 2021-05-07 22:12:13 +02:00
jan iversenandMartin Hjelmare 2f89ba24b6 Cleanup modbus binary_sensor signature (#49809)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-05-05 00:29:18 +02:00
jan iversen f0ec9c38b0 Fix modbus typing (#49938)
Add changes needed to please mypy and follow the coding rules
of the project.
2021-05-03 22:45:21 +02:00
jan iversen 8adbc62a6e Enable homeassistant.update_entity service for all modbus platforms (#49918)
* Rename _update() to update()

A platform neeed a function update(), even though
polling is false, this is due to the service:
homeassistant.update_entity, which calls update()

* Update test harnesss to script testing.

Test homeassistant.update_entity in all platforms.
This call calls update() in the platform to get
a new reading.

* Add reuse parameter.

* Move service call from helper to tests.

* Change run_service_update --> prepare_service_update.

* Remove entity_id parameter.
2021-05-02 10:41:36 +02:00
jan iversen 7ac05110ca Catch non payload modbus messages (#49910) 2021-05-02 00:03:52 +02:00
jan iversen aa8ce07e35 Start Modbus cover timer independent if there is a state to restore (#49919)
* Start timer independent if there is a state to restore.

* Update test cases, that now start working.
2021-04-30 22:36:55 +02:00
jan iversen 684ea9e49b Restructure modbus switch, and solve read/write conflicts (#49386)
Remove old style configuration from switch.
- The old style configuration allowed a number of illegal
  configurations, instead of adding if...log. in setup we
  only support the new configuration style.

Add new/changed configuration switch.

Removed verify_state and cleaned configuration to avoid possible
illegal configurations.
2021-04-30 16:47:18 +02:00
jan iversenandMartin Hjelmare 5b6d2edb48 Catch missing/unavailable response from modbus (#49632)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-04-29 15:59:17 +02:00
jan iversenandMartin Hjelmare e5e215353d Add swap byte/word/byteword option to modbus sensor (#49719)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-04-27 10:49:41 +02:00
jan iversen 33e8553d92 Fix frontend freeze due to modbus device not responding (#49651)
Changing the timeout from package default, secures SENDING will
timeout, and after 3 retries break off.

Remark: this commit is tested with pymodbus v2.5.1 the old version
v2.3.0 have several problems in this area.
self._value = await self.async_get_last_state()

pymodbus v2.5.1 is active on DEV (bumped in an earlier PR).
2021-04-25 23:11:01 +02:00
jan iversen 914451d99c Remove dead code in modbus sensor and 100% test coverage (#49634) 2021-04-25 15:25:02 +02:00
jan iversen f67c0ce8bb Secure 100% test coverage for modbus, binary_sensor and sensor (#49521)
* Secure 100% test coverage for modbus/binary_sensor.

* Test that class constructor is called.
2021-04-22 11:54:40 +02:00
jan iversen c9bdc9609c Do not close non existing clients in modbus (#49489)
* Only close if _client is present.

* Remove del.
2021-04-21 11:46:40 +02:00
jan iversen c14e525ac3 Update modbus state when sensor fails (#49481) 2021-04-20 14:54:20 +02:00
jan iversen a278ebd37b Bump pymodbus version to 2.5.1 (#49401) 2021-04-20 10:43:14 +02:00
jan iversen 8acc3f0b03 Fix modbus switch "old style" config problem (#49352)
Fix that using CONF_HUB in switch, changed the hub for all
subsequent switches.
2021-04-19 10:35:32 -07:00
jan iversen eb9ba527d0 Add pymodbus exception handling and isolate pymodbus to class modbusHub (#49052) 2021-04-19 08:18:15 -07:00