Search in sources :

Example 1 with MacroAction

use of org.openremote.agent.protocol.macro.MacroAction in project openremote by openremote.

the class AbstractManagerSetup method addDemoApartmentSceneEnableDisableTimer.

protected void addDemoApartmentSceneEnableDisableTimer(ServerAsset apartment, ServerAsset agent, Scene[] scenes) {
    AssetAttribute enableAllMacro = initProtocolConfiguration(new AssetAttribute("enableSceneTimer"), MacroProtocol.PROTOCOL_NAME).addMeta(new MetaItem(LABEL, Values.create("Enable scene timer")));
    for (Scene scene : scenes) {
        for (DayOfWeek dayOfWeek : DayOfWeek.values()) {
            String sceneAttributeName = scene.attributeName + "Enabled" + dayOfWeek;
            enableAllMacro.getMeta().add(new MacroAction(new AttributeState(new AttributeRef(apartment.getId(), sceneAttributeName), Values.create(true))).toMetaItem());
        }
    }
    enableAllMacro.getMeta().add(new MacroAction(new AttributeState(new AttributeRef(apartment.getId(), "sceneTimerEnabled"), Values.create(true))).toMetaItem());
    agent.addAttributes(enableAllMacro);
    AssetAttribute disableAllMacro = initProtocolConfiguration(new AssetAttribute("disableSceneTimer"), MacroProtocol.PROTOCOL_NAME).addMeta(new MetaItem(LABEL, Values.create("Disable scene timer")));
    for (Scene scene : scenes) {
        for (DayOfWeek dayOfWeek : DayOfWeek.values()) {
            String sceneAttributeName = scene.attributeName + "Enabled" + dayOfWeek;
            disableAllMacro.getMeta().add(new MacroAction(new AttributeState(new AttributeRef(apartment.getId(), sceneAttributeName), Values.create(false))).toMetaItem());
        }
    }
    disableAllMacro.getMeta().add(new MacroAction(new AttributeState(new AttributeRef(apartment.getId(), "sceneTimerEnabled"), Values.create(false))).toMetaItem());
    agent.addAttributes(disableAllMacro);
}
Also used : MacroAction(org.openremote.agent.protocol.macro.MacroAction) DayOfWeek(java.time.DayOfWeek) AssetAttribute(org.openremote.model.asset.AssetAttribute)

Aggregations

DayOfWeek (java.time.DayOfWeek)1 MacroAction (org.openremote.agent.protocol.macro.MacroAction)1 AssetAttribute (org.openremote.model.asset.AssetAttribute)1