use of org.openremote.model.asset.AssetAttribute in project openremote by openremote.
the class AbstractManagerSetup method linkDemoApartmentWithSceneAgent.
protected void linkDemoApartmentWithSceneAgent(ServerAsset apartment, ServerAsset agent, Scene[] scenes) {
for (Scene scene : scenes) {
apartment.addAttributes(new AssetAttribute(scene.attributeName, AttributeType.STRING, Values.create(AttributeExecuteStatus.READY.name())).setMeta(new MetaItem(LABEL, Values.create(scene.attributeLabel)), new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)), new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)), new MetaItem(EXECUTABLE, Values.create(true)), new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), scene.attributeName).toArrayValue())), new AssetAttribute(scene.attributeName + "AlarmEnabled", AttributeType.BOOLEAN).setMeta(new MetaItem(LABEL, Values.create(scene.attributeLabel + " alarm enabled")), new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)), new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)), new MetaItem(META_MACRO_ACTION_INDEX, Values.create(0)), new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), scene.attributeName).toArrayValue())), new AssetAttribute(scene.attributeName + "TargetTemperature", AttributeType.NUMBER).setMeta(new MetaItem(LABEL, Values.create(scene.attributeLabel + " target temperature")), new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)), new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)), new MetaItem(META_MACRO_ACTION_INDEX, Values.create(1)), new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), scene.attributeName).toArrayValue())));
for (DayOfWeek dayOfWeek : DayOfWeek.values()) {
// "MONDAY" => "Monday"
String dayOfWeekLabel = dayOfWeek.name().substring(0, 1) + dayOfWeek.name().substring(1).toLowerCase(Locale.ROOT);
apartment.addAttributes(new AssetAttribute(scene.attributeName + "Time" + dayOfWeek.name(), AttributeType.STRING).setMeta(new MetaItem(LABEL, Values.create(scene.attributeLabel + " time " + dayOfWeekLabel)), new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)), new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)), new MetaItem(RULE_STATE, Values.create(true)), new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())), new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), scene.attributeName + dayOfWeek.name()).toArrayValue())), new AssetAttribute(scene.attributeName + "Enabled" + dayOfWeek.name(), AttributeType.BOOLEAN).setMeta(new MetaItem(LABEL, Values.create(scene.attributeLabel + " enabled " + dayOfWeekLabel)), new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)), new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)), new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.ENABLED.toString())), new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), scene.attributeName + dayOfWeek.name()).toArrayValue())));
}
}
apartment.addAttributes(// The scene timer is enabled when the timer protocol starts
new AssetAttribute("sceneTimerEnabled", AttributeType.BOOLEAN, Values.create(true)).setMeta(new MetaItem(LABEL, Values.create("Scene timer enabled")), new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)), new MetaItem(SHOW_ON_DASHBOARD, Values.create(true)), new MetaItem(READ_ONLY, Values.create(true))), new AssetAttribute("enableSceneTimer", AttributeType.STRING).setMeta(new MetaItem(LABEL, Values.create("Enable scene timer")), new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)), new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)), new MetaItem(EXECUTABLE, Values.create(true)), new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), "enableSceneTimer").toArrayValue())), new AssetAttribute("disableSceneTimer", AttributeType.STRING).setMeta(new MetaItem(LABEL, Values.create("Disable scene timer")), new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)), new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)), new MetaItem(EXECUTABLE, Values.create(true)), new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), "disableSceneTimer").toArrayValue())));
}
Aggregations