GithubHelp home page GithubHelp logo

openhab2-addons-pre-new-build's Introduction

openhab2-addons-pre-new-build's People

Contributors

gozilla01 avatar

Stargazers

Tom avatar

Watchers

Tom avatar

openhab2-addons-pre-new-build's Issues

**TRA** Lib Add WHO=17 Scenari programmati

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.

**TRA** normalizeWhere Problem

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);
        }
    }

**OK** Lib message Lighting per bus_motion_detector

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 ?

**OK** Lib message Lighting per WHAT custom

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));
    }

**OK** Lib Message BaseOpenMessage

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");
            }
        }
    }

**OK** Lib message Lighting per WHAT temporizzati

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);
        }

    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.