Interact siemens s7 plc into home assistant homeassistant

INTERACT SIEMENS S7 PLC INTO HOME ASSISTANT HOMEASSISTANT (SUPPORT s300, S1200, S1500, LOGO)

VERY EFFORTLESS PROGRAMMER THAT COMES OUT INJECTABLE. WORKS STABLE.

Features

  • :zap: Direct PLC communication over S7 protocol via pys7.
  • :jigsaw: Multiple entity types: light, switch, button, binary_sensor, sensor, number.
  • :abacus: Value multipliers: scale raw PLC values before Home Assistant sees them (e.g., convert tenths or hundredths to human-friendly units).
  • :feather: Lightweight: minimal overhead, no broker/services required.
  • :hammer_and_wrench: Full UI configuration: set up and manage the integration entirely from Home Assistant’s UI.
  • :mag: Optional auto-discovery: the setup wizard pre-populates PLCs found on your local network while still allowing manual IP entry.
  • :page_facing_up: S7 STRING support for text sensors.

Requirements

  • A working Home Assistant installation.
  • A reachable Siemens S7 PLC (e.g., S7-1200/S7-1500/S7-300/S7-400) over ISO-on-TCP (port 102).
  • Network connectivity between Home Assistant host and the PLC (no firewalls blocking 102/TCP).
  • Python dependencies installed automatically from requirements.txt (notably pys7).
2 Likes

Hi,

Should it also work for a Logo 0BA7? I was able to add 2 Logo’s 0BA8, but my third is an older one and I’m getting an “Unknown error”.
When configuring the connection, it found all my Logo’s (inlcuding the 0BA7).

logs:

Logger: aiohttp.server
Bron: /usr/local/lib/python3.13/site-packages/aiohttp/web_protocol.py:481
Eerst voorgekomen: 11:38:18 (5 gebeurtenissen)
Laatst gelogd: 14:29:57

Error handling request from 192.168.1.86
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/pyS7/client.py", line 244, in __send
    header = self._recv_exact(4)
  File "/usr/local/lib/python3.13/site-packages/pyS7/client.py", line 275, in _recv_exact
    chunk = self.socket.recv(expected_length - len(data))
ConnectionResetError: [Errno 104] Connection reset by peer

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/pyS7/client.py", line 85, in connect
    connection_bytes_response: bytes = self.__send(connection_request)
                                       ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/pyS7/client.py", line 262, in __send
    raise S7CommunicationError(
        f"Socket error during communication: {e}."
    ) from e
pyS7.errors.S7CommunicationError: Socket error during communication: [Errno 104] Connection reset by peer.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/aiohttp/web_protocol.py", line 510, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/web_app.py", line 569, in _handle
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 87, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 86, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 41, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 83, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 234, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
    return await method(view, request, data, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 121, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 346, in async_configure
    result = await self._async_configure(flow_id, user_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 393, in _async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        flow, cur_step["step_id"], user_input
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 493, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/s7plc/config_flow.py", line 229, in async_step_user
    await self.hass.async_add_executor_job(coordinator.connect)
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/s7plc/coordinator.py", line 144, in connect
    self._ensure_connected()
    ~~~~~~~~~~~~~~~~~~~~~~^^
  File "/config/custom_components/s7plc/coordinator.py", line 127, in _ensure_connected
    self._client.connect()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/pyS7/client.py", line 102, in connect
    raise S7ConnectionError(f"Failed to complete connection setup: {e}") from e
pyS7.errors.S7ConnectionError: Failed to complete connection setup: Socket error during communication: [Errno 104] Connection reset by peer.