* refactor ModbusRegisterSensor to match the ModbusSwitch interface
* Please pylint, mypy etc.
* Remove PLATFORM.
Co-authored-by: jan Iversen <jancasacondor@gmail.com>
* 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.
* 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.
* 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.
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.
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).
* Add missing function in class.
write_coils was missing.
* Remove dead code.
The HA configuration secures that CONF_TYPE only contains legal values,
so having an empty assert to catch unknown values is dead code.
An empty assert is not informative.
* 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.
* WRITE_COIL uses write_coils in case of an array.
WRITE_REGISTER uses write_register/write_registers depending
on whether value is singular or an array.
WRITE_COIL is modified to be similar and uses
write_coil/write_coils depending on whether value is singular or an
array.
* Update SERVICE_WRITE_COIL to allow list.
* 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>
* Add Modbus light and fan entities
* Rework Fan and Light components to new config structure
* Fix Linter issue
* Rework Modbus switch initialization
* Properly update state on actuator methods
* Remove Fan and Light entity from this change. They will be merged separately
* Fix loading of the Switch platform
* Modbus switch - inherit from the SwitchEntity
* Add Modbus cover
* Fix improper commands written for Modbus cover via coil
* Make changes per review comments
* Fix default hub not defined
Since support for multiple hubs was added, the default hub option
was not implemented correctly. Now I added necessary logic to make
it work. First hub in a list will be used as a default hub.
* Move Cover config under Modbus section
* Revert setting up a default hub alias
* Make hub mandatory for Cover
* Add default scan interval
* Read scan_interval from discovery info
* Fix linter error
* Use default scan interval from Cover platform
* Handle polling for Modbus cover directly inside entity
* Move covers under hub config
* Fix for review comment
* Call update() from Cover actuator methods
* Fix time validation
* Remove unnecessary exception re-wraps
* Preserve exception chains on re-raise
We slap "from cause" to almost all possible cases here. In some cases it
could conceivably be better to do "from None" if we really want to hide
the cause. However those should be in the minority, and "from cause"
should be an improvement over the corresponding raise without a "from"
in all cases anyway.
The only case where we raise from None here is in plex, where the
exception for an original invalid SSL cert is not the root cause for
failure to validate a newly fetched one.
Follow local convention on exception variable names if there is a
consistent one, otherwise `err` to match with majority of codebase.
* Fix mistaken re-wrap in homematicip_cloud/hap.py
Missed the difference between HmipConnectionError and
HmipcConnectionError.
* Do not hide original error on plex new cert validation error
Original is not the cause for the new one, but showing old in the
traceback is useful nevertheless.
* modbus sensor: string data_type
Adds support for a string data_type. This allows the reading of holding registers that contain ascii string data
* Add modbus sensor string data_type #35269
Fingers crossed that I am putting these file in the correct location this time
* Delete const.py
* Delete sensor.py
* Add files via upload
* modbus sensor - add string support. Upload from local dev environment
* fix executable stauts
* fix flake8 failure
* Rename BinarySensorDevice to BinarySensorEntity
* Tweak
* Move deprecation warning to __new__, add test
* Move deprecation warning back to __init__
* Move deprecation warning to __init_subclass
* Rollback modbus to version 0.107.7
Update manifest to not use async.
Rollback entities to sync version.
Keep newer modifications apart from async.
Rollback __init__ to sync version but keep the new functionality.
add async sub directory
Adding the current (not working) version in a sub directory,
to allow easy sharing with a few alfa testers.
The async version are to be updated to use the serial/tcp already
available instead of the flaky pymodbus version. pymodbus is still
needed to encode/decode the messagess.
Update test cases to reflect sync implementation, but
keep the new functionality like e.g. conftest.py.
* do not publish async version
The async version will be made available in a forked repo, until
it is ready to replace the production code.
* add pyserial to manifest
pymodbus is very developer oriented and assumes every developer
adapt the requierements.txt to his/hers needs.
Our requirements.txt is different it contains all posibilities allowing
user to later change configuration without having to install extra
packages.
As a consequence manifest.json needs to include the pyserial.
* modbus: make truly async client creation
Make hass call listen_once async.
Integrate content of start_modbus into async_setup.
Do not use the boiler plate create tcp client function from
pymodbus as it is sync, and also does not work well with asyncio,
instead call the init_<type> directly, since that is async.
* both component/modbus and component/serial uses pyserial-async
but with slighty different version requirements.
Combined the 2.
* Review 1
* Review 2
* Review
@staticmethod is no good, because the function uses class variables.
* Review
Pytest is sometimes a bit cryptic, lets hope this does it.