Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modbus patch, to allow communication with "slow" equipment using tcp #32557

Merged
merged 15 commits into from Mar 29, 2020

Commits on Mar 26, 2020

  1. modbus: bumb pymodbus version to 2.3.0

    pymodbus version 1.5.2 did not support asyncio, and in general
    the async handling have been improved a lot in version 2.3.0.
    
    updated core/requirement*txt
    janiversen committed Mar 26, 2020
    Configuration menu
    Copy the full SHA
    715524c View commit details
    Browse the repository at this point in the history
  2. updated core/CODEOWNERS

    committing result of 'python3 -m script.hassfest'.
    janiversen committed Mar 26, 2020
    Configuration menu
    Copy the full SHA
    eb98d16 View commit details
    Browse the repository at this point in the history
  3. modbus: change core connection to async

    change setup() --> async_setup and update() --> async_update()
    
    Use async_setup_platform() to complete the async connection to core.
    
    listen for EVENT_HOMEASSISTANT_START happens in async_setup()
    so it needs to be async_listen.
    
    But listen for EVENT_HOMEASSISTANT_STOP happens in start_modbus()
    which is a sync. function so it continues to be listen().
    janiversen committed Mar 26, 2020
    Configuration menu
    Copy the full SHA
    8813e44 View commit details
    Browse the repository at this point in the history
  4. modbus: move setup of pymodbus into modbushub

    setup of pymodbus is logically connected to the class modbushub,
    therefore move it into the class.
    
    Delay construction of pymodbus client until event
    EVENT_HOMEASSISTANT_START arrives.
    janiversen committed Mar 26, 2020
    Configuration menu
    Copy the full SHA
    eb1b1fb View commit details
    Browse the repository at this point in the history
  5. modbus: use pymodbus async library

    convert pymodbus calls to refer to the async library.
    
    Remark: connect() is no longer needed, it is done when constructing
    the client. There are also automatic reconnect.
    janiversen committed Mar 26, 2020
    Configuration menu
    Copy the full SHA
    8c06336 View commit details
    Browse the repository at this point in the history
  6. modbus: use async update for read/write

    Use async functions for read/write from pymodbus.
    
    change thread.Lock() to asyncio.Lock()
    janiversen committed Mar 26, 2020
    Configuration menu
    Copy the full SHA
    5a4de07 View commit details
    Browse the repository at this point in the history
  7. Modbus: patch for slow tcp equipment

    When connecting, via Modbus-TCP, so some equipment (like the
    huawei sun2000 inverter), they need time to prepare the protocol.
    
    Solution is to add a asyncio.sleep(x) after the connect() and before
    sending the first message.
    
    Add optional parameter "delay" to Modbus configuration.
    Default is 0, which means do not execute asyncio.sleep().
    janiversen committed Mar 26, 2020
    Configuration menu
    Copy the full SHA
    09012c9 View commit details
    Browse the repository at this point in the history
  8. Modbus: silence pylint false positive

    pylint does not accept that a class construction __new__
    can return a tuple.
    janiversen committed Mar 26, 2020
    Configuration menu
    Copy the full SHA
    37b4b03 View commit details
    Browse the repository at this point in the history
  9. Modbus: move constants to const.py

    Create const.py with constants only used in
    the modbus integration.
    
    Duplicate entries are removed, but NOT any entry that would
    lead to a configuration change.
    
    Some entries were the same but with different names, in this
    case renaming is done.
    
    Also correct the tests.
    janiversen committed Mar 26, 2020
    Configuration menu
    Copy the full SHA
    b5b414c View commit details
    Browse the repository at this point in the history
  10. Modbus: move connection error handling to ModbusHub

    Connection error handling depends on the hub, not the
    entity, therefore it is logical to have the handling in
    ModbusHub.
    
    All pymodbus call are added to 2 generic functions (read/write)
    in order not to duplicate the error handling code.
    
    Added property "available" to signal if the hub is connected.
    janiversen committed Mar 26, 2020
    Configuration menu
    Copy the full SHA
    09fd688 View commit details
    Browse the repository at this point in the history
  11. Modbus: CI cleanup

    Solve CI problems.
    janiversen committed Mar 26, 2020
    Configuration menu
    Copy the full SHA
    0744ad4 View commit details
    Browse the repository at this point in the history
  12. Modbus: remove close of client

    close() no longer exist in the pymodbus library, use
    del client instead.
    janiversen committed Mar 26, 2020
    Configuration menu
    Copy the full SHA
    75352e4 View commit details
    Browse the repository at this point in the history

Commits on Mar 27, 2020

  1. Modbus: correct review comments

    Adjust code based on review comments.
    janiversen committed Mar 27, 2020
    Configuration menu
    Copy the full SHA
    4b1c64f View commit details
    Browse the repository at this point in the history

Commits on Mar 28, 2020

  1. Modbus: remove twister dependency

    Pymodbus in asyncio mode do not use twister but still throws a
    warning if twister is not installed, this warning goes into
    homeassistant.log and can thus cause confusion among users.
    
    However installing twister just to avoid the warning is not
    the best solution, therefore removing dependency on twister.
    janiversen committed Mar 28, 2020
    Configuration menu
    Copy the full SHA
    97f21bf View commit details
    Browse the repository at this point in the history
  2. Modbus: review, remove comments.

    remove commented out code.
    janiversen committed Mar 28, 2020
    Configuration menu
    Copy the full SHA
    fae9023 View commit details
    Browse the repository at this point in the history