Package: ojmicroline-thermostat
Asynchronous Python client for communicating with a OJ Microline Thermostat.AboutA Python package to control OJ Microline thermostats. It currently supports the WD5 series (OWD5, MWD5) and WG4 series (UWG4, AWG4).Installationpipinstallojmicroline-thermostatDatasetsThermostatThis object represents the current state of a thermostat.VariableTypeDescriptionmodelstringThe model name for this thermostat.serial_numberstringThe serial number for this thermostat.software_versionstringThe currently installed software version.zone_namestringThe name of the zone this thermostat belongs to.zone_idintegerThe ID of the zone this thermostat belongs to.namestringThe name of the thermostat.onlinebooleanIndicates if the thermostat is connected to the network.heatingbooleanIndicates if the thermostat is currently heating/is on.regulation_modeintegerThe currently set regulation mode of the thermostat, see below.supported_regulation_modeslistThe regulation modes this thermostat supports.min_temperatureintegerThe lowest temperature the thermostat can be set to.max_temperatureintegerThe highest temperature the thermostat can be set to.manual_temperatureintegerIf the regulation mode is set to manual mode, the thermostat will target this temperature.comfort_temperatureintegerIf the regulation mode is set to comfort mode, the thermostat will target this temperature.comfort_end_timedatetimeIf the regulation mode is set to comfort mode, it will end at this time.vacation_modebooleanIf true then the thermostat is set tovacation_temperaturefromvacation_begin_timetovacation_end_time. If false, then no vacation is in progress or scheduled.vacation_temperatureintegerIf the regulation mode is VACATION, the thermostat will target this temperature.vacation_begin_timedatetimeThe vacation regulation mode will begin at this time. Note that vacations may be scheduled to begin in the future.vacation_end_timedatetimeIf in vacation mode, the thermostat will return to schedule mode at this time.last_primary_mode_is_autobooleanUnknownThese fields are only available on WD5-series thermostats; for others, they may beNone:VariableTypeDescriptionthermostat_idintThe unique identifier for this thermostat.adaptive_modebooleanIf on then then the thermostat automatically changes heating start times to ensure that the required temperature has been reached at the beginning of any specific event.open_window_detectionbooleanIf on then the thermostat shuts off the heating for 30 minutes if an open window is detected.daylight_saving_activebooleanIf on, the "Daylight Saving Time" function of the thermostat will automatically adjust the clock to the daylight saving time for the "Region" chosen.sensor_modeintegerThe currently set sensor mode of the thermostat, see below.temperature_floorintegerThe temperature measured by the floor sensor.temperature_roomintegerThe temperature measured by the room sensor.boost_temperatureintegerIf the regulation mode is set to boost mode, the thermostat will target this temperature.boost_end_timedatetimeIf the regulation mode is set to boost mode, it will end at this time.frost_protection_temperatureintegerIf the regulation mode is set to frost protection mode, the thermostat will target this temperature.scheduleScheduleThe schedule the thermostat currently uses. (Thiscouldbe supported by WG4-series thermostats, it simply isn't implemented.)These fields are only available on WG4-series thermostats; for others, they may beNone:VariableTypeDescriptiontemperatureintegerThe current temperature; the thermostat uses the room sensor or floor sensor based on its configuration. Avoid using this directly; instead, call theget_current_temperature()method which also works for WD5-series thermostats.set_point_temperatureintegerThe temperature the thermostat is targeting. Avoid using this directly; instead, call theget_target_temperature()method which also works for WD5-series thermostats.Regulation modesIntegerConstantDescription1REGULATION_SCHEDULEThe thermostat follows the configured schedule.2REGULATION_COMFORTThe thermostat is in comfort mode untilcomfort_end_time.3REGULATION_MANUALThe thermostat is in manual mode, will not resume schedule unless changed.4REGULATION_VACATIONThe thermostat is in vacation mode, it started atvacation_begin_timeand ends atvacation_end_time.6REGULATION_FROST_PROTECTIONThe thermostat is set to frost protection, preventing the floor from freezing.8REGULATION_BOOSTThe thermostat is in boost mode for 1 hour, using themax_temperatureas target temperature.9REGULATION_ECOThe thermostat is in eco mode, using the lowest temperature of theschedule.Keep in mind that certain thermostats only support a subset of these modes; be sure to check theThermostat.supported_regulation_modesfield.Sensor modesIntegerConstantDescription1SENSOR_ROOM_FLOORThe thermostat takes the average of the room and floor temperature3SENSOR_FLOORThe thermostat is using the floor sensor for target temperature.4SENSOR_ROOMThe thermostat is using the room sensor for target temperature.MethodsOJMicrolineMethodParamsDescriptionloginNoneCreate a new session at the OJ Microline API.get_thermostatsNoneGet all thermostats from the OJ Microline API.set_regulation_moderesource: Thermostat,regulation_mode: int,temperature: int | None = None,duration: int = COMFORT_DURATIONSet the regulation mode based on the input.-resource: An instance of a Thermostat model returned byget_thermostats()-regulation_mode: An integer representing the regulation mode, see "Regulation modes"-temperature: An integer representing the temperature, eg: 2500. Only useful when setting the regulation mode to manual or comfort.-duration: The duration in minutes to set the temperature for; only applies to comfort mode.Usageimportasynciofromtimeimportsleepfromojmicroline_thermostatimportOJMicroline,Thermostat,WD5APIfromojmicroline_thermostat.constimport(REGULATION_BOOST,REGULATION_COMFORT,REGULATION_ECO,REGULATION_FROST_PROTECTION,REGULATION_MANUAL,REGULATION_SCHEDULE,REGULATION_VACATION,)REGULATION_MODES={REGULATION_SCHEDULE:"Schedule",REGULATION_ECO:"Eco",REGULATION_MANUAL:"None (Manual)",REGULATION_FROST_PROTECTION:"Frost Protection",REGULATION_BOOST:"Boost",REGULATION_COMFORT:"Comfort",REGULATION_VACATION:"Vacation",}asyncdefmain():"""Show example on using the OJMicroline client."""asyncwithOJMicroline(api=WD5API(customer_id=1234,api_key="<app-api-key>",username="<your-username>",password="<your-password>",),)asclient:# Thermostatsthermostats:list[Thermostat]=awaitclient.get_thermostats()forresourceinthermostats:print("####################")print(f"#{resource.name}")print("####################")print("- Details:")print(f"   Serial Number:{resource.serial_number}")print(f"   Mode:{REGULATION_MODES[resource.regulation_mode]}")print(f"   Temperature:{resource.get_current_temperature()}")print(f"   Target temperature:{resource.get_target_temperature()}")print("")print(f"- Setting to boost mode")awaitclient.set_regulation_mode(resource,REGULATION_BOOST)print("Sleeping for 5 seconds..")sleep(5)print(f"- Setting to schedule")# noqa: E501awaitclient.set_regulation_mode(resource,REGULATION_SCHEDULE)if__name__=="__main__":asyncio.run(main())ContributingThis is an active open-source project. We are always open to people who want to
use the code or contribute to it.We've set up a separate document for ourcontribution guidelines.Thank you for being involved! :heart_eyes:Setting up development environmentThis Python project is fully managed using thePoetrydependency
manager.You need at least:Python 3.9+PoetryInstall all packages, including all development requirements:poetryinstallPoetry creates by default an virtual environment where it installs all
necessary pip packages, to enter or exit the venv run the following commands:poetryshellexitSetup the pre-commit check, you must run this inside the virtual environment:pre-commitinstallNow you're all set to get started!As this repository uses thepre-commitframework, all changes
are linted and tested with each commit. You can run all checks and tests
manually, using the following command:poetryrunpre-commitrun--all-filesTo run just the Python tests:poetryrunpytestLicenseMIT LicenseCopyright (c) 2020-2024 Robbin JanssenPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.