* 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.
* 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.
* 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.
* 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>