This project has been transferred to a new repository.
gozilla01 / openhab2-addons-pre-new-build Goto Github PK
View Code? Open in Web Editor NEWOpenWebNet from 2.5.0.M2 to 2.5.0.M3-pre
OpenWebNet from 2.5.0.M2 to 2.5.0.M3-pre
This project has been transferred to a new repository.
Aggiungere alla libreria la gestione WHO=17
WHO=SCENARIO_PROGRAMMING
Aggiungere discovery con frame *#17*0##
elenco tutti i scenari ID, il webserver risponde con tutti i stati Start/stop e Abilititato/Disabilitato dei vari scenari.
Risolve la creazione del ownId con gruppi di comando.
who=1
e where=#1
Prima ownId = 1.1
dopo 1.#1
Aggiunta del parametro Who deviceWho
, questo comporta altri cambiamenti nelle altre funzioni, vedi PR
public String normalizeWhere(String where, Who deviceWho) {
String str = "";
if (isBusGateway) {
if (where.indexOf('#') < 0) { // no hash present
str = where;
} else if (where.indexOf("#4#") != -1) { // local bus: APL#4#bus
str = where;
} else if (where.indexOf('#') == 0 && deviceWho == Who.THERMOREGULATION) { // thermo zone via central unit:
// #0 or #Z (Z=[1-99]) --> Z
str = where.substring(1);
} else if (where.indexOf('#') > 0 && deviceWho == Who.THERMOREGULATION) { // thermo zone and actuator N: Z#N
// (Z=[1-99], N=[1-9]) -- > Z
str = where.substring(0, where.indexOf('#'));
} else {
logger.warn("==OWN== normalizeWhere() unexpected WHERE: {}", where);
str = where;
}
return str;
} else {
return OpenMessageFactory.getAddrFromWhere(where);
}
}
........
Nella libreria message Lighting:
Aggiungere una gestione ON-OFF-Request Valore Lux
Attenzione alle modifiche Lighting.Type
#28
public static Lighting requestMotionDetectorTurnOn(final String s, final Type type) {
// Correzione provvisoria per la problematica nel group con doppio ##
// BaseOpenMessage.a(s, type);
return new Lighting(String.format("*%d*%d*%s##", Lighting.h, WHAT.MOVEMENT_DETECTED.value(),
BaseOpenMessage.b(s, type).replaceFirst("\\##", "\\#")));
}
public static Lighting requestMotionDetectorTurnOff(final String s, final Type type) {
// Correzione provvisoria per la problematica nel group con doppio ##
// BaseOpenMessage.a(s, type);
return new Lighting(String.format("*%d*%d*%s##", Lighting.h, WHAT.END_MOVEMENT_DETECTED.value(),
BaseOpenMessage.b(s, type).replaceFirst("\\##", "\\#")));
}
public static Lighting requestMotionDetectorStatus(final String s, final Type type,
final String RequestChannel) {
// Correzione provvisoria per la problematica nel group con doppio ##
// BaseOpenMessage.a(s, type);
return new Lighting(String.format("*#%d*%s*%s##", LightingExt.h,
BaseOpenMessage.b(s, type).replaceFirst("\\##", "\\#"), RequestChannel));
}
Modificare detectDeviceType()
Aggiungere un nuovo OpenDeviceType specifico per bus_motion_detector per una gestione più pulita nel switch case
di OpenWebNetDeviceDiscoveryService
Attenzione alle modifiche Lighting.Type
#25
@Override
public OpenDeviceType detectDeviceType() {
if (this.isCommand()) {
final What what;
OpenDeviceType openDeviceType;
if ((what = this.getWhat()) == WHAT.OFF || what == WHAT.ON || what == WHAT.MOVEMENT_DETECTED
|| what == WHAT.END_MOVEMENT_DETECTED) {
openDeviceType = OpenDeviceType.SCS_ON_OFF_SWITCH;
} else {
openDeviceType = OpenDeviceType.SCS_DIMMER_SWITCH;
}
return openDeviceType;
}
return null;
}
Modificare OpenWebNetLightingHandler
Eliminare la gestione di MOVEMENT_DETECTED
e END_MOVEMENT_DETECTED
dal OpenWebNetLightingHandler
?
Nella libreria message Lighting:
Aggiungere una gestione ON con i nuovi WHAT temporizzati
Attenzione alle modifiche Lighting.Type
#28
public static Lighting requestTurnOnWhatCustom(final String s, final int hour, final int minute,
final int second, final Type type) {
return new Lighting(String.format("*#%d*%s*#2*%s*%s*%s##", Lighting.h,
BaseOpenMessage.b(s, type).replaceFirst("\\##", "\\#"), hour, minute, second));
}
Modificare in BaseOpenMessage
la funzione protected static String b
per gestire correttamente i comandi gruop.
Il WHERE
con Lighting.Type.GROUP
ha gia il prefisso #, nel switch case
non è necessario aggiungere #
Da:
protected static String b(final String s, final Type type) {
switch (BaseOpenMessage$1.a[type.ordinal()]) {
case 1:
case 2:
case 4: {
return s;
}
case 5: {
return s.concat("#9");
}
case 3: {
return "#".concat(s);
}
default: {
throw new IllegalArgumentException("invalid type");
}
}
}
A:
protected static String b(final String s, final Type type) {
switch (BaseOpenMessage$1.a[type.ordinal()]) {
case 1:
case 2:
case 3:
case 4: {
return s;
}
case 5: {
return s.concat("#9");
}
default: {
throw new IllegalArgumentException("invalid type");
}
}
}
Nella libreria message Lighting:
Aggiungere una gestione ON con i nuovi WHAT temporizzati
public static Lighting requestTurnOnWhat(final String s, final int what, final Type type) {
BaseOpenMessage.a(s, type);
return new Lighting(String.format("*%d*%d*%s##", Lighting.h, what, BaseOpenMessage.b(s, type)));
}`
Aggiungere nuovi WHAT temporizzati
TIMER_1_MIN(Integer.valueOf(2)),
TIMER_2_MIN(Integer.valueOf(12)),
TIMER_3_MIN(Integer.valueOf(13)),
TIMER_4_MIN(Integer.valueOf(14)),
TIMER_5_MIN(Integer.valueOf(15)),
TIMER_15_MIN(Integer.valueOf(16)),
TIMER_30_SEC(Integer.valueOf(7)),
TIMER_05_SEC(Integer.valueOf(18)),
BLINKING_05_SEC(Integer.valueOf(20)),
BLINKING_1_SEC(Integer.valueOf(21)),
BLINKING_1_5_SEC(Integer.valueOf(22)),
BLINKING_2_SEC(Integer.valueOf(23)),
BLINKING_2_5_SEC(Integer.valueOf(24)),
BLINKING_3_SEC(Integer.valueOf(25)),
BLINKING_3_5_SEC(Integer.valueOf(26)),
BLINKING_4_SEC(Integer.valueOf(27)),
BLINKING_4_5_SEC(Integer.valueOf(28)),
BLINKING_5_SEC(Integer.valueOf(29)),
Modificare detectDeviceType()
Modificare if
per includere i nuovi WHAT temporizzati come SCS_ON_OFF_SWITCH
Attualmente se si riceve *1*17*23##
, il discovery lo riconosce come SCS_DIMMER_SWITCH
@Override
public OpenDeviceType detectDeviceType() {
if (this.isCommand()) {
final What what;
OpenDeviceType openDeviceType;
if ((what = this.getWhat()) == WHAT.OFF || what == WHAT.ON || what == WHAT.MOVEMENT_DETECTED
|| what == WHAT.END_MOVEMENT_DETECTED) {
openDeviceType = OpenDeviceType.SCS_ON_OFF_SWITCH;
} else {
openDeviceType = OpenDeviceType.SCS_DIMMER_SWITCH;
}
return openDeviceType;
}
return null;
}
Con queste aggiunte nella lib, possiamo gestire i nuovi WHAT nel file OpenWebNetLightingHandler
private void handleSwitchCommand(ChannelUID channel, Command command) {
logger.debug("==OWN:LightingHandler== handleSwitchCommand() (command={} - channel={})", command, channel);
if (command instanceof OnOffType) {
if (OnOffType.ON.equals(command)) {
if (what == 0) {
bridgeHandler.gateway.send(Lighting.requestTurnOn(toWhere(channel), lightingType));
} else {
bridgeHandler.gateway.send(Lighting.requestTurnOnWhat(toWhere(channel), what, lightingType));
}
} else if (OnOffType.OFF.equals(command)) {
bridgeHandler.gateway.send(Lighting.requestTurnOff(toWhere(channel), lightingType));
}
} else {
logger.warn("==OWN:LightingHandler== Unsupported command: {}", command);
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.