Package ru.gentoos.ehouse.controller
Class SmartPlugController
java.lang.Object
ru.gentoos.ehouse.controller.Controller
ru.gentoos.ehouse.controller.SmartPlugController
- All Implemented Interfaces:
SmartPlug
Контроллер умной розетки Яндекс Умного дома (порт
Controllers/smart_plug.py).
Получает состояние розетки (напряжение, ток, потребление) и управляет ей через Yandex IoT API c повторными попытками.
-
Constructor Summary
ConstructorsConstructorDescriptionSmartPlugController(String deviceId, String apiKey, int voltageRounding, int amperageRounding, int consumptionRounding, int stateRetryCount, int stateRetryDelay, HttpTransport transport, io.opentelemetry.api.trace.Tracer tracer) Инициализирует контроллер розетки. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontrolPlug(boolean turnOn) Включает/выключает розетку.getState()Получает состояние розетки.state()Последнее полученное состояние.intКоличество попыток получения состояния.intПауза между попытками, сек.toString()
-
Constructor Details
-
SmartPlugController
public SmartPlugController(String deviceId, String apiKey, int voltageRounding, int amperageRounding, int consumptionRounding, int stateRetryCount, int stateRetryDelay, HttpTransport transport, io.opentelemetry.api.trace.Tracer tracer) Инициализирует контроллер розетки.- Parameters:
deviceId- идентификатор устройстваapiKey- OAuth-токен Yandex IoT APIvoltageRounding- знаков для вольтamperageRounding- знаков для амперconsumptionRounding- знаков для ваттstateRetryCount- попыток получения состоянияstateRetryDelay- пауза между попытками, сек.transport- HTTP-транспортtracer- трейсер (может бытьnull)
-
-
Method Details
-
stateRetryCount
public int stateRetryCount()Description copied from interface:SmartPlugКоличество попыток получения состояния.- Specified by:
stateRetryCountin interfaceSmartPlug
-
stateRetryDelay
public int stateRetryDelay()Description copied from interface:SmartPlugПауза между попытками, сек.- Specified by:
stateRetryDelayin interfaceSmartPlug
-
state
Description copied from interface:SmartPlugПоследнее полученное состояние. -
getState
Description copied from interface:SmartPlugПолучает состояние розетки. -
controlPlug
public boolean controlPlug(boolean turnOn) Description copied from interface:SmartPlugВключает/выключает розетку.- Specified by:
controlPlugin interfaceSmartPlug- Parameters:
turnOn-true— включить- Returns:
trueпри успехе
-
toString
-