GithubHelp home page GithubHelp logo

openwebnet2-openhab-pre's Introduction

OpenWebNet2-OpenHab-PRE

This repository starts from the OpenWebNet-OpenHab v2.5.0.M2-2

Index

Bus and Channels

Devices support some of the following channels:

Bus Name Description bus Parameter
Type
Description
Channel
Type (Read/Write)
Description
bus_on_off_switch WHO=1 Lightning where
String
Value where OWN
what
Integer (default = 0)
Value what OWN
addrtype
Integer (default = 1)
Address type 1= Point to Point, 2= Area, 3= Group, 4= General
hour
Integer (default = 0)
Timer in hour
minute
Integer (default = 0)
Timer in minute
second
Integer (default = 10)
Timer in second
switch
Switch (R/W)
To switch the device ON/OFF
bus_automation WHO=2 Automation where
String
Value where OWN
addrtype
Integer (default = 1)
Address type 1= Point to Point, 2= Area, 3= Group, 4= General
shutterPosition
Rollershutter (R/W)
To activate roller shutters (UP, DOWN, STOP, Percent)
shutterMotion
Integer (R)
Roller shutter movement 0= stop, 1= up, 2= down
bus_on_off_aux WHO=9 command auxiliary where
String
Value where OWN
switch
Switch (R/W)
To switch the device ON/OFF
bus_motion_detector WHO=1 motion decector
(movement and lux value detected)
where
String
Value where OWN
automaticToOff
Boolean
Automatic OFF after 2 seconds (default=false)
switch
Switch (R/W)
To switch the device ON/OFF
value
Integer (R)
Detected lux value
bus_command command management who
String
Value who OWN
what
String
Value what OWN for ON
whatOff
String
Value what OWN for OFF
compare
String
Code OWN for comparison
switch
Switch (R/W)
To switch the device ON/OFF
contact
Switch (R/W)
To switch the device OPEN/CLOSE
what
String (W)
Set the value what OWN

Changelog

v2.5.0.M3.pre12 31/07/2019

  • Bug fix

    • [FIX #80] thermo: setmode in MANUAL not work
    • FIX bug normalizeWhere for group command
    • FIX bug Lib
    • Temporary modification to the message.Lighting, correction for group command management for different Lighting.Type
    • Temporary modification to the message.Automation, correction for group command management for different Automation.Type
  • New features

    • [FIX #12 and #32] Add bus AUX for managing auxiliary controls (WHO = 9)
    • [FIX #63] Rollershutter items do not track changes in movement from external commands
      • [BREAKING CHANGE] channel shutter changed the name to shutterPosition
      • New channel shutterMotion (0= stop, 1= up, 2= down)
    • [FIX #69] Updating of article statuses, lighting and automation, with the received AMB-GR-GEN commands.
    • [Issue #35] Support for group addresses (WHERE=#n)
    • Temporary modification to the message.Lighting
      • Added management for new timed WHAT
      • Added management for bus_motion_detector
    • [Issue #79] Add what parameter to lighting for bus_on_off_switch and zb_on_off_switch
      • Added parameters what (default what= 0), hour, minute and second
    • Add bus bus_motion_detector for motion decector (movement and lux value detected)
      • Tested with type BMSE-3003, BMSE-1001 and 048834
      • Request lux value
      • Parameter where and automaticToOff
      • Channel switch state ON to the movement and after 2 seconds automatically OFF
      • Channel value numeric with detected value lux
    • [FIX #52 and #22] Add bus bus_command
    • Translation Italian

Example Group Command

openwebnet.things:

Bridge openwebnet:bus_gateway:mybridge "MyHOMEServer1" [host="192.168.1.35" , passwd="abcde" , port=20000 , discoveryByActivation=true]
{  
      bus_on_off_switch  MygroupArea    "Area 2"	 [where="2" , what=0 , addrtype=2]
      bus_on_off_switch  MygroupGroup   "Group 2"	 [where="#2" , what=0 , addrtype=3]
      bus_on_off_switch  MygroupGen     "General"  [where="0" , what=0 , addrtype=4]
}

openwebnet.items:

Switch   ILR_testArea1   "Area 2"   {channel="openwebnet:bus_on_off_switch:mybridge:MygroupArea:switch"}
Switch   ILR_testGroup1  "Group 2"  {channel="openwebnet:bus_on_off_switch:mybridge:MygroupGroup:switch"}
Switch   ILR_testGen1    "General"  {channel="openwebnet:bus_on_off_switch:mybridge:MygroupGen:switch"}

openwebnet.sitemap

sitemap openwebnet label="OpenWebNet Binding Example Sitemap"
{
   Frame label="Test AMB Lighing" 
   {     
      Switch item=ILR_testArea1     label="Area 2"     mappings=[ON="ON"]
      Switch item=ILR_testArea1     label="Area 2"     mappings=[OFF="OFF"]		   
   }
   Frame label="Test GROUP Lighing" 
   {     
      Switch item=ILR_testGroup1    label="Group 2"    mappings=[ON="ON"]
      Switch item=ILR_testGroup1    label="Group 2"    mappings=[OFF="OFF"]		   
   }
   Frame label="Test GEN Lighing"
   {
      Switch item=ILR_testGen1      label="General"    mappings=[ON="ON"]
      Switch item=ILR_testGen1      label=General"     mappings=[OFF="OFF"]		
   }
}

Example Bus Command

openwebnet.things:

Bridge openwebnet:bus_gateway:mybridge "MyHOMEServer1" [host="192.168.1.35" , passwd="abcde" , port=20000 , discoveryByActivation=true]
{  
      bus_command   Mycomm     "Command"       [who="1" , what="1" , where="22" , whatOff="0" , compare=""]
      bus_command   Mycomm1    "Command 1"     [who="1" , what="1" , where="21" , whatOff="0" , compare="*1*1*23##"]
      bus_command   Mycomm2    "Command 2"     [who="2" , what="1" , where="81" , whatOff="0" , compare="*1*1*23##"]
}

openwebnet.items:

String       iMyCommand       {channel="openwebnet:bus_command:mybridge:Mycomm:what"}
Switch       iMyCommand1      {channel="openwebnet:bus_command:mybridge:Mycomm:switch"}
Contact      iMyCommand2      {channel="openwebnet:bus_command:mybridge:Mycomm:contact"}

openwebnet.sitemap

sitemap openwebnet label="OpenWebNet Binding Example Sitemap"
{
   Frame label="Command" 
   {
     Text 	  item=iMyCommand   label="What [%s]"       icon="door"
     Switch   item=iMyCommand1  label="Switch [%s]"     icon="light"
     Text 	  item=iMyCommand2  label="Contact [%s]"    icon="door"
     Switch   item=iMyCommand1  label="da Button [%s]"  icon="light"  mappings=[ON="ON" , OFF="OFF"]     
   }
}

openwebnet.rules

// Scenario: Setting channel what
rule "testCommand"
when
        Item Luce_entrata changed 
then
        switch(Luce_entrata.state ) {
            case ON: {
               logInfo("Test rules testCommand", "success! ON" )
               iMyCommand.sendCommand("11")
            }
            case OFF: {
               logInfo("Test rules testCommand", "success! OFF" )
               iMyCommand.sendCommand("0")
            }
        }
           
end

Example Bus Motion Detector

openwebnet.things:

Bridge openwebnet:bus_gateway:mybridge "MyHOMEServer1" [host="192.168.1.35" , passwd="abcde" , port=20000 , discoveryByActivation=true]
{  
      bus_motion_detector   Mymotion     "Motion"       [where="22" , automaticToOff=false]
}

openwebnet.items:

Switch       iMymotion      {channel="openwebnet:bus_command:mybridge:Mymotion:switch"}
Number       iMymotion      {channel="openwebnet:bus_command:mybridge:Mymotion:value"}

Example Bus Lighting with parameter what

openwebnet.things:

Bridge openwebnet:bus_gateway:mybridge "MyHOMEServer1" [host="192.168.1.35" , passwd="abcde" , port=20000 , discoveryByActivation=true]
{  
      bus_on_off_switch   Mylight    "Light"   [where="22" , what=17 , addrtype=1]
      bus_on_off_switch   Mylight1   "Light"   [where="23" , what=99 , hour=0 , minute=3 , second=30 , addrtype=1]
}

openwebnet.items:

Switch       iMylight      {channel="openwebnet:bus_command:mybridge:Mylight:switch"}
Switch       iMylight1     {channel="openwebnet:bus_command:mybridge:Mylight1:switch"}
what Description
0 Turn on/off (default)
11 ON timed 1 Min
12 ON timed 2 Min
13 ON timed 3 Min
14 ON timed 4 Min
15 ON timed 5 Min
16 ON timed 15 Min
17 ON timed 30 Sec
18 ON timed 0.5 Sec
20 Blinking on 0.5 Sec
21 Blinking on 1 Sec
22 Blinking on 1.5 Sec
23 Blinking on 2 Sec
24 Blinking on 2.5 Sec
25 Blinking on 3 Sec
26 Blinking on 3.5 Sec
27 Blinking on 4 Sec
28 Blinking on 4.5 Sec
29 Blinking on 5 Sec
99 Custom

Test Lighting group addresses

last test upgrade pre7

Group Command Discovery Bus Principale Bus Principal Discovery Bus Local Bus Local Note
Area OK OK OK Problem (1) (1) requestTurnOn and requestTurnOff invalid integer format
Group OK Problem (1) OK Problem (1) (1) requestTurnOn and requestTurnOff invalid integer format
General OK OK (2) OK Problem (1) (1) requestTurnOn and requestTurnOff allowed value [0]
(2) By sending the command, the group and area handlers are also called, correct ???

Test Automation group addresses

last test upgrade pre7

Group Command Discovery Bus Principale Bus Principal Discovery Bus Principale Bus Local Note
Area OK OK OK Problem (1) (1) requestMoveUp and requestMoveDown invalid integer format
Group OK Problem (1) OK Problem (1) (1) requestMoveUp and requestMoveDown invalid integer format
General OK OK (2) OK Problem (1) (1) requestMoveUp and requestMoveDown allowed value [0]
(2) By sending the command, the group and area handlers are also called, correct ???

openwebnet2-openhab-pre's People

Contributors

gozilla01 avatar

Stargazers

Lionel Pinto avatar Tom avatar

Watchers

 avatar

openwebnet2-openhab-pre's Issues

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.

Rollershutter items do not track changes in movement from e…

Risolve FIX 63 da Massimo

  • Rollershutter items do not track changes in movement from external commands
    • [BREAKING CHANGE] canale shutter cambiato nome in shutterPosition
    • Nuovo canale shutterMotion (0= stop, 1= up, 2= down)
    • Da Completare aggiornamento del file README.MD

requestChannelState()

Durante la creazione di un nuovo thing viene richiamato sia la funzione initialize() che requestChannelState() all'interno del handler specifico del thing.
Nel caso che si modifica dei parametri del thing esistente, sia in paperUI che nel file, viene richiamata solo initialize(). Non richiamando requestChannelState() non abbiamo una completa inizializzazione/stato dei canali e il thing rimane in OFFLINE.

Nel file OpenWebNetThingHandler nella funzione handleCommand(ChannelUID channel, Command command) viene richiamati i requestChannelState()
Questa parte del codice gestire il REFRESH nel thing.

if (command instanceof RefreshType) {
            logger.debug("==OWN:ThingHandler== Refreshing channel {}", channel);
            // TODO move to a refreshChannel() method that subclasses can implement to disable setting the thing offline
            requestChannelState(channel);
            // set a schedule to put device OFFLINE if no answer is received after THING_STATE_REQ_TIMEOUT
            scheduler.schedule(() -> {
                // if state is still unknown after timer ends, set the thing OFFLINE
                if (thing.getStatus().equals(ThingStatus.UNKNOWN)) {
                    logger.info(
                            "==OWN:ThingHandler== Thing state request timer expired, still unknown. Setting thing={} to OFFLINE",
                            thing.getUID());
                    updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
                            "Could not get channel state");
                    logger.debug("==OWN:ThingHandler== Thing OFFLINE");
                }
            }, THING_STATE_REQ_TIMEOUT, TimeUnit.SECONDS);
            return;
        } else {
            handleChannelCommand(channel, command);
        }

Il command REFRESH avviene sono durante la creazione del thing e non dopo la modifica di uno o più parametri.
Altra nota all'interno del file

updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.NONE, "waiting state update...");
            // TODO handleCommand(REFRESH) : is it called automatically ? otherwise do here a:
            // bridgeHandler.requestDeviceState(getThing().getUID());

Mi domandavo se non era opportuno gestire il refresh del channel all'interno dei singoli handler nella funzione di initialize() aggiungendo questo codice:

updateStatus(ThingStatus.ONLINE);
ChannelUID channelUID;
for (Channel channel : getThing().getChannels()) {    
            logger.debug("==OWN:MotionDetectorHandler== initialize() request channel state thingUID={} channel={}",  thing.getUID(), channelUID.getId());      
            channelUID = channel.getUID();
            switch (channelUID.getId()) {
                case CHANNEL_MOTION_DETECTOR_SWITCH:
                    // is not possible to request channel state for Command buttons
                    updateState(channelUID, UnDefType.UNDEF);
                    break;
                case CHANNEL_MOTION_DETECTOR_VALUE:
                    bridgeHandler.gateway.send(LightingExt.requestMotionDetectorStatus(toWhere(channelUID),
                            lightingType, REQUEST_CHANNEL));
                    break;
                default: {
                    logger.warn("==OWN:MotionDetectorHandler== Unsupported ChannelUID {}", channelUID);
                }
            }
}

Penso, il problema dei CEN/CEN+ del cambio del nome sia associato a questo problema.
Una ricerca nei vari binding vedo, la gestione Request dei canali viene gestita all'interno di initialize()

Cosa facciamo ?

Libreria Message Lighting - detectDeviceType()

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;
    }
  • Visto la nuova implementazione per bus_motion_detector è opportuno aggiungere e gestire un nuovo OpenDeviceType con WHAT.MOVEMENT_DETECTED e WHAT.END_MOVEMENT_DETECTED ?
    es. OpenDeviceType.SCS_MOTION_DETECTOR_SWITCH

Questo estratto da OpenWebNetDeviceDiscoveryService

case SCS_ON_OFF_SWITCH: {
                    if (baseMsg.getWhat().equals(WHAT.MOVEMENT_DETECTED)
                            || baseMsg.getWhat().equals(WHAT.END_MOVEMENT_DETECTED)) {
                        thingTypeUID = OpenWebNetBindingConstants.THING_TYPE_BUS_MOTION_DETECTOR;
                        thingLabel = OpenWebNetBindingConstants.THING_LABEL_BUS_DETECTOR;
                        deviceWho = Who.LIGHTING;
                        break;
                    } else {
                        thingTypeUID = OpenWebNetBindingConstants.THING_TYPE_BUS_ON_OFF_SWITCH;
                        thingLabel = OpenWebNetBindingConstants.THING_LABEL_BUS_ON_OFF_SWITCH;
                        deviceWho = Who.LIGHTING;
                        break;
                    }
                }
case SCS_DIMMER_SWITCH: {

Se si, eliminare la gestione WHAT.MOVEMENT_DETECTED e WHAT.END_MOVEMENT_DETECTED all'interno del OpenWebNetLightingHandler.

Libreria Message Lighting e Automation

Correlato con il Issue #18
Il PR 19 corregge e implementata i seguenti punti.

Cambiamento nome da Lighting a LightingExt e da Automation a AutomationExt
Il cambiamento nel nome è stato necessario, solo provvisoriamente, per gestire la la nuova LightingExt.
Dopo la correzione definitiva della lib il nome rimane quello precedente Lighting e Automation

Implementazione Lighting per gestire i WHAT temporizzati
Inseriti nuovi WHAT da 11 a 29

TIMER_1_MIN(Integer.valueOf(11)),
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(17)),
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)),

Inseriti nuove funzione requestTurnOnWhat e requestTurnOnWhatCustom

    public static Lighting requestTurnOnWhat(final String s, final int what, final Type type) {
        // Correzione provvisoria per la problematica nel group con doppio con .replaceFirst("\\##", "\\#") ##        
        // BaseOpenMessage.a(s, type);
        return new Lighting(String.format("*%d*%d*%s##", Lighting.h, what, BaseOpenMessage.b(s, type)));
    }

    public static Lighting requestTurnOnWhatCustom(final String s, final int hour, final int minute,
            final int second, final Type type) {
        // Correzione provvisoria per la problematica nel group con doppio con .replaceFirst("\\##", "\\#") ##        
        // BaseOpenMessage.a(s, type);
       return new Lighting(String.format("*#%d*%s*#2*%s*%s*%s##", Lighting.h,
                BaseOpenMessage.b(s, type).replaceFirst("\\##", "\\#"), hour, minute, second));
    }

Implementazione Lighting per nuovo bus Motion Detector
Inseriti nuove funzione requestMotionDetectorStatus , requestMotionDetectorTurnOff e requestMotionDetectorStatus

     public static Lighting requestMotionDetectorTurnOn(final String s, final Type type) {
        // Correzione provvisoria per la problematica nel group con doppio con .replaceFirst("\\##", "\\#") ##
        // BaseOpenMessage.a(s, type);
        return new LightingExt(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 con .replaceFirst("\\##", "\\#") ##
        // 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 con .replaceFirst("\\##", "\\#") ##
        // BaseOpenMessage.a(s, type);
        return new LightingExt(String.format("*#%d*%s*%s##", Lighting.h,
                BaseOpenMessage.b(s, type).replaceFirst("\\##", "\\#"), RequestChannel));
    }

Problema con Type.GROUP nella libreria messagge Lighting e Automation
Nel PR è stato risolto provvisoriamente tramite aggiunta di .replaceFirst("\\##", "\\#") e commentando BaseOpenMessage.a(s, type); nelle funzioni:

  • Lighting;
    • requestTurnOn
    • requestTurnOff
    • requestTurnOnWhat
    • requestTurnOnWhatCustom
    • requestDimTo
    • requestDimToPercent
    • requestStatus
    • requestMotionDetectorStatus
    • requestMotionDetectorTurnOff
    • requestMotionDetectorStatus`
  • Automation;
    • requestStop
    • requestMoveUp
    • requestMoveDown

La reale correzione è da eseguire, all'înterno di BaseOpenMessage, la funzione protected static String b per gestire correttamente i comandi group.
Il WHERE con Lighting.Type.GROUP e Automation.Type.GROUP ha già il prefisso #, nel switch case 3 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");
            }
        }
    }

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

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

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.