* refactor ModbusRegisterSensor to match the ModbusSwitch interface
* Please pylint, mypy etc.
* Remove PLATFORM.
Co-authored-by: jan Iversen <jancasacondor@gmail.com>
* 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.
* Prepare test harness for new pymodbus return types.
Use pytest.fixture to mock pymodbus.
Use pytest.fixture to load modbus using mocked pymodbus
Add test of Exception/IllegalResponse/ExceptionResponse from pymodbus.
* Modbus.py is back at 100% test coverage.
* Added assert mock.called.
* add mock reset.
* 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>
* Update test harness to allow discovery_info testing.
This is a needed update, before the whole config is converted
to the new structure, because it allows test of both the old
and new configuration style.
The following changes have been made:
- Combine test functions into a single base_test.
- Prepare for new mock by combining the 2 common test functions into one.
- Change mock to be only modbusHub
- Do not replace whole modbus class, but only the class that
connects to pymodbus (modbusHub). This allows test of modbus
configurations and not only component configurations, and is needed
when testing discovery activated platform.
- Add test of climate.
Warning this is merely test of discovery,
the real cover tests still needs to be added.
- Add test of cover.
Warning this is merely test of discovery,
the real cover tests still needs to be added.
* Update comment for old config
* Do not use hass.data, but instead patch pymodbus library.
* Add test of configuration (old/new way as available).
* Move assert to test function.
Make assert more understandable by removing it from the helper.
add base_config_test (check just calls base_test) to make it clear if
test is wanted or just controlling the config.
* use setup_component to load Modbus since it is an integration.
* Optimized flow in test helper.
* check for false config in modbus tests.
add call to pytest.fail() if device cannot be defined.
* correct bit error in register read.
Only LSB is to be considered for checking ON/OFF
* Add register tests for modbus switch.
Copy the coil tests to work for register tests.
* allow test coverage to control switch.py
With both register and coil test the coverage is a log higher than 50%
* Correct minor bug in handling of register in modbus switch
* Add state_on/state_off test for modbus switch
* restore modbus switch exclusion from coverage
switch file coverage is only at 72%, ideally we want either 80%+ coverage on the file or 90%+ on the component itself which is only about 83% currently with this file included. this is so we keep the overall project coverage in 90%+.
Co-authored-by: Chris Talkington <chris@talkingtontech.com>
* Prepare test code for complex devices.
push entity_id to conftest, to make it common for all devices.
Add device to base_setup.
* Add test coverage for modbus switch (coil part).
* Update .coveragerc
* Update .coveragerc
Co-authored-by: Chris Talkington <chris@talkingtontech.com>
* Add test coverage of binary sensor.
Update conftest to be generic.
* Pass total config structure to run_base_test.
Simple devices like sensor/switch do only have one entry in the
dict array, whereas e.g. switch have multiple entries.
* Use STATE_ON / _OFF for binary_sensor test.
* Update coveragerc
Only exclude files that uses a third party library.
* Remove modbus/* from coveragerc
* Remove modbus from .coveragerc
* Update .coveragerc
Co-authored-by: Chris Talkington <chris@talkingtontech.com>
* 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.
* update common test for modbus integration
* remove log messages from modbus setup function.
* Make global method local
* Change parameter name to snake_case
Since all entity test functions are going to use
the modbus class, isolate the common parts in
conftest.py, and thereby make it simpler to write
additional test cases.
cleaned up test_modbus_sensor.py while splitting the code.