I believe the most common term would be a peephole, even when talking about historical architecture. The one with a sliding cover could be called a sliding peephole.
A medieval door with a peephole covered in metal bars.
Photo by shutterstock.com / BonnieBC
traditionalbuilding.com
Speculatorium is a historical architectural term for it but it is not used today. It has the same etymons as speculate, a current word you are familiar with, which are Latin speculāri and its participal stem speculāt-. Speculārī means "to spy out, watch, examine, observe" and it comes from Latin specĕre "to see, look". The suffix -orium can form nouns with the sense "an instrument with which a specified activity is carried out".
The term is listed in the book Illustrated Dictionary of Historic Architecture by Cyril M. Harris:
speculatorium a peephole with a grating in a door for inspecting visitors.
For example, speculatorium was used in an architectural illustration of the door of S.George's Chapel in Windsor, in the book Metal-work and its artistic design by Wyatt, M. Digby, from 1852:

front door with peep window. Are you looking for a medieval/historical term? – Tinfoil Hat Oct 11 '23 at 02:44