Commit graph

76 commits

Author SHA1 Message Date
jan iversen
0638088aee
Deprecate and remove lazy_error from modbus (#105037) 2023-12-05 13:08:33 +01:00
jan iversen
701a93c298
Modbus set device_class in slaves (#103442) 2023-11-05 20:20:13 +01:00
jan iversen
ec2364ef43
Add virtual_count == slave_count in modbus configuration (#100398)
* Add virtual_count as config parameter.

* Review (other PR) comments.

* Review.

* Review comment.
2023-09-15 14:00:02 +02:00
jan iversen
9acca1bf58
Make modbus retry fast on read errors (#99576)
* Fast retry on read errors.

* Review comments.
2023-09-12 10:01:15 -04:00
jan iversen
c268adb07e
modbus: Repair swap for slaves (#97960) 2023-08-18 13:23:04 +02:00
jan iversen
e42b9e6c4c
Modbus: set state_class etc in slaves. (#98332) 2023-08-18 10:52:57 +02:00
jan iversen
5a7084e78c
Correct number of registers to read for sensors for modbus (#98534) 2023-08-18 10:48:57 +02:00
jan iversen
a224b668d7
modbus: Adjust read count by slave_count (#97908) 2023-08-08 16:09:53 +02:00
jan iversen
bbc34bae87
modbus: use pb not pymodbus consistently as name. (#97780)
Use pb not pymodbus consistently as name.
2023-08-04 20:14:32 +02:00
Erik Montnemery
a71c097aeb
Revert "Allow setting an entity's name by its device class" (#93539) 2023-05-25 17:20:54 +02:00
Erik Montnemery
67c1051305
Allow setting an entity's name by its device class (#90767)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2023-05-09 18:55:55 +02:00
jan iversen
b9b5a279f2
Correct sensor restore entity in modbus (#87563)
* Correct sensor restore entity.

* Review comments.
2023-02-09 21:35:44 +01:00
Marc Mueller
da35097803
Update Optional typing (2) [Py310] (#86419) 2023-01-23 09:10:05 +01:00
GrahamJB1
200d3ae845
modbus slave unique ids (#86126)
modbus slave unique ids
2023-01-19 11:08:11 +01:00
GrahamJB1
bcd4c031c6
Support float in modbus register sensor (#86128)
register sensor should support float
2023-01-19 09:41:49 +01:00
GrahamJB1
9d9817328b
Reset Modbus value on down (#86127)
* modbus: slave should reset value on sensor down as parent does that

* modbus: slave should reset value on sensor down as parent does that
2023-01-18 08:49:38 +01:00
Marc Mueller
77e71cf18b
Improve modbus generic typing (#84737) 2022-12-29 12:37:31 +01:00
jan iversen
d2e5c85429
Remove pragma from discover check. (#68002) 2022-03-11 19:58:18 +02:00
jan iversen
a4915eb704
Handle exception in modbus slave sensor (#67472) 2022-03-02 09:49:57 -08:00
jan iversen
e891df0ff3
Allow multi read of Modbus sensor (#67378) 2022-02-28 11:07:55 -08:00
Marc Mueller
887d04be60
Use assignment expressions 32 (#58716) 2021-10-30 16:30:13 +02:00
jan iversen
cca7da77ad
Report modbus buffer too small or too big to unpack (#57838) 2021-10-20 15:22:01 -07:00
Robert Hillis
488a636aec
Clean up unused loggers (#57662) 2021-10-14 10:03:38 -07:00
jan iversen
ddd31951bc
Strictly type sensor.py. (#56377) 2021-09-20 07:35:11 +02:00
Matthias Alphart
cd0ae66d58
Add CONF_STATE_CLASS to sensor/__init__.py (#54106)
* add CONF_STATE_CLASS to const.py

* move to `sensor/__init__.py`

* move to sensor/const.py

* Revert "move to sensor/const.py"

This reverts commit 604d0d066b.

* move it to `sensor/const.py` but import it from `sensor/__init__.py`

* add Modbus
2021-08-27 05:54:50 +02:00
Matthias Alphart
51361fbd2b
Add configurable state_class to Modbus sensors (#54103)
* add configurable state_class

* Add test of new parameter.

Co-authored-by: jan Iversen <jancasacondor@gmail.com>
2021-08-25 11:50:54 +02:00
jan iversen
33f660118f
Add lazy_error_count to modbus (#54412)
* Add lazy_error_count.

* Use -=

* Review comments.
2021-08-21 15:49:50 +02:00
Erik Montnemery
2720ba2753
Move temperature conversions to sensor base class (4/8) (#54472)
* Move temperature conversions to entity base class (4/8)

* Fix litterrobot sensor

* Fix tests
2021-08-11 21:17:47 +02:00
jan iversen
02459e6813
Convert last properties in modbus to _attr_variable (#53919) 2021-08-08 23:23:21 +02:00
jan iversen
e8aa280d7f
Add modbus get_hub (#54277)
* Add dict with hubs.

* Update flexit to use get_hub.

* Remove executor_task for close.
2021-08-08 22:48:33 +02:00
jan iversen
cfb0def718
Change integration modbus to use _attr variables (#53511) 2021-07-26 21:20:34 +02:00
jan iversen
19a282255b
Remove duplicate functions in modbus climate/sensor. (#53141)
Convert all data types correctly for climate.
2021-07-19 23:52:58 -05:00
jan iversen
8d365e8bf5
After merge, review. (#51139) 2021-05-27 08:28:31 +02:00
Yuriy Sannikov
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
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
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
ad7be91b6a
Fix modbus blocking threads (#50619)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-05-15 19:54:17 +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
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
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
c14e525ac3
Update modbus state when sensor fails (#49481) 2021-04-20 14:54:20 +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
jan iversen
0f90678e0e
Change HomeAssistantType -> HomeAssistant in modbus (#49400) 2021-04-18 22:13:32 -10:00
jan iversen
ea9641f980
Apply Precision/Scale/Offset to struct in modbus sensor (#48544)
The single values in struct are corrected with presicion, scale and offset,
just as it is done with single values.
2021-04-16 22:33:58 +02:00
jan iversen
2511e1f229
Remove modbus duplicate strings (#48654)
* Reuse HA constants for serial configuration.

Reusing HA consts reduces the need for translation.

Sort/group constants in const.

* Change const name ATTR_* to CONF_*

* Correct wrong import

* ATTR_* for service and CONF_* for schemas.

* Revert change to service call.

* Rename CONF_TEMPERATURE -> ATTR_TEMPERATURE

Avoid possible division problem in set_temperature.
2021-04-04 14:02:47 +02:00
jan iversen
ffdfc521b9
Allow discovery configuration of modbus platforms (#46591)
* Change modbus configuration to new style.

The old (frozen) configuration is still supported, but when detected a big
warning is issued that it will soon be removed. This allows users to change
their configuration at their pace.

Clean configuration SCHEMAs and move common modbus parts
to MODBUS_SCHEMA (renamed from BASE_SCHEMA).

Add BASE_COMPONENT_SCHEMA to ensure common configuration of components.
All component define e.g. NAME, move these to a common schema.
change components (binary_sensor, sensor, switch) to new config

Add test set for modbus itself (old config and discovery_info).
Add test of devices discovery_info configuration

* Update discovery_info configuration for binary_sensor.

* Update discovery_info configuration for sensor.

* Update discovery_info configuration for switch.

* Review comments.

* update due to change in core

* flake8 problem.

* Correct log message.

* add should_poll property.

* Fix polling for Modbus binary sensor

* Fix polling for Modbus sensor

* Fix polling for Modbus switch

* Fix switch.

* Fix pytest errors.

* Update homeassistant/components/modbus/binary_sensor.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update homeassistant/components/modbus/binary_sensor.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update homeassistant/components/modbus/modbus.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update homeassistant/components/modbus/sensor.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update homeassistant/components/modbus/sensor.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update homeassistant/components/modbus/sensor.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update homeassistant/components/modbus/switch.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update homeassistant/components/modbus/switch.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update homeassistant/components/modbus/switch.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* ToogleEntity -> SwitchEntity and add abastract

* Update homeassistant/components/modbus/switch.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update tests/components/modbus/test_init.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* removed if/else in test.

* Remove other if.

Co-authored-by: Vladimir Zahradnik <vladimir@zahradnik.io>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-03-27 22:48:06 +01:00