# kostinos/hass-mosru-water architecture

> Architecture diagram of the GitHub repository kostinos/hass-mosru-water, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kostinos/hass-mosru-water
- Repository: https://github.com/kostinos/hass-mosru-water

## Overview

MOS.RU Water Meter is a Home Assistant integration that authenticates to mos.ru by QR, discovers a household’s water meters, and sends readings from configured HA sensors automatically or on demand. Setup and reauthentication are handled in the config flow; the coordinator reads portal state, refreshes sessions, and owns scheduled/manual submissions. Entities expose portal readings, submission state, inspection details, availability, and a manual button. The README also documents explicit replacement of the latest portal reading. Arrows follow excerpts and README statements; unsampled capabilities are included only where documented.

Main entry points: [`custom_components/mosru_water/coordinator.py`](https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/coordinator.py) (Update coordinator), [`custom_components/mosru_water/config_flow.py`](https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/config_flow.py) (Setup and QR flow), [`custom_components/mosru_water/__init__.py`](https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/__init__.py) (Integration services), [`custom_components/mosru_water/button.py`](https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/button.py) (Manual submit button)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Setup and access"]
  node_config_flow["Setup and QR flow<br/>[config_flow.py]"]
  node_config["Integration settings<br/>[const.py]"]
end

subgraph group_runtime["Reading workflow"]
  node_coordinator["Update coordinator<br/>[coordinator.py]"]
  node_integration["Integration services<br/>[__init__.py]"]
end

subgraph group_entities["Home Assistant entities"]
  node_button["Manual submit button<br/>[button.py]"]
  node_sensors["Status and meter sensors<br/>[sensor.py]"]
  node_device_info["Device metadata<br/>[entity.py]"]
end

subgraph group_portal["Portal integration"]
  node_api["MOS.RU API client<br/>[api.py]"]
  node_mosru{{"mos.ru / ed.mos.ru"}}
end

node_user(("Home Assistant user"))
node_ha_sensors(("Water sensors"))

node_user -->|"configures"| node_config_flow
node_config_flow -->|"authenticates and discovers"| node_api
node_config_flow -->|"QR login"| node_mosru
node_config_flow -->|"stores settings"| node_config
node_ha_sensors -->|"provides readings"| node_coordinator
node_integration -->|"creates and refreshes"| node_coordinator
node_coordinator -->|"reads and submits"| node_api
node_api -->|"calls portal API"| node_mosru
node_user -->|"presses"| node_button
node_button -->|"submits now"| node_coordinator
node_user -->|"requests replacement"| node_integration
node_integration -->|"replaces readings"| node_coordinator
node_coordinator -->|"publishes update data"| node_sensors
node_device_info -->|"provides device identity"| node_sensors
node_device_info -->|"provides device identity"| node_button

click node_config_flow "https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/config_flow.py"
click node_api "https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/api.py"
click node_coordinator "https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/coordinator.py"
click node_integration "https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/__init__.py"
click node_button "https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/button.py"
click node_sensors "https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/sensor.py"
click node_device_info "https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/entity.py"
click node_config "https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/const.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_config_flow,node_config,node_user toneBlue
class node_coordinator,node_integration toneAmber
class node_button,node_sensors,node_device_info toneMint
class node_api,node_mosru toneRose
class node_ha_sensors toneIndigo
```

## Components

### Setup and access

- [Setup and QR flow](https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/config_flow.py): `custom_components/mosru_water/config_flow.py`
- [Integration settings](https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/const.py): `custom_components/mosru_water/const.py`

### Reading workflow

- [Update coordinator](https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/coordinator.py): `custom_components/mosru_water/coordinator.py`
- [Integration services](https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/__init__.py): `custom_components/mosru_water/__init__.py`

### Home Assistant entities

- [Manual submit button](https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/button.py): `custom_components/mosru_water/button.py`
- [Status and meter sensors](https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/sensor.py): `custom_components/mosru_water/sensor.py`
- [Device metadata](https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/entity.py): `custom_components/mosru_water/entity.py`

### Portal integration

- [MOS.RU API client](https://github.com/kostinos/hass-mosru-water/blob/main/custom_components/mosru_water/api.py): `custom_components/mosru_water/api.py`
- **mos.ru / ed.mos.ru**

### Other components

- **Home Assistant user**
- **Water sensors**

## Connections

- Home Assistant user → Setup and QR flow: configures (evidence: `README.md`)
- Setup and QR flow → MOS.RU API client: authenticates and discovers (evidence: `custom_components/mosru_water/config_flow.py`)
- Setup and QR flow → mos.ru / ed.mos.ru: QR login (evidence: `README.md`)
- Setup and QR flow → Integration settings: stores settings (evidence: `custom_components/mosru_water/config_flow.py`)
- Water sensors → Update coordinator: provides readings (evidence: `custom_components/mosru_water/coordinator.py`)
- Integration services → Update coordinator: creates and refreshes (evidence: `custom_components/mosru_water/__init__.py`)
- Update coordinator → MOS.RU API client: reads and submits (evidence: `custom_components/mosru_water/coordinator.py`)
- MOS.RU API client → mos.ru / ed.mos.ru: calls portal API (evidence: `README.md`)
- Home Assistant user → Manual submit button: presses (evidence: `README.md`)
- Manual submit button → Update coordinator: submits now (evidence: `custom_components/mosru_water/button.py`)
- Home Assistant user → Integration services: requests replacement (evidence: `README.md`)
- Integration services → Update coordinator: replaces readings (evidence: `custom_components/mosru_water/__init__.py`)
- Update coordinator → Status and meter sensors: publishes update data (evidence: `custom_components/mosru_water/sensor.py`)
- Device metadata → Status and meter sensors: provides device identity (evidence: `custom_components/mosru_water/sensor.py`)
- Device metadata → Manual submit button: provides device identity (evidence: `custom_components/mosru_water/button.py`)
